I have made a program in C and Winapi in Visual Studio with Windows 10 that plays a sound file with different frequencies. However, the frequency of the sounds are not correct. It is about one and a half note lower than expected.
The sound file is in G, and to calculate the desimal number for C, as an example, I do the following:
Frequency of G * X = Frequency of C
X = Frequency of C / Frequency of G = 261.63 hz / 392.00 hz = 0.6674
I have another similar program, and the sounds have the right frequencies, so I can’t understand why it doesn’t work this time. Here’s a simplified version of the program, which is quite straightforward.
int Samplerate = 44100;
float Frequency = 44100 * 0.6674;
result = FMOD_System_Create(&system);
result = FMOD_System_SetSoftwareFormat(system, sampleRate, FMOD_SPEAKERMODE_MONO, FMOD_SPEAKERMODE_DEFAULT);
FMOD_System_SetDSPBufferSize(system, 1024, 4);
FMOD_System_Init(systemx, 12, FMOD_INIT_NORMAL, 0);
result = FMOD_System_CreateSound(system, “Sound1.wav”, FMOD_CREATESAMPLE | FMOD_LOOP_NORMAL | FMOD_2D, 0, &sound[0]);
result = FMOD_System_PlaySound(systemx, sound[0], 0, 1, &channel[channelnumber]);
result = FMOD_Channel_SetFrequency(channel[channelnumber], Frequency);
FMOD_Channel_SetPaused(channel[channelnumber], 0);
Thanks in advance.