Created
January 7, 2016 02:33
-
-
Save kindohm/76e9cf6579614d1139c4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- eval the functions below first, then you can do this: | |
midiInstrument $ (|+| note "45") $ mel m9 5 "0*8" | |
-- above, plays the first 5 notes of a m9 arpeggio, over a pattern of eighth notes, | |
-- starting at MIDI note #45 | |
-- the "mel" function below relies on a "scramble" function which I don't | |
-- really like. I'm not good enough at haskell to know to how pick | |
-- random values out of the scale/arpeggio. | |
let remPos num den = if x<0 then x+den else x where x = rem num den | |
scaleElt scale n = fromIntegral . (scale !!) $ fromIntegral $ remPos n (fromIntegral $ length scale) | |
scaleOctave scale n = (12 *) . fromIntegral . floor . ((fromIntegral n) /) $ fromIntegral $ length scale | |
sc s n = scaleOctave s n + scaleElt s n | |
ionian = [0,2,4,5,7,9,11] | |
aeolian = [0,2,3,5,7,8,10] | |
locrian = [0,1,3,5,6,8,10] | |
phryg = [0,1,3,5,7,8,10] | |
lydian = [0,2,4,6,7,9,11] | |
enig = [0,1,3,5,6,8,10,11] | |
minor = [0,3,7] | |
major = [0,4,7] | |
_9 = [0,4,7,10,14] | |
ninesus4 = [0,5,7,10,14] | |
add9 = [0,4,7,14] | |
madd9 = [0,3,7,14] | |
maj9 = [0,4,7,11,14] | |
m9 = [0,3,7,10,14] | |
sus2 = [0,2,7] | |
sus4 = [0,5,7] | |
_7 = [0,4,7,10] | |
m7 = [0,3,7,10] | |
eleven = [0,4,7,10,14,17] | |
_11 = [0,4,7,10,14,17] | |
m11 = [0,3,7,10,14,17] | |
_13 = [0,4,7,10,14,21] | |
m13 = [0,3,7,10,14,21] | |
mpent = [0, 3, 5, 7, 10, 12] | |
pent = [0, 2, 4, 7, 9, 12] | |
runUpOneOctave = run $ length ionian | |
runUpTwoOctaves = run $ 2 * length ionian | |
runUpThreeOctaves = run $ 3 * length ionian | |
runUpAndDown = append runUpTwoOctaves $ (+1) <$> rev runUpTwoOctaves | |
scramble p = within (0.25, 0.5) (0.25 <~) $ within (0.5,1) (1.25 ~>) $ within (0, 0.5) (0.5 ~>) $ within (0.25, 0.75) (0.75 <~) $ p | |
mel' scale runSize f cycles p = note (preplace(1,cycles) p (f $ sc scale <$> run runSize)) | |
melOld scale runSize p = note (preplace(1,1) p (sc scale <$> run runSize)) | |
mel scale runSize p = mel' scale runSize (scramble) 4 p | |
arpup scale x = note (sc scale <$> run x) | |
arpdown scale x = note (rev $ sc scale <$> run x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment