This is probably a set of reasonably obvious questions, but I just want
From what I understand about channels, and playing sounds, when you
call [i:6vk49acm]FSOUND_PlaySound( FSOUND_FREE, ptr_to_the_sample )[/i:6vk49acm] the
channel that FMOD selected to play the sample on is returned (as
mentioned in the docs). What I want to clarify is whether the channel that
was allocated remains the same [b:6vk49acm]while the sample is playing[/b:6vk49acm] – ie: I
assume there is no way that a sample can start playing on one channel,
then be transferred to another channel at some stage while it is still
playing … am I right? – even if it is looping?
I am also aware that if a channel is not reserved then a sample can
be “kicked off” a channel. Does this mean that the sample that was
originally playing on that channel ceases to play? – the moment it was kicked?
Also … If I set a sample to play on a channel – then want to test later
whether that sample is still playing, I assume that just testing whether a
channel is being used (using [i:6vk49acm]FSOUND_IsPlaying(channel)[/i:6vk49acm] ) is
insufficient, as the channel could be being used, but not by the same
sample that was started on it … is this correct?
… If so, then that would mean I would have to use both [i:6vk49acm]FSOUND_IsPlaying(channel)[/i:6vk49acm]
[b:6vk49acm]and[/b:6vk49acm] [i:6vk49acm]FSOUND_GetCurrentSample(channel)[/i:6vk49acm] to test whether [b:6vk49acm]a[/b:6vk49acm] sample
is being played on the channel [b:6vk49acm]and[/b:6vk49acm] that the sample is the same
one that was started on the channel in the first place … how am I going so far??
Any answers or comments would be greatly appreciated
I have another quesiton …
In regards to some of the channel functions – e.g. FSOUND_GetLoopMode – the parameter to pass
in is a channel, whereas a function like FSOUND_SetPaused the parameter is “channel number/handle”
Is this an anomaly of the documentation, or are the two cases different?
Am I right to assume that any where a channel is expected as a parameter, I can pass in a “channel handle”?
[quote:fncfr1l5]i’ve now updated the docs so that all functions say ‘The channel number/handle …'[/quote:fncfr1l5]
Next thing I have to ask is …. Is there a way that I can find out whether any sound is playing on a channel (i.e. I [b:fncfr1l5]don’t[/b:fncfr1l5] have a channel handle), and then force it to stop playing
…. or do i always need a channel handle??
Something I just thought of …
If I don’t currently have a channel handle, is there a way to get the channel handle off a currently playing sound??
Some function in a class makes a call to start playing a sound
Then another class wants that sound to lower in volume (or stop it, or whatever)
– Since the 2nd class doesn’t have the channel handle to the sound, it can’t access the fmod functions to do this
(well technically it can, but the functions of course will have no effect due to not having a channel handle ~:)
so back to the original question…
Is there a way to get the channel handle of a currently playing sound??
Would that work?
If I just use the channel number, then try to alter a sound playing on
a channel using just the channel number, wouldn’t that actually do nothing,
as I am not using a “Channel Handle” (y’know the whole channel number/
sample ref num combination thing)?
OK … I take that last post back ….
I just did some experimenting, and it turns out that you [b:1svoh2f6]can[/b:1svoh2f6] stop a sound,
or whatever, using just the channel number.
The channel handle is just to safe guard against the case where another
sound is playing on the same channel as a previous sound, then if you try
to stop the 1st sound, because the channel handles don’t match, the 2nd
sound won’t be stopped by mistake.
BUT you can stop the 2nd just by specifying the channel if you want.
… which is why you said about matching the sample pointers – then using
the channel number….
seems I didn’t quite get it before
think I’m on top of the whole thing now …. 8)
There is no way that a sample switches to another channel while playing, even when it starts over in a loop.
When a sample gets kicked off its channel, it ceases to play, at the moment it was kicked; with a latency of up to 25ms as the sample data is still in the mixing buffer.
I’m not sure, this depends on whether FSOUND_IsPlaying uses only the channel number or the reference count, too (the channel handle returned from the play functions does not only contain the channel number, see docs).
If it only uses the channel number you’d have to do it as you outlined, if it checks the reference count, too, one call to FSOUND_IsPlaying should suffice.
My guess is that it evaluates the full channel handle, not only the number.
I’ve never come to test this, haven’t ever reached the channel limit yet.
- night answered 14 years ago
Ok – that all makes sense
So just to clarify …
1) I start a sound and store the channel handle returned
2) For some reason the original sample being played is kicked off the channel
3) I then try to stop the original sound using the channel handle that I stored
Am I right to assume that the NEW sound being played on the channel will
NOT be stopped because the channel handle of the NEW sound will not
match the channel handle of the ORIGINAL sound? (remembering that the
channel handle is a combination of the channel number the sample was
played on and the reference count into the sample pool)
The docs cover the fact that you can’t change attributes (ie volume /
pan / frequency / 3d position) – but do not say anything about functions
Please login first to submit.