# HG changeset patch # User Masataka Kohagura # Date 1407663887 -32400 # Node ID 652dd569acc1c229210a483988413adb969cbd04 # Parent f31415b52f51ae6d163eff35bef4ab89573561fb add audio_settings function diff -r f31415b52f51 -r 652dd569acc1 example/synthesizer/main.cc --- a/example/synthesizer/main.cc Wed Aug 06 02:09:05 2014 +0900 +++ b/example/synthesizer/main.cc Sun Aug 10 18:44:47 2014 +0900 @@ -29,10 +29,9 @@ const char *usr_help_str = "Usage: ./synthesizer -wave \"sqr\" or \"tri\" [-freq freqency] [-vol volume]"; -static void -run_start(TaskManager *manager) +void +audio_settings(AudioDataPtr au) { - AudioDataPtr au = (AudioDataPtr)manager->allocate(sizeof(AudioData)); au->self = au; au->volume = volume; @@ -46,6 +45,15 @@ au->channels= 1; /* Mono */ au->samples= 8192; /* Buffer size: 8K = 0.37 sec. */ au->userdata= NULL; +} + + +static void +run_start(TaskManager *manager) +{ + AudioDataPtr au = (AudioDataPtr)manager->allocate(sizeof(AudioData)); + + audio_settings(au); HTaskPtr osc = manager->create_task(OSC_TASK); osc->set_inData(0,au,sizeof(AudioDataPtr)); diff -r f31415b52f51 -r 652dd569acc1 example/synthesizer/ppe/OSC.cc --- a/example/synthesizer/ppe/OSC.cc Wed Aug 06 02:09:05 2014 +0900 +++ b/example/synthesizer/ppe/OSC.cc Sun Aug 10 18:44:47 2014 +0900 @@ -13,15 +13,17 @@ SDL_AudioSpec Desired; SDL_AudioSpec Obtained; -double square(double t){ +double +square(double t) +{ double decimal_part = t - abs(t); return decimal_part < 0.5 ? 1 : -1; } -double tri(double t){ - +double +tri(double t) +{ double decimal_part = t - abs(t); - if(abs(t) % 2 != 0){ return decimal_part < 0.5 ? decimal_part : 1 - decimal_part; }else{ @@ -29,7 +31,9 @@ } } -double saw(double t){ +double +saw(double t) +{ double decimal_part = t - abs(t); return decimal_part; } @@ -60,7 +64,6 @@ for (int i = 0; i < framesize ; i++, step++){ frames[i] = saw(step * frequency / Obtained.freq) * volume ; } - } } @@ -78,7 +81,7 @@ SDL_OpenAudio(&Desired, &Obtained); SDL_PauseAudio(0); - SDL_Delay(200); + SDL_Delay(1000); SDL_Quit(); return 0;