#ifndef _portaudioTest_Wave_h_ #define _portaudioTest_Wave_h_ class Wave:public WithWaveLayout{ Sound snd; double f1,f2,a1,a2,sr; public: typedef Wave CLASSNAME; Wave(){ CtrlLayout(*this); freq1<<=THISBACK(OnChange);FileIn f; freq2<<=THISBACK(OnChange); amp1<<=THISBACK(OnChange); amp2<<=THISBACK(OnChange); device<<=THISBACK(OnChange); samplerate<<=THISBACK(OnChange); fpb<<=THISBACK(OnChange); button<<=THISBACK(OnPlay); button.SetLabel("Play"); freq1<<=440; freq2<<=440; amp1 <<=1; amp2 <<=1; for(int i=0;i0)?(int)fpb:1); snd.Open(Null,StreamParameters(~device,2,SND_FLOAT32,SoundDevice(~device).LowOutputLatency)); if(CheckError()) return; snd.Start(); SetTimeCallback(-250,THISBACK(CpuUsage)); }; void OnPlay(){ if(~button){ button.SetLabel("Stop"); Start(); }else{ button.SetLabel("Play"); KillTimeCallback(); cpu.SetLabel("CPU usage: -"); snd.Close(); } } bool CheckError(){ if(snd.IsError()){ error<<="[1 Error: "+snd.GetError(); return true; } error<<=""; return false; } }; #endif