Hello everyone :)

First post, and already hard stuff:

I’ve just started sound handling in my C# project, and out of several others, FMOD provides the most of what I need. But now I have encountered a bit of a problem, or my issue is just way too special:

Lets say, I have a music file that looks like AA-BBB-CCC. AA is the intro, BBB and CCC are two different loops of which the user should be able to switch between AA-BBB-BBB and AA-CCC-CCC.

Playing the loop AA-BBB-BBB… works just fine with [code:gsi8mz2e]sound.setLoopPoints(5000, TIMEUNIT.MS, 10000, TIMEUNIT.MS);[/code:gsi8mz2e]

But here the problems start:
[:gsi8mz2e]How to tell a sound to play AA-CCC-CCC without playing BBB before? I was thinking about splitting the whole thing into three different sounds, while playing AA once and the loops afterwards. For that, I need to tell AA to completely stop at 5000 and BBB to skip 0-5000 somehow…[/:m:gsi8mz2e]
[:gsi8mz2e]Is it possible to switch between the two loops "on the fly"? The sound would have to add an offset to its current playing position and add the same offset to both loop points…[/:m:gsi8mz2e][/list:u:gsi8mz2e]

Sounds confusing even to me, but there has to be a way to do such things, right? 😉

Oh, and if you have any suggestions to do things completely different with the same results, I’m open for new!


  • You must to post comments

I know this is not the best idea but… Why not make a song with the AA-BBB-BBB portion of the song and another one with AA-CCC-CCC and you swap the file it’s playing from on the fly?
Another thing you could do is check if the "intro" has finished playing (check if it has reached a certain milisecond) and then set the loop points for the second piece of the song you want it to play.
Some pseudocode here:
if(choice == 1)
SetLoopPoints(BBB_Start, MS, BBB_End, MS);
SetLoopPoints(CCC_Start, MS, CCC_End, MS);

I don’t know if those ideas helped.

  • You must to post comments

To #1: That would certainly be the "emergency" solution… but for that, I’d have to play the two sounds simultaneously, with one being played and the other being silent… or, at each switch, setting the offset of the other sound. The sound class does not provide this, only the Channel class has a .getPosition… how to use this properly?
To #2: In this case, since the Sound class does not have that, I’d have to run a timer, checking every millisecond if the "intro" has finished, to then add an offset to the sound (see #1). I guess that timer-thing will be a bit problematic?

By the way, I didn’t quite understand the order of the function calls and who is doing what. First, you let the system play a sound, with a channel that may be null, then you add the channel to a channel group which may have a modified pitch, and then you change the speed of the channel? I find this more and more confusing, could anyone explain this to me?

float speed_fac = 2f;
DSP dsp;
ChannelGroup group;
Channel channel;
system.createDSPByType(DSP_TYPE.PITCHSHIFT, ref dsp);
system.createChannelGroup("Group", ref group);
dsp.setParameter(0, 1 / speed_fac);

system.playSound(CHANNELINDEX.FREE, intro, false, ref channel);
float f = 0;
channel.addDSP(dsp, ref conn);
channel.getFrequency(ref f);
result = channel.setFrequency(f * speed_fac);

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.