i am trying to play a stream in real time ( I keep appedning data to it as it comes in from a nexternal source) but no matter what FMOD doesn’t want to carry on playing after the first chunk that got loaded, it seems as it is copying the memory stream/decoding it before playing, then as it is playing it doesn’t use my stream anymore.
I am using the following to play my stream:
var exinfo = new FMOD.CREATESOUNDEXINFO();
exinfo.cbsize = Marshal.SizeOf(exinfo);
exinfo.length = (uint)_buffer.Length;
_result = System.createStream(_buffer, MODE.CREATESTREAM | MODE.OPENMEMORY_POINT , ref exinfo, ref _sound);
FMODErrorCheck(_result);
_result = System.playSound(FMOD.CHANNELINDEX.FREE, _sound, false, ref _channel);
FMODErrorCheck(_result);
But no matter what, it only plays the amount of data that is in the stream at the point of calling playSound.
Can anyone know how to modify the buffer in real time? After the stream has started playing…?
If you wish to stream raw data, not PCM data you could achieve this by overriding the FMOD file system. There are two ways to achieve this, the first is by setting the file callbacks in the CreateSoundExInfo structure if this is for one specific file. The second is you can set the file system globally for all FMOD file operations (incase you want to do this with multiple files).
I will explain the latter, it would be trivial to switch to the former though. Refer to the “filecallbacks” FMOD example for a complete example.
Function pointers:
Callbacks:
Implementation: