packages feed

midi-alsa 0.1.2 → 0.1.3

raw patch · 2 files changed

+61/−10 lines, 2 filesdep ~midi

Dependency ranges changed: midi

Files

midi-alsa.cabal view
@@ -1,5 +1,5 @@ Name:             midi-alsa-Version:          0.1.2+Version:          0.1.3 License:          BSD3 License-File:     LICENSE Author:           Henning Thielemann <haskell@henning-thielemann.de>@@ -9,17 +9,24 @@ Build-Type:       Simple Synopsis:         Convert between datatypes of the midi and the alsa packages Description:-   MIDI is the Musical Instrument Digital Interface,-   ALSA is the Advanced Linux Sound Architecture.-   This package provides accessors to data structures-   of the ALSA sequencer interface-   via the more specific types from the @midi@ package.+  MIDI is the Musical Instrument Digital Interface,+  ALSA is the Advanced Linux Sound Architecture.+  This package provides accessors to data structures+  of the ALSA sequencer interface+  via the more specific types from the @midi@ package.+  The package also contains an orphan instance+  for the @alsa-seq:Event@ type of the @midi:Message.Class.Check@ class. Tested-With:      GHC==6.10.4 Cabal-Version:    >=1.6 Build-Type:       Simple+Source-Repository this+  Tag:         0.1.3+  Type:        darcs+  Location:    http://code.haskell.org/alsa/midi/+ Source-Repository head-  type:     darcs-  location: http://code.haskell.org/alsa/midi/+  Type:        darcs+  Location:    http://code.haskell.org/alsa/midi/  Flag splitBase   description: Choose the new smaller, split-up base package.@@ -30,7 +37,7 @@  Library   Build-Depends:-    midi >=0.1.5 && <0.2,+    midi >=0.1.7 && <0.2,     alsa-seq >=0.5 && <0.6,     data-accessor >=0.2.1 && <0.3,     utility-ht >=0.0.5 && <0.1
src/Sound/MIDI/ALSA/Check.hs view
@@ -1,17 +1,54 @@+{-+The instance Class.C Event.T is orphan.+I could put it in package 'midi' or 'alsa-seq'+but in both them it imposes a lot of new dependencies.+-}+{-# OPTIONS_GHC -fno-warn-orphans #-} module Sound.MIDI.ALSA.Check where +import qualified Sound.MIDI.Message.Class.Check as Class+import qualified Sound.MIDI.Message.Channel.Mode as Mode+ import qualified Sound.MIDI.ALSA as MALSA  import qualified Sound.ALSA.Sequencer.Event as Event  import Sound.MIDI.Message.Channel (Channel, )-import Sound.MIDI.Message.Channel.Voice (Controller, )+import Sound.MIDI.Message.Channel.Voice (Pitch, Velocity, Controller, Program, )  import Data.Accessor.Basic ((^.), ) import Data.Maybe.HT (toMaybe, ) import Control.Monad (guard, )  +instance Class.C Event.T where+   note = note+   program = program+   anyController = anyController+   mode = mode+   pitchBend = pitchBend+   channelPressure = channelPressure+++note ::+   Channel -> Event.T -> Maybe (Velocity, Pitch, Bool)+note chan e = do+   Event.NoteEv n c <- Just $ Event.body e+   guard (c ^. MALSA.noteChannel  ==  chan)+   let pitch    = c ^. MALSA.notePitch+       velocity = c ^. MALSA.noteVelocity+   case n of+      Event.NoteOn  -> Just (velocity, pitch, True)+      Event.NoteOff -> Just (velocity, pitch, False)+      _ -> Nothing++program ::+   Channel -> Event.T -> Maybe Program+program chan e = do+   Event.CtrlEv Event.PgmChange c <- Just $ Event.body e+   guard (c ^. MALSA.ctrlChannel  ==  chan)+   return $ c ^. MALSA.ctrlProgram+ anyController ::    Channel -> Event.T -> Maybe (Controller, Int) anyController chan e = do@@ -26,6 +63,13 @@    (c,n) <- anyController chan e    guard (ctrl==c)    return n++mode :: Channel -> Event.T -> Maybe Mode.T+mode chan e = do+   Event.CtrlEv Event.Controller c <- Just $ Event.body e+   guard (c ^. MALSA.ctrlChannel  ==  chan)+   MALSA.Mode m <- Just $ c ^. MALSA.ctrlControllerMode+   return m  pitchBend :: Channel -> Event.T -> Maybe Int pitchBend chan e =