packages feed

midi 0.1.5.1 → 0.1.5.2

raw patch · 3 files changed

+120/−8 lines, 3 filesdep ~basedep ~event-listdep ~non-negative

Dependency ranges changed: base, event-list, non-negative

Files

+ Makefile view
@@ -0,0 +1,2 @@+ghci:+	ghci -i:src -Wall test/Main.hs
midi.cabal view
@@ -1,5 +1,5 @@ Name:             midi-Version:          0.1.5.1+Version:          0.1.5.2 License:          GPL License-File:     LICENSE Author:           Henning Thielemann <haskell@henning-thielemann.de>@@ -13,11 +13,14 @@    The package contains definition of realtime and file MIDI messages,    reading and writing MIDI files.    It contains no sending and receiving of MIDI messages.-   Cf. alsa-midi, jack-midi and hmidi packages.-   For music composition with MIDI output, see Haskore.-Tested-With:      GHC==6.4.1 && ==6.8.2+   Cf. @alsa-seq@, @PortMidi@, @alsa@, @alsa-midi@ and @hmidi@ packages.+   For music composition with MIDI output, see @haskore@.+Tested-With:      GHC==6.4.1, GHC==6.8.2, GHC==6.10.4 Cabal-Version:    >=1.6 Build-Type:       Simple+Extra-Source-Files:+  Makefile+  src/Sound/MIDI/Example/Tomatosalad.hs Source-Repository head   type:     darcs   location: http://code.haskell.org/~thielema/midi/@@ -25,7 +28,7 @@ Source-Repository this   type:     darcs   location: http://code.haskell.org/~thielema/midi/-  tag:      0.1.5+  tag:      0.1.5.2  Flag splitBase   description: Choose the new smaller, split-up base package.@@ -36,8 +39,8 @@  Library   Build-Depends:-    event-list >=0.0.9 && < 0.1,-    non-negative>=0.0.1 && <0.1,+    event-list >=0.0.9 && < 0.2,+    non-negative>=0.0.1 && <0.2,     explicit-exception >=0.1 && <0.2,     bytestring >=0.9.0.1 && <0.10,     binary >=0.4.2 && <0.6,@@ -47,7 +50,7 @@   If flag(splitBase)     Build-Depends:       random >=1 && <2,-      base >= 2 && <6+      base >= 2 && <5   Else     Build-Depends:       base >= 1.0 && < 2
+ src/Sound/MIDI/Example/Tomatosalad.hs view
@@ -0,0 +1,107 @@+{-+The famous song, that is named "Tomatensalat" in German.+-}+module Main where++import qualified Sound.MIDI.File      as MidiFile+import qualified Sound.MIDI.File.Save as Save++import Sound.MIDI.File (ElapsedTime, )++import qualified Sound.MIDI.File.Event.Meta as MetaEvent+import qualified Sound.MIDI.File.Event      as Event++import qualified Sound.MIDI.Message.Channel       as ChannelMsg+import qualified Sound.MIDI.Message.Channel.Voice as VoiceMsg++-- import qualified Sound.MIDI.Parser.Report as Report++import qualified Data.EventList.Relative.TimeMixed as EventListTM+import qualified Data.EventList.Relative.BodyTime  as EventListBT+import qualified Data.EventList.Relative.MixedTime as EventListMT+import qualified Data.EventList.Relative.TimeBody  as EventList+-- import Data.EventList.Relative.MixedBody ((/.), (./), )++import qualified Data.ByteString.Lazy as B++-- import qualified Numeric.NonNegative.Wrapper as NonNeg++-- import Data.Tuple.HT (mapSnd, )++++g0,c1,d1,e1,f1,g1,a1 :: ElapsedTime -> (VoiceMsg.Pitch, ElapsedTime)+[g0,c1,d1,e1,f1,g1,a1] =+   map (\p t -> (VoiceMsg.toPitch (p-12), t))+      [55,60,62,64,65,67,69]++melody :: [(VoiceMsg.Pitch, ElapsedTime)]+melody =+   g0 3 :+   c1 1 :+   c1 1 :+   c1 1 :+   e1 1 :+   d1 1 :+   c1 1 :+   d1 1 :+   g0 1 :+   g0 1 :+   g0 3 :+   c1 1 :+   c1 1 :+   c1 1 :+   e1 1 :+   d1 1 :+   c1 1 :+   g1 3 :+   e1 3 :+   f1 1 :+   f1 1 :+   f1 1 :+   a1 1 :+   g1 1 :+   f1 1 :+   e1 1 :+   e1 1 :+   e1 1 :+   g1 1 :+   f1 1 :+   e1 1 :+   d1 1 :+   d1 1 :+   d1 1 :+   f1 1 :+   e1 1 :+   d1 1 :+   c1 3 :+   []++++song :: Int -> MidiFile.T+song pn =+   let chan = ChannelMsg.toChannel 0+       vel = VoiceMsg.toVelocity VoiceMsg.normalVelocity+       event =+          Event.MIDIEvent .+          ChannelMsg.Cons chan .+          ChannelMsg.Voice+   in  MidiFile.Cons MidiFile.Parallel (MidiFile.Ticks 4)+          [EventList.cons 0+              (Event.MetaEvent $ MetaEvent.SetTempo 1500000) $+           EventListTM.switchTimeR const $+           EventListMT.consTime 0 $+           EventListBT.fromPairList $+           concatMap (\(pgm, (n,t)) ->+              [(event $ VoiceMsg.ProgramChange pgm, 0),+               (event $ VoiceMsg.NoteOn  n vel, t),+               (event $ VoiceMsg.NoteOff n vel, 0)]) $+           zip (cycle $ map VoiceMsg.toProgram [pn..(pn+4)]) $+           concat (replicate 5 melody)]++main :: IO ()+main =+   B.writeFile "tomatosalad.mid" (Save.toByteString (song  8)) >>+   B.writeFile "hal.mid"         (Save.toByteString (song 16)) >>+   B.writeFile "graphtheory.mid" (Save.toByteString (song 24))