Audio From Scratch With Go: Notes to Sound
Oct 05, 2020
In the last post the tune to ‘Brother Jacob’ was generated using GoAudio. We started of by actually generating all the notes and their corresponding frequencies, and mapping them to a corresponding string, such that when we played A4 we would get a frequency of 440.
There were two problems with this from what I can tell, the first is that this approach is potentially repetitive. Each time we want to generate some music, we’re likely to generate a mapping of notes to frequencies.
...
➦
Audio From Scratch With Go: Frère Jacques
Sep 13, 2020
In the last post I ended by saying we would be able to use GoAudio to generate some simple tunes. In this post we will actually put that to the test. Click the video to hear the end result :)
Frère Jacques | Brother John Brother John / Frère Jacques is a popular nursing rhyme, and also one of the few things I was taught to play on the piano as a kid.
...
➦
Audio From Scratch With Go: Harmonics
Sep 12, 2020
So far, we have seen how we can generate pure signals such as sine waves, square waves and triangle waves. These are handy signals for debugging and easy to generate, but in the real world instruments don’t generate such pure signals. For example, when plucking a guitar string it will vibrate along mutliple frequencies. These different vibrations are called the ‘harmonics’, which consist of the ‘fundamental’ frequency + overtone frequencies. So the final sound that we hear is a combination of waves vibrating along these different frequencies.
...
➦
Audio From Scratch With Go: ADSR
Sep 05, 2020
With everything that we have added to our library so far we are almost capable of generated small tunes. One thing that’s missing to make it sound more ‘natural’ is a way for the notes to start and stop.
In this post we will implement a type of envelope called “ADSR”, for “Attack, Decay, Sustain, Release”. Which will make the notes sound more natural as they are played in sequence.
...
➦
Audio From Scratch With Go: Waveform tables
Aug 31, 2020
In the previous post the aim was to synthesize different waveforms, such as triangle waves and square waves. While this implementation gives us a good start, it is not as performant as we would like. All these waveforms were cyclical, so there was not an actual need to always calculate the right value in the moment.
The solution when you don’t want to recalculate something over and over is caching, and in the case of audio progamming we are going to store the waveform in a ‘table’, through which we can look up the values with an Oscillator.
...
➦
Audio From Scratch With Go: Waveform synthesis
Aug 19, 2020
In the previous posts we first looked at how we can generate a sine wave as ‘raw’ floats and interpret them using ffplay. Later we explored how to read / write .wave files and how to extract and create ‘automation tracks’ using breakpoints.
As you might have noticed, we’ve never actually created .wave files from scratch with our own sound data. So, it’s about time to change that. In this blogpost we’ll look at how we can create a variety of basic soundwaves.
...
➦
Audio From Scratch With Go: Extracting Breakpoints
Aug 08, 2020
So far everything we’ve done with breakpoints involved us creating a breakpoint file and using this to automate part of a track. Now we’ll take a look at how we can take an existing track and extract some breakpoints from this. For this post, we’ll take a look at extracting the amplitudes from the .wave files, as this is one of the most straightforward properties that we can extract.
There is nothing here that we’ve not seen in the previous posts, but rather we are going to combine what we’ve already learned to create a new tool to do this.
...
➦
Audio From Scratch With Go: Automated Constant-Power Panning
Aug 06, 2020
In a previous post we have looked at how we can turn a mono audio signal into a stereo signal with an applied pan. One drawback of this program was that it was not possible to change the pan throughout the track, meaning that once a pan had been selected it would be applied to the entire song.
Now that we have implemented breakpoints, we can start looking at changing the pan (and other properties) throughout the duration of the track.
...
➦
Audio From Scratch With Go: Breakpoints
Jul 28, 2020
Audio Breakpoints To clear up a potential mistake, this blogpost is about breakpoints for audio files, not the ones we use for debugging code ;-). A breakpoint file forms the basis for what is often called ‘envelopes’ or ‘automation tracks’ in DAWs.
They are simple files that contain pairs of timestamp:value data. With this simple structure, they allow us to specify what certain properties of the sound file should look like at various points in time.
...
➦
Audio From Scratch With Go: Stereo panning
Jul 20, 2020
In the previous post we have written code to change the amplitude of wave files.
Now we’ll take a look at how we can turn a mono wave file into a stereo wave file with optional panning, and explore how this is represented internally by the WAVE file format.
Channels The raw audio data inside a WAVE file consists of multiple frames. For now, we have called them ‘samples’ although that is strictly speaking not entirely correct.
...
➦