Academy Dashboard Forum Production Production Techniques An error in "The Circle of Fifths!" Reply To: An error in "The Circle of Fifths!"

Jonathan Marshall

    Hi Lisa and Chris,

    The number sequence looks like it is subtracting something slightly less than 0.98 but rounding to 1 decimal place each time:

    -1.0 = -0.98 rounded down
    -2.0 = -1.96 rounded down
    -2.9 = -2.94 rounded up
    -3.9 = -3.92 rounded up
    -4.9 = -4.90
    -5.9 = -5.88 rounded down
    -6.8 = -6.86 ??? oops
    -7.8 = -7.84 rounded up
    -8.8 = -8.82 rounded up
    -9.8 = -9.80
    -10.7 = -10.78 oops again

    With tuning notes in the DX7 synth code I wrote - I pre-calculated a floating point (double) table of note frequencies for each MIDI note number (MIDI note 69 = Concert A). Excuse the C++ code:

    void masterTune (double concert_A)
    if (concert_A > 0.0)
    for (int note = 0; note < 128; note ++)
    noteToFrequency_ [note] = concert_A * pow (2.0, (float (note - 69) / 12.0));

    Obviously there are going to be rounding errors in these calculations but they shouldn't accumulate because the pitch of each note is calculated individually and not based on the pitch of a lower note. This is just really the start of the calculations for my program - each voice has six oscillators at different ratios / detunes from the fundamental which is the frequency from the table adjusted by the pitch envelope and pitch bend + modulation controls. Then it has to calculate the output waveform ...

    I don't know for sure but I believe that most (if not all) DAWs use floating point instead of integer for summing. It would make sense - for the DX7 I initially coded in floating point and it sounded great until I played more than one note! Recoding the waveform rendering code in integer with a few other speed-up tricks and the it can play 32 voices with nary a glitch.