Board advice for synth project. Does 4.0 make sense?

Status
Not open for further replies.

colorado_hick

Well-known member
I am trying to choose a board for my next synth. For the first one (https://hackaday.io/project/163160-chromatic-button-synth) I just used one of the DAC channels on the 3.6. It is just doing simple wave form synthesis. When I play more then 3 or 4 notes at the same time things get pretty crunchy and distorted.

For V2 (see chasis here: https://photos.app.goo.gl/UojEQzD4vJLHp2LP6) I have added a 3 axis joystick so I can play around with some FM synthesis. I would also like to get up to 8 note polyphony.

Im curious for my application if I could get by with the PT8211 audio kit or should I splurge for audio shield? With the new Teensy 4.0 boards has there been any improvements to the onboard DAC that for a simple application like mine would make the additional components unnecessary?
thanks!
 
I am trying to choose a board for my next synth. For the first one (https://hackaday.io/project/163160-chromatic-button-synth) I just used one of the DAC channels on the 3.6. It is just doing simple wave form synthesis. When I play more then 3 or 4 notes at the same time things get pretty crunchy and distorted.

For V2 (see chasis here: https://photos.app.goo.gl/UojEQzD4vJLHp2LP6) I have added a 3 axis joystick so I can play around with some FM synthesis. I would also like to get up to 8 note polyphony.

Im curious for my application if I could get by with the PT8211 audio kit or should I splurge for audio shield? With the new Teensy 4.0 boards has there been any improvements to the onboard DAC that for a simple application like mine would make the additional components unnecessary?
thanks!

The Teensy 4.0 does not have an onboard DAC, though if you aren't using a SPI device, you can use the MQSL and MQSR pins (pins 10 and 12).

Instead of a DAC, it is probably best to use I2S output and do digital sound output. I had a thread about doing sound output without using the audio shield that gives two sample sketches, one using a cheap I2S amplifier to a mono speaker (or possibly I2S amplifier to stereo speakers), and also using MQS to output sound:

Here is the I2S mono amplifier that I used, plus another I2S board that can do stereo (I haven't tried the stereo board yet):

2019-08-30-23-32-005-teensy.jpg


Note, the Teensy 4 has multiple different sound inputs/outputs:
  • Main I2S channel, with 4 separate outputs (OUT1A, OUT1B, OUT1C, OUT1D), 1 input (IN1), plus the 3 clocking pins (MCLK1, BCLK1, and LRCLK1);
  • Second I2S channel, with 1 output (OUT2), 1 input (IN2), plus the 3 clocking pins (MCLK2, BCLK2, and LRCLK2);
  • MQS (medium quality sound) left/right output;
  • S/PDIF input/output (IIRC, while the pins are defined, there isn't yet library support for this);
  • I would imagine you can probably use the 6 serial ports for MIDI in/output;
  • USB audio is a possibility, though I don't know what level of support there is;
  • I have no idea whether the CAN buses can be used for sound; and
  • Using a PWM pin for output with appropriate capacitors and amplification.
 
Last edited:
Thanks Micheal.
This is really helpful (especially after I researched some of these protocols that I do not know much about!) I guess what it comes down to for me is the most likely scenario is that I would be interfacing I2S to some sort of external DAC. The amplifier is not that intriguing to me because I want line level signal only.

I am still missing some basics. If I am using the audio libraries to do FM synthesis, then interfacing I2S to something else for digital -> audio conversion, does that 'something else' have impact on the quality of my audio signal or the complexity of what I can do with synthesis or my polyphony level? Or does all of that synthesis and waveform summing happen on the teensy board before the I2S interface? If the only thing that happens after the I2S interface is digital audio conversion then it seems like the 8211 kit (https://www.pjrc.com/store/pt8211_kit.html) would be a great option for me. In other words I am assuming that what the audio shield brings to the table that the 8211 kit doesn't have is the audio-> digital conversion and the SD card slot, neither of which impact me, but I would love to have someone validate that assumption.

Is the PT8211 audio kit compatible with teensy 4.0 just using header pins?
 
Thanks Micheal.
This is really helpful (especially after I researched some of these protocols that I do not know much about!) I guess what it comes down to for me is the most likely scenario is that I would be interfacing I2S to some sort of external DAC. The amplifier is not that intriguing to me because I want line level signal only.

I am still missing some basics. If I am using the audio libraries to do FM synthesis, then interfacing I2S to something else for digital -> audio conversion, does that 'something else' have impact on the quality of my audio signal or the complexity of what I can do with synthesis or my polyphony level? Or does all of that synthesis and waveform summing happen on the teensy board before the I2S interface? If the only thing that happens after the I2S interface is digital audio conversion then it seems like the 8211 kit (https://www.pjrc.com/store/pt8211_kit.html) would be a great option for me. In other words I am assuming that what the audio shield brings to the table that the 8211 kit doesn't have is the audio-> digital conversion and the SD card slot, neither of which impact me, but I would love to have someone validate that assumption.

Is the PT8211 audio kit compatible with teensy 4.0 just using header pins?

Somebody with more depth in the sound processing area will have to answer most of these questions. I believe (but I certainly do not know) that everything wtihin the Teensy is handled in a digital fashion (i.e. I2S).

I believe the PT8211 kit will not work with the Teensy 4.0 if you attach it directly, due to the pinout differences for sound between the Teensy 3.2/3.5/3.6 and Teensy 4.0. Like the larger audio adapter, you would likely need to use jumper wires, etc. to reroute the pins.
 
... When I play more then 3 or 4 notes at the same time things get pretty crunchy and distorted...
Assuming you new to this it sounds like you are overflowing the signal and you are hearing digital clipping.... which even a bit of is very nasty.

I don't use the audio library so I don't know how various moduals deal with signal overflow specifically but you definitely need lower gain if you are handling multiple voices.

https://forum.pjrc.com/threads/35400-Audio-Tutorial-and-gain-clipping


Use more attenuation before/when mixing signals together. You don't need to reduce each to 1/n gain to avoid clipping as the signal phases tend to cancel out much of the 'gain' from adding signals. Making soft synths I used to start with about 20% gain to allow for polyphonic output and the tweak upwards.
 
I should mention it's very unlikely running your code on a T4 will improve anything. Also I believe some of the audio options mentioned above are not available yet for T4.


fyi... should read 'Assuming you're new to this...' above ;)
 
As MichaelM noted - I can confirm the PT8211 kit works {at least on the minimal testing done in Beta} with T4 - when properly wired - same changes as needed for the Audio card where pin locations changed - for the fewer pins used.
 
Thanks Micheal.
This is really helpful (especially after I researched some of these protocols that I do not know much about!) I guess what it comes down to for me is the most likely scenario is that I would be interfacing I2S to some sort of external DAC. The amplifier is not that intriguing to me because I want line level signal only.

I am still missing some basics. If I am using the audio libraries to do FM synthesis, then interfacing I2S to something else for digital -> audio conversion, does that 'something else' have impact on the quality of my audio signal or the complexity of what I can do with synthesis or my polyphony level? Or does all of that synthesis and waveform summing happen on the teensy board before the I2S interface?

The Teensy 4.0 has far more horsepower for synthesis and any I2S->audio card can be patched onto the output pins so no need to stay with the one suggested. Loads on Aliexpress and elsewhere. My personal preference is the PCM5102 for synthesisers, but the AKM velvet sound ones for mixers.

Always best to try to use 96kHz sampling so you reduce the likelihood of aliases coming into the audio band. Needs twice the horsepower of course but the Teensy 4 isn't bad.
 
Hello, I am a beginner, and the horsepower you alluded to is what made me buy the teensy on a whim after a review by hackaday. I regret it now since all this is overwhelming. I gave up on trying to use the 4.0 as a USB host and midi to cv converter. so Please I wanted to ask what would be the best way to use the teensy as a polyphonic/wavetable/fm synthesizer and send the output to a headphone or speaker. Thank you
 
Hello, I am a beginner, and the horsepower you alluded to is what made me buy the teensy on a whim after a review by hackaday. I regret it now since all this is overwhelming. I gave up on trying to use the 4.0 as a USB host and midi to cv converter. so Please I wanted to ask what would be the best way to use the teensy as a polyphonic/wavetable/fm synthesizer and send the output to a headphone or speaker. Thank you

If you're a beginner it's always best to build someone else's design first.
Google for existing projects such as
https://www.pjrc.com/polymod-polyphonic-digital-modular-synth/
https://www.hackster.io/news/teensy...kable-step-sequencer-synthesizer-e57fcee233b7
or many others. Build one of them and get it working and you'll then learn the basics to move onto designing your own synth.
 
For polyphony all the audio channel mixing is done on Teensy and the final data is sent to a DAC (onboard DAC for <T4 or external). For mixing you need to make sure you don't under/overflow the final data or it'll cause "cracking" in the audio. For this you should use higher precision temporal buffer (e.g. 32bit) than your final output (e.g. 16bit) and clip the under/overflow data when converting from the temporal to the final audio buffer. For example if the final mixed sample data value is 40000 after adding up all the channels, you should clip it to max 32767 for 16bit output. Also for polyphony you should reduce the dynamic range of individual channels to reduce clipping which causes it's own type of distortion but you shouldn't do it with 1/n ratio (n-number of channels) like oddson said or you'll unnecessarily reduce the precision.

If you want to get quickly up to speed or check how it can be done, I have this GitHub project: https://github.com/JarkkoPFC/arduino-music-player

Below is a video of the project doing 32 channel stereo mixing on Teensy 4 + Audio Shield (16bit stereo, 44KHz) with wavetable-based instruments. For wavetable FM I'm also doing anti-aliasing of the sample data to improve quality and support multiple wavetables per instrument to better handle wider range of frequencies. IIRC, the piano instrument for example uses 3 wavetables for better quality that are used depending which notes are being played, but for most instruments it's fine to use only one wavetable.


I have the project also running on <T4 using onboard 12bit DAC (only mono for now even on MCU's with two DAC's). Below is video of the project running on T3.6 using the 12bit DAC of the MCU and mixing 8 channels. T3.6 can mix much more channels, but this piece of music I wanted to record just happens to use 8 channels. The audio quality in the video doesn't quite do justice though because it's played back through speakers and recorded on my phone:


Cheers, Jarkko
 
Last edited:
As well as a hard limiter as Jarkkol suggests, it is usually better to include a softer compression system on the output as well so that the limiter only operates once. Getting the compression law and time constants right on this isn't easy, and varies for the type of sounds you are producing, but gives a much better sounding output, and helps add some 'punch' to the sound if implemented correctly. Look at the webpages of some of the best compressors on the market and they often give basic details (but not the finer points) of how their product works. One possibility is to start with this one which I know sounds really good.

https://www.drawmer.com/products/pro-series/dl441.php
 
Ah yes, I was wondering if it's a common practice to have "soft clamping" for audio. We do this similar stuff in graphics where we use different tone mapping operators to map HDR image to SDR range, which gives specific look to the image, so sounds analogous to the "compression" in audio. Similarly "auto attack/release" sounds analogous to camera auto exposure, to expose image properly for different illumination levels.
 
Added stereo support for Teensy 3.5/3.6 as well, and better recording to demonstrate the audio quality of the 12bit onboard DAC's:

 
Soft limiter code available...

Added stereo support for Teensy 3.5/3.6 as well, and better recording to demonstrate the audio quality of the 12bit onboard DAC's:


If you want it, I have working soft limiter/compressor code that works on a T3.5.

It is designed to drive an external gain cell, but the logic for hard and soft knees, gain ratios, attack and release times, etc is all there.

Richard
 
Status
Not open for further replies.
Back
Top