a lot of users of wxMusik do request the play gap less feature. for this i have to check for silence at the end and the start of a stream. and i need to start the next stream stiched gaplessly to the first one. can the be done at all with fmod?
- gunnar67 asked 14 years ago
What about a DSP unit hooked to the decoder
on FMOD_Open() it feeds the DSP and the DSP sends back a modified buffer.
Then FMOD fills the memory with the returned buffer untill it’s full.
This way you can manipulate the stream anyway you want and it will reduce skips when you’re listening music and in the sametime something else makes excessive use of CPU.
So when there’s no sound you flush that part of the buffer and FMOD actualy recieves a smaller buffer to put in memory.
I realy want this kind feature for several things like:
– speed manipulation
– pre-buffer equalizer so that the player doesn’t skip when my browser uses 80% CPU to generate a webpage
Adding after it starts is important for me. I want to start a single stream playing, then before it finishes select another to start but I can make guarantees about giving you the next one early enough to be buffered. I want to keep doing this over and over, not prepare a set to play up front and then do PlaySound. I don’t know what the next piece will be until about halfway into the play time of the active stream, and definitely won’t be able to predict a complete sequence before it starts playing (depends on ingame player decisions). I also cannot use FSB (all the pieces will be streams and from my own file functions).
If I miss it, I miss it and there is a gap, but most of the time it should work since the first stream will be several seconds long, providing plenty of time to buffer up the next stream to start when it ends. I can already get close using 2 streams with the second one paused now, but not perfect because of the timing (frame rate may be too low to get the end callback to unpause the second stream in time).
If you know the length of the streams, you could try adding sync points to your stream, and triggering syncpoint callbacks using FSOUN_Stream_AddSyncPoint (or add them with a sound editing program like Sound Forge.) You can also monitor where you stand in your stream using FSOUND_Stream_GetPosition and FSOUND_Stream_GetLength.
If its a stream going over the network and you don’t know when it ends, you can instead monitor the sound levels. Instead of checking for silences, check for when the signal drops below a certain level for a certain time, say -30dB for more than a second. This might you enough time to setup a second stream and start it up before the first one ends. This should work well enough for music that is loud enough throughout and doesn’t end too abruptly. You could also smooth out transitions by ramping volume down on the first stream, and ramping up volume on the second one.
- symbiote answered 14 years ago
Another way that shouldn’t be too difficult with fmod ex is to create a user created stream.
Then load the streams you want to play gapless in another fmod stream.
Now each time the user created stream requests some data, you can feed it data using readData on the already opened streams.
As soon as you know what the next stream will be, you can already open it, and at the end of the first stream, you just call readData on the second stream to fill the gap.
- Adion answered 14 years ago
The point is to get rid of the polling… even using the callbacks won’t be any more accurate than the rate at which FMOD_System_Update() is called so it can miss it. All I really want is for FMOD to be able to unpause a prepared stream in time not to have a gap at the end of the playing one.
Two jobs ago when I had to do this, what I did was create a synch point some 25ms before the end of the previous track, and associated it with a callback that determined the next sound to play and played it. The 25ms overlap was unnoticeable, and I couldn’t use the end callback, because there would be a gap before the next sound started.
This worked out very well for us, though your mileage may vary.
- Adiss answered 14 years ago
Please login first to submit.