packages feed

music-preludes 1.7.2 → 1.8

raw patch · 20 files changed

+278/−352 lines, 20 filesdep −reverse-applydep ~lensdep ~lilyponddep ~music-articulationPVP ok

version bump matches the API change (PVP)

Dependencies removed: reverse-apply

Dependency ranges changed: lens, lilypond, music-articulation, music-dynamics, music-dynamics-literal, music-parts, music-pitch, music-pitch-literal, music-score, musicxml2

API changes (from Hackage documentation)

Files

examples/analysis.hs view
@@ -1,14 +1,13 @@  {-# LANGUAGE TypeFamilies #-} -import Music.Prelude.Standard+import Music.Prelude import qualified Music.Score as Score-import Data.Colour.Names (red)  markIf :: (HasColor a, HasPitches' a, Score.Pitch a ~ Behavior Pitch) => (Interval -> Bool) -> Score a -> Score a markIf p     = mapIf (\x -> p $ withOrigin c $ unb $ x ^?! pitches) mark   where-    mark         = color red+    mark         = colorRed     mapIf p f    = uncurry mplus . over _1 f . mpartition p     unb          = (! 0)     withOrigin x = (.-. x)@@ -17,7 +16,7 @@ markImperfect = text "Imperfect consonances" . markIf isImperfectConsonance markDiss      = text "Dissonances"           . markIf isDissonance --- Try different subjects+-- Try different subjects: subject = [c..c'] -- subject = [c,d,cs,gs,f,fs,g_,gs_,fs,f,e,ds',c] 
+ examples/analysis_durations.hs view
@@ -0,0 +1,27 @@+-- -fno-warn-typed-holes+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE ConstraintKinds #-}+{-# LANGUAGE FlexibleContexts #-}++import Music.Prelude hiding ((</>))+import qualified Music.Score+import qualified System.Process+import qualified Data.List++music = asScore $ times 55 (stretch (1/8) c) |> times 28 (stretch (1/16) d)++main = do+  -- open music+  putStrLn $ "Durations: "+  mapM_ (\(x,y) -> putStrLn ("  " ++ show x ++ " \t" ++ show y)) $ (scoreDurations music)+++voiceDurations :: Voice a -> [Duration]+voiceDurations = view durationsV++countDurationsV :: Voice a -> [(Duration, Int)]+countDurationsV = fmap (\xs -> (head xs, length xs)) . Data.List.group . Data.List.sort . voiceDurations++scoreDurations :: (HasPart' a, Ord (Music.Score.Part a)) => Score a -> [(Duration, Int)]+scoreDurations = countDurationsV . view phrases
examples/annotatations.hs view
@@ -4,10 +4,7 @@    Written by Carlo Nucera -}-module Annotations where--import Music.Prelude.Basic hiding  (Interval)-import Music.Pitch (Interval)+import Music.Prelude  main :: IO () main = openLilypond . showAnnotations' ""@@ -20,16 +17,13 @@ subjectDiff :: [Interval] subjectDiff = zipWith (.-.) (tail subject) subject --- reify :: Pitch -> Score BasicNote--- reify = (`up` c) . pure . (.-. c)--intervalAnnotations :: [Interval] -> (Score BasicNote -> Score BasicNote)+intervalAnnotations :: [Interval] -> (Score StandardNote -> Score StandardNote) intervalAnnotations = foldr1 (.) . zipWith notate (map spanify [0..])   where     spanify :: Duration -> Span     spanify t = (0 .+^ t) >-> 1 -    notate :: Span -> Interval -> (Score BasicNote -> Score BasicNote)+    notate :: Span -> Interval -> (Score StandardNote -> Score StandardNote)     notate s n = annotateSpan s ("       " ++ showIntervalName n)       showIntervalName = filter (/= '_') . show
examples/bartok.hs view
@@ -1,18 +1,12 @@ -{-# LANGUAGE OverloadedStrings #-}- import Music.Prelude.Basic -{-  -  Bela Bartok: Wandering (excerpt)-  From Mikrokosmos, vol. III--  Inspired by the Abjad transcription--}--main = openLilypond music--+-- |+-- Bela Bartok: Wandering (excerpt)+-- From Mikrokosmos, vol. III+-- +-- Inspired by the Abjad transcription+--   music :: Score BasicNote music = let@@ -35,4 +29,4 @@    in meta $ compress 8 $ left </> down _P8 right -+main = openLilypond music
examples/canon.hs view
@@ -1,12 +1,8 @@ -{-# LANGUAGE OverloadedStrings #-}--{--  This simple example shows how to construct a 4-part canon.--}-module Main where--import Music.Prelude.Basic+-- |+-- Simple canon on a familiar subject.+-- +import Music.Prelude  frere = mempty   |> times 2 (scat [c,d,e,c]^/4) 
− examples/canon.music
@@ -1,15 +0,0 @@--let-  frere = mempty-    |> times 2 (scat [c,d,e,c]^/4) -    |> times 2 (scat [e,f,g^*2]^/4) -    |> times 2 (scat [g,a,g,f,scat [e,c]^*2]^/8)-    |> times 2 (scat [c,g_,c^*2]^/4)--  frere2 = delay 2 frere </> frere-  frere4 = delay 4 frere2 </> frere2--  info = title "Frere Jaques" . composer "Trad." . tempo (metronome (1/4) 120)--in info $ asScore $ frere4-
examples/chords.hs view
@@ -1,11 +1,5 @@ -{-# LANGUAGE NoMonomorphismRestriction #-}- import Music.Prelude--import Control.Concurrent.Async-import Control.Applicative-import System.Process (system)  -- kStrum = 0.005 kStrum = 0
examples/duo.hs view
@@ -1,25 +1,10 @@ -{-# LANGUAGE -    OverloadedStrings, -    ConstraintKinds,-    NoMonomorphismRestriction #-}- module Main where -import Control.Lens hiding ((|>))-import System.Process (runCommand) import Music.Prelude.Basic -main = do-    -- writeMidi "test.mid" music-    -- writeXml "test.xml" $ music^/4-    -- openXml music-    openLilypond $ asScore music-    -- playMidiIO "Graphic MIDI" $ music^/10- toLydian :: Score BasicNote -> Score BasicNote toLydian = pitches' %~ (\p -> if ((p::Behavior Pitch) ! 0) == ((c::Behavior Pitch) ! 0) then cs else p)--- TODO cleanup  subj1 = (^/2) $     (legato.accent) (b_ |> c) |> (legato.accent) (c |> b_^*2)@@ -36,7 +21,5 @@  music = asScore $ clef CClef $ level pp $ compress 2 $ part1 |> toLydian part2 --- (|>) :: Score a -> Score a -> Score a--- a |> b = mcatMaybes $ fmap Just a ||> fmap Just b--+main :: IO ()+main = open music
examples/dynamics.hs view
@@ -6,9 +6,6 @@ -- A simple subject subj  = times 20 $ scat [c,d,e,f]^/8 |> scat [g,fs]^/2 -unb :: Behavior a -> a-unb = (! 0)- -- The  music = id   $ title "Dynamics"@@ -17,4 +14,4 @@     rcat $ map (\phase -> level (stretch phase sine*fff) $ subj) [5.0,5.2..6.0] -main  = open $ asScore $ music+main = open music
+ examples/fugue1.hs view
@@ -0,0 +1,95 @@+-- -fno-warn-typed-holes+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}++import Music.Prelude hiding ((</>))+import qualified Music.Score+import qualified System.Process++++-- mn'  = "(a (b c)) (> gs (a b)) ((c e d c) %-1d) %-2d"+dot x y = stretchTo 1 (stretch 3 x <> stretch 1 y)+mn'' = (stretchTo 1.mconcat)[(stretchTo 1.mconcat)[a,(stretchTo 1.mconcat)[b,c]],(stretchTo 1.mconcat)[gs `dot` (stretchTo 1.mconcat)[a,b]]]++++mn = scat [a^*2,b,c',d',gs^*2,scat[a,b]^/2]^/4+cn = (\x -> x |> downDiatonic c 1 x |> (downDiatonic c 2 x)) $ scat [c',e',d',c']^/8+s  = mn |> cn+m  = set (pitches'.mapped.rel c._alteration) 0 $ upDiatonic c 2 s+++-- Expositions+ex1 = delay 2 (up _P5 s)   </> s+ex2 = delay 2 (down _P4 s) </> s+ex3 = delay 2 (up _P5 m)   </> m+ex4 = delay 2 (down _P4 m) </> m+ex5 = delay 2 (up _P5 s)   </> s++-- Interludes+il = times 8 $ scat [c',e',d',c']^/8++music = scat [ex1,il,ex2,il,ex3,il,ex4,ex5]+++main = open $ over parts' id $ asScore music++++++++++++++++++++++++-- |+-- Parallel composition preserving parts.+--+-- If the part of a and b differ, compose using (<>).+-- If the part of a and b equal, the contents of a and b are placed in section 1 2 and section 2 2 respectively.+--+-- TODO handle subsections correctly. I.e. the parts must not only be distinct but noone must be a superset of the other+-- (what's the terminology for this?).+-- For an unexpected result, see+-- >>> foldl (</>) mempty [c,d,e,f,g]+--+(<<>) = (</>)++(</>) :: (HasParts' a, Semigroup a, Music.Score.Part a ~ Part) => a -> a -> a+a </> b = set parts' pa a <> set parts' pb b+  where+    (pa, pb) = case (a^?parts, b^?parts) of+        (Nothing,Nothing) -> (mempty, mempty)+        (Just x, Nothing) -> (x, mempty)+        (Nothing,Just x)  -> (mempty, x)+        (Just x, Just y)  -> if x /= y then (x, y) else divide2 x+    divide2 a = let [x,y] = divide 2 a in (x,y)+    +    -- if equal+    -- [pa',pb'] = divide 2 pa++upDiatonic o n = over (pitches'.mapped) (upDiatonicP o n)+downDiatonic o n = over (pitches'.mapped) (downDiatonicP o n)++rel o = iso (\p -> p .-. o) (\v -> o .+^ v)+++openAudio x = do+    void $ writeMidi "test.mid" $ x+    void $ System.Process.system "timidity -Ow test.mid"+    void $ System.Process.system "open -a Audacity test.wav"
examples/mozart.hs view
@@ -1,16 +1,6 @@ -{-# LANGUAGE-    OverloadedStrings,-    TypeFamilies,-    FlexibleContexts,-    NoMonomorphismRestriction #-}--module Main where+import Music.Prelude import qualified Music.Score-import Music.Prelude.Standard hiding (open, play, openAndPlay)-import Control.Concurrent.Async-import Control.Applicative-import System.Process (system)  {-         W.A. Mozart: Ave Verum (excerpt)@@ -178,23 +168,7 @@ --         g p x = clef (case defaultClef p of { 0 -> GClef; 1 -> CClef; 2 -> FClef } ) x fixClefs = id -concurrently_ :: IO a -> IO b -> IO ()-concurrently_ = concurrentlyWith (\x y -> ())--concurrentlyWith :: (a -> b -> c) -> IO a -> IO b -> IO c-concurrentlyWith f x y = uncurry f <$> x `concurrently` y- palindrome x = rev x |> x --- main :: IO () main = open score'---- play, open, openAndPlay :: Score Note -> IO ()   -tempo_ = 80-play x = return () -- openAudio $ stretch ((60*(8/3))/tempo_) $ fixClefs $ x-open x = openLilypond' LyScoreFormat $ fixClefs $ x-openAndPlay x = play x `concurrently_` open x-
+ examples/note_voice_score.hs view
@@ -0,0 +1,32 @@++>>> [(1,c)^.note]^.voice++>>> [(1<->2,c)^.event]^.score++>>> [(1,c)^.note]^.voice <> [(2,d)^.note]^.voice+[(1,0)^.note,(2,2)^.note]^.voice++-- Compose two voices using relative time, resulting score uses absolute time+>>> renderAlignedVoice $ aligned 0 0 $ [(1,c)^.note]^.voice <> [(2,d)^.note]^.voice+[(0 <-> 1,0)^.event,(1 <-> 3,2)^.event]^.score++-- Align end rather than beginning+>>> renderAlignedVoice $ aligned 0 1 $ [(1,c)^.note]^.voice <> [(2,d)^.note]^.voice+[(-3 <-> -2,0)^.event,(-2 <-> 0,2)^.event]^.score++-- Align midpoint to 5+>>> renderAlignedVoice $ aligned 5 0.5 $ [(1,c)^.note]^.voice <> [(3,d)^.note]^.voice+[(3 <-> 4,0)^.event,(4 <-> 7,2)^.event]^.score++>>> :t \xs ys -> (^.voiceFromPairs) $ zip xs ys+[Duration] -> [a] -> Voice a++>>> :t \xs ys -> (^.voice) $ zipWith (curry $ (^.note)) xs ys+[Duration] -> [a] -> Voice a+++>>> renderAlignedVoice $ aligned 0 0.5 $ [(1,x)^.note | x <- [0..21]]^.voice++[(-11 <-> -10,0)^.event,(-10 <-> -9,1)^.event,(-9 <-> -8,2)^.event,(-8 <-> -7,3)^.event,(-7 <-> -6,4)^.event,(-6 <-> -5,5)^.event,(-5 <-> -4,6)^.event,(-4 <-> -3,7)^.event,(-3 <-> -2,8)^.event,(-2 <-> -1,9)^.event,(-1 <-> 0,10)^.event,(0 <-> 1,11)^.event,(1 <-> 2,12)^.event,(2 <-> 3,13)^.event,(3 <-> 4,14)^.event,(4 <-> 5,15)^.event,(5 <-> 6,16)^.event,(6 <-> 7,17)^.event,(7 <-> 8,18)^.event,(8 <-> 9,19)^.event,(9 <-> 10,20)^.event,(10 <-> 11,21)^.event]^.score++  :: (Num t, Enum t) => Score t
examples/part.hs view
@@ -1,38 +1,20 @@  {-# LANGUAGE OverloadedStrings, TypeFamilies #-} -import Music.Prelude.Standard hiding (open, play, openAndPlay)+-- |+-- Arvo Pärt: Cantus in Memory of Benjamin Britten (1977)+-- +-- Inspired by the Abjad transcription+--+import Music.Prelude hiding (open) import qualified Music.Score as Score-import Control.Concurrent.Async-import Control.Applicative-import System.Process (system) -{-    -    Arvo Pärt: Cantus in Memory of Benjamin Britten (1977)--    Inspired by the Abjad transcription--}---main :: IO ()-main = open music--ensemble :: [Part]-ensemble = [solo tubularBells] <> (divide 2 (tutti violin)) <> [tutti viola] <> [tutti cello] <> [tutti doubleBass]--music :: Score StandardNote-music = meta $ stretch (3/2) $ {-before 60-} (mempty <> bell <> delay 6 strings)-    where-        meta = id-          . title "Cantus in Memoriam Benjamin Britten" -          . composer "Arvo Pärt" -          . timeSignature (6/4) -          . tempo (metronome (1/4) 120)- withTintin :: (HasPitches' a, Score.Pitch a ~ Behavior Pitch) => Pitch -> Score a -> Score a withTintin p x = x <> tintin p x --- | Given the melody voice return the tintinnabular voice.+-- | +-- Given the a melody voice return the tintinnabuli voice.+--  tintin :: (HasPitches' a, Score.Pitch a ~ Behavior Pitch) => Pitch -> Score a -> Score a tintin tonic = pitches . mapped %~ relative tonic tintin' @@ -45,88 +27,52 @@ tintin' :: Interval -> Interval tintin' melInterval      | isNegative melInterval = error "tintin: Negative interval"-    | otherwise = last $ takeWhile (< melInterval) $ tintinStandardNotes+    | otherwise              = last $ takeWhile (< melInterval) $ tintinStandardNotes     where         tintinStandardNotes = concat $ iterate (fmap (+ _P8)) minorTriad         minorTriad = [_P1,m3,_P5] --bell :: Score StandardNote-bell = let-    cue :: Score (Maybe StandardNote)-    cue = stretchTo 1 (rest |> a) -    in parts' .~ (ensemble !! 0) $ text "l.v." $ mcatMaybes $ times 40 $ scat [times 3 $ scat [cue,rest], rest^*2]--strings :: Score StandardNote-strings = strings_vln1 <> strings_vln2 <> strings_vla <> strings_vc <> strings_db--strings_vln1 = clef GClef $ parts' .~ (ensemble !! 1) $ up (_P8^*1)   $ strings_cue-strings_vln2 = clef GClef $ parts' .~ (ensemble !! 2) $ up (_P8^*0)   $ stretch 2 strings_cue-strings_vla  = clef CClef $ parts' .~ (ensemble !! 3) $ down (_P8^*1) $ stretch 4 strings_cue-strings_vc   = clef FClef $ parts' .~ (ensemble !! 4) $ down (_P8^*2) $ stretch 8 strings_cue-strings_db   = clef FClef $ parts' .~ (ensemble !! 5) $ down (_P8^*3) $ stretch 16 strings_cue-strings_cue = delay (1/2) $ withTintin (down (_P8^*4) $ asPitch a) $ mainSubject- fallingScale :: [Score StandardNote] fallingScale = [a',g'..a_]  fallingScaleSect :: Int -> [Score StandardNote] fallingScaleSect n = {-fmap (annotate (show n)) $-} take n $ fallingScale -mainSubject :: Score StandardNote-mainSubject = stretch (1/6) $ asScore $ scat $ mapEvensOdds (accent . (^*2)) id $ concatMap fallingScaleSect [1..30]----------------- mapEvensOdds :: (a -> b) -> (a -> b) -> [a] -> [b]-mapEvensOdds f g xs = let-    evens = fmap (xs !!) [0,2..]-    odds = fmap (xs !!) [1,3..]-    merge xs ys = concatMap (\(x,y) -> [x,y]) $ xs `zip` ys-    in take (length xs) $ map f evens `merge` map g odds---openAudacity :: Score StandardNote -> IO ()    -openAudacity x = do-    void $ writeMidi "test.mid" $ x-    void $ system "timidity -Ow test.mid"-    void $ system "open -a Audacity test.wav"+mapEvensOdds f g [] = []+mapEvensOdds f g [a] = [f a]+mapEvensOdds f g (a : b : cs) = f a : g b : mapEvensOdds f g cs -openAudio :: Score StandardNote -> IO ()    -openAudio x = do-    -- void $ writeMidi "test.mid" $ x-    void $ system "timidity -Ow test.mid"-    void $ system "open -a Audacity test.wav"+mainSubject :: Score StandardNote+mainSubject = stretch (1/6) $ asScore $ scat $ mapEvensOdds (accent . (^*2)) id $ concatMap fallingScaleSect [1..30] -fixClefs :: Score StandardNote -> Score StandardNote-fixClefs = id--- fixClefs = pcat . fmap (uncurry g) . extractParts'---     where---         g p x = clef (case defaultClef p of { 0 -> GClef; 1 -> CClef; 2 -> FClef } ) x+bell :: Score StandardNote+bell = let+    cue :: Score (Maybe StandardNote)+    cue = stretchTo 1 (rest |> a) +    in parts' .~ solo tubularBells $ text "l.v." $ mcatMaybes $ times 40 $ scat [times 3 $ scat [cue,rest], rest^*2] -concurrently_ :: IO a -> IO b -> IO ()-concurrently_ = concurrentlyWith (\x y -> ())+strings :: Score StandardNote+strings = pcat [+    parts' .~ violins1     $ up (_P8^*1)   $ stringPart,+    parts' .~ violins2     $ up (_P8^*0)   $ stretch 2 stringPart,+    parts' .~ violas       $ down (_P8^*1) $ stretch 4 stringPart,+    parts' .~ cellos       $ down (_P8^*2) $ stretch 8 stringPart,+    parts' .~ doubleBasses $ down (_P8^*3) $ stretch 16 stringPart]+    where+        stringPart = delay (1/2) $ withTintin (down (_P8^*4) $ asPitch a) $ mainSubject -concurrentlyWith :: (a -> b -> c) -> IO a -> IO b -> IO c-concurrentlyWith f x y = uncurry f <$> x `concurrently` y+music :: Score StandardNote+music = meta $ stretch (3/2) $ {-before 60-} (mempty <> bell <> delay 6 strings)+    where+        meta = id+          . title "Cantus in Memoriam Benjamin Britten" +          . composer "Arvo Pärt" +          . timeSignature (6/4) +          . tempo (metronome (1/4) 120) -play, open, openAndPlay :: Score StandardNote -> IO ()   -tempo_ = 120-play x = openAudio $ stretch ((60*4)/tempo_) $ fixClefs $ x-open x = openLilypond' LyScoreFormat $ fixClefs $ x-openAndPlay x = play x `concurrently_` open x+openBook :: Score StandardNote -> IO ()+openBook = openLilypond' LyScoreFormat +main :: IO ()+main = openBook music
examples/scheme.hs view
@@ -10,8 +10,8 @@    See Scheme files in example directory -  Requires husk-scheme to be in your path-    http://hackage.haskell.org/package/husk-scheme+  Requires husk-scheme, to install say:+    cabal install husk-scheme -} module Main where @@ -25,12 +25,10 @@ import           Language.Scheme.Parser import           Language.Scheme.Types import           Language.Scheme.Variables-import           Music.Prelude+import           Music.Prelude hiding (Number) import qualified Music.Score               as Score import qualified System.Environment import qualified System.IO.Unsafe--- import qualified Data.List--- import System.Random  type LispScore = Score Integer instance AffineSpace Integer where@@ -129,8 +127,11 @@ class HasLisp a where   _unlisp :: Prism' LispVal a +_lisp :: HasLisp a => Getter a LispVal+_lisp = re _unlisp+ toLisp :: HasLisp a => a -> LispVal-toLisp = view (re _unlisp)+toLisp = view _lisp  fromLisp :: HasLisp a => LispVal -> Maybe a fromLisp = preview _unlisp@@ -184,8 +185,11 @@ instance HasLisp a => HasLisp (Score.Note a) where   _unlisp = _unlisp . note +instance HasLisp a => HasLisp (Score.Event a) where+  _unlisp = _unlisp . event+ instance HasLisp a => HasLisp (Score a) where-  _unlisp = _unlisp . from unsafeNotes+  _unlisp = _unlisp . from unsafeEvents  instance (HasLisp a, HasLisp b) => HasLisp (a, b) where   _unlisp = prism' (lcons . over _1 toLisp . over _2 toLisp) $ \xs -> case xs of
examples/test1.scm view
@@ -1,21 +1,22 @@  ; Usage: ;   runhaskell examples/scheme.hs examples/test1.scm-(let ((first-note-duration  5/3) -      (second-note-duration 2)-      (foo (lambda (x) x)))+(let ((*base-note-value* 4) +      (identity-function (lambda (x) x)))    ;(rcat   ;  (move 3 (times 4 (scat (stretch first-note-duration c) (stretch second-note-duration d) eb)))   ;  (move 3 (times 4 (scat (stretch first-note-duration c) (stretch second-note-duration d) eb))))   -  (stretch 4+  (stretch *base-note-value*   (scat-    (compress 8 (scat c d e))+    (compress 8 (apply scat (list c d e)))     (compress 16 (scat c d e))     (compress 8 (scat c d e f))-    (up (foo m3)+    (up (identity-function m3)       (scat         (compress 16 (scat c d e))         (compress 8 (scat c d e))         (compress 16 (scat c d e (pcat f bb))))))))++
examples/trio.hs view
@@ -1,135 +1,56 @@ -{-# LANGUAGE-    OverloadedStrings,-    NoMonomorphismRestriction #-}--import Music.Prelude.Standard hiding (open, play, openAndPlay)-import Control.Concurrent.Async-import Control.Applicative-import System.Process (system)--{-    -    String quartet-    Hommage a Henrik Strindberg--}---- Ensemble-[vl1, vl2]  = divide 2 (tutti violin)-vla         = tutti viola-vc          = tutti cello+import Music.Prelude -music :: Score StandardNote-music = mainCanon2+-- |+-- String quartet+--+-- Hommage a Henrik Strindberg+--  tremCanon = compress 4 $-    (delay 124 $ set parts' vl1 $ subjs^*1)+    (delay 124 $ set parts' violins1 $ subjs^*1)         <>-    (delay 120 $ set parts' vl2 $ subjs^*1)+    (delay 120 $ set parts' violins2 $ subjs^*1)         <>-    (delay 4 $ set parts' vla $ subjs^*2)+    (delay 4 $ set parts' violas $ subjs^*2)         <>-    (delay 0 $ set parts' vc  $ subjs^*2)+    (delay 0 $ set parts' cellos  $ subjs^*2)     where-        subjs = scat $ map (\n -> palindrome $ rev2 $ subj n) [1..40::Int]+        subjs = scat $ map (\n -> palindrome2 $ rev2 $ subj n) [1..40::Int]         subj n              | n < 8     = a_^*2  |> e^*1   |> a^*1             | n < 16    = a_^*2  |> e^*1   |> a^*1   |> e^*1   |> a^*1             | n < 24    = a_^*2  |> e^*0.5 |> a^*0.5 |> e^*0.5 |> a^*0.5             | otherwise = e^*0.5 |> a^*0.5     -mainCanon2 = palindrome mainCanon <> celloEntry+mainCanon2 = palindrome2 mainCanon <> celloEntry -celloEntry = set parts' vc e''^*(25*5/8)+celloEntry = set parts' cellos e''^*(25*5/8)  mainCanon = timeSignature (time 6 8) $ asScore $ -    (set parts' vl1 $ harmonic 2 $ times 50 $ legato $ accentLast $ +    (set parts' violins1 $ harmonic 2 $ times 50 $ legato $ accentLast $          octavesUp 2 $ scat [a_,e,a,cs',cs',a,e,a_]^/8)           <> -    (set parts' vl2 $ harmonic 2 $ times 50 $ legato $ accentLast $ +    (set parts' violins2 $ harmonic 2 $ times 50 $ legato $ accentLast $          octavesUp 2 $ scat [d,g,b,b,g,d]^/8)^*(3/2)          <> -    (set parts' vla $ harmonic 2 $ times 50 $ legato $ accentLast $ +    (set parts' violas $ harmonic 2 $ times 50 $ legato $ accentLast $          octavesUp 2 $ scat [a,d,a,a,d,a]^/8)^*(3*2/2)          <> -    set parts' vc a'^*(25*5/8)+    set parts' cellos a'^*(25*5/8)                                      -------------------------------mapEvensOdds :: (a -> b) -> (a -> b) -> [a] -> [b]-mapEvensOdds f g xs = let-    evens = fmap (xs !!) [0,2..]-    odds = fmap (xs !!) [1,3..]-    merge xs ys = concatMap (\(x,y) -> [x,y]) $ xs `zip` ys-    in take (length xs) $ map f evens `merge` map g odds---openAudacity :: Score StandardNote -> IO ()    -openAudacity x = do-    void $ writeMidi "test.mid" $ x-    void $ system "timidity -Ow test.mid"-    void $ system "open -a Audacity test.wav"--openAudio :: Score StandardNote -> IO ()    -openAudio x = do-    void $ writeMidi "test.mid" $ x-    void $ system "timidity -Ow test.mid"-    void $ system "open -a Audacity test.wav"--fixClefs :: Score StandardNote -> Score StandardNote-fixClefs = pcat . fmap (uncurry g) . extractPartsWithInfo-    where-        g p x = clef (case defaultClef p of { 0 -> GClef; 1 -> CClef; 2 -> FClef } ) x+music :: Score StandardNote+music = mainCanon2 -concurrently_ :: IO a -> IO b -> IO ()-concurrently_ = concurrentlyWith (\x y -> ())+openBook :: Score StandardNote -> IO ()+openBook = openLilypond' LyScoreFormat -concurrentlyWith :: (a -> b -> c) -> IO a -> IO b -> IO c-concurrentlyWith f x y = uncurry f <$> x `concurrently` y+main :: IO ()+main = openBook music --- palindrome x = rev2 x |> x -- TODO--- rev2 = rev rev2 = id----main :: IO ()-main = open music--play, open, openAndPlay :: Score StandardNote -> IO ()   -tempo_ = 130-play x = openAudio $ stretch ((60*(8/3))/tempo_) $ fixClefs $ x-open x = openLilypond' LyScoreFormat $ fixClefs $ x-openAndPlay x = play x `concurrently_` open x-+palindrome2 = id
examples/tuplet.hs view
@@ -3,37 +3,23 @@  module Main where -import Prelude-import System.Process (runCommand) import Music.Prelude.Basic -main = do-    -- writeMidi "test.mid" music-    -- writeXml "test.xml" $ music^/4-    -- openXml music-    openLilypond music-    -- playMidiIO "Graphic MIDI" $ music^/10----- infixr 7 //--- (//) = flip times--music :: Score BasicNote-music = {-fadeIn 1 $-} {-fadeOut 1 $-} rcat $ map test [1..5]- test 1  = group 5 g |> g^*3                   test 2  = group 3 fs |> fs^*3                   test 3  = group 3 f |> group 5 f |> group 3 f |> group 7 f test 4  = group 3 e |> group 5 e |> c |> group 7 e test 5  = ds |> group 5 ds |> ds |> group 7 ds -- all above ok-- test 8 = times 5 d^/5 |> times 3 d^/3 -- ok test 9 = times 4 cs^/5 |> cs^*(1/5+1/3)    -- not ok, needs to be bound from last quintuplet note  test 99 = group 5 c |> group 3 c |> c^*2 +group n = times n^/(fromIntegral n) +music :: Score BasicNote+music = {-fadeIn 1 $-} {-fadeOut 1 $-} rcat $ map test [1..5] -group n = times n^/(fromIntegral n)+main :: IO ()+main = open music
music-preludes.cabal view
@@ -1,6 +1,6 @@  name:                   music-preludes-version:                1.7.2+version:                1.8 author:                 Hans Hoglund maintainer:             Hans Hoglund license:                BSD3@@ -18,8 +18,7 @@  extra-source-files:     README.md,                         examples/*.hs,-                        examples/*.scm,-                        examples/*.music+                        examples/*.scm  source-repository head   type:                 git@@ -28,7 +27,7 @@ library     build-depends:      base                    >= 4 && < 5,                         aeson                   >= 0.7.0.6 && < 1,-                        lens                    >= 4.3.3 && < 4.4,+                        lens                    >= 4.6 && < 4.7,                         split,                         containers,                         vector-space            >= 0.8.7 && < 0.9,@@ -41,16 +40,15 @@                         semigroups              >= 0.13.0.1 && < 1,                         data-default,                         monadplus,-                        reverse-apply,-                        lilypond                == 1.7.2,-                        musicxml2               == 1.7.2,-                        music-score             == 1.7.2,-                        music-pitch             == 1.7.2,-                        music-dynamics          == 1.7.2,-                        music-articulation      == 1.7.2,-                        music-parts             == 1.7.2,-                        music-pitch-literal     == 1.7.2,-                        music-dynamics-literal  == 1.7.2,+                        lilypond                == 1.8,+                        musicxml2               == 1.8,+                        music-score             == 1.8,+                        music-pitch             == 1.8,+                        music-dynamics          == 1.8,+                        music-articulation      == 1.8,+                        music-parts             == 1.8,+                        music-pitch-literal     == 1.8,+                        music-dynamics-literal  == 1.8,                         -- For examples:                         async     if !os(windows)
src/Music/Prelude/Basic.hs view
@@ -39,12 +39,12 @@ import           Data.Default import           Data.Typeable -import           Music.Pitch             hiding (Fifths, Note)+import           Music.Pitch             hiding (Fifths) import qualified Music.Pitch import           Music.Dynamics import           Music.Articulation import           Music.Parts             hiding (Part)-import           Music.Score             hiding (Pitch, Dynamics, Articulation, Interval)+import           Music.Score             hiding (Clef(..), Pitch, Dynamics, Articulation, Interval)  import           Control.Lens.Operators  hiding ((<.>), (<|), (|>)) import           Control.Monad.Plus
src/Music/Prelude/Standard.hs view
@@ -40,7 +40,7 @@ import           Music.Dynamics import           Music.Articulation import           Music.Parts-import           Music.Score             hiding (Fifths, Interval, Note, Part, Pitch, Dynamics, Articulation)+import           Music.Score             hiding (Clef(..), Fifths, Interval, Part, Pitch, Dynamics, Articulation)  import           Music.Prelude.Instances ()