Fundamentals
Export Targets
Code Export
Patcher UI
Special Topics
RNBO Raspberry Pi OSCQuery Runner
Working with Scala and Custom Tuning
How to define a custom tuning for MIDI / Frequency conversion in RNBO
The mtof object takes as input a MIDI pitch value, returning a corresponding frequency value. By default, these frequency values are drawn from twelve-tone equal temperament, which means that the ratio of the frequencies of any adjacent pair of notes is the same, and that the octave has been divided into twelve parts. But twelve-tone equal temperament is just one of many ways to map scale degrees to frequencies.
Scala
Luckily, we don't need to invent a language for dealing with various tunings. The software tool Scala is a powerful system for describing, storing, generating, and working with different musical tunings and keyboard mappings. Support for Scala's syntax and file formats is built into RNBO's mtof and ftom objects, and RNBO also includes the scala.* family of objects. These work alongside the mtof and ftom objects to control the tunings used in your RNBO device.
In RNBO, you can select tunings from Scala's large archive of musical tunings, define or generate your own tunings, and apply keyboard mappings to customize how MIDI notes are mapped to frequencies by mtof and ftom.
mtof and ftom
RNBO's mtof and ftom objects support Scala's system for describing musical tunings in two ways: either by name from the Scala archive, or by defining a tuning using a list of values. The scala.scl object lets you define a tuning using the same syntax as is used in the .scl
file format. However, it's also possible to define a tuning directly using a RNBO list. See the reference for more details.
Using Named Tunings for mtof
A simple way to use a named tuning from the Scala archive is to give the name of the tuning, omitting the file extension .scl
, to the mtof or ftom object as an argument. The object will then use that tuning when performing the MIDI/frequency conversion. You should be able to use any named tuning that you find on the Scala archive, though please note that RNBO may be using an older version of the archive that might not include recently added tunings.
In the above image, the same MIDI note 60
is sent to two mtof objects, one using twelve-tone equal temperament and one using the iter4
tuning from the Scala archive.
You can also switch between multiple tunings in your patch by filling the scala.list object with multiple named tunings. In the following image, scala.list has been given three different tunings.
Making your own Tuning Using the Scala Format
The scala.scl object allows you to input tunings in Scala's .scl
format directly into a codebox editor, which will output that tuning in a list-based format that RNBO's mtof and ftom objects recognize. You can then send that list to a [set scale]
object box and then on to mtof or ftom.
You can read about how the .scl
format works on the Scala website, and find more information about how to convert to RNBO's list-based format in the RNBO Package Manual.
Keyboard Mapping
The twelve-key piano keyboard might not be the most intuitive or appropriate fit for the custom tuning you've defined or scale you've found via the Scala archive. For example, what if you have a tuning with 7 scale degrees which repeats at the octave after those 7 scale degrees? You could imagine mapping where those 7 scale degrees were mapped onto the "white keys" of the piano keyboard so a performer could play just those keys.
This idea is called keyboard mapping, and Scala uses a .kbm
format that RNBO supports (see the Defining a Keyboard Mapping section of the reference guide).
The above image demonstrates this sort of mapping defined in the scala.kbm codebox editor and applied to mtof and ftom. For more information about how to define a keyboard mapping, visit the Scala website.