
3. The Bass
The Bass is a low sound in music. It is not always that guitar you see in musical groups. In electronic music, a synthesizer often serves as the bass, and in classical music, a double bass.
They all serve similar functions. They have a low sound, mark the rhythm, and define the foundation of harmony.

In Another One Bites the Dust by Queen, you can hear an electric bass. It's the typical one you see in music bands, especially rock bands.
In the track Blinding Lights by The Weeknd, you can hear a synthetic bass. Synthetic means that the sound was not generated by a "real" instrument. It was created by a computer or synthesizer. Identify it by listening to the lower sounds of the track.
In electronic music, the bass is one of the most important elements. It serves two functions at once: it sets the rhythm and defines the harmony.
The drum kit we've seen so far only keeps the rhythm. You can't play melodies with a drum kit. The bass is different: it allows you to create rhythms and play any note at the same time.
In the rhythmic part, the bass works together with the kick drum. Sometimes both sound at the same time, reinforcing each other. Other times they alternate: when the kick hits, the bass steps back.
In the harmonic section, the bass establishes the root note. This is the foundational note upon which everything is built. For example, imagine the bass plays the note C. All the music develops around that note as the base.
Harmonic Part
Now that we understand the role of the bass, let's see how to use it in our code. Previously, we used the sound() function to play a sound. Now we will use the note() function to play musical notes.
The letters c1, d1, e1... represent musical notes. We will see this in detail later. For now, notice something important: the bass can play different notes, unlike the drums.
Listen to the song Billie Jean by Michael Jackson. At the beginning of the song, the bass repeats a small melody.
Rhythmic Part
Now let's look at the rhythmic part of the bass. We have our usual basic rhythm. Now we add the bass.
In this case, the bass plays the note C2 (a C). We will see what C2 exactly means in the next lesson. For now, think of it as simply a musical note.
Listen to the bass in Around the World by Daft Punk. It's practically creating the kick drum rhythm with a bit of melody.
Duration of Bass Notes
The bass has another important difference: the duration of the notes. The "bd" (kick) is a hit whose sound disappears quickly. The bass, on the other hand, can sustain the note for much longer.
Notice the following example. The kick drum sound disappears quickly. The bass sound lasts throughout the entire cycle.
Combining Rhythm and Melody
In the previous examples, we saw how the bass can play notes and create rhythm separately. You can also do both at the same time. This way, you combine the rhythmic and harmonic function of the bass into a single pattern.
Simplifying Our Code
Now that we are writing more complex patterns, let's learn some shortcuts. Look at this pattern: [hh hh] [hh hh] [hh hh] [hh hh]. We have 8 hi-hats (hh) in a loop. It's the same as writing hh*8:
[hh hh] [hh hh] [hh hh] [hh hh] = hh*8
Similarly, the same happens with [c4 c4]: they are 2 notes in one beat. You can simply write c4*2.
Another less obvious simplification is: "[- sd]*2" = "- sd - sd"
Remember that what we put in quotes "" lasted one cycle. If we only put one beat in the cycle "[- sd]", this beat will last the entire cycle. The brackets divide the beat in 2, so each sound will last half of a cycle. By multiplying by 2, it's like having "[- sd][- sd]". This represents 2 beats of one cycle divided in 2. It is time-equivalent to "- sd - sd.
"[- sd]*2" = "[- sd][- sd]" = "- sd - sd"
Use the form that is clearest and most comfortable for you. Both are correct and produce exactly the same result.
Comments
As the code gets longer, you might find it helpful to add some comments to document your work. Comments have no effect on the output. They are only there to help you (and others) understand it better.
A comment starts with the characters // and then you can write whatever you want.
The Bass of Billie Jean
To bring together what we've learned so far, we are going to reconstruct the bass line of the song Billie Jean by Michael Jackson. It's a legendary and easily recognizable bass line.
The drum part you already know, we have only replaced the hi-hat hh with some maracas sh.
As for the bass, we have only added the notes from the Billie Jean theme. To fully understand what we are writing, we will need to learn what these notes are. But first, now that we can play notes of different durations, let's review what options we have. 👉>>
