Confusion about System addDsp

actually the real reason you’re having this issue is that the sound is being played at 48khz really, and its a 44khz sound, so not really Dirac related. The point above still stands though. You either have to use a sound that matches the sample rate of your output (resample the wav to 48khz) or set the output to match the sample rate of the sound with System::setSoftwareFormat and set it to 44100 in this case.

So I replaced
FMOD_System_GetSoftwareFormat(system, &sampleRate, NULL, NULL);
sampleRate = 44100;
but there was no change. The program still played the file one semitone above normal.
Then I tried to replace
FMOD_ChannelGroup_AddDSP(channelgroup,1, mydsp);
FMOD_CHANNEL *channel[3];
FMOD_System_PlayDSP(system, mydsp, channelgroup, 0, &channel[1]);
but then there was no sound.

Did you call it before FMOD_System_Init? I have modified the example do call setSoftwareFormat before init with 44100, and with my other recommendations, it is playing perfectly.

Yes, now now it plays the file in the right tuning. That’s great. But I still can’t make the System_PlayDSP command work, when I replace it for the AddDSP command, though the value of the result variable is FMOD_OK. There is just no sound, and I am not able to see anything wrong with the syntax of the command.

Hi Ketil. I’ve checked into this. playDSP would be the best way to do it, but it looks like there is a bug where the dsp is not transferring its channel count to the resampler. I’ll try to get this into a build which goes out in the next day or 2.

Another way to fix it is to use process callback instead of read callback, and make sure the process FMOD_DSP_PROCESS_QUERY mode gets the right number of channels back. Using read callback, it is getting 0 channels back at the moment which is the reason for the issue.

Hi again,

I have recompiled the program with your last Fmod version, but I still have one issue, though I don’t know if it is directly related to Fmod or something else. I have transferred the console application to become a function in a Windows API program, just making the necessary adjustments. When I include the command FMOD_System_PlayDSP(systemx, mydsp, channelgroup, 0, &channel[1]) in the function, the program exits with the debug message Native’ has exited with code -1 (0xffffffff). However, when I put a system(“pause”) command after the PlayDSP command it works, but then I also get the additional console application window. I see no reason why the program should exit, as it doesn’t do so when I remove the PlayDSP command. I therefore wonder if you could give me an idea what could be wrong?


I guess I’ll have to use a thread function. But if I then want to play more than one file like this simultaneously, don’t I then have to make two thread functions?

It really sounds to me like your program just exited because you didnt wait for input.
I dont see why you would need a thread, or think you need threads to play sounds? FMOD has a playsound command, you just call them one after the other.
The standard way to make a windows program is to respond to messages, or run a main loop in winmain and translate and dispatch the necessary windows messages as they come in (you still need to do this either way), but in between this stuff, call your game code update function, which would be calling fmod functions. Have you written a windows program before? This is starting to get off topic for FMOD Q/A but there are plenty of resources online to get you started.

Hi Brett!
No, no, this must be a misunderstanding. I know how to program in C for Windows and how to make sounds with Fmod. Though I admit that my understanding of the DSP functionalities is somewhat limited. The issue is that I have a function with a playDSP command that I call from the main program. But when I call the function an it reaches the playDSP command, the proram exits. It might be because of some triviality that I have overlooked, but I am not able to see that for now. So if you could take a look at the code of the function below, and see if you can find anything wrong, it would appreciate it very much. The other functions that is called by this function is the same as in the previous examples.

void timestretch(int selection, float time, float pitch, char infileName[]){

FMOD_DSP		        *mydsp;
FMOD_CHANNELGROUP	*channelgroup;
    void				        *dirac;

userDataStruct state;

result = FMOD_System_GetSoftwareFormat(systemx, &sampleRate, NULL, NULL);	
result = FMOD_System_CreateSound(systemx, infileName, FMOD_LOOP_NORMAL, 0, &sound[selection]);

state.sReadPosition = 0;
state.sSound = sound[selection];

result = FMOD_Sound_GetLength(sound[selection], &state.sFileNumFrames, FMOD_TIMEUNIT_PCM);


result = FMOD_Sound_GetFormat(sound[selection], NULL, NULL, &state.sNumChannels, &state.sNumBits);


dirac = DiracCreateInterleaved(kDiracLambdaPreview, kDiracQualityPreview, state.sNumChannels, sampleRate, &diracDataProviderCallback, (void*)&state);

    static FMOD_DSP_DESCRIPTION  dspdesc; 

    memset(&dspdesc, 0, sizeof(FMOD_DSP_DESCRIPTION)); 

    strcpy(, "My first DSP unit");      
	dspdesc.numinputbuffers     = 0;                      = &myDSPCallback; 
            dspdesc.userdata     = (void *)dirac; 

    result = FMOD_System_CreateDSP(systemx, &dspdesc, &mydsp); 


result = FMOD_System_GetMasterChannelGroup(systemx, &channelgroup);


result = FMOD_System_PlayDSP(systemx, mydsp, channelgroup, 0, &channel[1]);




Thanks in advance.


When debugging with the above code; I get the following error message:

Unhandled exception at 0x75c8812f (KernelBase.dll) in DhruvaNada2.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0026f068…


I made the “state” variable into a global variable and then it worked. I therefore consider the case solved. Thanks for all help and support.