I have made a MIDI application in C for Windows using Fmod and my own sound files. I connect a MIDI keyboard, and it works fine, except for some minor issues.
Included in the program is a pitch bend function that makes it possible to move or slide the sound between notes by rapidly changing the pitch in small increments. When doing this there is however occasinally, and with irregular intervals, som muted knocking sounds in the background, and I wonder if it could be possible to get rid of these. It also frequently happens that the controls on the PC screen freezes, while it is still possible to play the keyboard. In addition, I have som sound loops going on in the background using other channels.
The sound files are from 2 to 10 seconds long, and I notice that there are more knocking sounds with the longer sound files. I also use a short dsp fade in function, because it softens the playing of the sounds, but I also notice that there is more knocking sounds when using this function than when not using it. I therefore wonder if it is a question about the computerâs capacity. That there are too much processing going on in short time intervals for a normal computer to handle.
I could give the whole code, about 100 lines, but maybe itâs not necessary. I give for now the parts that I believe is most relevant:
First Playsound with the dsp function:
result = FMOD_System_PlaySound(systemx, sound[soundnr], 0, 1, &channel[chx]);
result = FMOD_System_Update(systemx);
FMOD_Channel_SetFrequency(channel[chx], kfreq * scale[keynumber]);
FMOD_Channel_SetVolume(channel[chx], Volume);
FMOD_System_GetSoftwareFormat(systemx, &rate, 0, 0);
ERRCHECK(result,101);
result = FMOD_Channel_GetDSPClock(channel[chx], 0, &dspclock);
ERRCHECK(result,102);
FMOD_System_Update(systemx);
result = FMOD_Channel_AddFadePoint(channel[chx], dspclock, 0.0f);
ERRCHECK(result,102);
result = FMOD_Channel_AddFadePoint(channel[chx], dspclock + (rate * 0.05), Volume);
ERRCHECK(result,102);
FMOD_System_Update(systemx);
result = FMOD_Channel_SetPaused(channel[chx], 0);
Then the code for the pitch bend:
// GLOBAL VARIABLES:
// float Slidingpoint[1000];
// int S_point;
// int Slidingnote[37];
// int Slide;
if(message == 224){
//keyvalue=((dwParam1>>16)&0xFF); // Value given earlier when pressing a key
Slide = (int) (keyvalue - 64);
FMOD_System_Update(systemx);
if(keynumber < 12) frequency = Slidingpoint[S_point + Slide];
if(keynumber > 11 && keynumber < 24) frequency = Slidingpoint[S_point + Slide] / 2;
if(keynumber > 23) frequency = Slidingpoint[S_point + Slide] / 4;
result = FMOD_Channel_SetFrequency(channel[chx], kfreq * frequency);
FMOD_System_Update(systemx);
}
The variable âkeyvalueâ increases or decreases as the wheel on the midi keyboard is moved forward or backward. The âSlidingpointâ table is a series of frequencies in small intervalls. The âS_pointâ variable is the element number in âSlidingpointâ that corresponds to the frequency of the note from which the pitch bend starts. Hope itâs understandable.
Anyway, thanks for a fantastic system, and thanks in advance if someone would try to help me out with this. It would be greatly appreciated.
Sincerely