eYFi-Mega based Audio Synthesizer

Mentor(s) : Sourav, Prasad, eYRDC
Interns : Aravinda Harithsa, Marefat Abbas


Introduction

eYFi Mega based Audio Synthesizer is an Audio device project where we will create an audio synthesizer or in simple words audio generator. In this project we will be using 4x4 16 Key Universal Keypad and a speaker. Using Keypad we will generate different tones as programmed.

eYFi Mega

eYFi Mega Development board is an Atmega2560 and ESP32 based development board, made in India. This board is developed by eYantra at IIT Bombay.

Key-points:

  • Atmega2560 and ESP32 based
  • WiFi Compatible
  • FreeRTOS Compatible
  • Arduino IDE suitable

Audio Synthesizer

A Audio Synthesizer is an electronic musical instrument that generates audio signals. Synthesizers generate audio through methods including subtractive synthesis, additive synthesis, and frequency modulation synthesis. Synthesizers are typically played with keyboards or controlled by sequencers, software, or other instruments, often via MIDI.

Digital Signal Processing (DSP)

Mathematical manipulation of Digial Signals like Audio, Video, Pressure, Temperature, etc is called as Digital Signal Processing (DSP). It is the use of digital processing, such as by computers or more specialized digital signal processors, to perform a wide variety of signal processing operations. DSP can involve linear or nonlinear operations. Nonlinear signal processing is closely related to nonlinear system identification and can be implemented in the time, frequency, and spatio-temporal domains.

About Sound

Sounds are just vibrations, our ears pick up the vibrations from objects as they hit the air particles in front of them and the energy is passed on; air particle to air particle; until air particles in our ear pass on this vibrating energy to our ear drum and through some other clever nature stuff we convert this to electrical signals in our ear that the brain can interpret as sound. The pitch of a sound is the speed at which it vibrates, its frequency

Sounds from vibrations produce sound waves and as such like other types of wave have certain properties, they two main ones we’re interested in are the frequency which is how many times is that repeated and the amplitude is how much intensity is that having .An important thing to notice about the wave is that the amplitude changes over the time . It’s not instant high then instant low. We can produce sounds like this and they are called square waves but in nature this type of sound waves are rare find

We are using DAC Audio library to play (sa re ga ma pa da ne sa) tones which are stored as values between 0-65535 . It uses a digital to analogue interface, which are built into the ESP32 (but not Arduino’s), hence why I chose that chip for the main development. This allows the relatively precise control over the final waveform. There are other ways of getting sound out of an ESP32, such as it’s in-built support for I2S streaming. With this you can output digital sound to nearly any pin and with couple or so components you can get stereo sound out. Really quite cool. In the future the library will support this approach but for now it uses the DAC pin which reduces external components (admittedly very slightly) and I think conceptually it is easier for a beginner to see how sound could be produced that way. In any case that’s the way the design was originally conceived!!

What is a DAC ?

In electronics, a digital-to-analog converter (DAC, D/A, D2A, or D-to-A) is a system that converts a digital signal into an analog signal. An analog-to-digital converter (ADC) performs the reverse function. There are several DAC architectures the suitability of a DAC for a particular application is determined by figures of merit including: resolution, maximum sampling frequency and others. Digital-to-analog conversion can degrade a signal, so a DAC should be specified that has insignificant errors in terms of the application.

DAC‘s will take a digital value and convert it to an output voltage on a specified pin. Typically in the range 0v to Vcc . So for example if the Vcc was 3.3V and our digital value could be anything between 0 and 255 (8bits). Setting it to 0 would result in 0V at the output pin, a value of 127 would be approx 1.65V at the output pin and 255 would be 3.3V. In this way we could control the brightness of a light or speed of a motor by altering the voltage supplied to it using a digital number 0 for lowest value, 255 for largest and then any value in-between.

We can also use PWM as well but the quality will not be same as DAC.PWM will just simulate what DAC does when it comes to audio. DAC’s in particular come into their own when it comes to sound. Once your sound has been stored digitally (converted using an ADC) if you want to listen to it again with your analogue ears then we need to be able to convert it back from the digital data into a analogue signal again and hence the DAC’s.

Resolution and accuracy The higher the resolution then the more accurate your digital stored sound will be when replayed. Note that there are other factors to sound accuracy – such as sample rate – which we will cover in later articles on producing sound. For now we will just look at resolution. In the CD specification it was 16 bit resolution, so the original sound when converted to a voltage using a microphone was stored as a 16 bit number – a number between 0 and 65535 . The higher the number of bits to store the sound the finer and more accurate sound representation we will get. However the human ear has limitations and it’s not just a matter of the more the number of bits the better the sound as there comes a point when our ears cannot tell the difference.

In the ESP32 the resolution is 256, it has a 8 bit DAC (values from 0 to 255). This may seem poor but in fact it does allow us to have a good representation of sound . But With our 3.3 volts processor this should mean a 0 sent to the DAC would give 0V on the DAC output pin and 255 would give 3.3V on the DAC output pin. However in real life the circuitry gives just slightly different values for various technical reasons. Generally starting a little over 0V and ending at around 3.24V for value of 255.