MIDI microtonality

 

This page is a demo of the han­dling of micro­tonal­i­ty in the real-time MIDI and MIDI file envi­ron­ments of the Bol Processor BP3  (ver­sion 3.0.7 and high­er). Install BP3 by fol­low­ing the instruc­tions for  MacOSLinux and Windows on the page Bol Processor 'BP3' and its PHP inter­face.

All exam­ples here are from the "-da.tryMPE" project, which is part of the ctests fold­er (down­load here). The syn­tac­tic mod­el for micro­tonal­i­ty is explained here. For details on work­ing with real-time MIDI, read the Real-time MIDI page. Some Csound scores are shown for the sake of clar­i­ty, as the han­dling of micro­tonal­i­ty in the Csound envi­ron­ment of BP3 pro­duces the same results as MIDI.

👉 The fol­low­ing is a com­pre­hen­sive but detailed pre­sen­ta­tion of all aspects of the use of micro­tonal­i­ty in BP3. It is not nec­es­sary to under­stand the details when start­ing with micro­tonal­i­ty! The expla­na­tion is only intend­ed to assist musi­cians who wish to cre­ate new mate­r­i­al by com­bin­ing sev­er­al tun­ing schemes in the same musi­cal work. To try the micro­ton­al process on real musi­cal works, lis­ten for instance to the com­par­i­son of tem­pera­ments, or play François Couperin's Les Ombres Errantes (in the ctests/Imported_MusicXML folder) on a MIDI instru­ment using its opti­mal tun­ing scheme rameau_en_sib:

Couperin's Les Ombres Errantes, Csound ren­der­ing with scale rameau_en_sibImage

For geeks: Microtonality in real-time MIDI and MIDI files mim­ics the MIDI Polyphonic Expression (MPE) method of mod­i­fy­ing pitch­bend val­ues on notes dis­trib­uted on sep­a­rate chan­nels (up to 15 simul­ta­ne­ous notes). However, it works on devices that are not MPE-compliant.

Check pitchbender sensitivity

Make sure that your out­put MIDI device is sen­si­tive to pitch­bend mes­sages. Try the following:

_chan(2) C4 _pitchrange(200) _pitchbend(+100) E4 _pitchbend(+200) C4 _pitchbend(-200) C4 _pitchbend(0) C4

You should hear C4 F4 D4 Bb3 C4 instead of C4 C4 C4 C4 C4. This shows that the MIDI device accepts pitch­bend mes­sages and that its range is ± 200 cents, or ± 2 semi­tones. This is the range we use for microtonality.

For geeks: The actu­al val­ues are in the range 0 - 16383, but thanks to the "_pitchrange(200)" instruc­tion, the actu­al cent val­ues can be used.

When using micro­ton­al scales, this pitch range of ± 200 cents is set auto­mat­i­cal­ly by send­ing an appro­pri­ate mes­sage to the 16 MIDI channels.

The "_pitchbend()" com­mands will be tak­en care of, and their val­ues will be added to the pitch­bend com­mands that adjust the pitch­es to the micro­ton­al scale. If this com­bi­na­tion exceeds the range of ± 200 cents, an error mes­sage will be displayed.

MIDI channels

In the pre­vi­ous exam­ple, MIDI events (notes and pitch­ben­der com­mands) were sent on chan­nel 2. This is to ensure that your MIDI out­put device is receiv­ing and mix­ing all chan­nels, tech­ni­cal­ly MIDI mode 4 (omni off, mono).

It was pos­si­ble to send mes­sages on chan­nel 2 because the Microtonality mode was not set. This mode is set on as a "_scale()" com­mand is found. In this case, the "_chan()" com­mands are ignored, as all chan­nel assign­ments are made by the micro­tonal­i­ty process.

Diapason tuning

Since note fre­quen­cies are dis­played when the Trace micro­tonal­i­ty mode is acti­vat­ed in "-se.tryMPE", the tun­ing of the dia­pa­son (note A4/la 3 on a con­ven­tion­al key­board) is important.

By default (in Bol Processor set­tings and on MIDI devices) this set­ting is 440 Hz. If you change the val­ue in the set­tings, the note fre­quen­cies will change accord­ing­ly. The BP3 will send a mes­sage to the MIDI device to tune the dia­pa­son, but many devices do not under­stand this com­mand. (This is the case with PianoTeq Stage.) In this case, tune the device independently.

Microtonal scales

On top of project "-da.tryMPE" you can see the line:

-to.tryMPE

This refers to a tonal­i­ty resource stored in the "tonality_resources" fold­er. This resource has been down­loaded to your com­put­er when run­ning an installer (or a Linux script) as explained on pages Quick install MacOS, Quick install Windows, or Quick install Linux.

At the bot­tom of the project page there is a but­ton called EDIT '-to.tryMPE'. This will take you to this resource:

Here are the scales stored in "-to.tryMPE":

