Bazza Nava Devlog #4 - Music for space stations


Welcome to the weekly devlog that is updated once every three months!

Needless to say, progress has been slow lately. My goals were to find and implement the instruments samples, and mostly write the music for the game. Unfortunately I faced two issues: writing block, and slight depression. Hopefully the latter is behind me now, despite the current context. Anyway, despite those difficulties, I have been able to achieve something! Let's dig in!

Music composition

As I said in my previous posts (and as the title of the game implies), I chose bossa nova as the musical genre for the game. It's a fun & relaxing style of music, but with enough complex harmonies to convey strong emotions (something between contempt and melancholy). My main inspirations were classics like Summer Samba, The Girl from Ipanema and Mas Que Nada, as well as some game soundtracks like Machinarium's Prague Radio, Zelda's Zora's Domain and Mario Odyssey's Bubblaine. Fun fact: they all qualify as "elevator music", despite the fact that we don't hear music in elevator since decades. I guess I just like those kind of ambiances.

There are a lot of interesting patterns that we can get from these musics. One thing they almost all have in common is acoustic guitars. It's the main instrument, and defines both the rhythm and the harmony. But… I chose not to use it. The reason being: there is already an acoustic guitar among the playable instruments. I don't want it to blend with the background music. Every instruments I use for this music must be different from the instruments with which the player can interact! Yep… That makes thing complicated. So, what should replace the guitar? I decided it should be a piano. It works generally well for jazz, and bossa nova as well. And I've already made sure there isn't any piano in the playable instruments (only rhodes and organ). I experimented a bit, and finally found a nice balance by playing high chords with the piano. It's a bit in the style of this part of La Soledad by Pink Martini. In the ends though, I still use an electric guitar, but it is not the main instrument and is soft enough to not be mixed with the game's guitars. It reminded me of another good reason to not use guitars: VST guitars in DAW sound like crap (well, the way I use it at least).

Another challenge was the percussion. I fetched a lot of samples of Latino percussion (maracas, claves, castanets, bongo…), only to realize later that they are not that much used in bossa nova! Bossa nova is heavily influenced by jazz, and as such uses drums a lot, mostly with brushes… Unfortunately brushes as well don't sound really well in DAW. With the (free) samples I had in hand, it was hard to do something soft enough. So I kept mostly my Latino samples. The result is something that has too much "beach level" vibes in my taste, but mixed with the rest it fits right.

But the hardest part was the harmony… Wow, I sure wasn't ready! I thought I had the "bossa nova" style in mind. I could easily imagine chords that sound nice and relaxing, just like I wanted. But once I was in front of my keyboard… I couldn't find them! I fumbled, experimented things… Turns out bossa nova is quite complex! It's jazz: lot of 7th, 9th, 13th (I didn't know those existed!), diminished and augmented chords… Just by looking for Summer Samba chords grid, I couldn't find the same twice! Eventually I found some nice motifs by forgetting about music theory as I envisioned it and just hitting random notes. But that would conflict with the game's logic, as I will explain later.

After several month of research and writing, I finally have Bazza Nava's main (and only) theme! It is 4 minutes long (that is how long a game session will last), has a verse and chorus, and even an extra section for the end! Here is an excerpt!

Then it was time to implement it in the game. Thanks to the sheet system I had implemented, it was quite easy to do! But… It also showed the limit of the game's logic. I used a very traditional view of music theory, with modes and chords. But as stated above, bossa nova is a jazz genre and is much more complex, using a lot of dissonances and playing with expectations. While I am able to shift from a musical mode to an other (and it happens frequently), I cannot use harmonic or melodic modes, nor diminished or augmented chords. And my default probabilities for notes had to be modified for each sections (thanks to the "modifiers" I implemented), as there is very few chords that didn't have a 7th or 9th… At some points I had to cheat: I played a major chord instead of a minor one, and reduced the probability of the third note.

Does it mean that it doesn't work? No, the selected notes still sound nice, and make consistent melodies or solo! It's just that there are some additional notes that could be used to sound even better… It's not a perfect solo system, but still provides the feeling I aimed for.

But before hearing it, I had to make some adjustments to the implementations!

The instruments

