Tracking the moment of completion of playback in the buffer.
I use the code to play a list consisting of a sequence of bytes. The entire audio fragment is played successfully. The problem is that the cycle sending the sequence of bytes to STREAM ends much faster than the playback of the entire audio recording ends. I hoped to paint the lines on the screen synchronously with each buffer while the sound is playing. But the cycle runs quickly, and the entire melody, consisting of elements transmitted by the cycle, sounds much longer. How to track the moment when each elementary fragment in the cycle has worked in online mode.
Play sound buffer:
If General.lstFinish.Size>0 Then
streamerP.Initialize("stream", Starter.mSampleRate, Starter.mMono, Starter.mBitRate, streamerP.VOLUME_MUSIC)
streamerP.StartPlaying
i=0
For Each b() As Byte In General.lstFinish
s=i*shag
scvS.ScrollPosition=s
If i>0 Then scvS.Panel.GetView(i-1).Color=Colors.White
scvS.Panel.GetView(i).Color=Colors.Green
streamerP.Write(b)
i=i+1
Next
streamerP.Write(Null) 'when this "message" will be processed, the player will stop.
End If
Or make the buffer small enough to only hold (for example) 30 ms of audio, and check the return status of AudioStreamer.Write to pace your line painting or whatever it is that you need done (approximately, close enough) in synch with the audio.
Does using AudioStreamer.PlaybackComplete event to detect "the moment when each elementary fragment in the cycle has worked" cause audio clicks?
Maybe Erel's method of using a crystal ball clock might work:
Or make the buffer small enough to only hold (for example) 30 ms of audio, and check the return status of AudioStreamer.Write to pace your line painting or whatever it is that you need done (approximately, close enough) in synch with the audio.