0
0

hello folks,

i am developing a program which allows to draw multiple lines on the screen. each line represents a sine oscillator being played. in order to always know exactly, which channel belongs to which line object, i wanted not to use FMOD_CHANNEL_FREE when calling System::playDSP.
i first passed an integer value with the object ID but then figured out that it won’t work…

has anyone a clue how i could:

a) define the channel index myself according to the line ID (which is guaranteed to be unique)

or b) use another technique to always be able to identify a line’s channel?

thx in advance,
xonic

  • You must to post comments
0
0

Sounds like FMOD_CHANNEL_REUSE might be what you’re looking for. So you could use FMOD_CHANNEL_FREE at the start to get a valid channel handle for each line, then every subsequent call to playDSP use FMOD_CHANNEL_REUSE.

Hope this helps,

-Pete

  • You must to post comments
0
0

You can use REUSE the first time too, just as long as you pass 0 in it will create a new channel handle, then from then on it reuses it.

  • You must to post comments
0
0

thanks for helping out!

well, maybe i was just too tired yesterday for seeing the solution.
i slept over it and realized i could even use FMOD_CHANNEL_FREE.

this is how my code looks:
[code:1f46fd6b]- (void)playSoundOnChannel:(int)channelID withFrequency:(CGFloat)frequency{

result = FMOD_OK;

result = system->playDSP(channelID, sineDSP, false, &channels[channelID]);
ERRCHECK(result);

result = channels[channelID]->setFrequency(frequency);
ERRCHECK(result);

}[/code:1f46fd6b]

so if changing it to:
[code:1f46fd6b]- (void)playSoundOnChannel:(int)channelID withFrequency:(CGFloat)frequency{

result = FMOD_OK;

result = system->playDSP(FMOD_CHANNEL_FREE, sineDSP, false, &channels[channelID]);
ERRCHECK(result);

result = channels[channelID]->setFrequency(frequency);
ERRCHECK(result);

}[/code:1f46fd6b]
i could always get the ID of a channel by just checking the index of the channels array holding all my channels since that index happens to have the same value range as my line IDs have.

so… this leaves me with just another little question i’d like to ask to make sure i understood this:
if i have a sineDSP object, i can play it as often as i want (actually until my max_voices are all in use) by just triggering the playDSP method and do not need any further sineDSP objects? right?

thanks!
best,
xonic

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.