Mapping Pitch to a Musical Scale

When playing game music, you may sometimes want to generate some of the notes in real-time, either to add variation to a looping song, or for the music to better reflect what is happening in the game.

To achieve this, instruments must be sampled and implemented in Atom Craft. Many files may be required to cover all the notes and articulations necessary. Such a large memory footprint may not be available, especially on mobile games.

In this post, we will see how to create lightweight instruments from a single sample by mapping its pitch to a musical scale.

Creating a Pitch Map

We will start by recording the instrument.

  • Record any tonal instrument you have access to: piano, guitar, glockenspiel, synthesizer, etc.
  • Keep only the note that will be your root key. In our example, we recorded two instruments: one at C4 and the other at C6.

Import these recordings in Atom Craft.

  • Create a Polyphonic Cue.
  • Drag and drop one of the notes on the Cue to create a Track and a Waveform Region.

If you play the Cue at that point, it will obviously always play the same note. Adjusting the Pitch Random Range property of the Cue would not help, as it would produce out-of-tune sounds, the pitch values being truly random.

So we need another method in order to play notes tuned to a certain scale. For this, we will use an AISAC:

  • Create an AISAC-Control called “PitchScale”.
  • Select your Cue and create a new AISAC.
  • Add a Pitch graph to the AISAC.

Next, we need to map the pitch so that it corresponds to a musical scale.

We have to create a step graph, where each step corresponds to a note in the target scale above and below the root key. The destination values for a pitch graph are expressed in cents. Since 1 semitone is equal to 100 cents, we must add steps in multiples of 100 to create the desired scale. To minimize pitch-shift artifacts, it is recommended to stay within +/- 1 octave or +/- 1200 cents of the root key.

For example, if you want to create a pentatonic major scale over two octaves, you will need to create eleven steps with the following values -1200, -1000, -800, -500, -300, 0, 200, 400, 700, 900, 1200. Here is how it should look:

01 Pitch graph scale


Moving the AISAC will allow to play notes in the desired scale. In case a more generative approach is needed, it is also possible to use the AISAC’s random function to pick up each note.

  • Select the AISAC.
  • Change the Control Type to Random.
  • New properties will appear: set the Random Range to 2 and Default Control Value to 0.5.

The bar above the AISAC Control Values should turn green, showing the random range.

From now on, each time we play the Cue the pitch will be randomized but will stay in tune.

02 Random AISAC

Automating pitch mapping with CRI Robot

As you have probably noticed, these graphs can have a lot of points. It can be extremely cumbersome and error-prone to adjust them manually, especially for more complex scales.

Thankfully, using the Robot API, we can write a script that will automatically generate the desired graph. In a previous post, we saw how to manipulate AISAC graphs, and we will use the same API function in this case too.

Here is a summary of how the script works:

  • We start by providing a list of different scales and their intervals.
  • Once the user has selected a scale, we generate the pitch values for each step (in cents).
  • Finally, we generate the Control Values required to create our step graph, based on how many intervals the scale has.

This script can generate pitch graphs for 8 popular scales, but it is easy to edit the list to add your favorite.

You will find both the demo project and the script below, so you can try with your own sounds and scales!

Leave a Reply

Your email address will not be published. Required fields are marked *