packages feed

zmidi-core 0.8.2 → 0.9.0

raw patch · 11 files changed

+107/−111 lines, 11 filessetup-changed

Files

CHANGES view
@@ -1,3 +1,13 @@+ 0.8.2 to 0.9.0:+  +  * Improvements to handling pitch bend. The value of pitch +    bend is now represented as a Word14 and it is encoded+    and decoded according to the MIDI spec (previously it+    was left uninterpreted).+    Thanks to Joachim Tilsted Kristensen.++  * Removed ZMidi.Core.VersionNumber file. This means we can +    have a vanilla Setup.hs file.  0.8.1 to 0.8.2: 
Setup.hs view
@@ -1,29 +1,2 @@-#!/usr/bin/env runhaskell- import Distribution.Simple-import Distribution.Simple.Setup ( SDistFlags )-import Distribution.PackageDescription ( HookedBuildInfo, emptyHookedBuildInfo )---main = defaultMainWithHooks sdist_warning_hooks--sdist_warning_hooks :: UserHooks-sdist_warning_hooks = simpleUserHooks { preSDist = sdistVersionWarning }---sdistVersionWarning :: Args -> SDistFlags -> IO HookedBuildInfo-sdistVersionWarning _ _ = -    mapM_ putStrLn msg >> printVersionNumberFile >> return emptyHookedBuildInfo-  where-    msg = [ "-------------------------------------------------------"-          , "-------------------------------------------------------"-          , ""-          , "WARNING - is ZMidi.Core.VersionNumber correct?"-          , ""-          , "-------------------------------------------------------"-          , "-------------------------------------------------------"-          ]--printVersionNumberFile :: IO ()-printVersionNumberFile = -  readFile "src/ZMidi/Core/VersionNumber.hs" >>= putStrLn+main = defaultMain
src/ZMidi/Core.hs view
@@ -3,7 +3,7 @@ -------------------------------------------------------------------------------- -- | -- Module      :  ZMidi.Core--- Copyright   :  (c) Stephen Tetley 2010-2013+-- Copyright   :  (c) Stephen Tetley 2010-2018 -- License     :  BSD3 -- -- Maintainer  :  Stephen Tetley <stephen.tetley@gmail.com>@@ -28,7 +28,6 @@   , module ZMidi.Core.Pretty.Ascii   , module ZMidi.Core.Pretty.Csv   , module ZMidi.Core.ReadFile-  , module ZMidi.Core.VersionNumber   , module ZMidi.Core.WriteFile          ) where@@ -39,5 +38,4 @@ import ZMidi.Core.Pretty.Ascii import ZMidi.Core.Pretty.Csv import ZMidi.Core.ReadFile-import ZMidi.Core.VersionNumber import ZMidi.Core.WriteFile
src/ZMidi/Core/Datatypes.hs view
@@ -4,7 +4,7 @@ -------------------------------------------------------------------------------- -- | -- Module      :  ZMidi.Core.Datatypes--- Copyright   :  (c) Stephen Tetley 2010-2013+-- Copyright   :  (c) Stephen Tetley 2010-2018 -- License     :  BSD3 -- -- Maintainer  :  Stephen Tetley <stephen.tetley@gmail.com>@@ -26,8 +26,11 @@  module ZMidi.Core.Datatypes    (++  -- * A word14 type (for pitch bends)  +    Word14   -- * MidiFile syntax.-    DeltaTime+  , DeltaTime   , TagByte    , MidiFile(..)@@ -51,11 +54,51 @@        ) where +import Data.Bits import Data.Int import Data.Word +-------------------------------------------------------------------------------+-- Word14+------------------------------------------------------------------------------- +-- | Midi represents pitch bend values as Word14 value+-- (range 0 to 16383).+--+-- It seems useful to make a distinction between this type+-- and Word16, even though it implemented as a Word16 under +-- the hood.+--+newtype Word14 = Word14 { getWord14 :: Word16 }+  deriving (Enum,Eq,Ord,Integral,Real,Bits) +-- | For addition, but especially multiplication, operate+-- on integers rather than the underlying Word16 the we don't +-- get "eager" modulo operations.+makeWord14 :: Integer -> Word14+makeWord14 i = Word14 $ fromInteger $ i `mod` 16384++extractWord14 :: Word14 -> Integer+extractWord14 = fromIntegral . getWord14++instance Bounded Word14 where+  minBound = 0+  maxBound = 16383++instance Num Word14 where+  a + b = makeWord14 $ extractWord14 a + extractWord14 b+  a - b = makeWord14 $ extractWord14 a - extractWord14 b+  a * b = makeWord14 $ extractWord14 a * extractWord14 b+  abs a = Word14 $ abs (getWord14 a)+  negate a = makeWord14 $ negate (extractWord14 a)+  signum a = Word14 $ signum (getWord14 a)+  fromInteger = makeWord14+++instance Show Word14 where+  showsPrec p = showsPrec p . getWord14++ -- | All time values in a MIDI track are represented as a \delta\  -- from the previous event rather than an absolute time.  --@@ -302,9 +345,10 @@     -- Change the pitch of a sounding note. Often used to      -- approximate microtonal tunings.     -- -    -- NOTE - currently value is uninterpreted.+    -- NOTE - as of v0.9.0 the value is interpreted.+    -- This is a Word14 value, the range is (0..16383).     ---    | PitchBend           Word8 Word16+    | PitchBend           Word8 Word14     deriving (Eq,Ord,Show)
src/ZMidi/Core/Internal/ExtraTypes.hs view
@@ -3,7 +3,7 @@ -------------------------------------------------------------------------------- -- | -- Module      :  ZMidi.Core.Internal.ExtraTypes--- Copyright   :  (c) Stephen Tetley 2010-2013+-- Copyright   :  (c) Stephen Tetley 2010-2018 -- License     :  BSD3 -- -- Maintainer  :  Stephen Tetley <stephen.tetley@gmail.com>@@ -58,8 +58,11 @@ joinByte (SB a b) = (a .&. 0xF0) + (b .&. 0x0F)  +++ ----------------------------------------------------------------------------------- helper for varlen+-- Helper for varlen --------------------------------------------------------------------------------  -- | Space efficient representation of length fields.
src/ZMidi/Core/Pretty.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE CPP                        #-}+    {-# LANGUAGE CPP                        #-} {-# OPTIONS -Wall #-}  --------------------------------------------------------------------------------@@ -239,7 +239,7 @@ valVoiceEvent (NoteOn c n v)          = hex2 c <+> hex2 n <+> hex2 v valVoiceEvent (NoteAftertouch c n v)  = hex2 c <+> hex2 n <+> hex2 v valVoiceEvent (ChanAftertouch c v)    = hex2 c <+> hex2 v-valVoiceEvent (PitchBend c v)         = hex2 c <+> hex4 v+valVoiceEvent (PitchBend c v)         = hex2 c <+> hex4 (fromIntegral v)   -- | Get formatted value.
src/ZMidi/Core/Pretty/Csv.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP                   #-} {-# OPTIONS -Wall #-}  --------------------------------------------------------------------------------@@ -28,7 +29,9 @@ import ZMidi.Core.Pretty.Internal  +#if !MIN_VERSION_base(4,8,0) import Data.Monoid+#endif   -- | Print the MIDI file to stdout (CSV format).
src/ZMidi/Core/ReadFile.hs view
@@ -4,7 +4,7 @@ -------------------------------------------------------------------------------- -- | -- Module      :  ZMidi.Core.ReadFile--- Copyright   :  (c) Stephen Tetley 2010-2015+-- Copyright   :  (c) Stephen Tetley 2010-2018 -- License     :  BSD3 -- -- Maintainer  :  Stephen Tetley <stephen.tetley@gmail.com>@@ -180,7 +180,7 @@  pitchBend :: Word8 -> ParserM MidiVoiceEvent pitchBend ch = -    "pitch bend"        <??> (PitchBend ch)      <$> word16be+    "pitch bend"        <??> (PitchBend ch)      <$> word14be   @@ -343,6 +343,16 @@  -------------------------------------------------------------------------------- -- helpers++word14be :: ParserM Word14+word14be = (\lsb msb -> toWord14BE (lsb,msb)) <$> word8 <*> word8+++toWord14BE :: (Word8,Word8) -> Word14+toWord14BE (lsb,msb) = msb' .|. lsb'+  where+    lsb' = fromIntegral lsb+    msb' = (fromIntegral msb) `shiftL` 7   impossibleMatch :: String -> ParserM a
− src/ZMidi/Core/VersionNumber.hs
@@ -1,28 +0,0 @@-{-# OPTIONS -Wall #-}------------------------------------------------------------------------------------- |--- Module      :  ZMidi.Core.VersionNumber--- Copyright   :  (c) Stephen Tetley 2010-2015--- License     :  BSD3------ Maintainer  :  stephen.tetley@gmail.com--- Stability   :  unstable--- Portability :  GHC------ Version number--------------------------------------------------------------------------------------module ZMidi.Core.VersionNumber-  ( -    zmidi_core_version--  ) where---- | Version number------ > (0,8,1)----zmidi_core_version :: (Int,Int,Int)-zmidi_core_version = (0,8,1)
src/ZMidi/Core/WriteFile.hs view
@@ -4,7 +4,7 @@ -------------------------------------------------------------------------------- -- | -- Module      :  ZMidi.Core.WriteFile--- Copyright   :  (c) Stephen Tetley 2010-2015+-- Copyright   :  (c) Stephen Tetley 2010-2018 -- License     :  BSD3 -- -- Maintainer  :  Stephen Tetley <stephen.tetley@gmail.com>@@ -117,7 +117,8 @@     optTagByte rs (0xD `u4l4` c) *> putWord8 v    putVoiceEvent rs (PitchBend c v)            = -    optTagByte rs (0xE `u4l4` c) *> putWord16be v+    let (lsb,msb) = fromWord14BE v in+    optTagByte rs (0xE `u4l4` c) *> putWord8 lsb *> putWord8 msb   -- Note - F7 (terminator) should be the last byte in the @@ -231,6 +232,16 @@  -------------------------------------------------------------------------------- -- Output helpers+++-- | Helper for Pitch Bend, min is 0, max is 16383+-- (lsb, msb)+fromWord14BE :: Word14 -> (Word8,Word8)+fromWord14BE a = (lsb,msb)+  where+    lsb = fromIntegral (a .&. 0x007f)+    msb = (.&. 0x7f) $ fromIntegral (a `shiftR` 7) +  optTagByte :: MidiRunningStatus -> Word8 -> PutM () optTagByte RS_OFF n = putWord8 n
zmidi-core.cabal view
@@ -1,5 +1,5 @@ name:             zmidi-core-version:          0.8.2+version:          0.9.0 license:          BSD3 license-file:     LICENSE copyright:        Stephen Tetley <stephen.tetley@gmail.com>@@ -14,6 +14,17 @@   .   Changelog:   .+  v0.8.2 to v0.9.0:+  .+  * Improvements to handling pitch bend. The value of pitch +    bend is now represented as a Word14 and it is encoded+    and decoded according to the MIDI spec (previously it+    was left uninterpreted).+    Thanks to Joachim Tilsted Kristensen.+  .+  * Removed ZMidi.Core.VersionNumber file. This means we can +    have a vanilla Setup.hs file.+  .   v0.8.1 to v0.8.2:   .   * Updated to compile with ghc-8.4. Thanks to Evan Laforge.@@ -22,44 +33,6 @@   .    * Fixed error with missing CPP directive in ZMidi.Core.Pretty.   . -  v0.7.0 to v0.8.0:-  .-  * Updated to compile without errors with GHC 7.10.-  .-  v0.6.0 to v0.7.0:-  .-  * Changed @ChannelPrefix@ constructor to have a single -    argument - channel number (previously it stored a constant -    tag 0x01 as well as channel number).-  .-  * Added @SysExCont@ and @SysExEscape@ constructors to the -    @MidiSysExEvent@ data type.-  .-  * Added new pretty printers - @Csv@ based on @midicsv@ and -    @Ascii@ based on the ASCII MIDI representation in the book -    Beyond Midi (the zmidi ASCII representation is simplified).-    The demo application @MidiPrint@ now allows choice of pretty-    printer.-  .-  * @printMidiHeader@ and @printMidiTrack@ from @Pretty@ changed-    to MidiFiles as arguments, @printMidi@ has now become -    @putMidi@.-  .-  v0.5.0 to v0.6.0:-  .-  * Extended the parser and changed the syntax tree to interpret -    MIDI Running Status. -  . -  * Added a module @ZMidi.Core.Canonical@ to translate MidiFiles-    to a canonical form where any shorthand NoteOff introduced by -    Running Status is expanded to regular NoteOn and NoteOff -    events (with Running Status set, MidiFiles can signal NoteOff -    events as another NoteOn with 0 channel velocity).-  .-  * Added a hack to the pretty printer to stop printing ASCII-    chars greater than 164 causing an error when printing to -    stdout.-  .   For older changes see - CHANGES file.   . build-type:         Simple@@ -90,7 +63,6 @@     ZMidi.Core.Pretty.Internal,     ZMidi.Core.Pretty.Interp,     ZMidi.Core.ReadFile,-    ZMidi.Core.VersionNumber,     ZMidi.Core.WriteFile    other-modules: