Help with cleanly mixing multiple AudioSynthWaveform voices on Teensy 4.0

ejanders

New member
Hi everyone,


I’m working on a Teensy 4.0 project with the Audio Shield, where I want to play multiple simultaneous tones (up to 8 voices) using AudioSynthWaveform. My goal is to play simple chords, each voice controlled by a separate softpot.


Here’s what I’ve tried so far:


  • I used multiple AudioSynthWaveform objects connected to an AudioMixer4, and then to the I2S output.
  • I kept the amplitude of each waveform low (0.3) and tried smoothing the output, but when I play two or more tones, I still hear harsh digital noise / interference.
  • I experimented with trying to manually sum floating-point samples and push them to I2S, but AudioOutputI2S::update() doesn’t accept arguments and AudioStream::allocate() is protected, so that approach doesn’t work.

Some observations:


  • The noise occurs even when the summed amplitudes are well below 1.0.
  • It happens even when the notes are octaves apart, so it doesn’t seem to be a beating or phase problem.
  • Smoothing or envelopes don’t fix it.

My questions are:


  1. Is there a recommended way to safely mix more than 2–4 AudioSynthWaveform voices into a single output without producing digital noise?
  2. Should I be using a different approach for polyphony (e.g., multiple mixers, separate outputs, or another class)?
  3. Are there any best practices for avoiding HF spikes when summing waveforms in the Teensy Audio Library?

Any advice or examples for clean polyphonic output would be greatly appreciated!

TLDR;
I’m trying to play multiple AudioSynthWaveform voices on a Teensy 4.0 via a single AudioMixer4, but when I sum 2+ tones I hear harsh digital noise even at low amplitudes. Smoothing and envelopes don’t help. How can I safely mix multiple voices for clean polyphonic output?
 
Please post a short code example, using the </> code tags, that can be directly imported into the Arduino IDE, and demonstrates the problem.

To answer question 1, yes, you must cascade multiple mixers to mix more than 4 voices. You must then be careful setting levels so the result can’t sum to more than 1.0; the signal can distort badly and in unexpected ways if you don’t do this.
 
And, if you can upload a photo of the hardware setup for us to review.

Did you plug headphones into the headphone connector or did you plug a powered speaker into the headphone connector? This connector is only meant for headphones. This connector uses a virtual ground, not the Teensy ground, not a powered speaker ground.
 
Hi, thank you for your quick responses! Sorry for the delay on my end, classes are quite busy right now...
I did end up figuring it out - it was an issue with my amp module; the potentiometer on it wasn't working right so I could only use it super quiet or super loud, so I was getting distortion as a result of that.
I am using a powered speaker into the line out connector - is that not its intended use? Is there a better way to link the output to a externally powered speaker? Thanks for your help.
 
I am using a powered speaker into the line out connector
Ideally that would be worded “I am using a powered speaker driven by the line out connector” … but there isn’t really a line out connector as such, just a place you can solder a 5x2 header (with one pin omitted).

If you’re using an existing connector, it’s the 3.5mm headphone connector, and as stated by @BillFM must not be used to drive powered speakers or anything else that doesn’t have a floating ground.
 
Back
Top