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:
- Load soundfile into memory.
- 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".
- 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
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.
- SkitZos asked 11 years ago
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.
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
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.
- chriss answered 11 years ago
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;[/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);
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:
FMOD::DSP * m_DSP;
Here is a example from main.cpp
SoundEngine->AddDSP_EffectToFile("sound//FavSound.wav", DSP_TYPE_ECHO, FMOD_DSP_ECHO_DELAY, 0.5f);
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();
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.
for(int i=0; i < (int)m_VDSP.size(); i++)
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?
Thanks in advance
Got a new question…
when I want to add a DSP to a whole channelgroup (mastergroup in this case), I use:
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
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
Please login first to submit.