Advertisement
Guest User

Untitled

a guest
May 26th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 3.08 KB | None | 0 0
  1. ; Overtone Set Functions
  2.  
  3. ; gets overtone keynums of keynum- hard-coded to make partials {5 7 11 13 15 21}
  4. function Overtone_Chord_Step_1(fundamentalKeyNum)                                 ;DEF1 works
  5. with alteredNotes = {}, harmonic_List = {5 7 11 13 15 21}, Harm = 0
  6. loop
  7. for h in harmonic_List
  8. set Harm = last(keynum(harmonics(1, h, hertz(fundamentalKeyNum))))
  9. set alteredNotes &= Harm
  10. finally alteredNotes
  11. end
  12. end
  13.  
  14. Overtone_Chord_Step_1(1)
  15.  
  16. ; gets mtpcs
  17. function Get_microtonal_pcs_of_alt_notes(KeyNum_Of_Fundamental)                ;DEF2 works now
  18. with re-tuned_Notes = Overtone_Chord_Step_1(KeyNum_Of_Fundamental),           ;usingDEF1
  19. FinalChord = {}, mctpcs = {},
  20. c = 0, CentVals = 0
  21. loop for n in re-tuned_Notes
  22. set c = n - floor(n)
  23. set CentVals = c
  24. set mctpcs &= c + pitch-class(floor(n))
  25. finally mctpcs
  26. end
  27. end
  28.  
  29. Get_microtonal_pcs_of_alt_notes(60)
  30.  
  31. function Round_List(list_to_round)                           ;DEF2.5
  32. loop
  33. with roundlist = {}
  34. for n in list_to_round
  35. set roundlist &= round(n)
  36. finally roundlist
  37. end
  38. end
  39.  
  40.  
  41. function Overtone_Chord_step_2(noteSet, fundamentalKeynum)                 ;DEF3
  42. with comparitorSet = Get_microtonal_pcs_of_alt_notes(fundamentalKeynum),  ;usingDEF(2[1])
  43.      roundedComparitor = Round_List(comparitorSet),                      ;using;DEF2.5
  44.      NoteSetPcs = pitch-class(noteSet),
  45.      finalList = {}, newCompr = {}
  46.   if (length(list-intersection( roundedComparitor, NoteSetPcs)) = 0)
  47.     set finalList = noteSet
  48.   else
  49.     loop
  50.       with hit = 0
  51.       for indexCount from 0
  52.       for n in NoteSetPcs
  53.       set newCompr &= n
  54.       set hit = length(list-intersection(roundedComparitor, newCompr))
  55.       if (hit < 1)
  56.         set finalList &= noteSet[indexCount]
  57.       else
  58.         loop for microtonalNote in comparitorSet
  59.           if (round(microtonalNote) = n )
  60.             set finalList &= microtonalNote
  61.             set newCompr = {}
  62.           end
  63.         end
  64.       end
  65.       finally finalList
  66.     end
  67.   end
  68. end
  69.  
  70. Overtone_Chord_step_2({60 61 62 63 64 65 66 67 68 69 70 71 72}, 60)
  71.  
  72.  
  73.  
  74. function octaveMultipliers(noteSet)                                     ;DEF4
  75.   loop
  76.     with octaveMulti = {}
  77.     for n in noteSet
  78.     set octaveMulti &= floor(n / 12.0)
  79.     finally octaveMulti
  80.   end
  81. end
  82.  
  83. octaveMultipliers({ 60 61 62 63})
  84.  
  85. function OvertoneChord(noteSet, fundamentalKeynum)            ;DEF5
  86.   loop
  87.     with properRegister = {},
  88.          improperRegister = Overtone_Chord_step_2(noteSet, fundamentalKeynum), ;usingDEF(3[2.5,2,1])
  89.          getOctaveMultiplier = octaveMultipliers(noteSet)                       ;usingDEF4
  90.     for om in getOctaveMultiplier
  91.     for n in improperRegister
  92.     if (n != floor(n))
  93.       set properRegister &= n + 12 * om
  94.     else
  95.       set properRegister &= n
  96.     end
  97.     finally properRegister
  98.   end
  99. end
  100.  
  101. ;testing      
  102. OvertoneChord({60 61 62 63 64 65 66 67 68 69 70 71 72}, 0)
  103. OvertoneChord({60 61 62 63 64 65 66 67 68 69 70 71 72}, 1)
  104. OvertoneChord({60 61 62 63 64 65 66 67 68 69 70 71 72}, 2)
  105. OvertoneChord({60 61 62 63 64 65 66 67 68 69 70 71 72}, 3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement