Microtonal musical systems

When playing a note with play you can provide the notes in a couple ways:
play C #the note name
play 60 #the key on the keyboard that corresponds to that note

I was looking through the wiki page for Svara and it has note names like M’a which corresponds to F#.

Would it be possible to add the names of notes for other musical systems like in Indian Classical Music?

1 Like
doh = 60 ### any names you want
re = 70  ### also allows for
mi = 80  ### Indian microtuning
skale = [doh,re,mi]
for i in 0..2
  play skale[i]
  sleep 1

That would totally work for a session or a song but I was thinking making a more permanent change to the code base to allow for those additional names.

I can’t seem to find where it would be though, thought my search felt a little superficial

Update: Ok, I checked out the code and it looks like it might be in app/server/ruby/lib/sonicpi/note.rb further investigation commencing :stuck_out_tongue:

Happy to consider proposals for changes.

However, it’s important to note that the solfège method of education for music uses the terms doh, re, mi, etc to refer to the intervals on a scale - so definitely shouldn’t be hard-coded to specific MIDI numbers.

Having said that, I do think there’s huge value in taking the same approach as the live coding system Ixi Lang took which is to allow people to work directly with scale intervals as that has been shown to make things simple and musical for beginners.

So something like the following might make sense:

play :doh #=> plays the first note of the current scale (perhaps the default is C Major)
use_scale :d, :minor
play :doh #=> now plays :d
use_scale :f, :major
use_scale_intervals #=> let people use integers to refer to scale intervals
play 1 #=> plays :f

I see what you mean about how the intervals
are translated in notes.rb:

      {cf: -1, CF: -1, Cf: -1, cF: -1,
       cb: -1, CB: -1, Cb: -1, cB: -1,
       c:  0,  C:  0,
       cs: 1,  CS: 1, cS: 1, Cs: 1,
       df: 1,  DF: 1, Df: 1, dF: 1,
       db: 1,  DB: 1, Db: 1, dB: 1,
       d:  2,  D:  2,
       eb: 3,  EB: 3, Eb: 3, eB: 3,
       ef: 3,  EF: 3, Ef: 3, eF: 3,
       ds: 3,  DS: 3, Ds: 3, dS: 3,
       e:  4,  E:  4,
       fb: 4,  FB: 4, Fb: 4, fB: 4,
       ff: 4,  FF: 4, Ff: 4, fF: 4,
       f:  5,  F:  5,
       es: 5,  ES: 5, Es: 5, eS: 5,
       fs: 6,  FS: 6, Fs: 6, fS: 6,
       gb: 6,  GB: 6, Gb: 6, gB: 6,
       gf: 6,  GF: 6, Gf: 6, gF: 6,
       g:  7,  G:  7,
       gs: 8,  GS: 8, Gs: 8, gS: 8,
       ab: 8,  AB: 8, Ab: 8, aB: 8,
       af: 8,  AF: 8, Af: 8, aF: 8,
       a:  9,  A:  9,
       bb: 10, BB: 10, Bb: 10, bB: 10,
       bf: 10, BF: 10, Bf: 10, bF: 10,
       as: 10, AS: 10, As: 10, aS: 10,
       b:  11, B: 11,
       bs: 12, BS: 12, Bs: 12, bS: 12}

      0  => :C,
      1  => :Cs,
      2  => :D,
      3  => :Eb,
      4  => :E,
      5  => :F,
      6  => :Fs,
      7  => :G,
      8  => :Ab,
      9  => :A,
      10 => :Bb,
      11 => :B}


    MIDI_NOTE_RE = /\A:?(([a-gA-G])([sSbBfF]?))([-]?[0-9]*)\Z/

With that method, it seems like that is used for the purposes of Western music but maybe by allowing to play with the intervals then other systems could be used.

The time between posting this and now, I did some reading and it seems like my perception of something like Indian classical music wasn’t right; there are still 12 intervals but I guess the starting point is different? I’ll do some more research :slight_smile:

Thanks, you two!

Oh, and just to make sure I didn’t cause confusion. In terms of a permanent solution. I didn’t mean for something like Doh Re Me to be hardcoded, but something like one of the tables from that wiki page:

Play Sa === Play C === Play 60

Cause I don’t think that’ll change any time soon.

I ’ d be tempted to use numbers instead of note names …

I probably would too

Would you dare the ratios for a scale ?
I’ve looked before and could never find
the numbers …

Hmm, I think the best I find at the moment would be in that wiki page under the section “Swaras in Carnatic music“

In that chart, it seems to say, given a base note, or Shadja, then the scale is built upon some number of semi tones.

So, if I’m reading it correctly, maybe if we assume C is the Shadja, then we can build up the subsequent notes?

I think tonight, I’ll try building out a temporary variable list like you mentioned and then I’ll see how it sounds.

I let you know what I find out and maybe I’ll share some code here and we can determine if it sounds right. :slight_smile:

Ok, what do you think of this?

sa = 60 #0
ra = 61 #1
ri = 62 #2
ru = 63 #3
gi = 63 #3
gu = 64 #4
ma = 65 #5
mi = 66 #6
pa = 67 #7
dha = 68 #8
dhi = 69 #9
na = 69  #9
dhu = 70 #10
ni = 70  #10
nu = 71  #11

live_loop :amen do
  sample :loop_tabla, amp: 2
  sleep sample_duration(:loop_tabla)

use_synth :pluck

15.times do
  play (ring mi, gi, ru, gi).tick
  sleep 0.1

5.times do
  play (ring na+2, ni+2, nu+2, ni+2, na+2).tick
  sleep 0.25

5.times do
  play (ring pa, dha, nu, dha, pa).tick
  sleep 0.25

sleep 1

13.times do
  play ma
  sleep 0.3

2.times do
  play ru
  sleep 0.3
  play ma
  sleep 0.3
  play mi
  sleep 0.3
  play ma
  sleep 0.3
  play ma
  sleep 0.3
  play ma
  sleep 0.3
  play ma
  sleep 0.3
  play ru
  sleep 0.3
  play ma
  sleep 0.3
  play mi
  sleep 0.3
  play ma
  sleep 1

I tried to pseudo-recreate the beginning of this song:

But, to be honest, I used intervals to get it all in line :rofl: so, take that for what you will.

Ok, what do you think of this?

Sounds good ! … O.K. for Bollywood ,
but Ravi might be more like …???

skale = ["sa    ","ra    ","ri    ","ru/gi ",
         "gu    ","ma    ","mi    ", "pa    ",
         "dha   ","dhi/na","dhu/ni","nu    ",
         "SA    "]
numerator = [1,16,9,6,5,4,45,3,8,27,9,15,2]
denominator = [1,15,8,5,4,3,32,2,5,16,5,8,1]

# For sa = 440 Hz

for i in 0..12
puts skale[i],f,"Hz midi #",hz_to_midi(f)


1 Like

That is some really impressive code, @hitsware; amazing job finding that chart and translating it. Where did you find it?

I do like the sound of it more now too

I feel like your code could be something that could be included in Note.rb to maintain a reference to those ratios.

Heck, I’m definitely saving this thread for the purposes of keeping it :slight_smile:

Thank You !

Where did you find it?

By the grace of Google :slight_smile:

I do like the sound of it more now too

Music is all in Your Mind … But that is where it counts !

1 Like