module Harmonic.Interface.Tidal.Orchestra (
Voice(..), VoiceLines(..), voiceLines, vlGet, voiceOct,
Rig(..), noArt,
flute, oboe, clarinet, bassoon,
horn, trombone, basstrom,
harp, timpani,
violin1, violin2, viola, cello, contrabass,
flute', oboe', clarinet', bassoon',
horn', trombone', basstrom',
harp', timpani',
violin1', violin2', viola', cello', contrabass',
bassdrum, tamtam,
pizz, spicc, marc, legg, arco,
Instrument, divisi, divisi2, divisi3,
clip, voiceBase, voiceTier,
) where
import Sound.Tidal.Context hiding (voice, clip)
import qualified Data.Map.Strict as Map
import Harmonic.Interface.Tidal.Bridge (VoiceFunction, arrange, overlapF)
import Harmonic.Interface.Tidal.Form (IK)
import Harmonic.Interface.Tidal.Instruments (ch, vel)
import Harmonic.Interface.Tidal.Score (dyn, degrees)
import Harmonic.Interface.Tidal.Form (Kinetics(..))
import Harmonic.Interface.Tidal.Utils (oct)
import Harmonic.Rules.Types.ProgressionContext (Layer(..))
data Voice
= Soprano | Alto | Tenor | Bass
| Soprano8va | Alto8va | Tenor8va | Bass8va
| Soprano15va | Alto15va | Tenor15va | Bass15va
| Soprano8vb | Alto8vb | Tenor8vb | Bass8vb
| Soprano15vb | Alto15vb | Tenor15vb | Bass15vb
| Soprano' | Alto' | Tenor' | Bass'
| Soprano8va' | Alto8va' | Tenor8va' | Bass8va'
| Soprano15va' | Alto15va' | Tenor15va' | Bass15va'
| Soprano8vb' | Alto8vb' | Tenor8vb' | Bass8vb'
| Soprano15vb' | Alto15vb' | Tenor15vb' | Bass15vb'
| Soprano'' | Alto'' | Tenor'' | Bass''
| Soprano8va'' | Alto8va'' | Tenor8va'' | Bass8va''
| Soprano15va'' | Alto15va'' | Tenor15va'' | Bass15va''
| Soprano8vb'' | Alto8vb'' | Tenor8vb'' | Bass8vb''
| Soprano15vb'' | Alto15vb'' | Tenor15vb'' | Bass15vb''
deriving (Int -> Voice -> ShowS
[Voice] -> ShowS
Voice -> String
(Int -> Voice -> ShowS)
-> (Voice -> String) -> ([Voice] -> ShowS) -> Show Voice
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Voice -> ShowS
showsPrec :: Int -> Voice -> ShowS
$cshow :: Voice -> String
show :: Voice -> String
$cshowList :: [Voice] -> ShowS
showList :: [Voice] -> ShowS
Show, Voice -> Voice -> Bool
(Voice -> Voice -> Bool) -> (Voice -> Voice -> Bool) -> Eq Voice
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Voice -> Voice -> Bool
== :: Voice -> Voice -> Bool
$c/= :: Voice -> Voice -> Bool
/= :: Voice -> Voice -> Bool
Eq, Eq Voice
Eq Voice =>
(Voice -> Voice -> Ordering)
-> (Voice -> Voice -> Bool)
-> (Voice -> Voice -> Bool)
-> (Voice -> Voice -> Bool)
-> (Voice -> Voice -> Bool)
-> (Voice -> Voice -> Voice)
-> (Voice -> Voice -> Voice)
-> Ord Voice
Voice -> Voice -> Bool
Voice -> Voice -> Ordering
Voice -> Voice -> Voice
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Voice -> Voice -> Ordering
compare :: Voice -> Voice -> Ordering
$c< :: Voice -> Voice -> Bool
< :: Voice -> Voice -> Bool
$c<= :: Voice -> Voice -> Bool
<= :: Voice -> Voice -> Bool
$c> :: Voice -> Voice -> Bool
> :: Voice -> Voice -> Bool
$c>= :: Voice -> Voice -> Bool
>= :: Voice -> Voice -> Bool
$cmax :: Voice -> Voice -> Voice
max :: Voice -> Voice -> Voice
$cmin :: Voice -> Voice -> Voice
min :: Voice -> Voice -> Voice
Ord, Int -> Voice
Voice -> Int
Voice -> [Voice]
Voice -> Voice
Voice -> Voice -> [Voice]
Voice -> Voice -> Voice -> [Voice]
(Voice -> Voice)
-> (Voice -> Voice)
-> (Int -> Voice)
-> (Voice -> Int)
-> (Voice -> [Voice])
-> (Voice -> Voice -> [Voice])
-> (Voice -> Voice -> [Voice])
-> (Voice -> Voice -> Voice -> [Voice])
-> Enum Voice
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: Voice -> Voice
succ :: Voice -> Voice
$cpred :: Voice -> Voice
pred :: Voice -> Voice
$ctoEnum :: Int -> Voice
toEnum :: Int -> Voice
$cfromEnum :: Voice -> Int
fromEnum :: Voice -> Int
$cenumFrom :: Voice -> [Voice]
enumFrom :: Voice -> [Voice]
$cenumFromThen :: Voice -> Voice -> [Voice]
enumFromThen :: Voice -> Voice -> [Voice]
$cenumFromTo :: Voice -> Voice -> [Voice]
enumFromTo :: Voice -> Voice -> [Voice]
$cenumFromThenTo :: Voice -> Voice -> Voice -> [Voice]
enumFromThenTo :: Voice -> Voice -> Voice -> [Voice]
Enum, Voice
Voice -> Voice -> Bounded Voice
forall a. a -> a -> Bounded a
$cminBound :: Voice
minBound :: Voice
$cmaxBound :: Voice
maxBound :: Voice
Bounded)
data VoiceLines = VoiceLines
{ VoiceLines -> Pattern Int
_vl :: Pattern Int
, VoiceLines -> Pattern Int
soprano :: Pattern Int
, VoiceLines -> Pattern Int
alto :: Pattern Int
, VoiceLines -> Pattern Int
tenor :: Pattern Int
, VoiceLines -> Pattern Int
bass :: Pattern Int
, VoiceLines -> Pattern Int
soprano' :: Pattern Int
, VoiceLines -> Pattern Int
alto' :: Pattern Int
, VoiceLines -> Pattern Int
tenor' :: Pattern Int
, VoiceLines -> Pattern Int
bass' :: Pattern Int
, VoiceLines -> Pattern Int
soprano'':: Pattern Int
, VoiceLines -> Pattern Int
alto'' :: Pattern Int
, VoiceLines -> Pattern Int
tenor'' :: Pattern Int
, VoiceLines -> Pattern Int
bass'' :: Pattern Int
}
voiceLines :: VoiceLines
voiceLines :: VoiceLines
voiceLines = VoiceLines
{ _vl :: Pattern Int
_vl = Pattern Int
"~"
, soprano :: Pattern Int
soprano = Pattern Int
"3"
, alto :: Pattern Int
alto = Pattern Int
"1"
, tenor :: Pattern Int
tenor = Pattern Int
"2"
, bass :: Pattern Int
bass = Pattern Int
"0"
, soprano' :: Pattern Int
soprano' = Pattern Int
"4"
, alto' :: Pattern Int
alto' = Pattern Int
"2"
, tenor' :: Pattern Int
tenor' = Pattern Int
"3"
, bass' :: Pattern Int
bass' = Pattern Int
"1"
, soprano'' :: Pattern Int
soprano''= Pattern Int
"5"
, alto'' :: Pattern Int
alto'' = Pattern Int
"3"
, tenor'' :: Pattern Int
tenor'' = Pattern Int
"4"
, bass'' :: Pattern Int
bass'' = Pattern Int
"2"
}
voiceBase :: Voice -> Voice
voiceBase :: Voice -> Voice
voiceBase = Int -> Voice
forall a. Enum a => Int -> a
toEnum (Int -> Voice) -> (Voice -> Int) -> Voice -> Voice
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int -> Int -> Int
forall a. Integral a => a -> a -> a
`mod` Int
20) (Int -> Int) -> (Voice -> Int) -> Voice -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Voice -> Int
forall a. Enum a => a -> Int
fromEnum
voiceTier :: Voice -> Int
voiceTier :: Voice -> Int
voiceTier = (Int -> Int -> Int
forall a. Integral a => a -> a -> a
`div` Int
20) (Int -> Int) -> (Voice -> Int) -> Voice -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Voice -> Int
forall a. Enum a => a -> Int
fromEnum
data VLetter = LtrS | LtrA | LtrT | LtrB
voiceLetter :: Voice -> VLetter
voiceLetter :: Voice -> VLetter
voiceLetter Voice
v = case Voice -> Voice
voiceBase Voice
v of
Voice
Soprano -> VLetter
LtrS; Voice
Soprano8va -> VLetter
LtrS; Voice
Soprano15va -> VLetter
LtrS; Voice
Soprano8vb -> VLetter
LtrS; Voice
Soprano15vb -> VLetter
LtrS
Voice
Alto -> VLetter
LtrA; Voice
Alto8va -> VLetter
LtrA; Voice
Alto15va -> VLetter
LtrA; Voice
Alto8vb -> VLetter
LtrA; Voice
Alto15vb -> VLetter
LtrA
Voice
Tenor -> VLetter
LtrT; Voice
Tenor8va -> VLetter
LtrT; Voice
Tenor15va -> VLetter
LtrT; Voice
Tenor8vb -> VLetter
LtrT; Voice
Tenor15vb -> VLetter
LtrT
Voice
_ -> VLetter
LtrB
vlGet :: Voice -> VoiceLines -> Pattern Int
vlGet :: Voice -> VoiceLines -> Pattern Int
vlGet Voice
v = case (Voice -> VLetter
voiceLetter Voice
v, Voice -> Int
voiceTier Voice
v) of
(VLetter
LtrS, Int
0) -> VoiceLines -> Pattern Int
soprano; (VLetter
LtrS, Int
1) -> VoiceLines -> Pattern Int
soprano'; (VLetter
LtrS, Int
_) -> VoiceLines -> Pattern Int
soprano''
(VLetter
LtrA, Int
0) -> VoiceLines -> Pattern Int
alto; (VLetter
LtrA, Int
1) -> VoiceLines -> Pattern Int
alto'; (VLetter
LtrA, Int
_) -> VoiceLines -> Pattern Int
alto''
(VLetter
LtrT, Int
0) -> VoiceLines -> Pattern Int
tenor; (VLetter
LtrT, Int
1) -> VoiceLines -> Pattern Int
tenor'; (VLetter
LtrT, Int
_) -> VoiceLines -> Pattern Int
tenor''
(VLetter
LtrB, Int
0) -> VoiceLines -> Pattern Int
bass; (VLetter
LtrB, Int
1) -> VoiceLines -> Pattern Int
bass'; (VLetter
LtrB, Int
_) -> VoiceLines -> Pattern Int
bass''
voiceOct :: Voice -> Int
voiceOct :: Voice -> Int
voiceOct Voice
v = case Voice -> Voice
voiceBase Voice
v of
Voice
Soprano -> Int
0; Voice
Alto -> Int
0; Voice
Tenor -> Int
0; Voice
Bass -> Int
0
Voice
Soprano8va -> Int
1; Voice
Alto8va -> Int
1; Voice
Tenor8va -> Int
1; Voice
Bass8va -> Int
1
Voice
Soprano15va -> Int
2; Voice
Alto15va -> Int
2; Voice
Tenor15va -> Int
2; Voice
Bass15va -> Int
2
Voice
Soprano8vb -> (-Int
1); Voice
Alto8vb -> (-Int
1); Voice
Tenor8vb -> (-Int
1); Voice
Bass8vb -> (-Int
1)
Voice
_ -> (-Int
2)
clip :: (Int, Int) -> ControlPattern -> ControlPattern
clip :: (Int, Int) -> ControlPattern -> ControlPattern
clip (Int
lo, Int
hi) = (ValueMap -> Bool) -> ControlPattern -> ControlPattern
forall a. (a -> Bool) -> Pattern a -> Pattern a
filterValues (\ValueMap
vm ->
case String -> ValueMap -> Maybe Value
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup String
"note" ValueMap
vm of
Just (VF Double
v) -> Double
v Double -> Double -> Bool
forall a. Ord a => a -> a -> Bool
>= Int -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
lo Bool -> Bool -> Bool
&& Double
v Double -> Double -> Bool
forall a. Ord a => a -> a -> Bool
<= Int -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
hi
Just (VN Note
nt) -> let v :: Double
v = Note -> Double
unNote Note
nt in Double
v Double -> Double -> Bool
forall a. Ord a => a -> a -> Bool
>= Int -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
lo Bool -> Bool -> Bool
&& Double
v Double -> Double -> Bool
forall a. Ord a => a -> a -> Bool
<= Int -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
hi
Maybe Value
_ -> Bool
True)
data Rig = Rig
{ Rig -> String
rigName :: String
, Rig -> Int
rigFlute, Rig -> Int
rigOboe, Rig -> Int
rigClarinet, Rig -> Int
rigBassoon :: Int
, Rig -> Int
rigHorn, Rig -> Int
rigTrombone, Rig -> Int
rigBasstrom :: Int
, Rig -> Int
rigHarp, Rig -> Int
rigTimpani :: Int
, Rig -> Int
rigViolin1, Rig -> Int
rigViolin2, Rig -> Int
rigViola, Rig -> Int
rigCello, Rig -> Int
rigContrabass :: Int
, Rig -> Maybe (Int, Int)
rigBassdrum, Rig -> Maybe (Int, Int)
rigTamtam :: Maybe (Int, Int)
, Rig -> ControlPattern
rigPizz, Rig -> ControlPattern
rigSpicc, Rig -> ControlPattern
rigMarc, Rig -> ControlPattern
rigLegg, Rig -> ControlPattern
rigArco :: ControlPattern
, Rig -> Int
rigContinuo :: Int
, Rig -> [ControlPattern]
rigSetup :: [ControlPattern]
}
noArt :: ControlPattern
noArt :: ControlPattern
noArt = ValueMap -> ControlPattern
forall a. a -> Pattern a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ValueMap
forall k a. Map k a
Map.empty
instrument :: (Int, Int) -> Int -> Instrument
instrument :: (Int, Int) -> Int -> Instrument
instrument (Int, Int)
bounds Int
chan Layer
lyr (Double, Double)
ki IK
k VoiceLines
vl VoiceFunction
vf Voice
v =
(Int, Int) -> ControlPattern -> ControlPattern
clip (Int, Int)
bounds (ControlPattern -> ControlPattern)
-> ControlPattern -> ControlPattern
forall a b. (a -> b) -> a -> b
$ (Double, Double)
-> IK
-> (Int, Int)
-> Layer
-> VoiceFunction
-> (Progression -> Progression)
-> [Pattern Int]
-> ControlPattern
arrange (Double, Double)
ki IK
k (-Int
9,Int
9) Layer
lyr VoiceFunction
vf (Int -> Progression -> Progression
overlapF Int
0) [Voice -> VoiceLines -> Pattern Int
vlGet Voice
v VoiceLines
vl] ControlPattern -> ControlPattern -> ControlPattern
forall b. Unionable b => Pattern b -> Pattern b -> Pattern b
# Int -> ControlPattern
ch Int
chan ControlPattern -> ControlPattern -> ControlPattern
forall a. Num a => Pattern a -> Pattern a -> Pattern a
|+ Pattern Note -> ControlPattern
oct (Int -> Pattern Note
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Voice -> Int
voiceOct Voice
v))
instrument' :: (Int, Int) -> Int -> Layer -> Pattern Int -> Pattern String -> IK -> Pattern Int -> ControlPattern
instrument' :: (Int, Int)
-> Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
instrument' (Int, Int)
bounds Int
chan Layer
lyr Pattern Int
octv Pattern String
dy IK
k Pattern Int
degs =
(Int, Int) -> ControlPattern -> ControlPattern
clip (Int, Int)
bounds (ControlPattern -> ControlPattern)
-> ControlPattern -> ControlPattern
forall a b. (a -> b) -> a -> b
$ Pattern Note -> ControlPattern
note (Layer -> Pattern Int -> IK -> Pattern Int -> Pattern Note
degrees Layer
lyr Pattern Int
octv IK
k Pattern Int
degs) ControlPattern -> ControlPattern -> ControlPattern
forall b. Unionable b => Pattern b -> Pattern b -> Pattern b
# Int -> ControlPattern
ch Int
chan ControlPattern -> ControlPattern -> ControlPattern
forall b. Unionable b => Pattern b -> Pattern b -> Pattern b
# Pattern Double -> ControlPattern
vel (Pattern String -> Pattern Double
dyn Pattern String
dy) ControlPattern -> ControlPattern -> ControlPattern
forall a. Num a => Pattern a -> Pattern a -> Pattern a
|* Pattern Double -> ControlPattern
vel (Kinetics -> Pattern Double
kDynamic (IK -> Kinetics
forall a b. (a, b) -> a
fst IK
k))
flute, oboe, clarinet, bassoon, horn, trombone, basstrom, harp, timpani,
violin1, violin2, viola, cello, contrabass :: Rig -> Instrument
flute :: Rig -> Instrument
flute = (Int, Int) -> Int -> Instrument
instrument (Int, Int)
fluteRange (Int -> Instrument) -> (Rig -> Int) -> Rig -> Instrument
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rig -> Int
rigFlute
oboe :: Rig -> Instrument
oboe = (Int, Int) -> Int -> Instrument
instrument (Int, Int)
oboeRange (Int -> Instrument) -> (Rig -> Int) -> Rig -> Instrument
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rig -> Int
rigOboe
clarinet :: Rig -> Instrument
clarinet = (Int, Int) -> Int -> Instrument
instrument (Int, Int)
clarinetRange (Int -> Instrument) -> (Rig -> Int) -> Rig -> Instrument
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rig -> Int
rigClarinet
bassoon :: Rig -> Instrument
bassoon = (Int, Int) -> Int -> Instrument
instrument (Int, Int)
bassoonRange (Int -> Instrument) -> (Rig -> Int) -> Rig -> Instrument
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rig -> Int
rigBassoon
horn :: Rig -> Instrument
horn = (Int, Int) -> Int -> Instrument
instrument (Int, Int)
hornRange (Int -> Instrument) -> (Rig -> Int) -> Rig -> Instrument
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rig -> Int
rigHorn
trombone :: Rig -> Instrument
trombone = (Int, Int) -> Int -> Instrument
instrument (Int, Int)
tromboneRange (Int -> Instrument) -> (Rig -> Int) -> Rig -> Instrument
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rig -> Int
rigTrombone
basstrom :: Rig -> Instrument
basstrom = (Int, Int) -> Int -> Instrument
instrument (Int, Int)
basstromRange (Int -> Instrument) -> (Rig -> Int) -> Rig -> Instrument
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rig -> Int
rigBasstrom
harp :: Rig -> Instrument
harp = (Int, Int) -> Int -> Instrument
instrument (Int, Int)
harpRange (Int -> Instrument) -> (Rig -> Int) -> Rig -> Instrument
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rig -> Int
rigHarp
timpani :: Rig -> Instrument
timpani = (Int, Int) -> Int -> Instrument
instrument (Int, Int)
timpaniRange (Int -> Instrument) -> (Rig -> Int) -> Rig -> Instrument
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rig -> Int
rigTimpani
violin1 :: Rig -> Instrument
violin1 = (Int, Int) -> Int -> Instrument
instrument (Int, Int)
violin1Range (Int -> Instrument) -> (Rig -> Int) -> Rig -> Instrument
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rig -> Int
rigViolin1
violin2 :: Rig -> Instrument
violin2 = (Int, Int) -> Int -> Instrument
instrument (Int, Int)
violin2Range (Int -> Instrument) -> (Rig -> Int) -> Rig -> Instrument
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rig -> Int
rigViolin2
viola :: Rig -> Instrument
viola = (Int, Int) -> Int -> Instrument
instrument (Int, Int)
violaRange (Int -> Instrument) -> (Rig -> Int) -> Rig -> Instrument
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rig -> Int
rigViola
cello :: Rig -> Instrument
cello = (Int, Int) -> Int -> Instrument
instrument (Int, Int)
celloRange (Int -> Instrument) -> (Rig -> Int) -> Rig -> Instrument
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rig -> Int
rigCello
contrabass :: Rig -> Instrument
contrabass = (Int, Int) -> Int -> Instrument
instrument (Int, Int)
contrabassRange (Int -> Instrument) -> (Rig -> Int) -> Rig -> Instrument
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rig -> Int
rigContrabass
flute', oboe', clarinet', bassoon', horn', trombone', basstrom', harp', timpani',
violin1', violin2', viola', cello', contrabass'
:: Rig -> Layer -> Pattern Int -> Pattern String -> IK -> Pattern Int -> ControlPattern
flute' :: Rig
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
flute' = (Int, Int)
-> Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
instrument' (Int, Int)
fluteRange (Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern)
-> (Rig -> Int)
-> Rig
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rig -> Int
rigFlute
oboe' :: Rig
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
oboe' = (Int, Int)
-> Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
instrument' (Int, Int)
oboeRange (Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern)
-> (Rig -> Int)
-> Rig
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rig -> Int
rigOboe
clarinet' :: Rig
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
clarinet' = (Int, Int)
-> Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
instrument' (Int, Int)
clarinetRange (Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern)
-> (Rig -> Int)
-> Rig
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rig -> Int
rigClarinet
bassoon' :: Rig
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
bassoon' = (Int, Int)
-> Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
instrument' (Int, Int)
bassoonRange (Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern)
-> (Rig -> Int)
-> Rig
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rig -> Int
rigBassoon
horn' :: Rig
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
horn' = (Int, Int)
-> Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
instrument' (Int, Int)
hornRange (Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern)
-> (Rig -> Int)
-> Rig
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rig -> Int
rigHorn
trombone' :: Rig
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
trombone' = (Int, Int)
-> Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
instrument' (Int, Int)
tromboneRange (Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern)
-> (Rig -> Int)
-> Rig
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rig -> Int
rigTrombone
basstrom' :: Rig
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
basstrom' = (Int, Int)
-> Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
instrument' (Int, Int)
basstromRange (Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern)
-> (Rig -> Int)
-> Rig
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rig -> Int
rigBasstrom
harp' :: Rig
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
harp' = (Int, Int)
-> Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
instrument' (Int, Int)
harpRange (Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern)
-> (Rig -> Int)
-> Rig
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rig -> Int
rigHarp
timpani' :: Rig
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
timpani' = (Int, Int)
-> Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
instrument' (Int, Int)
timpaniRange (Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern)
-> (Rig -> Int)
-> Rig
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rig -> Int
rigTimpani
violin1' :: Rig
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
violin1' = (Int, Int)
-> Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
instrument' (Int, Int)
violin1Range (Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern)
-> (Rig -> Int)
-> Rig
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rig -> Int
rigViolin1
violin2' :: Rig
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
violin2' = (Int, Int)
-> Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
instrument' (Int, Int)
violin2Range (Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern)
-> (Rig -> Int)
-> Rig
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rig -> Int
rigViolin2
viola' :: Rig
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
viola' = (Int, Int)
-> Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
instrument' (Int, Int)
violaRange (Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern)
-> (Rig -> Int)
-> Rig
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rig -> Int
rigViola
cello' :: Rig
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
cello' = (Int, Int)
-> Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
instrument' (Int, Int)
celloRange (Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern)
-> (Rig -> Int)
-> Rig
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rig -> Int
rigCello
contrabass' :: Rig
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
contrabass' = (Int, Int)
-> Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
instrument' (Int, Int)
contrabassRange (Int
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern)
-> (Rig -> Int)
-> Rig
-> Layer
-> Pattern Int
-> Pattern String
-> IK
-> Pattern Int
-> ControlPattern
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rig -> Int
rigContrabass
fluteRange, oboeRange, clarinetRange, bassoonRange, hornRange, tromboneRange, basstromRange, harpRange, timpaniRange, violin1Range, violin2Range, violaRange, celloRange, contrabassRange :: (Int, Int)
fluteRange :: (Int, Int)
fluteRange = (-Int
12, Int
26)
oboeRange :: (Int, Int)
oboeRange = ( -Int
2, Int
33)
clarinetRange :: (Int, Int)
clarinetRange = (-Int
22, Int
34)
bassoonRange :: (Int, Int)
bassoonRange = (-Int
28, Int
15)
hornRange :: (Int, Int)
hornRange = (-Int
29, Int
17)
tromboneRange :: (Int, Int)
tromboneRange = (-Int
28, Int
17)
basstromRange :: (Int, Int)
basstromRange = (-Int
39, -Int
5)
harpRange :: (Int, Int)
harpRange = (-Int
29, Int
42)
timpaniRange :: (Int, Int)
timpaniRange = (-Int
22, Int
0)
violin1Range :: (Int, Int)
violin1Range = ( -Int
5, Int
45)
violin2Range :: (Int, Int)
violin2Range = ( -Int
5, Int
45)
violaRange :: (Int, Int)
violaRange = (-Int
12, Int
28)
celloRange :: (Int, Int)
celloRange = (-Int
24, Int
24)
contrabassRange :: (Int, Int)
contrabassRange = (-Int
36, Int
0)
hit :: Double -> Maybe (Int, Int) -> Pattern Bool -> ControlPattern
hit :: Double -> Maybe (Int, Int) -> Pattern Bool -> ControlPattern
hit Double
_ Maybe (Int, Int)
Nothing Pattern Bool
_ = ControlPattern
forall a. Pattern a
silence
hit Double
secs (Just (Int
nt, Int
c)) Pattern Bool
pat = Pattern Bool -> ControlPattern -> ControlPattern
forall a. Pattern Bool -> Pattern a -> Pattern a
struct Pattern Bool
pat (ControlPattern -> ControlPattern)
-> ControlPattern -> ControlPattern
forall a b. (a -> b) -> a -> b
$ Pattern Note -> ControlPattern
midinote (Int -> Pattern Note
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
nt) ControlPattern -> ControlPattern -> ControlPattern
forall b. Unionable b => Pattern b -> Pattern b -> Pattern b
# Int -> ControlPattern
ch Int
c ControlPattern -> ControlPattern -> ControlPattern
forall b. Unionable b => Pattern b -> Pattern b -> Pattern b
# Pattern Double -> ControlPattern
sustain (Double -> Pattern Double
forall a. a -> Pattern a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Double
secs)
bassdrum, tamtam :: Rig -> Pattern Bool -> ControlPattern
bassdrum :: Rig -> Pattern Bool -> ControlPattern
bassdrum Rig
r = Double -> Maybe (Int, Int) -> Pattern Bool -> ControlPattern
hit Double
0.05 (Rig -> Maybe (Int, Int)
rigBassdrum Rig
r)
tamtam :: Rig -> Pattern Bool -> ControlPattern
tamtam Rig
r = Double -> Maybe (Int, Int) -> Pattern Bool -> ControlPattern
hit Double
0.5 (Rig -> Maybe (Int, Int)
rigTamtam Rig
r)
pizz, spicc, marc, legg, arco :: Rig -> ControlPattern
pizz :: Rig -> ControlPattern
pizz = Rig -> ControlPattern
rigPizz
spicc :: Rig -> ControlPattern
spicc = Rig -> ControlPattern
rigSpicc
marc :: Rig -> ControlPattern
marc = Rig -> ControlPattern
rigMarc
legg :: Rig -> ControlPattern
legg = Rig -> ControlPattern
rigLegg
arco :: Rig -> ControlPattern
arco = Rig -> ControlPattern
rigArco
type Instrument =
Layer -> (Double, Double) -> IK -> VoiceLines -> VoiceFunction -> Voice -> ControlPattern
divisi :: Int -> Instrument -> Instrument
divisi :: Int -> Instrument -> Instrument
divisi Int
nDesks Instrument
instr Layer
lyr (Double, Double)
rng IK
k VoiceLines
vl VoiceFunction
vf Voice
v
| Int
nDesks Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
1 = Instrument
instr Layer
lyr (Double, Double)
rng IK
k VoiceLines
vl VoiceFunction
vf Voice
v
| Bool
otherwise =
[ControlPattern] -> ControlPattern
forall a. [Pattern a] -> Pattern a
stack [ Instrument
instr Layer
lyr (Double, Double)
rng IK
k VoiceLines
vl VoiceFunction
vf (Int -> Voice -> Voice
forall {a} {p}. (Enum a, Enum p) => Int -> p -> a
primeN Int
i Voice
v) | Int
i <- [Int
0 .. Int
nDesks Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1] ]
ControlPattern -> ControlPattern -> ControlPattern
forall a. Num a => Pattern a -> Pattern a -> Pattern a
|* Pattern Double -> ControlPattern
vel (Pattern Double
1 Pattern Double -> Pattern Double -> Pattern Double
forall a. Fractional a => a -> a -> a
/ Pattern Double -> Pattern Double
forall a. Floating a => a -> a
sqrt (Int -> Pattern Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
nDesks))
where
primeN :: Int -> p -> a
primeN Int
i p
v' =
let idx :: Int
idx = p -> Int
forall a. Enum a => a -> Int
fromEnum p
v'
base :: Int
base = Int
idx Int -> Int -> Int
forall a. Integral a => a -> a -> a
`mod` Int
20
tier :: Int
tier = Int -> Int -> Int
forall a. Ord a => a -> a -> a
min Int
2 (Int
idx Int -> Int -> Int
forall a. Integral a => a -> a -> a
`div` Int
20 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
i)
in Int -> a
forall a. Enum a => Int -> a
toEnum (Int
base Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
20 Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
tier)
divisi2, divisi3 :: ControlPattern
divisi2 :: ControlPattern
divisi2 = Pattern Double -> ControlPattern
vel (Pattern Double
1 Pattern Double -> Pattern Double -> Pattern Double
forall a. Fractional a => a -> a -> a
/ Pattern Double -> Pattern Double
forall a. Floating a => a -> a
sqrt Pattern Double
2)
divisi3 :: ControlPattern
divisi3 = Pattern Double -> ControlPattern
vel (Pattern Double
1 Pattern Double -> Pattern Double -> Pattern Double
forall a. Fractional a => a -> a -> a
/ Pattern Double -> Pattern Double
forall a. Floating a => a -> a
sqrt Pattern Double
3)