0
0

I’m using a three channel aiff file for a Guitar Hero-style music game. Channel 0 is the lead guitar channel I can mutes and unmutes at will. That works. I also need to add a DSP to the guitar channel at will. That doesn’t seem to work. Interestingly, if I replace the multichannel "song.aiff" with a single channel file (e.g. "singleChannelSoundEffect.aiff"), the DSP does work.

1) How do I apply a DSP effect on one channel of a multichannel sound? I’m using FMOD_Channel_AddDSP but to no avail (see code below)

2) Ultimately, I’d like to route the multitrack channel 0 to both left and right speakers, channel 1 (song, left speaker) to left speaker and channel 2 (song, right speaker) to the right speaker. Obviously, I still need to be able to apply a DSP on the guitar sound (and not the song channels).

[code:3lsvei5v]
FMOD_SOUND *song;
FMOD_CHANNEL *songChannel;
FMOD_DSP *dsp;

// Load song
// song.aiff consists of three channels: 0 – guitar track (mono), 1 – song left speaker, 2 – song right channel
[self errorCheck: FMOD_System_CreateStream(system, "song.aiff", FMOD_SOFTWARE, NULL, &song)];
[self errorCheck: FMOD_System_PlaySound (system, FMOD_CHANNEL_FREE, song, TRUE, &songChannel)];

// Mix channels
float leftLevels[3] = { 1, 0, 0 };
float rightLevels[3] = { 0, .75, .75 };

/*
Ultimately, I’d like to have something like this: leftLevels[3] = { 1, .75 , 0 }; rightLevels[3] = { 1, 0, .75 }; and still able to apply a DSP on the guitar channel only.
*/

[self errorCheck: FMOD_Channel_SetSpeakerLevels(songChannel, 0, leftLevels, 3)];
[self errorCheck: FMOD_Channel_SetSpeakerLevels(songChannel, 1, rightLevels, 3)];

// Add DSP effect (to guitar channel only!)
[self errorCheck: FMOD_System_CreateDSPByType (system, FMOD_DSP_TYPE_PITCHSHIFT, &dsp)]; // adding an easy to hear pitch shift DSP for testing purposes

[self errorCheck: FMOD_DSP_SetParameter(dsp, FMOD_DSP_PITCHSHIFT_PITCH, 2.0)]; // For testing purposes, we set pitch to one octave higher

[self errorCheck: FMOD_Channel_AddDSP (songChannel, dsp, 0 )]; // Works if song.aiff is single channel, doesn’t work when song.aiff is multichannel

[self errorCheck: FMOD_DSP_SetSpeakerActive(dsp, 0, TRUE)]; // Still doesn’t work on multichannel file
[/code:3lsvei5v]

  • You must to post comments
0
0

Maybe I should rephrase the question: how do I apply a DSP on one channel of a multichannel wav/aiff?

Any suggestions highly appreciated.

  • You must to post comments
0
0

It looks like your approach is correct. I would reccomend debugging this using FMOD Profiler, it will show the DSP tree and the volume levels per channel on each node. To set this up just pass in FMOD_INIT_ENABLE_PROFILE, Profiler will also show how much CPU is being used.

Note that if you are testing this on iOS with a 3-channel pitch shift can be very expensive. When you say it isn’t working, what is happening? The signal is coming through clean or there is no sound at all?

An alternative is to bake in the effect into a fourth channel to encode into the multichannel wav. There are a number of advantages of doing it this way, firstly DSP effects can be quite expensive particularly on handheld devices, so baking it in offline is a big saving. Secondly you can afford to use more expensive DSP effects when you bake them in offline, the only downside is that the parameters are fixed and you can’t automate the values over time.

  • You must to post comments
0
0

Thx Peter, I’m trying to add a DSP on only one of the three channels (not all three). The DSP parameter is dependent on user input, so the DSP effect has to be real-time, not offline. So far, CPU load doesn’t seem to be a huge issue.

What I meant by ‘isn’t working’ is that the three channel AIFF or WAV plays normally, just without DSP effect. When I replace the three channel AIFF with a single channel AIFF file, the sound plays WITH the DSP effect. Same code, just a different file.

  • You must to post comments
0
0

[quote:747pm6lx]What I meant by ‘isn’t working’ is that the three channel AIFF or WAV plays normally, just without DSP effect. When I replace the three channel AIFF with a single channel AIFF file, the sound plays WITH the DSP effect. Same code, just a different file.[/quote:747pm6lx]
That is very unusual. If you connect profilier and post a screen shot that should give us some insight into what is going on.

  • You must to post comments
0
0

Hi Peter, here are the screenshots.

[img:spdywveg]http://airguitarmove.com/fmod/dspnet_capture_multichannelAIFF.png[/img:spdywveg]
Screenshot 1: 3 channel AIFF, song plays normally but DSP doesn’t seem active (stays at 0.0% CPU). DSP is supposed to be pitch shift channel 0 only (not 1 and 2).

[img:spdywveg]http://airguitarmove.com/fmod/dspnet_capture_singlechannelAIFF.png[/img:spdywveg]
Screenshot 2: Recompiled code with a 1 channel AIFF. Song plays with with audible DSP.

Any ideas why the DSP doesn’t attach to channel 0 of the multichannel AIFF?

  • You must to post comments
0
0

You need to set the DSP parameter FMOD_DSP_PITCHSHIFT_MAXCHANNELS to 3, otherwise it will default to the system output number of channels (which is 2 for iPhone) causing it to just pass the audio through.

  • You must to post comments
0
0

Yep, that was it, thx Mathew.

  • You must to post comments
Showing 7 results
Your Answer

Please first to submit.