# Sound played does not have the right frequency

**URL:** <https://qa.fmod.com/t/sound-played-does-not-have-the-right-frequency/21583>\
**Category:** FMOD Engine\
**Created:** [May 6, 2024, 1:15pm UTC](https://qa.fmod.com/t/sound-played-does-not-have-the-right-frequency/21583 "2024-05-06T13:15:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Keitel1](https://avatars.discourse-cdn.com/v4/letter/k/3da27b/32.png) [@Keitel1](https://qa.fmod.com/u/Keitel1)\
**Post date:** [May 6, 2024, 1:15pm UTC](https://qa.fmod.com/t/sound-played-does-not-have-the-right-frequency/21583/1 "2024-05-06T13:15:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Keitel1](https://avatars.discourse-cdn.com/v4/letter/k/3da27b/32.png) [@Keitel1](https://qa.fmod.com/u/Keitel1)\
**Post date:** [May 7, 2024, 5:24pm UTC](https://qa.fmod.com/t/sound-played-does-not-have-the-right-frequency/21583/2 "2024-05-07T17:24:56Z")

</div>

I have now come to realize that this problem only occurs in Debug mode. When running it in Release mode it works as expected. I don’t understand why it is like this, but the problem is solved.

---

<div class="post-metadata">

**Author:** ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)\
**Post date:** [May 8, 2024, 3:11am UTC](https://qa.fmod.com/t/sound-played-does-not-have-the-right-frequency/21583/3 "2024-05-08T03:11:27Z")

</div>

Sounds like the issue may be due to differences in floating point precision/behavior between release and debug. Either way, I’m happy to hear that it isn’t an issue in release.