Most of these are "exot­ic" in the sense that they won't pro­duce inter­est­ing music. They have been designed to high­light tech­ni­cal features:

  • The gra­ma scale is an inter­pre­ta­tion of the Indian sys­tem that divides the octave into "twenty-two shrutis", see The two-vina exper­i­ment for details. We use one par­tic­u­lar (prob­a­bly incor­rect) solu­tion, which sets the pra­mana shru­ti at 21 cents. Technically speak­ing — the rea­son for this choice — this scale has 23 grades which count as 22 notes. Click the EDIT but­ton to see its structure.
  • The just into­na­tion scale is a stan­dard scale with 12 grades and 12 notes, prob­a­bly suit­able for use in some har­mon­ic con­texts. Click the EDIT but­ton and dis­play the image to see that it has a wolf's fifth between D and A.
  • The meantone_try scale is pure­ly tech­ni­cal. It has 12 grades and 7 notes. The grades are approx­i­mate­ly semi­tones and the notes sug­gest the white keys of a piano key­board. Another fea­ture is that it has an extend­ed octave of 1219 cents instead of 1200. Notes are labelled by key numbers.
  • The meantone_try2 scale is iden­ti­cal to meantone_try except that its base key is #64 instead of #60. This may be nec­es­sary to use spe­cif­ic key num­bers of the key­board of the MIDI out­put device.
  • The piano scale has 12 grades and 12 notes. It is an equal-tempered scale with an extend­ed octave of 1204 cents. An inter­est­ing point is that all its fifths are per­fect (see pic­ture).
  • The zest24-supergoya17plus3_Db scale was cre­at­ed by import­ing its SCALA def­i­n­i­tion (from this archive). It cov­ers a con­ven­tion­al octave (ratio 2/1) with 20 grades, but the SCALA file did not con­tain any note names. So, 12 notes were cho­sen at ran­dom, with key num­bers as their names.
  • The Bohlen-Pierce scale which has a "tri­tave" inter­val of ratio 3/1 instead of 2/1 in the octave. The tri­tave is divid­ed into 13 grades and 13 notes (see Wikipedia and pic­ture).

These scales cov­er all the cas­es nec­es­sary to check the tech­ni­cal oper­a­tion of micro­tonal­i­ty han­dling in real-time MIDI, MIDI files, and Csound envi­ron­ments. Don't expect to hear inter­est­ing music in the fol­low­ing exam­ples! Only make sure that Trace micro­tonal­i­ty is checked in "-se_tryMPE", so that you can read cent cor­rec­tions in the trace.

Listening to scales

The fol­low­ing are exam­ples of 12-note scales:

_scale(piano,0) C4 C#4 D4 D#4 E4 F4 F#4 G4 G#4 A4 A#4 B4 C5
_velcont _scale(just intonation,0) _vel(120) C4 C#4 D4 D#4 E4 F4 F#4 G4 G#4 A4 A#4 B4 C5 _vel(60)

The sec­ond argu­ment to the "_scale()" com­mand is called the block key. It is the key whose fre­quen­cy should remain equal to that of a con­ven­tion­al 12-grade equal-tempered scale (a stan­dard tun­ing of elec­tron­ic instru­ments). If it is set to 0 or 60, this means that the block key is the 60th key on a piano key­board, usu­al­ly called "mid­dle C" or C4/do3. If the A4/la3 is 440 Hz, key #60 should be 261.63 Hz, which we call the base fre­quen­cy, fol­low­ing the prac­tice in Csound..

See for exam­ple the top of set­tings of the piano scale in the tonal­i­ty resource "-to.tryMPE":

For geeks: The Csound GEN51 line at the top is pure­ly infor­ma­tive. It could be placed on top of Csound scores, but the Bol Processor uses note fre­quen­cies instead when uncon­ven­tion­al posi­tions are required — see Csound tun­ing in BP3.

Looking at the trace of the process when play­ing the "_scale(piano,0)" sequence yields the following:

§ key 60: "C4" chan 2 scale #5, block key 60, corr 0 cents, freq 261.630 Hz
§ key 61: "C#4" chan 2 scale #5, block key 60, corr 0 cents, freq 277.187 Hz
§ key 62: "D4" chan 2 scale #5, block key 60, corr 0 cents, freq 293.670 Hz
§ key 63: "D#4" chan 2 scale #5, block key 60, corr 1 cents, freq 311.312 Hz
§ key 64: "E4" chan 2 scale #5, block key 60, corr 1 cents, freq 329.824 Hz
§ key 65: "F4" chan 2 scale #5, block key 60, corr 1 cents, freq 349.436 Hz
§ key 66: "F#4" chan 2 scale #5, block key 60, corr 2 cents, freq 370.428 Hz
§ key 67: "G4" chan 2 scale #5, block key 60, corr 1 cents, freq 392.229 Hz
§ key 68: "G#4" chan 2 scale #5, block key 60, corr 2 cents, freq 415.792 Hz
§ key 69: "A4" chan 2 scale #5, block key 60, corr 2 cents, freq 440.516 Hz
§ key 70: "A#4" chan 2 scale #5, block key 60, corr 3 cents, freq 466.980 Hz
§ key 71: "B4" chan 2 scale #5, block key 60, corr 2 cents, freq 494.463 Hz
§ key 72: "C5" chan 2 scale #5, block key 60, corr 3 cents, freq 524.168 Hz

The first thing we notice is that the fre­quen­cy of C4 (key #60) is 261.630 Hz, the base fre­quen­cy of the block key. One octave high­er, the fre­quen­cy of C5 is 525.260 Hz. This gives an octave ratio of 2.0034, which equates to a stretch­ing of 3 cents, close to 4 cents due to the rounding.

This is con­firmed by the Csound score:

t 0.000 60
i1 0.000 0.333 261.630 90.000 90.000 0.000 0.000 0.000 0.000 ; C4
i1 0.333 0.333 277.187 90.000 90.000 0.000 0.000 0.000 0.000 ; C#4
i1 0.666 0.334 293.670 90.000 90.000 0.000 0.000 0.000 0.000 ; D4
i1 1.000 0.333 311.312 90.000 90.000 0.000 0.000 0.000 0.000 ; D#4
i1 1.333 0.333 329.824 90.000 90.000 0.000 0.000 0.000 0.000 ; E4
i1 1.666 0.334 349.436 90.000 90.000 0.000 0.000 0.000 0.000 ; F4
i1 2.000 0.333 370.428 90.000 90.000 0.000 0.000 0.000 0.000 ; F#4
i1 2.333 0.333 392.229 90.000 90.000 0.000 0.000 0.000 0.000 ; G4
i1 2.666 0.334 415.792 90.000 90.000 0.000 0.000 0.000 0.000 ; G#4
i1 3.000 0.333 440.516 90.000 90.000 0.000 0.000 0.000 0.000 ; A4
i1 3.333 0.333 466.980 90.000 90.000 0.000 0.000 0.000 0.000 ; A#4
i1 3.666 0.334 494.463 90.000 90.000 0.000 0.000 0.000 0.000 ; B4
i1 4.000 0.333 524.168 90.000 90.000 0.000 0.000 0.000 0.000 ; C5

When the fre­quen­cies are dis­played using the just into­na­tion scale, the octave ratio is exact­ly 2/1. Listen to the scale with decreas­ing velocities:

On the same scale, lis­ten to a series of fifths C4/G4, D4/A4, E4/B4, F5/C5 show­ing that they are per­fect except the wolf's fifth D4/A4 (see pic­ture):

scale(just intonation,0) {C4 D4_ E4_ F4_, G4 A4 B4 C5}

Checking large intervals

Due to round­ing (3 cents instead of 4) in the piano scale, check that round­ing errors do not accu­mu­late over octaves. The fol­low­ing is also an exer­cise for those whose ear is trained in piano tun­ing. We'll play iden­ti­cal notes in two scales: the piano scale with its extend­ed octave, then the stan­dard equal tem­pera­ment scale with an octave of 2/1:

_tempo(1/2) {_scale(piano,0) C2 C3 C4 C5 C6 C7 _scale(0,0) C2 C3 C4 C5 C6 C7 1/16, 1/16 C2 C3 C4 C5 C6 C7 C2 C3 C4 C5 C6 C7}

The instruc­tion "_scale(0,0)" sets the scale to the stan­dard stan­dard equal tem­pera­ment scale. The lay­out of the notes in this poly­met­ric struc­ture is as follows:

There is a short delay (1/16 beat) on the notes of the sec­ond line to empha­sise the beats, if there are any. You can hear beats in the first part, as scales are dif­fer­ent, but per­fect uni­son in the sec­ond part. This is how it sounds on a PianoTeq Stage phys­i­cal mod­el­ling synthesiser:

This result should not be tak­en as a rad­i­cal state­ment about how to tune a piano! Pianoteq syn­the­siz­ers already repro­duce the octave stretch­ing that piano tuners tend to do to com­pen­sate for the inhar­monic­i­ty of the strings. An addi­tion­al octave stretch­ing of four cents is there­fore not worth mentioning.

The trace only shows notes whose fre­quen­cies have been corrected:

§ key 36: "C2" chan 2 scale #6, block key 60, corr -7 cents, freq 65.144 Hz
§ key 48: "C3" chan 2 scale #6, block key 60, corr -3 cents, freq 130.589 Hz
§ key 60: "C4" chan 2 scale #6, block key 60, corr 0 cents, freq 261.630 Hz
§ key 72: "C5" chan 2 scale #6, block key 60, corr 3 cents, freq 524.168 Hz
§ key 84: "C6" chan 2 scale #6, block key 60, corr 7 cents, freq 1050.760 Hz
§ key 96: "C7" chan 2 scale #6, block key 60, corr 11 cents, freq 2106.381 Hz

We note that 5 octaves gives a total stretch of 18 cents, or 3.6 cents per octave. The fre­quen­cy ratio between C4 and C7, three octaves high­er, is 2106.381/261.630 = 8.0509, whose cube root is 2.0042, again very close to the ratio of 2.0046 in the piano scale def­i­n­i­tion. Unsurprisingly, the C-sound score reveals exact­ly the same numbers.

Effect of the block key

Let us super­im­pose two phras­es of the same notes in the same scale but with­out the same block key:

G3 A3 B3 {_scale(just intonation,A4) C4 D4 E4 A4, _scale(just intonation,C4) C5 D5 E5 A5}

It sounds strange, giv­en that the note inter­vals are not exact­ly one octave:

The analy­sis of the trace gives an inter­est­ing result:

§ key 60: "C4" chan 2 scale #3, block key 69, corr 15 cents, freq 263.907 Hz
§ key 72: "C5" chan 3 scale #3, block key 60, corr 0 cents, freq 523.260 Hz
§ key 62: "D4" chan 2 scale #3, block key 69, corr 18 cents, freq 296.739 Hz
§ key 74: "D5" chan 3 scale #3, block key 60, corr 3 cents, freq 588.358 Hz
§ key 64: "E4" chan 2 scale #3, block key 69, corr 2 cents, freq 330.014 Hz
§ key 76: "E5" chan 3 scale #3, block key 60, corr -13 cents, freq 654.334 Hz
§ key 69: "A4" chan 2 scale #3, block key 69, corr 0 cents, freq 440.007 Hz
§ key 81: "A5" chan 3 scale #3, block key 60, corr -15 cents, freq 872.423 Hz

First, key #72 (C5) of scale #4 has 0 cents cor­rec­tion because the block key of this scale is C4 and it has no octave stretch­ing. The same for key #69 (A4) of scale #3 whose block key is A4.

Pitch val­ues can be deduced from the image of the just into­na­tion scale., For instance, A4 (key #69) has 0 cent cor­rec­tion on the score because it is the block key. The cor­rect­ed C4 fre­quen­cy of this scale is 263.907 Hz (i.e. 15 cents above its base fre­quen­cy 261.63 Hz) and the fre­quen­cy ratio for A is 5/3, which yields 440.007 Hz as shown above.

Secondly, since notes C4 and C5 are super­im­posed with dif­fer­ent cent cor­rec­tions, i.e. dif­fer­ent pitch­ben­der set­tings, they must be sent on dif­fer­ent MIDI chan­nels: 2 and 3. This is the approach bor­rowed from MPE. Same for D4/D5, E4/E5, A4/A5. Note that each MIDI chan­nel is reused as soon as it is free of notes.

For geeks: In this exam­ple, the notes G3 A3 B3 played at the begin­ning are not mod­i­fied by a micro­ton­al scale. They are there­fore played on the stan­dard equal tem­pered scale of the MIDI device. As a result, they appear on the Csound score in octave point pitch-class format:

i1 0.000 1.000 7.07 90.000 90.000 0.000 0.000 0.000 0.000 ; G3
i1 1.000 1.000 7.09 90.000 90.000 0.000 0.000 0.000 0.000 ; A3
i1 2.000 1.000 7.11 90.000 90.000 0.000 0.000 0.000 0.000 ; B3
i1 3.000 1.000 263.907 90.000 90.000 0.000 0.000 0.000 0.000 ; C4
i1 3.000 1.000 523.260 90.000 90.000 0.000 0.000 0.000 0.000 ; C5
i1 4.000 1.000 296.739 90.000 90.000 0.000 0.000 0.000 0.000 ; D4
i1 4.000 1.000 588.358 90.000 90.000 0.000 0.000 0.000 0.000 ; D5
i1 5.000 1.000 330.014 90.000 90.000 0.000 0.000 0.000 0.000 ; E4
i1 5.000 1.000 654.334 90.000 90.000 0.000 0.000 0.000 0.000 ; E5
i1 6.000 1.000 440.007 90.000 90.000 0.000 0.000 0.000 0.000 ; A4
i1 6.000 1.000 872.423 90.000 90.000 0.000 0.000 0.000 0.000 ; A5

Effect of the base key

The meantone_try scale

Let us use meantone_try and meantone_try2 scale to play the same phrase. We call these scales "exot­ic" because the names of their notes are not in the English, Italian/Spanish/French, or Indian stan­dard. Here we use the key num­bers of the MIDI out­put device.

The only dif­fer­ence is the key num­bers. In meantone_try2, the base key is #64 instead of #60.

Try:

_scale(meantone_try,69) key#60 key#62 key#65 key#69 key#72

The result:

§ key 60: "key#60" chan 2 scale #4, block key 69, corr -5 cents, freq 260.875 Hz
§ key 62: "key#62" chan 2 scale #4, block key 69, corr -2 cents, freq 293.331 Hz
§ key 65: "key#65" chan 2 scale #4, block key 69, corr 13 cents, freq 351.866 Hz
§ key 69: "key#69" chan 2 scale #4, block key 69, corr 0 cents, freq 440.007 Hz
§ key 72: "key#60" chan 2 scale #4, block key 69, corr 13 cents, freq 527.204 Hz

The fre­quen­cy of key#69 is 440 Hz since it is the block key. The actu­al sequence heard on the MIDI out­put device is C4 D4 F4 A4 C5. Note that the octave ratio C5/C4 is 527.204/260.875 which is greater than 2 because this scale has an octave stretched by 19 cents.

Now try:

_scale(meantone_try2,73) key#64 key#66 key#69 key#73 key#76

The result:

§ key 64: "key#64" chan 2 scale #5, block key 73, corr -5 cents, freq 260.875 Hz
§ key 66: "key#66" chan 2 scale #5, block key 73, corr -2 cents, freq 293.331 Hz
§ key 69: "key#69" chan 2 scale #5, block key 73, corr 13 cents, freq 351.866 Hz
§ key 73: "key#73" chan 2 scale #5, block key 73, corr 0 cents, freq 440.007 Hz
§ key 76: "key#64" chan 2 scale #5, block key 73, corr 13 cents, freq 527.204 Hz

Note again that the fre­quen­cy of the base key #73 is 440 Hz. The fre­quen­cies are iden­ti­cal, the only change is the key num­bers asso­ci­at­ed with the notes. The actu­al sequence played on the MIDI out­put device should again be C4 D4 F4 A4 C5, assum­ing that key #64 is the mid­dle key of its keyboard.

A very exotic scale

The scale called zest24-supergoya17plus3_Db is more "exot­ic" than the pre­vi­ous one because it has 20 grades and 12 notes. The orig­i­nal scale down­loaded from an archive did not have note names, so we decid­ed to label twelve posi­tions with the key num­bers #60 to #71. As you can see in the pic­ture, the inter­vals are very irreg­u­lar. The choice of 12 tones is moti­vat­ed by the desire to be able to map them onto the 12 keys of a stan­dard piano key­board. We'll see a dif­fer­ent case later.

Try the following:

_scale(zest24-supergoya17plus3_Db,0) key#60 key#62 key#65 key#69 key#72

The result in real-time MIDI:

§ key 60: "key#60" chan 2 scale #7, block key 60, corr 0 cents, freq 261.630 Hz
§ key 62: "key#62" chan 2 scale #7, block key 60, corr 67 cents, freq 305.258 Hz
§ key 65: "key#65" chan 2 scale #7, block key 60, corr 176 cents, freq 386.605 Hz
§ key 69: "key#69" chan 2 scale #7, block key 60, corr 75 cents, freq 459.488 Hz
§ key 72: "key#60" chan 2 scale #7, block key 60, corr 0 cents, freq 523.260 Hz

and the Csound score:

i1 0.000 1.000 261.630 90.000 90.000 0.000 0.000 0.000 0.000 ; key#60
i1 1.000 1.000 305.258 90.000 90.000 0.000 0.000 0.000 0.000 ; key#62
i1 2.000 1.000 386.605 90.000 90.000 0.000 0.000 0.000 0.000 ; key#65
i1 3.000 1.000 459.488 90.000 90.000 0.000 0.000 0.000 0.000 ; key#69
i1 4.000 1.000 523.260 90.000 90.000 0.000 0.000 0.000 0.000 ; key#60

Key #60 is the base key and its fre­quen­cy is 261.630 Hz as declared in the tonal­i­ty resource. Note that the key #72, an octave high­er, also has "key#60" as its note name. Its fre­quen­cy of 523.260 Hz is twice 261.630 since octaves are not stretched.

Looking at the pic­ture, we can cal­cu­late the fre­quen­cy of key#65 which has a fre­quen­cy ratio of 1.478. This gives 1.478 x 261.63 = 386.69 Hz, which is very close to that in the score. Minor errors are due to the round­ing of cents to whole numbers.

If you play this score on a con­ven­tion­al MIDI device, you won't hear the cor­rect fre­quen­cies unless the device is tuned to a 20-grade equal tem­pera­ment scale. Conversely, the ren­der­ing in C-Sound is accurate.

When a scale has more than 12 grades, the ref­er­ence tem­pered scale must have the same num­ber of grades, regard­less of the num­ber of notes (which is indeed small­er). Apart from the musi­cal aspect — which we won't dis­cuss here — this has a tech­ni­cal advan­tage: the cent cor­rec­tions, which are devi­a­tions from the equal tem­pera­ment scale, will always be less than 100 cents. This is impor­tant because the sen­si­tiv­i­ty of pitch­ben­ders is set to ± 200 cents.

The Bohlen-Pierce scale

The Bohlen-Pierce scale has a "tri­tave" inter­val of ratio 3/1 instead of 2/1 in the octave. The tri­tave is divid­ed into 13 grades and 13 notes (see Wikipedia).

The "just-intonation" ver­sion has been imple­ment­ed in the tonal resource -to.tryMPE — see pic­ture.

Play the full sequence of notes over a tritave:

_scale(Bohlen-Pierce,0) C4 Db4 D4 E4 F4 Gb4 G4 H4 Jb4 J4 A4 Bb4 B4 C5

Be aware that notes with names like C, Db, D, etc. have dif­fer­ent posi­tions than notes with the same names in a 12 tone scale.

This yields:

§ key 60: "C4" … corr 0 cents, freq 261.630 Hz
§ key 61: "Db4" … corr 33 cents, freq 282.522 Hz
§ key 62: "D4" … -> key 63 corr 1 cents, freq 311.312 Hz
§ key 63: "E4" … -> key 64 corr 35 cents, freq 336.365 Hz
§ key 64: "F4" … -> key 65 corr 82 cents, freq 366.174 Hz
§ key 65: "Gb4" … -> key 67 corr 36 cents, freq 400.239 Hz
§ key 66: "G4" … -> key 68 corr 84 cents, freq 435.960 Hz
§ key 67: "H4" … -> key 70 corr 17 cents, freq 470.772 Hz
§ key 68: "Jb4" … -> key 71 corr 65 cents, freq 512.788 Hz
§ key 69: "J4" … -> key 73 corr 19 cents, freq 560.492 Hz
§ key 70: "A4" … -> key 74 corr 66 cents, freq 610.163 Hz
§ key 71: "Bb4" … -> key 76 corr 0 cents, freq 659.266 Hz
§ key 72: "B4" … -> key 77 corr 68 cents, freq 726.449 Hz
§ key 73: "C5" … -> key 79 corr 1 cents, freq 784.457 Hz

The fre­quen­cy ratio C5 / C4 is, as expect­ed, 784.457 / 261.630 = 3.

The Bohlen-Pierce scale played on Pianoteq

Since the scale cov­ers a tri­tave that would extend from A4 (key #60) to G5 (key #79) on a con­ven­tion­al 12-note MIDI device, each note is mapped to the key that requires the least amount of pitch­bend. As a result, pitch­bend cor­rec­tions are nev­er greater than ± 100 cents.

The Csound score:

i1 0.000 1.000 261.630 90.000 90.000 0.000 0.000 0.000 0.000 ; C4
i1 1.000 1.000 282.522 90.000 90.000 0.000 0.000 0.000 0.000 ; Db4
i1 2.000 1.000 311.312 90.000 90.000 0.000 0.000 0.000 0.000 ; D4
i1 3.000 1.000 336.365 90.000 90.000 0.000 0.000 0.000 0.000 ; E4
i1 4.000 1.000 366.174 90.000 90.000 0.000 0.000 0.000 0.000 ; F4
i1 5.000 1.000 400.239 90.000 90.000 0.000 0.000 0.000 0.000 ; Gb4
i1 6.000 1.000 435.960 90.000 90.000 0.000 0.000 0.000 0.000 ; G4
i1 7.000 1.000 470.772 90.000 90.000 0.000 0.000 0.000 0.000 ; H4
i1 8.000 1.000 512.788 90.000 90.000 0.000 0.000 0.000 0.000 ; Jb4
i1 9.000 1.000 560.492 90.000 90.000 0.000 0.000 0.000 0.000 ; J4
i1 10.000 1.000 610.163 90.000 90.000 0.000 0.000 0.000 0.000 ; A4
i1 11.000 1.000 659.266 90.000 90.000 0.000 0.000 0.000 0.000 ; Bb4
i1 12.000 1.000 726.449 90.000 90.000 0.000 0.000 0.000 0.000 ; B4
i1 13.000 1.000 784.457 90.000 90.000 0.000 0.000 0.000 0.000 ; C5

Examples of music using the Bohlen-Pierce scale :
https://en.xen.wiki/w/Bohlen-Pierce_scale/Music

To con­vert to Bohlen-Pierce notes played on an exter­nal MIDI device, con­nect it to the input of BP3, then run the fol­low­ing "tun­ing dae­mon" (see below):

_vel(0) C0 _script(wait for­ev­er) _scale(Bohlen-Pierce,0)

Combination of several scales

In the fol­low­ing exam­ple, two phras­es are played on top of each oth­er, using dif­fer­ent micro­ton­al scales.

On the pianoroll (see pic­ture), key#60 is shown as C4. The note key#62, shown as D4, seems to be unique, although two key#62 notes are super­im­posed with slight­ly dif­fer­ent cent cor­rec­tions. The same is true with key#72 shown as C5.

{ _scale(zest24-supergoya17plus3_Db,0) key#60 key#62 key#69 key#72 , _scale(meantone_try,69) key#69 key#62 key#60 key#72 }

The result:

§ key 60: "key#60" chan 2 scale #7, block key 60, corr 0 cents, freq 261.630 Hz
§ key 69: "key#69" chan 3 scale #4, block key 69, corr 0 cents, freq 440.007 Hz
§ key 62: "key#62" chan 2 scale #7, block key 60, corr 67 cents, freq 305.258 Hz
§ key 62: "key#62" chan 3 scale #4, block key 69, corr -2 cents, freq 293.331 Hz
§ key 69: "key#69" chan 2 scale #7, block key 60, corr 75 cents, freq 459.488 Hz
§ key 60: "key#60" chan 3 scale #4, block key 69, corr -5 cents, freq 260.875 Hz
§ key 72: "key#60" chan 2 scale #7, block key 60, corr 0 cents, freq 523.260 Hz
§ key 72: "key#60" chan 3 scale #4, block key 69, corr 13 cents, freq 527.204 Hz

The sec­ond (key 62) and last (key 72) notes are iden­ti­cal, but because they belong to dif­fer­ent scales, their fre­quen­cies are not iden­ti­cal. For this pur­pose, they are played on dif­fer­ent MIDI chan­nels. The super­im­po­si­tion cre­ates (nasty) mis­match­es that reflect the dif­fer­ences in tuning:

Use of _scale(0,0)

So far we have used "_scale(0,0)" to spec­i­fy the return to a 12-grade equal tem­pered scale after using a micro­ton­al scale. It can also be used to force micro­ton­al mode in a musi­cal item that does not require spe­cif­ic micro­ton­al scales.

Pitchbend adjust­ments are not shown on this graph

For exam­ple, try to play the phrase:

_pitchrange(200) C4 _pitchbend(100) C4 {_pitchbend(-100) C4, _pitchbend(200) C4} C4 _pitchbend(0) C4

This is a (rather sil­ly) way of cre­at­ing a sequence of notes using the same note with pitch­bend cor­rec­tions. In fact, we are look­ing for­ward to hearing:

C4 C#4 {B3, D4} C#4 C4

The first solu­tion does not work because the chord {B3, D4} con­sists of two of the same note A4 with dif­fer­ent pitch­bend val­ues. It works in Csound, but in MIDI we hear:

An incor­rect ren­der­ing of C4 C#4 {B3, D4} C#4 C4

Proper nota­tion, with­out the aid of micro­tonal­i­ty, would be, for example:

_pitchrange(200) C4 _pitchbend(100) C4 {_pitchbend(-100) C4, _chan(2) _pitchrange(200) _pitchbend(200) C4} C4 _pitchbend(0) C4

So we have to send the two C4s of the poly­met­ric expres­sion on sep­a­rate MIDI chan­nels. But the micro­ton­al cal­cu­la­tion does this auto­mat­i­cal­ly. So, putting "_scale(0,0)" at the begin­ning won't change the tun­ing but it will force the micro­ton­al mode:

_scale(0,0) _pitchrange(200) C4 _pitchbend(100) C4 {_pitchbend(-100) C4, _pitchbend(200) C4} C4 _pitchbend(0) C4

Now we hear:

A cor­rect ren­der­ing of C4 C#4 {B3, D4} C#4 C4 using the micro­ton­al mode

and the trace shows:

§ key 60: "C4" chan 2
§ key 60: "C4" chan 2
--> with addi­tion­al pitch­bend val­ue of 4095
§ key 60: "C4" chan 2
--> with addi­tion­al pitch­bend val­ue of -4096
§ key 60: "C4" chan 3
--> with addi­tion­al pitch­bend val­ue of 8191
§ key 60: "C4" chan 2
--> with addi­tion­al pitch­bend val­ue of 4095
§ key 60: "C4" chan 2

Csound scores are the same in all cas­es (pitch­bend para­me­ters in bold):

i1 0.000 1.000 8.00 90.000 90.000 0.000 0.000 0.000 0.000 ; C4
i1 1.000 1.000 8.00 90.000 90.000 0.000 99.988 99.988 0.000 ; C4
i1 2.000 1.000 8.00 90.000 90.000 0.000 -100.000 -100.000 0.000 ; C4
i1 2.000 1.000 8.00 90.000 90.000 0.000 199.976 199.976 0.000 ; C4
i1 3.000 1.000 8.00 90.000 90.000 0.000 99.988 99.988 0.000 ; C4
i1 4.000 1.000 8.00 90.000 90.000 0.000 0.000 0.000 0.000 ; C4

For geeks: It wouldn't be a good idea to set micro­tonal­i­ty mode by default for all musi­cal works, because (1) chan­nel assign­ment takes up pro­cess­ing time, and (2) this would ren­der all "_chan()" com­mands inef­fec­tive. In some MIDI envi­ron­ments, MIDI chan­nels are used to send mes­sages to dif­fer­ent instruments.

Combination with pitchbend commands

The fol­low­ing is an exam­ple of com­bin­ing a micro­ton­al phrase with a glob­al pitch­bend com­mand of + 100 cents:

_chan(4) _pitchrange(200) _scale(zest24-supergoya17plus3_Db,0) _pitchbend(+100) key#60 key#62 key#65 key#69 key#72 _pitchbend(0) key#72

The result is:

§ key 60: "key#60" chan 2 scale #7, block key 60, corr 0 cents, freq 261.630 Hz
--> with addi­tion­al pitchbend value 4095
§ key 62: "key#62" chan 2 scale #7, block key 60, corr 67 cents, freq 305.258 Hz
--> with addi­tion­al pitch­bend val­ue 4095
§ key 65: "key#65" chan 2 scale #7, block key 60, corr 176 cents, freq 386.605 Hz
--> with addi­tion­al pitch­bend val­ue 4095
§ key 69: "key#69" chan 2 scale #7, block key 60, corr 75 cents, freq 459.488 Hz
--> with addi­tion­al pitch­bend val­ue 4095
§ key 72: "key#60" chan 2 scale #7, block key 60, corr 0 cents, freq 523.260 Hz
--> with addi­tion­al pitch­bend val­ue 4095
§ key 72: "key#60" chan 2 scale #7, block key 60, corr 0 cents, freq 523.260 Hz

The "_chan(4)" com­mand is used here to prove that it is ignored in micro­tonal­i­ty mode. The MIDI trace shows that an addi­tion­al cor­rec­tion has been applied. Therefore, the fre­quen­cy val­ues are not those played on the out­put MIDI device. However, the Csound score is explicit:

i1 0.000 1.000 261.630 90.000 90.000 0.000 99.988 99.988 0.000 ; key#60
i1 1.000 1.000 305.258 90.000 90.000 0.000 99.988 99.988 0.000 ; key#62
i1 2.000 1.000 386.605 90.000 90.000 0.000 99.988 99.988 0.000 ; key#65
i1 3.000 1.000 459.488 90.000 90.000 0.000 99.988 99.988 0.000 ; key#69
i1 4.000 1.000 523.260 90.000 90.000 0.000 99.988 99.988 0.000 ; key#60
i1 5.000 1.000 523.260 90.000 90.000 0.000 0.000 0.000 0.000 ; key#60

The num­bers 99.988 and 99.988 are the pitch­bend cor­rec­tions (in cents) at the begin­ning and end of the note declared on each line.

The "grama" Indian scale

The gra­ma scale

We have already dis­cussed the ancient Indian tonal sys­tem which divides the octave into "twenty-two shrutis", see The two-vina exper­i­ment for details. We'll try this gra­ma scale by set­ting the pramāņa ṣru­ti to 21 cents.

In short, this tun­ing scheme is a twelve degree chro­mat­ic scale: Sa, Re komal, Re, Ga komal, Ga, Ma, Ma tivra, Pa, Dha komal, Dha, Ni komal, Ni. These names stand for C, Db, D, Eb, E, F, F#, G, Ab, A, Bb, B in English notation.

Each note of the Indian scale, except Sa (C) and Ma tivra (F#), can occu­py two enhar­mon­ic posi­tions. This explains why the gra­ma tun­ing scheme has 23 posi­tions and 22 notes.

In accor­dance with the syn­tax of the Bol proces­sor, notes are referred to as sound objects in low­er case. For exam­ple, the two enhar­mon­ic posi­tions of Re komal are called r1_ and r2_, and the two posi­tions of Re are called r3_ and r4_. A trail­ing '_' is nec­es­sary to indi­cate octave num­bers unam­bigu­ous­ly: the note d3_4 is the low posi­tion of Dha in the 4th octave, which is admit­ted­ly close to A4 in the Western scale.

The pramāņa ṣru­ti is the tonal dis­tance between all pairs of enhar­mon­ic posi­tions, for instance between r1_ and r2_. For the sake of sim­plic­i­ty, we've set it to 21 cents (a syn­ton­ic com­ma), which is a com­mon mis­take made by Western and Indian musi­col­o­gists. In real­i­ty it is a vari­able val­ue — see Raga into­na­tion.

Play the scale:

_scale(grama, d3_4) sa_4 r1_4 r2_4 r3_4 r4_4 g1_4 g2_4 g3_4 g4_4 m1_4 m2_4 m3_4 p3_4 p4_4 d1_4 d2_4 d3_4 d4_4 n1_4 n2_4 n3_4 n4_4 sa_5

The result (Csound is identical):

§ key 60: "sa_4" …corr 15 cents, freq 263.907 Hz
§ key 61: "r1_4" …corr 6 cents, freq 278.150 Hz
§ key 62: "r2_4" …corr -73 cents, freq 281.544 Hz
§ key 63: "r3_4" …-> key 61 corr 98 cents, freq 293.331 Hz
§ key 64: "r4_4" …-> key 62 corr 19 cents, freq 296.910 Hz
§ key 65: "g1_4" …-> key 63 corr 10 cents, freq 312.935 Hz
§ key 66: "g2_4" …-> key 63 corr 31 cents, freq 316.754 Hz
§ key 67: "g3_4" …-> key 64 corr 2 cents, freq 330.014 Hz
§ key 68: "g4_4" …-> key 64 corr 23 cents, freq 334.042 Hz
§ key 69: "m1_4" …-> key 65 corr 14 cents, freq 352.070 Hz
§ key 70: "m2_4" …-> key 65 corr 35 cents, freq 356.366 Hz
§ key 71: "m3_4" …-> key 66 corr 6 cents, freq 371.285 Hz
§ key 72: "p3_4" …-> key 66 corr 96 cents, freq 391.097 Hz
§ key 73: "p4_4" …-> key 67 corr 17 cents, freq 395.870 Hz
§ key 74: "d1_4" …-> key 68 corr 8 cents, freq 417.235 Hz
§ key 75: "d2_4" …-> key 68 corr 29 cents, freq 422.327 Hz
§ key 76: "d3_4" …-> key 69 corr 0 cents, freq 440.007 Hz
§ key 77: "d4_4" …-> key 69 corr 21 cents, freq 445.377 Hz
§ key 78: "n1_4" …-> key 70 corr 12 cents, freq 469.414 Hz
§ key 79: "n2_4" …-> key 70 corr 33 cents, freq 475.143 Hz
§ key 80: "n3_4" …-> key 71 corr 4 cents, freq 495.034 Hz
§ key 81: "n4_4" …-> key 71 corr 25 cents, freq 501.075 Hz
§ key 82: "sa_5" …-> key 72 corr 16 cents, freq 528.118 Hz

The gra­ma scale (22 notes) played on Pianoteq

Listen to the same scale played against a drone (read the Microtonality page):

The Csound ren­der­ing of the gra­ma scale (23 grades) played against a drone. This ver­sion has an addi­tion­al note m4_ that does not belong to the pre­ced­ing scale. 

We said ear­li­er that, in the gra­ma tun­ing scheme, d3_4 occu­pies the posi­tion of A4 in the Western scale. Since the block key is #76 (d3_4), the fre­quen­cy of d3_4 is close to 440 Hz. Consequently, the posi­tion of sa_4 (263.907 Hz) is 15 cents high­er than the base fre­quen­cy (261.63 Hz).

This scale can be played on any MIDI device that accepts pitch­bend com­mands. The 22 notes of the scale, cov­er­ing an octave, are mapped to the 12 keys of a MIDI key­board. Each note is mapped to the key that requires the least amount of pitch­bend. As a result, pitch­bend cor­rec­tions are nev­er greater than ± 100 cents. For exam­ple, d3_4 is mapped to key #69, which hap­pens to be that of A4 on a con­ven­tion­al keyboard.

Read the Raga Intonation page to see how this the­o­ret­i­cal frame­work can be adapt­ed for mod­el­ling real music.

Microtonality in sound-objects

A sound-object is a sequence of MIDI events and/or Csound score lines — read Sound-object pro­to­types for details. Therefore the pitch­es of notes it con­tains can be mod­i­fied by micro­ton­al scales. In the "-da.tryMPE" project, try for instance:

_scale(just intonation,0) a f b b

and check fre­quen­cy cor­rec­tions in the trace (both MIDI and Csound):

§ key 69: "A4" octave 4 scale #3, block key 60, corr -15 cents, freq 436.212 Hz
§ key 41: "F2" octave 2 scale #3, block key 60, corr -1 cents, freq 87.258 Hz
§ key 71: "B4" octave 4 scale #3, block key 60, corr -11 cents, freq 490.764 Hz
§ key 71: "B4" octave 4 scale #3, block key 60, corr -11 cents, freq 490.764 Hz
§ key 71: "B4" octave 4 scale #3, block key 60, corr -11 cents, freq 490.764 Hz
§ key 71: "B4" octave 4 scale #3, block key 60, corr -11 cents, freq 490.764 Hz

The posi­tion of A on the just into­na­tion scale (see pic­ture) is 884 cents above C, which is 15 cents below its posi­tion on the equal tem­pera­ment scale (900 cents). The same goes for B which is 1088 cents above C, and thus 11 cents below its posi­tion on the equal tem­pera­ment scale (1100 cents). 

Applying microtonal corrections to MIDI input notes

This demon­strates the BP3's abil­i­ty to act as an inter­face between MIDI devices, retun­ing the input in real time to a micro­ton­al scale.

The fil­ter of the input MIDI device should be set to "treat & pass" for all cat­e­gories of events that will be trans­mit­ted (see picture).

We show a tem­po­rary solu­tion that works very well, but will be sim­pli­fied in the future.

If, for exam­ple, you want to retune the input to the just into­na­tion scale, run the fol­low­ing "tun­ing daemon":

_script(wait for C0 channel 16) _scale(just intonation,A4) _vel(0) C0

The "wait for C0 channel 16" com­mand that caus­es the machine to hang up while it lis­tens for some kind of input. In fact, the note "C0 channel 16" should not be part of the stream of notes you need to retune, oth­er­wise it will stop the process!

The note C0 with veloc­i­ty 0 is inaudi­ble and will not be played unless the note "C0 channel 16" releas­es the wait­ing state. This note is need­ed for attach­ing the script instruction.

An alter­na­tive to this set­up is:

_vel(0) C0 _script(wait forever) _scale(just intonation,A4)

The "wait forever" com­mand caus­es the machine to hang until the STOP or PANIC but­ton is pressed. Again, we need a dum­my (inaudi­ble) note C0, at the end of which the script instruc­tion is appended.

Because mul­ti­ple instances of BP3 can be run simul­ta­ne­ous­ly (read Real-time MIDI), you can set up a bank of "tun­ing dae­mons" that inter­act with peo­ple and MIDI devices to cre­ate inter­est­ing vari­a­tions of tonal structures.

Leave a Reply

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