Arduino DUE for making a little digital synth

Hello,

I'm interested in creating a synthesizer barely similar to the Korg Volca Keys. Since I have limited knowledge of analog electronics, I'm thinking of starting with something simple using the Arduino Due. Specifically, I'd like to:

  1. Develop a digital sawtooth oscillator with a frequency range from 20Hz to around 20kHz.
  2. Implement true MIDI hardware communication to play notes with my MIDI keyboard (Arturia Keystep 32).
  3. Digitally implement an ADSR (Attack Decay Sustain Release).
  4. Digitally implement a low-pass filter (digital implementation due to the next point).
  5. Digitally implement an ASDR on the filter.
  6. Make all sounds come out from the DAC to a headphone jack.

I plan to control all parameters with separate potentiometers, utilizing all 12 analog inputs.

Currently, I'm stuck at point 1. I attempted the tutorial at https://docs.arduino.cc/tutorials/due/simple-waveform-generator , but I found that I can only reach a relatively low frequency.

Is the Arduino Due the right choice for this project, or should I consider another board? Additionally, considering that I am more of a programmer than an electronics expert, is this path relatively simple?

Thank you in advance for your guidance!

Hi, @wootrop.
This project does not seem easy to me. It's strange that even though it's easy for you, you run into problems right from the start. According to the datasheet, the Arduino Due has a pretty fast DAC.

1 Like

I think it will need a faster CPU. Ideally an FPGA.

Either way, I think you will need to go beyond the Arduino API and program CPU features directly. The example in the tutorial isn't useful apart from demonstrating the limitations.

I made a quick frequency generator for a project at work using a Due. I just needed 2 or 3 sine waves with different frequencies, none of the expensive test kit we had could do that. I only needed low frequencies known at compile time, which made it very doable.

One method as follows:

  1. Create a wave table in RAM for each channel
  2. Set a timer interrupt for a particular sample rate
  3. In the interrupt, get the value for each channel and sum them
  4. Write the DAC register with the summed value

If the max freq is 20kHz and you had 128 samples per cycle then the required interrupt rate is 2.56 Mhz, or about 30 instruction cycles per interrupt, which is really on the limit of what the Due could handle. If the max freq was 10kHz, that would be more manageable.

There may be a way to use DMA to offload some of the data transfer.

To handle the analog inputs, I would set up the ADC to do conversions automatically. Handling of the UI I would do in a background loop, which would also re-calculate the wave tables.

So probably steps 1 to 3 would be doable but only with limitations. Adding a low pass filter adds more CPU load, which is where you might struggle.

Anyway, I would develop a proof of concept with Due and see how much CPU time it requires.

1 Like

Take look at Teensy 4 (600 MHz ARM). See the digital audio library.

https://www.pjrc.com/teensy/td_libs_Audio.html

2 Likes

Don't be silly no need for a FPGA, this is audio not VHF work.

One of the best synth projects aground is the Mozzi project. It has been implemented for various processors and a Due is one of them.

Check it out here, including sample sounds to listen to:-

3 Likes

Hello,
Thank you all for the responses.

I had already heard about the Teensy microcontroller, but what held me back a bit was the fact that the Teensy 4 doesn't have an integrated DAC on board. I would have had to order the audio shield as well, with parts to solder... (I don't have a soldering iron, and I'm not skilled at soldering). Besides, being in Italy, I would have had to order these two things from the United States. So, I opted for the Arduino DUE, also considering some small past experiences with the Arduino UNO.

As for Mozzi library, it seems like an excellent point to start with, but on the website, it doesn't appear to natively support Arduino DUE. I have also tried running some examples but it doesn't work...

However, I may have found a good starting point:

Do you have any other boards to recommend that are easy to use and perhaps designed specifically for audio hardware development?

In the meantime, I will try to do some more research and experiments with Arduino DUE.
Thank you very much!

True but it has something much better than an DAC it has:-

2 I2S/TDM and 1 S/PDIF digital audio port

As to the Due, then look at these examples I created some years back,
DueSynth.zip (7.2 KB)

3 Likes

Thanks @Grumpy_Mike for the source codes. I gave them a quick look, but I have a general doubt...

How can I obtain any audio waveform that has a 0 voltage offset at the output? In other words, how can I obtain any audio waveform that swings equally in the positive and negative directions?

I read on the internet that using PWM, I can control a device that produces analog voltages, even in the negative range. Would it be suitable for audio as well? At this point, the use of DAC seems to be unnecessary, and the choice of Arduino Due might be superficial. I'm a bit confused...

Do you happen to have any advice? Thanks a lot.

You have to do this in hardware, as you will struggle to get an D/A that handles negative voltages. This is very easy to do. Just two resistors and a capacitor. For a Due the top resistor would be to the 3V3 pin not the 5V one.

Audio Bias

No.

PWM can only produce values from 0 to Vcc. Where Vcc is the voltage of the processor driving the pin. However, you simply use the above circuit with a PWM generated output signal.

So either the D/A or PWM can be used to provide the output you need.

Note like a lot of pins on the Due, DAC outputs can handle very little in terms of output current and is very easily damaged. This is 3mA source and 6mA sink current.

This pinout shows you which is which:-

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.