0
0

Hello!

What I am looking to do is have a ‘Level’ class that has two types of BGM that play depending on where a plater is in that level.

This means that I need to stop one sound from playing and start the other. It seems to me like this would be a very obvious thing to do, so I’m sorry if it is, but I really can’t figure out from the documentation how to go about this.

At the moment I am playing the sounds with PlaySound passed with a channel. I then return the channel from the Level and ->setpaused() but this never works. In fact nothing I try and do to the channel seems to effect the sound, so I think I have some kind of wrong idea about the link between a sound and a channel also.

Any advice, or a point of what to read about would be appreciated.

  • You must to post comments
0
0

I am a complete noob myself, as I have only started working with FMOD Ex today, but perhaps I can do something for you, since I have been able to effectively do things with my channels.

As far as I understand, a sound is a file you have somehow made accessible and a channel is like an instance of that sound. Much like an instance of a class. When you call playSound, you give it a pointer to a channel, which after the call will contain the channel of that playing sound.

Now, there are, as you can find in the documentation, many things you can do if you have stored this channel. As far as my knowledge goes, with the C++ API it would go like:

myChannel->setPaused(true);
myChannel2->setPaused(false);

// Or something of that nature if I correctly understood what you wanted to accomplish.

If this code gets executed, I suppose it really should stop playing.

I can only hope my meager experience with this API can be of service to you. If not, hopefully someone else can.

Cheers,
Dysprosium

  • You must to post comments
0
0

Hi, thanks for your reply.

Yeah I was looking at channel::setpaused and trying to play with Mute and setPosition also. What the problem seemed to be, was that I was returning a channel and no matter what function I called it wasn’t effecting the sound.

I have a sort of wrapper class around my sounds, what I wanted was quite complicated and now it is cleaer to me that I must have some piece of logic in that class that is wrong.

At any rate, I started a new console project and did the following (after initialising it of course):

[code:17unnolp]FMOD::Sound* thisSound;

result = sys->createSound("C:\\sss.mp3",FMOD_SOFTWARE,0,&thisSound);

result = sys->playSound(FMOD_CHANNEL_FREE,thisSound,false,&channel);

system("pause");

channel->setMute(true); //->setPaused(true);

system("Pause");

channel->setMute(false);
channel->setPosition(0,FMOD_TIMEUNIT_MS);
///channel->setPaused(false);

system("Pause");
sys->release();[/code:17unnolp]

That code is not exactly what you would put into a project, but it worked fine. So that means I will just have to re-think the way I make my wrapper class.

Sorry for posting, this probably should have been one of the first things I tried.

Thanks again for the reply though.

  • You must to post comments
0
0

Are you calling System::update() every frame?

  • You must to post comments
0
0

I do now. Silly me, that was one of the things that helped make it work right.

I have a class that contains random things, and also a sound and a channel. The basic idea was you could use this class as an object to be stored in a vector. So, what I do is, get the class object from this store and call the play function:

[code:1lrav52z]void MipSound::playMipSound(bool initPaused,bool useChannel){
thisSystem->playSound(FMOD_CHANNEL_FREE,thisSound,initPaused,&thisChannel);
}[/code:1lrav52z]

and I use the channel (I have another function that uses no channel also).

Like I said, I want to be able to stop and change the sound. For now I want to make use of this function:

[code:1lrav52z]void MipSound::stopMipSound(){
thisChannel->setMute(true);
}[/code:1lrav52z]

The best way I can see at the moment to ‘stop’ a channel from playing, is to mute it, and when you want to play it again set the position to 0 before doing it and then unmute it. However, wouldn’t I run out of channels? Even if I didn’t this seems like a horrible way of doing it.

It feels to me like I need to ‘free’ the channel while it is not in use – unless this is done automatically if muted?

Thanks again for your replies, they have helped me solve my problem ^_^.

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.