MBS Audio stopping

Okay…found some time to test the MBS Audio plugin…
And with a little tweaking I get the sweep sine wave with the Port Audio example app.

The Callback looks like this now to generate the sweep:

Var n,c,i As Integer
Var f As Single
Var increment As Single = frequency / 7639.437

PlayWindow.FrequencyLabel.Text = Str(frequency) + " Hz"

c=FrameCount-1
for i=0 to c
  sinIndex = sinIndex + increment
  if sinIndex>2*3.1415926 then sinIndex=sinIndex-2*3.1415926
  f = sin(sinIndex) / 2
  
  outputBuffer.SingleValue(n)=f // left
  n=n+4
  outputBuffer.SingleValue(n)=f // right
  n=n+4
next

If frequency <= 20000 then frequency = frequency + 20

Tried to stop the audio with a simple PlayWindow.Close as there is this Close event:

dim e as integer
if s<>nil then
  e=s.Stop
  e=s.Close
end if

But of course the app just hangs…
What is the correct way to stop the audio?

Can you send me the test project to debug?

Your callback does have “#pragma” lines to disable background tasks?

Yes…those are unchanged from the PortAudio example.

PortAudio.zip (37.0 KB)

Ops…forgot the Info.plist

info.plist.zip (866 Bytes)

Strange. Doesn’t happen here on macOS or Windows as far as I see.

Anyway, I see that the example does call abort or window.close from callback, which should not happen.

Happens on my MacStudio and Macbook Air here…

Is there a better way to stop the audio output when the sweep is through?

PS: Currently cooking sweet&sour and my girlfriend comes home soon…so a while afk (o;

Okay…either have to study the docs more or switch to another solution (o;

But sweet&sour was fine (o;

Well, if you like to have an easier live, don’t use the playback via callback, but via queue. That is easier.

See PortAudioStreamBufferedMBS class with buffer.