Are you generating audio to play or are you playing audio from a file?
SuperStrictFramework brl.basicImport brl.retroImport ray.libImport ray.audioConst BUFFERSIZE:Int = 2048 * 2'// The Raylib drawing routines are optional.InitWindow(500, 500, "stream")InitAudioDevice()Global my_stream:RAudioStream = InitAudioStream(44100, 16, 2)Global a_writebuff:Short[BUFFERSIZE * 2] Global writeBuf:Short Ptr = Varptr a_writebuff[0]Global BufPtr%Global song:RWave = LoadWave("sample.wav")Global songPtr:Short Ptr = song.DataPlayAudioStream(my_stream)SetMasterVolume(0.33)While Not WindowShouldClose() BeginDrawing() ClearBackground(Black) '// Audio stuff here // '///////// Local buffproc:Int = IsAudioStreamProcessed(my_stream) '// audio stream wants more data If buffproc Then For Local i:Int = 0 Until BUFFERSIZE * 2 Step 2 writeBuf[i] = songPtr[BufPtr] writeBuf[i + 1] = songPtr[BufPtr + 1] BufPtr:+2 BufPtr:Mod song.sampleCount*2 Next UpdateAudioStream(my_stream, writeBuf, BUFFERSIZE * 2) End If '///////// DrawText("song ptr: "+String(Int(BufPtr)), 10,10,20,Gray) EndDrawing()Wend
Here is an basic example that uses the Raylib mod with the audio to stream for a 16bit stereo file. The raylib drawing stuff is not needed to use the audio library. I would recommend that you make the most basic program you can to confirm that the streaming works correctly, then work on the other stuff.Sample audio file can be downloaded here: http://www.gutterbox.com/download/sample.wavCode: [Select]SuperStrictFramework brl.basicImport brl.retroImport ray.libImport ray.audioConst BUFFERSIZE:Int = 2048 * 2'// The Raylib drawing routines are optional.InitWindow(500, 500, "stream")InitAudioDevice()Global my_stream:RAudioStream = InitAudioStream(44100, 16, 2)Global a_writebuff:Short[BUFFERSIZE * 2] Global writeBuf:Short Ptr = Varptr a_writebuff[0]Global BufPtr%Global song:RWave = LoadWave("sample.wav")Global songPtr:Short Ptr = song.DataPlayAudioStream(my_stream)SetMasterVolume(0.33)While Not WindowShouldClose() BeginDrawing() ClearBackground(Black) '// Audio stuff here // '///////// Local buffproc:Int = IsAudioStreamProcessed(my_stream) '// audio stream wants more data If buffproc Then For Local i:Int = 0 Until BUFFERSIZE * 2 Step 2 writeBuf[i] = songPtr[BufPtr] writeBuf[i + 1] = songPtr[BufPtr + 1] BufPtr:+2 BufPtr:Mod song.sampleCount*2 Next UpdateAudioStream(my_stream, writeBuf, BUFFERSIZE * 2) End If '///////// DrawText("song ptr: "+String(Int(BufPtr)), 10,10,20,Gray) EndDrawing()Wend