packages feed

wavesurfer 0.0.4 → 0.0.6

raw patch · 4 files changed

+54/−9 lines, 4 filesdep ~bytestring-lexing

Dependency ranges changed: bytestring-lexing

Files

Sound/WaveSurfer.hs view
@@ -104,8 +104,7 @@ decodeAttributes :: DT.Record -> Result [Attribute] decodeAttributes = return . map f     where f s = let (k, v) = BSC.break (==':') s-                    v'     = BS.tail v-                in (k, if BS.null v' then Nothing else Just v')+                in (k, if BS.null v then Nothing else Just (BS.tail v))  -- | Decode a 'Double'. decodeDouble :: DT.Field -> Result Double@@ -126,10 +125,13 @@ decode :: ByteString -> Result Content decode s = do     xs <- DT.decode whiteSpace s-    mapM decodeRecord (filter f xs)+    mapM (decodeRecord . filter g) (filter f xs)     where+        -- Get rid of empty lines and comments         f []     = False         f (r:rs) = not (BSC.null r) && (BSC.head r /= comment)+        -- Get rid of empty fields+        g        = not . BSC.null  interact :: (Record -> Record) -> ByteString -> Result ByteString interact f s = do
+ examples/data.ws view
@@ -0,0 +1,31 @@+# BodyAndSoul 60
+0.277037 0.4774 NOTE CLUSTER:1 MIDI_NOTE:63 MIDI_VELOCITY:85 
+0.556944 0.750504 NOTE CLUSTER:2 MIDI_NOTE:65 MIDI_VELOCITY:73
+0.750504 0.997803 NOTE CLUSTER:2 MIDI_NOTE:63 MIDI_VELOCITY:81
+0.997803 1.7697 NOTE CLUSTER:2 MIDI_NOTE:65 MIDI_VELOCITY:83
+1.7697 1.99961 NOTE CLUSTER:1 MIDI_NOTE:63 MIDI_VELOCITY:63
+2.10516 2.46032 NOTE CLUSTER:2 MIDI_NOTE:70 MIDI_VELOCITY:84
+2.52704 3.8507 NOTE CLUSTER:2 MIDI_NOTE:70 MIDI_VELOCITY:93
+4.25177 4.48958 NOTE CLUSTER:1 MIDI_NOTE:68 MIDI_VELOCITY:69
+4.55694 4.7505 NOTE CLUSTER:2 MIDI_NOTE:70 MIDI_VELOCITY:67
+4.7505 4.9978 NOTE CLUSTER:2 MIDI_NOTE:68 MIDI_VELOCITY:81
+4.9978 5.7505 NOTE CLUSTER:2 MIDI_NOTE:70 MIDI_VELOCITY:89
+5.7505 6.0139 NOTE CLUSTER:1 MIDI_NOTE:68 MIDI_VELOCITY:88
+6.1644 6.50429 NOTE CLUSTER:2 MIDI_NOTE:75 MIDI_VELOCITY:86
+6.50429 7.00479 NOTE CLUSTER:1 MIDI_NOTE:73 MIDI_VELOCITY:74
+7.01768 7.45781 NOTE CLUSTER:2 MIDI_NOTE:72 MIDI_VELOCITY:65
+7.50429 8.00479 NOTE CLUSTER:1 MIDI_NOTE:70 MIDI_VELOCITY:68
+8.55694 8.96425 NOTE CLUSTER:2 MIDI_NOTE:73 MIDI_VELOCITY:58
+8.96425 9.3604 NOTE CLUSTER:1 MIDI_NOTE:70 MIDI_VELOCITY:91
+9.36378 9.63658 NOTE CLUSTER:2 MIDI_NOTE:66 MIDI_VELOCITY:70
+9.69892 9.94381 NOTE CLUSTER:1 MIDI_NOTE:58 MIDI_VELOCITY:69
+10.1052 10.9101 NOTE CLUSTER:2 MIDI_NOTE:65 MIDI_VELOCITY:81
+11.0952 11.6182 NOTE CLUSTER:2 MIDI_NOTE:63 MIDI_VELOCITY:62
+12.2518 12.4896 NOTE CLUSTER:2 MIDI_NOTE:61 MIDI_VELOCITY:71
+12.5569 12.7522 NOTE CLUSTER:1 MIDI_NOTE:63 MIDI_VELOCITY:65
+12.8012 12.9547 NOTE CLUSTER:1 MIDI_NOTE:65 MIDI_VELOCITY:76
+12.9955 13.5069 NOTE CLUSTER:2 MIDI_NOTE:68 MIDI_VELOCITY:111
+13.527 13.4966 NOTE CLUSTER:2 MIDI_NOTE:68 MIDI_VELOCITY:94
+13.4966 13.8325 NOTE CLUSTER:2 MIDI_NOTE:70 MIDI_VELOCITY:75
+13.8325 14.0093 NOTE CLUSTER:1 MIDI_NOTE:64 MIDI_VELOCITY:73
+14.1052 15.8096 NOTE CLUSTER:0 MIDI_NOTE:61 MIDI_VELOCITY:64
+ examples/test.hs view
@@ -0,0 +1,9 @@+import qualified Data.ByteString.Lazy as B+import qualified Sound.WaveSurfer     as WS++main :: IO ()+main = do+    s <- WS.interact id `fmap` B.getContents+    case s of+        Right bs -> B.putStr bs+        Left e   -> putStrLn ("Parse failed: " ++ e)
wavesurfer.cabal view
@@ -1,5 +1,5 @@ name:               wavesurfer-version:            0.0.4+version:            0.0.6 synopsis:           Parse WaveSurfer files description:        Parse WaveSurfer files license:            BSD3@@ -14,12 +14,15 @@ build-type:         Simple cabal-version:      >= 1.2 +extra-source-files: examples/data.ws+                    examples/test.hs+ library   exposed-modules:  Sound.WaveSurfer    build-depends:    base >= 3,-                    binary == 0.4.*,-                    bytestring == 0.9.*,-                    bytestring-lexing == 0.2,-                    bytestring-show == 0.2.*,-                    delimited-text == 0.0.*+                    binary >= 0.4 && < 0.5,+                    bytestring >= 0.9 && < 0.10,+                    bytestring-lexing >= 0.2 && < 0.3,+                    bytestring-show >= 0.2 && < 0.3,+                    delimited-text >= 0.0 && < 0.1