Just like the 3D models, I had to find 9 soundfonts for my instruments. Not in any format: I need a list of sound file (ogg or wav) to use them in my samplers. Not a file for every single note, but a least 3 per octave. Some sites are a great source for this kind of sample. The Philharmonia Orchestra provides a list of high quality instrument samples, and the FreePats project also has several instruments in the SFZ format (which comes with wav files).

However all these samples come with differences in volumes and length. For the first one, I just had to adjust the volume for each sampler. A lot of trial and error, but doable. The second one though was a bit trickier… Some sample were cut too early, and thus didn't feel natural at all! Some other were way too long, or even were looping forever (yep, you can do that with a wav file)! So I had to implement a new feature in my sampler plugin: an envelop! For those who don't know, a sound envelop describes the volume of that sound in time.It looks like this:

Sound Envelopes - Teach Me Audio
Attack is the time for the note to reach its full volume once the key is pressed, decay and sustain describes its volume while the key is held, and release how it fades out after the key is released. Those varies according to the instrument (a guitar can have a long release, while it is almost instant with a flute). In my case, I was mostly interested in sustain and release, so I implemented only those. However, since I want to make my Godot plugin available for everyone, I will surely have to implement at least the attack too!
The logic is quite simple: I play the sample, launch a "sustain" timer, at the end of which I use a tween for the release to fade out the volume. This way the length of each instrument sound is configurable!

Then I added a little "feature" to the game! Initially, the instruments played a random note each time the player pressed their respective button. But we can make them even more chaotic, by making them play every time they bounce on something!
Of course, it must have some limitations, otherwise it will be too noisy:

  • The instrument must not play too frequently when it bounces. For that, I put a delay that "locks" it for 0.1 seconds after it has played a note.
  • When the player is using the instrument, it must not play on bounce, so that the player feel they have some control on the melody. Same solution as above, except that this time the delay is 1.5 seconds after the player played the instrument.
  • An instrument shouldn't play when it stops in mid-air and is in contact of a body (for example, a wall). It feels glitchy, and doesn't convey the "bouncing" feed-back. For that, I cheated a bit: I decided that an instrument shouldn't play a note if it detects several collisions of the same body consecutively. That means that sometime it will bounce silently, but most of the time it works and prevent it from playing frenetically when it is stuck against a wall.
  • The player must still hear clearly the instruments they are playing in order to have a satisfying feedback. For this, every "bouncing" note must be played with a lower volume, so that the bouncing instruments are in the background, and the used ones are in the lead.

For that last point though, the solution is not to change each instrument volume whenever they play! Remember: they all have different volumes. We can't arbitrarily remember their initial volume, and diminish it. Plus, some of them use multisamplers to play several notes at the same time! On top of that, the envelop system described above already interact with the sample's volume. Directly changing it would be too hazardous and complex. What we need here is to use Godot audio buses.

Remember when my sampler used dynamic buses to adjust their pitch effect? A solution that I have abandoned, as using the pitch on the audio stream turned out to be much more effective. But I can reuse it, in order to change the volume on a Amplify effect for each instrument!

func _init():
  # create an audio bus
  bus_index = AudioServer.get_bus_count()
  AudioServer.add_bus(bus_index)
  AudioServer.set_bus_name(bus_index, 'player' + str(bus_index))
  amplifier = AudioEffectAmplify.new()
  AudioServer.add_bus_effect(bus_index, amplifier)
func _ready():
  sampler = instrument.instance()
  # Put custom bus between sampler's one
  AudioServer.set_bus_send(bus_index, sampler.bus)
  sampler.bus = AudioServer.get_bus_name(bus_index)
  add_child(sampler)

This code turned out to be useful after all! Each instrument is now connected to their own dedicated bus. Then I just have to edit the amplifier on that bus to lower or increase the volume just before a note is played.

Also, all instruments are connected to a "Instruments" bus with a Compressor effect. This way, when they all play together, their volume is lowered a bit to prevent them to be too loud.


Alright, now that everything is in place, let's have a look at how it plays:

https://twitter.com/Itooh_/status/1251576930694041602


Next time, I will add a new special feature to the game. So far there have been nine instruments, that are played with the 1-9 keys. But what about 0? Well, I plan to add a special thing for that button. It will require some technical research, but hopefully the result will be fun! See you then!

Get Bazza Nava

Leave a comment

Log in with itch.io to leave a comment.