Advertisement
harleyTLV

notes with freqs

Mar 12th, 2021
1,552
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (
  2. var
  3.     // all notes from C - B
  4.     notes = 65.to(65+6).collect({|char|char.asAscii}).rotate(-2),
  5.     // at what notes do we have half tone intervals to next note (counting notes from 0 for C)
  6.     half_tones = [ 2, 6 ],
  7.     // all notes including those for half-tones
  8.     notes_with_sharp = notes.collect({|note, index|
  9.       if(half_tones.matchItem(index), { [ note ] }, { [ note, note.asString ++ \is ] });
  10.     }).flatten,
  11.     // all relevant scale numbers
  12.     scale_numbers = 0.to(8).collect({|scale| scale }),
  13.     // all notes in all scales
  14.     all_notes = scale_numbers.collect({|scale|
  15.         notes_with_sharp.collect({|note|
  16.             note.asString ++ " " ++ scale.asString;
  17.         });
  18.     }).flatten,
  19.     // frequencies for each half-steps four scales down and for scales up the A4 note - C0 - B8
  20.     note_freqs = Array.geom(12*4 + 10, 440, 2.pow(-1/12)).reject({arg f;f==440}).reverse ++ Array.geom(12*4 + 3, 440, 2.pow(1/12)),
  21.     all_notes_with_freqs = Dictionary.newFrom( all_notes.collect({|a_note, index| [ a_note, note_freqs.at(index) ] }).flatten );
  22.  
  23.     all_notes_with_freqs.at("C 1").postln;
  24.     all_notes_with_freqs.at("Gis 4").postln;
  25. )
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement