0
0

First of, I’m implementing a sound interface based on newest FMOD into our game project with C++.

I got a problem understanding the theoretical usage of DSP, I will try to explain my scenario and you might see what I’m doing wrong and can enlighten me, here it goes:

I have an array of all the DSP in the main header of the "engine" and in startup I initialize them all so I have those I need ready to add to soundfiles instantly.

I have a class that controls all the information about the loaded soundfile, and in that soundfile-class, I have a vector to store different DSP_Effect.

Which (DSP_Effect) is another class that controls all the information about one specific DSP, so here goes a scenario:

  1. Load soundfile into memory.
  2. Add some DSP to the vector in the soundfile-class, with a pointer to the specificed DSP from the array in the base header of the "engine".
  3. When the soundfile is about to play I "AddDSP" all from the vector-list to the active channel that carries out the sound to the speakers, beacuse I don’t have a specific channel to each sound.

Now the problem; Is that a good way to handle multiple DSPs connected to a soundfile?, beacuse it feels that I’m little bit off in understanding how the DSP system works, and yes I have read the manual multiple times to try to figure it out.

Second question; All the initialized DSP in startup, can I use the same DSP to multiple soundfiles?, I mean that when I add to the vector for the specific soundfile I will give it a pointer from the DSP-array in the base class to add in the vector-list.

If someone has the time to read and even more understand what I’m trying to do, please give me some ideas or thoughts because I’m pretty much stuck.

Thanks for any reply
Christer

PS: I might be able to provide a better explaination with some of the code if the text isn’t understandable, then let me know.

  • You must to post comments
0
0

Look at the example ‘dsp_custom’! You can see there how dsp works. It’s just a callback function that is called everytime the buffer gets new data from the sound. When it is called it just takes the input, doe’s something with it and writes it to the output. So it’s no problem to bind that dsp function to more then one channel. Because it is just called from there. So it’s the same as a usual c++ function.

To the first question: i’m not sure if i understood what you want to do. As i understood you want to have a class that stores all dsp functions you want to use. And when you call a functin from it, where you want to bind all dsp effects to the given channel.

Like this?
[code:310mkhej]
myDspObject->BindDSPEffectsToChannel(Channel);
[/code:310mkhej]
If the answere is yes, it is good if you wnat to bind all DSP Effects to the given channel.

Look at the std::map from c++, maybee it is better. Here you can store something, like the dsp and acess it with an key, like a string for example.

When you can do somethin like this
[code:310mkhej]
myDspObject->BindDSPEffectToChannel(Channel,"Echo");
[/code:310mkhej]
But as i remember, fmod does something like this, so you just need to write a class for it if you want to write your own dsp effects or if you want to add dsp groups at once.

Hope this helps.

  • You must to post comments
0
0

Okey, almost, I will try to explain better with some code.

in the SoundEngine.h (SoundEngine-Class) I have (as private):
[code:310vzps3]DSP_Effect * m_DSP_Effects[20];[/code:310vzps3]
and as a function in the SoundEngine I have [code:310vzps3]FMOD_RESULT InitDSP_Effects();[/code:310vzps3]
Which will initialize all my DSP in the array of DSP_Effect:s

And it looks like this for any needed DSP: [code:310vzps3] result = m_DSP_Effects[DSP_TYPE_ECHO]->Init(DSP_TYPE_ECHO);
ErrorCheck(result);
result = pSystem->createDSPByType(FMOD_DSP_TYPE_ECHO, m_DSP_Effects[DSP_TYPE_ECHO]->GetDSPp());
ErrorCheck(result);[/code:310vzps3]DSP_TYPE_ECHO is only a enum (this case nr. 5)

Here is the definition for a DSP_Effect object:
[code:310vzps3]class DSP_Effect
{
private:
int m_nType;
int m_nWhich_DSP_Effect;
float m_fValue;
FMOD::DSP * m_DSP;
FMOD_RESULT result;
public:
.....
};[/code:310vzps3]

