hamusic 0.1 → 0.1.1
raw patch · 4 files changed
+128/−2 lines, 4 files
Files
- hamusic.cabal +3/−1
- src/Music/Analysis/Interface.lhs +72/−0
- src/Music/Analysis/MusicXML2Haskore.lhs +0/−1
- src/Script.dtd +53/−0
hamusic.cabal view
@@ -1,6 +1,6 @@ ------------------------------------------------------------------------------- name: hamusic -version: 0.1 +version: 0.1.1 author: Samuel Silva <silva.samuel@alumni.uminho.pt> maintainer: Samuel Silva <silva.samuel@alumni.uminho.pt> copyright: Copyright (c) 2008 Samuel Silva @@ -23,6 +23,7 @@ README TODO src/Makefile + src/Script.dtd doc/Tutorial-hamusic.lt.pdf script/haskellPP.pl @@ -69,6 +70,7 @@ Music.Analysis.MusicXML2Haskore Music.Analysis.MusicXML2ABC Music.Analysis.Chord + Music.Analysis.Interface Music.Analysis.Script Script
+ src/Music/Analysis/Interface.lhs view
@@ -0,0 +1,72 @@+\begin{code} +-- | +-- Maintainer : silva.samuel@alumni.uminho.pt +-- Stability : experimental +-- Portability: portable +-- This module implements interface between Haskell representation and file +-- representation +module Music.Analysis.Interface where +import Music.Analysis.PF (mapL, concatL, (><), split, p1, p2) +import Music.Analysis.Base (Number) +import Music.Analysis.Abstract.Settings (Settings, getNumber) +import Music.Analysis.Abstract.Motive (Motive, toMotive, fromMotive) +import Music.Analysis.Abstract.Rhythm (RhythmNode, durationNode) +import Data.List (sum, (++)) +import Data.Bool (Bool(..), otherwise) +import Data.Maybe (maybe) +import Data.Ord (Ord(..)) +import Data.Tuple (uncurry) +import Data.Function ((.), id) +import Data.Char (String) +import Prelude (Num(..)) +\end{code} + +This class define architecture to implements interfaces. +\begin{code} +-- * Interface +-- | makes generic interface +class Interface a where + -- | reads interface + input :: String -> a + -- | prints interface + output :: a -> String +\end{code} + +Measure computing are defined to output this information that is ignored on our +model. +\begin{code} +-- * Build/Consume Measures +-- | destroy measures +catMeasures :: Motive [a] -> Motive a +catMeasures = + toMotive . + (id >< concatL) . + fromMotive +-- | build measures +uncatMeasures :: Measure a => Motive a -> Motive [a] +uncatMeasures = + toMotive . + split p1 (uncurry (aux1 [])) . + fromMotive + where + aux1 :: Measure a => [a] -> Settings -> [a] -> [[a]] + aux1 acc _ [] = [acc] + aux1 acc s (h:t) | aux2 s acc h = aux1 (acc++[h]) s t + | otherwise = acc : aux1 [h] s t + aux2 :: Measure a => Settings -> [a] -> a -> Bool + aux2 s acc h = + (maybe 4 id . getNumber "CompassDown") s >= + (sum (mapL nodeDuration acc)) + nodeDuration h +-- | Measure class. +class Measure a where + nodeDuration :: a -> Number -- ^ computes node's duration +instance Measure RhythmNode where + nodeDuration = durationNode +instance Measure (a, RhythmNode) where + nodeDuration = nodeDuration . p2 +instance Measure ((a,RhythmNode), b) where + nodeDuration = nodeDuration . p2 . p1 +instance Measure (((a, RhythmNode), b), c) where + nodeDuration = nodeDuration . p2 . p1 . p1 +\end{code} +
src/Music/Analysis/MusicXML2Haskore.lhs view
@@ -20,7 +20,6 @@ --import Music.Analysis.Zip (VoiceZipNode) --import Music.Analysis.Voices (MultiVoiceNode) --import Music.Analysis.Instruments (MultiInstrumentNode, settings) -import Music.Analysis.Interface () --import Haskore (Music(..), Pitch, Dur, PitchClass) --import Haskore.Basics (Music(..), Pitch, Dur, PitchClass(..)) --import Haskore.Performance ()
+ src/Script.dtd view
@@ -0,0 +1,53 @@+<!DOCTYPE script SYSTEM "Script.dtd" [ + + <!-- + This is my DTD to Abstract Music Combinators/Commands + --> + + <!ELEMENT script (action*)> + <!ATTLIST script + author CDATA #IMPLIED + date CDATA #IMPLIED + description CDATA #IMPLIED> + + <!ELEMENT action ((filter | reification | stat | + parttime | timepart | haskore | midi)*)> + <!ATTLIST action + input CDATA #REQUIRED + output CDATA #IMPLIED + warnings (yes | no) #IMPLIED> + + <!-- use stat instead --> + <!-- + <!ELEMENT length EMPTY> + <!ATTLIST length + select (part | measure ) #REQUIRED + mode (simple | map | concat) #IMPLIED> + --> + + <!ELEMENT filter EMPTY> + <!ATTLIST filter + select (note | note-grace | note-cue | note-normal) #REQUIRED + mode (yes | no) #IMPLIED> + + <!ELEMENT reification EMPTY> + <!ATTLIST reification + value (1 | 2 | 3 | 4 | 5) #REQUIRED> + + <!ELEMENT stat (count*)> + <!ATTLIST stat + verbose (yes | no) #IMPLIED> + + <!ELEMENT count EMPTY> + <!ATTLIST count + select (part | measure | music-data | note | + note-grace | note-cue | note-normal) #REQUIRED> + + <!ELEMENT parttime EMPTY> + <!ELEMENT timepart EMPTY> + <!ELEMENT haskore EMPTY> + + <!ELEMENT midi EMPTY> + <!ATTLIST midi + play (yes | no) #IMPLIED> +]>