Teensy 3.6 as a top octave generator

Status
Not open for further replies.

aaaxon

Active member
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.

Thanks,
Michael
 
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.
 
Paul,

Thanks for the quick reply! Here is what I'm trying to do:
<https://hackaday.com/2018/08/22/ask-hackaday-answered-the-tale-of-the-top-octave-generator/>

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.

Thanks,
Michael
 
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. :)

Code:
// 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() {
}
 
I happen to have a Teensy LC on hand. I know it has fewer timers than a big teensy. Can I generate more than one PWM tone with a Teensy LC? Looking for at least 3 square waves to XOR into a metallic sound source.

Thanks!
 
I appreciate your help! Now that I can see I can make a steady signal as shown above without using the blocking tone() method, I am all set.
 
Status
Not open for further replies.
Back
Top