Here is a example from main.cpp
[code:310vzps3]SoundEngine->LoadFile("sound//FavSound.wav");
SoundEngine->AddDSP_EffectToFile("sound//FavSound.wav", DSP_TYPE_ECHO, FMOD_DSP_ECHO_DELAY, 0.5f);
SoundEngine->PlaySound("sound//FavSound.wav");[/code:310vzps3]
This example only uses one DSP but you should understand the point, and DSP_TYPE_ECHO is only a enum (this case nr. 5) and the last parameter is the value of the DSP.

Then we go deeper into the "AddDSP_EffectToFile"-function:
First it looks up if the sound is loaded (checks with the filename) and then when it founds the loaded soundfile-object it will call: [code:310vzps3]AddDSPToList(m_DSP_Effects[nType]->GetDSP(), nWhich_DSP_Effect, fValue);[/code:310vzps3]The first parameter is the initialized echo effect from the startup of the SoundEngine (nType = 5, ie DSP_TYPE_ECHO). Second parameter is the FMOD’s definition of ECHO_DELAY and last is the value.
[code:310vzps3]void SoundFile::AddDSPToList(FMOD::DSP *dsp, int nWhich_DPS_Effect, float fValue)
{
DSP_Effect * m_DSPTemp = new DSP_Effect();
m_DSPTemp->SetDSP(dsp);
m_DSPTemp->SetParameters(nWhich_DPS_Effect, fValue);
m_VDSP.push_back(m_DSPTemp);
}[/code:310vzps3]
And the m_VDSP looks like this in SoundFile.h: [code:310vzps3]vector<DSP_Effect
> m_VDSP;[/code:310vzps3]
That is somehow how I thought it should be and work, but I may lack c++-skills or FMOD-skills which makes the whole thing not work, but I would like to know if my thinking is somewhat right?

now the final thing, to call the "PlaySound". It does everything it needs to do, and the
[code:310vzps3]pSystem->playSound(FMOD_CHANNEL_FREE, m_VCachedSoundFiles[i]->GetFMOD_Sound(), TRUE, m_VCachedSoundFiles[i]->GetFMOD_pChannel());[/code:310vzps3]
After given a channel, I does some more settings and then in the final stage before unpausing the sound.
[code:310vzps3]m_VCachedSoundFiles[i]->ApplyAllDSP();[/code:310vzps3]
[code:310vzps3]void SoundFile::ApplyAllDSP()
{
for(int i=0; i < (int)m_VDSP.size(); i++)
{
m_Channel->addDSP(m_VDSP[i]->GetDSP());
}
}[/code:310vzps3]
This last function should add all the loaded DSPs into the channel before it should be played, so all right effects would be added and viola it should play up the sound with all effects, thing is that now it plays up the sound but with non DSP whatsoever, so the final question is, is it my lack of programmaing experience or FMOD understanding I’m lacking?
Suggestions/thoughts, please

Thanks in advance
Christer

  • You must to post comments
0
0

Yeah!, I got it to work, just like I wanted it to work, but my question remains, is this a good way to proceed about DSPs ?

Peace :)
Christer

  • You must to post comments
0
0

Got a new question…
when I want to add a DSP to a whole channelgroup (mastergroup in this case), I use:
[code:jlddp8kp]pMasterGroup->addDSP(dspTest);[/code:jlddp8kp]
That works, it will add a echo effect on the whole group.
But lets say I want to remove the DSP on the whole group, how do I proceed?
Because I will reuse dspTest so I don’t want to release it (then I need to re-initialize) and remove() doesn’t work, it give me "FMOD error! (14) DSP connection error. Connection possibly caused a cyclic depe
ndancy."

So how would I do to remove a DSP effect from a whole group? for a single channel I got it to work, but only beacuse I created a pointer to the original DSP, and I hope that isn’t needed for a group aswell.

Thanks in advance
Christer

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.