Skip to content

Instantly share code, notes, and snippets.

@marcusmueller
Created January 15, 2015 14:03
Show Gist options
  • Save marcusmueller/666ca6a3d0d00c7c2ab7 to your computer and use it in GitHub Desktop.
Save marcusmueller/666ca6a3d0d00c7c2ab7 to your computer and use it in GitHub Desktop.
Answers

step=wave_table_len/10:

consider the for loop:

    for (size_t n = 0; n < buff.size(); n++){
        buff[n] = wave_table(index += step);
    }

now, we see that we hit the wave_table_lenth item in wave_table when n==10; now remember that this wave table lookups happens modulo wavetable_len, ie. wave_table(n * wave_table_len)==wave_table(0) for n being any integer.

This means that our generated signal is 10 sample periodic!

We thus learn that f_sine = f_sample/wave_table_len * step. Thus, step is the relative frequency of the generated sine. Yay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment