Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

musical transposition in javascript

Name: Anonymous 2010-06-10 13:34

I'm trying to make a transposer in JavaScript..
Give it a key and a scale/mode and it will generate it for you
For instance
C Lydian (WWWHWWH) is C D E F# G A B
C Aeolian (WHWWHWW) is C D Eb F G Ab Bb
I cannot for the life of me figure out how to accomplish this.
Thoughts?
>inb4 SICP

Name: Anonymous 2010-06-10 14:40

>>12
Okay, how about something like
keys = { "C", "C#/Db", "D", ... }
scales = { "Major": "2212221", ... } // how many semitones difference (i.e. 2 = whole, 1 = half)
function thingy(offset, scale) {
  to_print = '#'; // start off printing the sharps by default
  for (i = 0, key = offset; i++, key += scales[scale][i]; i < scales[scale].length) { // or something to that effect, also wrap around keys[] with key % 12 somewhere
    if (keys[key] like keys[key+1]) { if they both contain the same letter, you're printing the wrong ones
      to_print = 'b';
    } // if (a like b) will only happen once
    add_to_print_queue (keys[key]);
  }
  print_the_queue();
}

I dunno, I made it up as I went along. But something like that.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List