Fabian Fabro

Posted on

Basic Overview of Audio Signal Processing w/Web Audio API

Audio Signal Processing, a topic where most of the material I find on this is dense information. In a nutshell, audio signals are the representation for sound waves, whether it is an analog or digital source, being computed and generated to be utilized as data for application.

It is actually a subtopic of Digital Signal Processing, which is the main topic of translating data into a computer form to be used, where data can vary from speech, imaging, telecommunication, seismology, biomedical engineering, etc.

But for now, I'd like to focus on the audio portion of data processing.

Examples in applying Audio Signal Processing:

• storage
• data compression
• music information retrieval
• speech processing
• localization
• acoustic detection
• transmission
• noise cancellation
• acoustic fingerprinting
• sound recognition
• synthesis
• enhancement (equalization, filtering, level compression, echo and reverb removal or addition, etc.)

What are Audio Signals?

It is the representation of sound. There are two different types of signals: Analog and Digital Signals.

Analog is represented with a sign wave, described with Period, Amplitude, Phase and Frequency.

Frequency - amount of times the period occurs

Period, Amplitude, Phase, Frequency

Here is an example of an Analog Signal, from a sound effect I designed for a hobby game I am developing:

Let's Zoom in more:

Little bit more:

One more:

Looking at the audio data in this retrospect, we can actually see the lines are becoming more solid than seeing the wavy line. With this representation of the data, it can be translated and interpreted as digital data to be processed with the computer now. This is most represented as a sine wave.

Digital is represented with a square wave. It carries data in binary form. It's described with bit rate and bit interval. As you can see the difference with the sine wave, the square wave is more straight-forward with no curves and slopes. This means that the sound would be cutoff with no steady progression. A good example of a representation for a square wave is Synthesizer music. The synthesizer, an electric keyboard, plays a note and you can hear the sound immediately at a high gain, or volume, and when letting of the note, it cuts off immediately.

A great analogy of comparing Analog and Digital signals is:

Analog is like the human voice where you can control your volume, speed, and articulation, etc.

Digital is like picking a note on an electric guitar immediately (unless you control your volume with the volume knob).

Now I mentioned Sine and Square Wave, but there are actually two more called Sawtooth and Triangle Waves. These are the four basic waveforms of

What is the Processing?

With this, we can introduce a bit about Web Audio API, which retrieves and manipulates audio data, as an example with processing audio signals.

``````//using AudioContext method from Web Audio API
var audioContext = new AudioContext();

//Apply the createOscillator method to osc variable
let osc;
osc = audioContext.createOscillator();

//Assign the type of waveform as "sine"
osc.type = "sine";

//Apply the frequency value to 440
osc.frequency.value = 440;

//connect osc to the destination
osc.connect(audioContext.destination);

//output sound
osc.start(audioContext.currentTime);
``````

Hey! We got sound! You are hearing a sine wave of 440hz or the music note value "A."

With this example, we are creating an audio signal, which is the oscillator and giving the waveform type. We are manipulating the oscillator by giving a frequency value of 440. You could adjust other parts to the audio, like the amplitude which would adjust the gain or volume.

Audio Spectrum is another way of manipulating audio signals for a visual display. This reads the frequencies and amplitude in order to control the shape of each bar.

This was just an introduction to audio signal processing. I would like to probably make another blog part to this topic because there is just so much to learn about software with audio. I hope my blog helped understand the use and power of audio into technology in some way.

If you are still curious about the topics of audio in software, you can check out other related topics that branch off from Audio Signal Processing:
- Discrete Fourier Transform
- Fast Fourier Transform
- Spectrum Analyzer
- Game Audio Implementation
- Sound Theory

https://www.videomaker.com/article/c04/18241-know-your-audio-signal-processing-techniques

https://www.javatpoint.com/difference-between-analog-signals-and-digital-signals