Last active
March 23, 2016 18:19
-
-
Save lvm/a8b3d392a87696656075 to your computer and use it in GitHub Desktop.
Tidal lazy helpers
This file contains 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
cps 1 | |
-- for `espeak` | |
import System.Cmd | |
-- lazy helpers | |
let wf0 n = within(0, n) | |
sw f = sometimes(wf0 0.5 f) | |
sw' d h f = sometimes(within (d, h) f) | |
nm p = note $ toMIDI p | |
--- | |
ch :: Int -> [Int] -> Pattern Int ; ch n chord = listToPat [ch + n | ch <- chord] | |
--- q $ note (cho 48 "1 [~ 1] 1 1 " [0, 3, 7, 5]) | |
cho n pat chord = preplace(1,1) pat $ listToPat [ch + n | ch <- chord] | |
--- q $ note (cho' 48 3 "1 [~ 1] 1 1 " [0, 3, 7, 5]) | |
cho' n off pat chord = cho (n+off) pat chord | |
--- q $ slowcho [47, 45, 42] "[1 !] 1 1 1" [0, 3, 0, 3] | |
slowcho nlist pat chord = slowcat[note (cho n pat chord) | n <- nlist] | |
--- q $ slowcho' [47, 45, 42] 3 "[1 !] 1 1 1" [0, 3, 0, 3] | |
slowcho' nlist off pat chord = slowcat[note (cho' n off pat chord) | n <- nlist] | |
-- q $ slowcat[note (cho 60 "1 1 1" (rotate i [0,3,7,10])) | i <- [0..3]] | |
rotate :: Int -> [a] -> [a] | |
rotate _ [] = [] | |
rotate n xs = zipWith const (drop n (cycle xs)) xs | |
-- q $ chrot [51, 48] "1 1 1 1" [0, 3, 5, 7] | |
chrot nlist pat chord = slowcat[slowcho nlist pat (rotate i chord) | i <- [0..((length chord)-1)]] | |
-- espeak: msg, voice, amp, pitch, speed | |
espeak' m v a p s = system $ "espeak -v " ++ v ++ " -a " ++ a ++ " -p " ++ p ++ " -s " ++ s ++ " \"" ++ m ++ "\"" | |
shespeak' m v a p s = system $ "espeak -v " ++ v ++ "+f1 -a " ++ a ++ " -p " ++ p ++ " -s " ++ s ++ " \"" ++ m ++ "\"" | |
whisper' m v a p s = system $ "espeak -v " ++ v ++ "+whisper -a " ++ a ++ " -p " ++ p ++ " -s " ++ s ++ " \"" ++ m ++ "\"" | |
croak' m v a p s = system $ "espeak -v " ++ v ++ "+croak -a " ++ a ++ " -p " ++ p ++ " -s " ++ s ++ " \"" ++ m ++ "\"" | |
espeak m = espeak' m "en" "25" "50" "160" | |
shespeak m = shespeak' m "en" "25" "50" "160" | |
whisper m = whisper' m "en" "25" "50" "160" | |
croak m = croak' m "en" "25" "50" "160" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment