Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Teensy 3.6 as a top octave generator

  1. #1

    Teensy 3.6 as a top octave generator

    I need a TOG (Top Octave Generator) for a synth modification. Is it realistic to think that a Teensy 3.6 + the Audio Library would work for this? I'd like to use the PWM pins, not the audio expansion board. Any initial opinions would be appreciated before I jump in and start the work.


  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Could you explain what you mean by "Top Octave Generator"?

    I did a quick search and found an article about generating 12 square waves at different frequencies. If you want something like that, you could pretty easily use 12 of the waveform synth objects, combine them using mixers, and output that to the DAC pin. Even Teensy 3.2 should be able to handle that pretty easily.

    The waveform object can give you sine, sawtooth and other options apart from square waves.

    The DAC is only 12 bits resolution and lacks fancy features like analog volume control that you get from the audio shield. But if you don't need full 16 bit quality, the build in DAC works pretty well.

  3. #3

    Thanks for the quick reply! Here is what I'm trying to do:

    The Teensy 3.6 would need generate 12 independent clocks on 12 different PWM pins. Each frequency would be a note of the chromatic scale with C8 (4186 Hz) as the highest. This provides 12 independent frequencies that can be divided in hardware for lower frequencies. The rest of the hardware already exists; I'm trying to replace the TOG with a Teensy.


  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Quick followup to this old thread, when Teensy 3.6 was the latest board.

    Now Teensy 4.0 is available, with PWM capable of 18 independent frequencies. So this is now very easy.

    // Top Octave Generator
    void setup() {
      analogWriteFrequency(2, 4186.01);
      analogWriteFrequency(4, 4434.92);
      analogWriteFrequency(5, 4698.64);
      analogWriteFrequency(6, 4978.03);
      analogWriteFrequency(7, 5274.04);
      analogWriteFrequency(10, 5587.65);
      analogWriteFrequency(11, 5919.91);
      analogWriteFrequency(12, 6271.93);
      analogWriteFrequency(13, 6644.88);
      analogWriteFrequency(14, 7040.00);
      analogWriteFrequency(15, 7458.62);
      analogWriteFrequency(18, 7902.13);
      // can also use 19, 22, 28, 34, 36, 38
      analogWrite(2, 128);
      analogWrite(4, 128);
      analogWrite(5, 128);
      analogWrite(6, 128);
      analogWrite(7, 128);
      analogWrite(10, 128);
      analogWrite(11, 128);
      analogWrite(12, 128);
      analogWrite(13, 128);
      analogWrite(14, 128);
      analogWrite(15, 128);
      analogWrite(18, 128);
      // Also generate 6 more frequencies, just to
      // show that more than 12 are possible...
      analogWriteFrequency(19, 1200);
      analogWriteFrequency(22, 1300);
      analogWriteFrequency(28, 1400); // bottom side
      analogWriteFrequency(34, 1500); // bottom side
      analogWriteFrequency(36, 1600); // bottom side
      analogWriteFrequency(38, 1700); // bottom side
      analogWrite(19, 128);
      analogWrite(22, 128);
      analogWrite(28, 128);
      analogWrite(34, 128);
      analogWrite(36, 128);
      analogWrite(38, 128);
    void loop() {

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts