Bazza Nava Devlog #0 - Back to musical toys!


Hello there! It's been a while since I haven't written anything about game development. Let's fix it!

After the semi-cancellation of my last project, I moved on to a little game I had in mind for quite a while. It's called Bazza Nava, and, well, I guess this entry will mostly be about presenting it.

The joy of playing music

Bazza Nava is a game where the player plays various instruments during a song. It has no score or objective, the purpose is to enjoy the music. Playing a musical instrument is an extremely fun and satisfying experience, and the goal of the game is to procure this sensation without requiring any particular skill. Each one of the 10 instrument is played with a single button (from 0 to 9), which will render a “random” note. The notes will be generated so that it will always stays in harmony and create interesting melodies!

Bazza Nava is mostly a simplified version of Wii Music. Remember that weird game? The core idea behind it was basically to let players pretend that they are playing a musical instrument in a band, and just enjoy their performance. No rhythm challenge, no score, no real objectives… Just music! In a pretty silly setting, with Miis and dog costumes. Do I like this game though? Heck no! For a lot of reasons, that might have evolved since its release. It starts with a very interesting idea, but just doesn't have the guts to fully explore it. Instead it just offered poorly rendered MIDI versions of a few songs in the public domain (talk about low ambitions from a musical game), a lack of variety in its mechanics, and a lot of disputable game-design choices to “gamify” the concept and not really let players fully express themselves. I suspect Nintendo to not really have believed in that project, and ship it as fast as possible.

This isn't a critic of Wii Music though, nor are my intentions to “fix” it! I mention it because, despite all its flaws, the game has some very interesting ideas. One of them being “You press a button (or shake a Wiimote), and it makes music”! This is fun! As a amateur piano player, I also like to turn on my keyboard, make random chords, and just enjoy the sounds it makes. It's a very childish feeling of “I pressed a button and it made a sound!!!!!”. I first thought of Bazza Nava as a parody of Wii Music (I even considered Waa Muzaac for its title), by just taking that concept, and expand it in a silly way. With bossa-nova because that's a cool genre!

How it works

Unlike my previous game, I have a lot of confidence in the feasibility of this one. Mostly because I have already made something like it! Last year, for a specific video project, I released a little game called Top 365 Best Stuff. It's in French, but don't worry, you just can play it by just pressing the arrow keys and spacebar. It is written in Javascript, using Vue and ToneJS, and the way it works is pretty simple:

Each of the 4 instruments is a sampler, that extrapolates notes from a few audio file. They can play absolutely any note, based on only 4 samples. This is managed by ToneJS, but we will see in a bit how we can build our own. Basically, each sample is associated with a tone When the sampler have to play a note, it selects the closest sample, and change its pitch accordingly. This way the sound doesn't feel distorted!

Then, I use some music theory and probabilities to always play “good” notes. The song of the game is entirely in the G mixolydian mode, which to simplify means it can only use 7 specific notes in each octave. If you want to learn mode about modes, I suggest you to watch this short video by 8-Bit Music Theory (which is a really cool channel, for those you like music and video game!). So I only select notes from this mode (in two octaves), but not completely randomly! That would sounds a bit strange. Instead, each note is associated with a probability. The 3rd and 5th have high chances to get picked (between 30 and 50%), because they define the scale and the G major chord. The root has a high probability too, but not too much, since it could feel a bit redundant. The 2nd is great for creating tension and bringing a more stable note, so it can be nice to have it frequently too! And there are notes that can be played, but are a bit more “risky”, like the 7th who doesn't really fit if it isn't in the right context, so we still want to hear it now and then, but not too much.

On top of that, each instrument have different set of probabilities, so that they doesn't sound exactly the same! Every time the player press a button, we roll a dice (with a good ol' Math.random), and see on which case we fall. The result, while a bit erratic, is fairly consistent!

So, for Bazza Nava, I will basically implement the logic I already have in Godot. Godot is a really cool engine, and I just love using it! It is great for prototyping, it has a philosophy that encourage good patterns, and a ton of cool tools for audio!

Though Bazza Nava will be a little bit more complex than my short JS game. I don't want the instrument to only play on one scale and one chord. I want them to play along with a song, that I will compose myself! In order to do that, they have to change their mode in time according to the music's progression, so that the highest probabilities are on notes that are in harmony with the song.

But that will be a challenge for later! For now, let's see the very basics.

Creating a Godot plugin

I need a sampler for Godot. Good news: that is also a thing I have already made in the past! In Void Garden, a game I made for the Godot Wild Jam #8, I created a very basic sampler to randomly play note on a scale. I took inspiration from this tutorial from Pigdev studio about sound shifting in Godot, and my own knowledge on music theory from my experimentation with the Web Audio API. See, every note is a frequency. If you double that frequency, you obtain the next octave. If you multiply it by 3/2, you obtain the 5th. Long story short, the interval between each note's frequency is F*2^(1/12). So, if I have a note N, and I want to pitch it to a note X, the pitch value should be :

2^((X-N)/12)

And thus my sampler was able to play any note from a set of samples. What it does, in short, is creating its own audio bus connected to an output bus, associating a set of samples to notes (G4, A4, etc…), then when asked to play a note, calculating which sample is the closest one (based on a "note value", C0 being 0, C#0 1, D0 2, C1 13, etc…), playing it with a AudioStreamPlayer connected to its bus, and changing this bus pitch (with a PitchShift Effect) using the formula above.

And it works great! But it's a bit tedious to configure. You have to insert samples one by one in an array, then create an other array of the same size to configure the corresponding notes, they had to be in the right order… It's okay for a jam, but I certainly can do better! So I decided to create a little Godot Plugin alongside Bazza Nava, to have an easy way to create basic samplers in Godot. It will be released alongside the game. What it does isn't complex: it allows to create Sampler nodes, that takes an array of NoteSample. NoteSample is a type of resource included in that plugin. It takes an AudioStream, a note, and an octave! Samplers are now really easy to configure, and can even be exported and shared or copy-pasted between projects! I even have a new functionality: Multisampler, which is a sampler that can play several notes at a time (using, you might guess, several sampler under the hood).

Writing a plugin with Godot turned out quite easy! In fact, it's almost just like creating nodes for a game. The trickiest part was to type correctly the NoteSample resource. Unfortunately, I stumbled across a bug, which still had an open issue. There is a fix in preparation (I even tested it, hurray to open-source), but it won't be merged before a while. For now, I had to use a little hack by giving the wrong type in the Sampler code, but it still shows the NoteSample resource in the editor. That's not really great, even for the end user (there will be a weird warning about that in the doc), but for now it's the best I can do.

What about scaling the sampler? I thought about that for a while, then decided to not include it in the plugin. At least yet! I want the plugin to be really basic and simple to use, and introducing some advanced music theory such a mode might create some confusion. So as of now, my Sampler is a just an instrument that play any given note, and that's it.

sampler.play_note("C", 4)

There is also some options to calculate note values and play with them (to obtain the note 2 and a half tones above another one, for example). Which is what I'll discuss now!

The state of the game

After my sample plugin, I have also implemented the mode probability logic! It works as I have explained above: a Player is set to a scale, and some notes in that scale have higher chances to be picked. The Player select a random note given those probabilities, then an octave, and plays it with a sampler.

player.setHarmony('C', music_theory.Scale.MAJOR)
player.play_random_note()

Unlike Top 365 which had only one mode, this time we can select note from multiple ones! Modes are defined by half-tones intervals in a scale. For instance, MAJOR is [0,2,2,1,2,2,2,1]. Any note can thus be calculated from the first one. Fun fact: modes themselves can be calculated from one another! E Phrygian is just the same notes than C Major, but with the 3rd note as root! This will come useful later.

There will be other logics to implements. I would like to have an instruments that can play chords (like in Top 365). But this will be for another time! What I will work on next is a metronome, that will capture the beat of a song and send signals to tell when we change measure. Then I want a system that change the scale of all players based on a sheet describing what chord is used at which beat!

Good news: I've already written metronomes in Unity and Javascript, and I think I know how to implement one in Godot. This project is kinda the regrouping of a lot of things I've learned in previous games, so progress should be pretty fast! Stay tuned next week to see how it went!

Get Bazza Nava

Leave a comment

Log in with itch.io to leave a comment.