Close

Numerically Controlled Oscillator

A project log for PICSPEAK

A rudimentary voice synthesiser in less than 1kB of code.

luciolucio 12/11/2016 at 22:100 Comments

So I did try to use the NCO (Numerically Controlled Oscillator) to generate a variable time base for each vowel and it kind of worked. It actually turned out to be easier than expected.

The idea worked like this:

  1. I kept the PWM working on TMR2 with a fixed frequency of 32kHz.
  2. I modified the main loop to wait on the NCO interrupt instead of the TMR2 postscaler.
  3. I assigned an initial NCO "increment" (524) to obtain the standard 8kHz sample rate.

I run a test to verify that this way I would get the same output as before (when using the TMR2 interrupt). it did!
(NOTE: increment = Fout / (Fosc / 2^20) = 8000 / (16MHz/1MB) = 524)

Then:

  1. I removed the tables for the vowels 'e' and 'i' and replaced them in the scheduler with 'a'.
  2. I added for each 'part' in the schedule a setting for the NCO increment leaving the value to 524 ( the constant EIGHTK) for all non vowels.
  3. I scaled the value of INC proportionally to the length of each of the vowels tables. (E = 645, I = 870)

While debugging the new code I found out a bug in the "silence" table (the signature was supposed to be changed to 0xff, but I had forgotten to update it).

I created a new branch of the project on Github (NCO) and later went back and fixed the "silence bug" in the "master" too...

Discussions