diff --git a/.gitignore b/.gitignore index 7ac31bd..9d798ef 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,4 @@ Test/MiniTest.hs Test/buganalysis.hs Test/log.txt Test/debug.nb -Test/debugs.dat \ No newline at end of file +Test/debugs.dat diff --git a/AudioFile.hs b/AudioFile.hs deleted file mode 100644 index ca3abc1..0000000 --- a/AudioFile.hs +++ /dev/null @@ -1,58 +0,0 @@ -{-# LANGUAGE ConstraintKinds #-} -module AudioFile( - writeMono - , writeStereo - , readMono - ) where - -import Prelude hiding(length,map,zip,head,take) -import Data.WAVE -import Signal -import Common -import Data.List.Stream - -wave f c l samples = WAVE - { waveHeader = WAVEHeader { waveNumChannels = c - , waveFrameRate = floor (getF f) - , waveBitsPerSample = 32 - , waveFrames = Just l - } - , waveSamples = samples - } - -writeMono :: Sample a - => FilePath - -> Time -- ^ Sample duration - -> Sampled Time a - -> IO () -writeMono name duration signal = - let theRate = rate signal - d = floor (getT duration * getF theRate) - boundedSignal = takeS d $ (getSignal signal) - samples = map (\x -> [doubleToSample . toDouble $ x]) boundedSignal - w = wave theRate 1 d samples - in - putWAVEFile name w - -writeStereo :: (Sample left, Sample right) - => FilePath - -> Time -- ^ Duration - -> Sampled Time (left,right) - -> IO () -writeStereo name duration signal = - let theRate = rate signal - d = floor (getT duration * getF theRate) - boundedSignal = takeS d (getSignal signal) - samples = map (\(x,y) -> [doubleToSample . toDouble $ x, doubleToSample . toDouble $ y]) boundedSignal - w = wave theRate 2 d samples - in - putWAVEFile name w - -readMono :: Sample a - => FilePath - -> IO (Sampled Time a) -readMono name = do - w <- getWAVEFile name - let f = Frequency (fromIntegral $ waveFrameRate (waveHeader w)) - t = dual f - return $ Sampled t (fromListS 0 . map (fromDouble . sampleToDouble . head) . waveSamples $ w) \ No newline at end of file diff --git a/Signal.cabal b/Signal.cabal index f39cd36..d9615dd 100644 --- a/Signal.cabal +++ b/Signal.cabal @@ -14,47 +14,55 @@ maintainer: misc@alpheccar.org copyright: 2013, alpheccar.org category: Math build-type: Simple -cabal-version: >=1.8 +cabal-version: >=1.10 library + default-language: Haskell2010 + other-extensions: + CPP + + hs-source-dirs: src exposed-modules: - Transform - Plot - Signal - Generators - Fixed - TestCases - Common - Windows - SpecialInt - Trace - AudioFile - MultiRate - Spectrogram - VAD - Noise - Filter + Signal.Transform + Signal.Plot + Signal + Signal.Generators + Signal.Fixed + Signal.TestCases + Signal.Common + Signal.Windows + Signal.SpecialInt + Signal.Trace + Signal.AudioFile + Signal.MultiRate + Signal.Spectrogram + Signal.VAD + Signal.Noise + Signal.Filter other-modules: - TypeAddition - Internal + Signal.Internal build-depends: - base ==4.6.*, - vector ==0.10.*, - hmatrix ==0.14.*, - stream-fusion ==0.1.*, - HPDF ==1.4.*, - HaskellViewer >=0.4.2.1, - test-framework ==0.8.*, - test-framework-hunit ==0.3.*, - HUnit ==1.2.5.*, - primitive ==0.5.*, - containers ==0.5.*, - statistics ==0.10.*, - deepseq ==1.3.*, - random ==1.0.*, - WAVE ==0.1.*, - mtl ==2.1.*, - polynomial ==0.6.* - ghc-options: -O2 + base, + vector, + hmatrix, + hmatrix-gsl, + stream-fusion, + HPDF, + HaskellViewer, + test-framework, + test-framework-hunit, + HUnit, + primitive, + containers, + statistics, + deepseq, + random, + WAVE, + mtl, + polynomial, + singletons + if (os(darwin)) - ghc-options: -pgmP llvm-gcc-4.2 -optP-E \ No newline at end of file + ghc-options: -pgmP llvm-gcc-4.2 -optP-E + else + ghc-options: -O2 -cpp -pgmPcpphs -optP--cpp diff --git a/Test/Test.hs b/Test/Test.hs index bdc9a6c..32defcd 100644 --- a/Test/Test.hs +++ b/Test/Test.hs @@ -3,37 +3,37 @@ {-# LANGUAGE BangPatterns #-} {-# LANGUAGE GADTs #-} module Main( - main - - ) where + main + + ) where import Prelude hiding((++)) -import Plot +import Signal.Plot import Graphics.PDF hiding(Orientation(..), Vertical) -import Transform +import Signal.Transform import Signal -import Generators -import Fixed -import TestCases -import Common -import Windows +import Signal.Generators +import Signal.Fixed +import Signal.TestCases +import Signal.Common +import Signal.Windows import qualified Data.Vector.Unboxed as U import qualified Numeric.GSL.Fourier as F -import Trace +import Signal.Trace import System.Random -import Displayable +import HaskellViewer.Displayable import Control.DeepSeq import Control.Applicative((<$>)) -import AudioFile -import Playable -import Viewer(play) -import Spectrogram -import VAD +import Signal.AudioFile +import HaskellViewer.Playable +import HaskellViewer.Viewer(play) +import Signal.Spectrogram +import Signal.VAD import Data.List.Stream((++)) import System.Timeout -import Noise +import Signal.Noise import System.IO -import Filter +import Signal.Filter import Math.Polynomial import qualified Debug.Trace as T @@ -133,17 +133,27 @@ wav = do let theTimes = uniformSamples (period s) 0.0 display $ plotSignals (floor $ 2.0 * getF (rate s)) (period s) [ AS s] +avad = do + s <- readMono "Test.wav" :: IO (Sampled Time Double) + let v = vad s + let theTimes = uniformSamples (period s) 0.0 + display $ plotSignals (floor $ 2.0 * getF (rate s)) (period s) [ AS s, AS v] + + myTest = do - --s <- readMono "Test.wav" :: IO (Signal Time Double) + s <- readMono "Test.wav" :: IO (Sampled Time Double) let tr = dual (Frequency 44100) +-- theTimes = {-# SCC "theTimes" #-} uniformSamples s 0.0 :: Signal Time theTimes = {-# SCC "theTimes" #-} uniformSamples tr 0.0 :: Signal Time --s = mapS (\t -> 0.01*sin (2*pi*4000*getT t)) theTimes - --si = vad s - sv = tr - ----theFrames = uniformSamples sv 0 + si = vad s +-- sv = tr + sv = si +-- theFrames = uniformSamples sv 0 --myLen !s (!a:l) = myLen (s+1) l --myLen !s [] = s - display $ discreteSignalsWithStyle (floor $ 6.0 / getT sv) plotStyle { horizontalBounds = Just (0,6.0) +-- display $ discreteSignalsWithStyle (floor $ 6.0 / getT sv) plotStyle { horizontalBounds = Just (0,6.0) + display $ discreteSignalsWithStyle (floor $ 6.0 / samplingPeriod s) plotStyle { horizontalBounds = Just (0,6.0) , verticalBounds = Just (0,6.0) } [ AS theTimes] @@ -254,22 +264,22 @@ lightGreen = Rgb 0.6 1.0 0.6 lightYellow = Rgb 1.0 1.0 0.6 plotStyle = - (defaultPlotStyle { title = Just "Temporal" - , signalStyles = [ defaultSignalStyle 0.8 lightBlue - , defaultSignalStyle 0.8 lightRed - , defaultSignalStyle 0.8 lightGreen + (defaultPlotStyle { title = Just "Temporal" + , signalStyles = [ defaultSignalStyle 0.8 lightBlue + , defaultSignalStyle 0.8 lightRed + , defaultSignalStyle 0.8 lightGreen , defaultSignalStyle 0.8 lightYellow - ] - , verticalLabel = Just "Amplitude" - }) + ] + , verticalLabel = Just "Amplitude" + }) fftStyle = - plotStyle { verticalLabel = Just "Energy", title = Just "Frequential", horizontalLabel = Just "Hz" + plotStyle { verticalLabel = Just "Energy", title = Just "Frequential", horizontalLabel = Just "Hz" , signalStyles = [ defaultSignalStyle 0.8 lightBlue - , defaultSignalStyle 0.8 lightRed - , defaultSignalStyle 0.8 lightGreen + , defaultSignalStyle 0.8 lightRed + , defaultSignalStyle 0.8 lightGreen , defaultSignalStyle 0.8 lightYellow - ] - } + ] + } pict = display $ plotSignals (floor $ getT dr * getF samplingFrequency) sp [ AS mySignalA , AS mySignalC diff --git a/TypeAddition.hs b/TypeAddition.hs deleted file mode 100644 index 4432782..0000000 --- a/TypeAddition.hs +++ /dev/null @@ -1,39 +0,0 @@ -{-# LANGUAGE TypeOperators #-} -{-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE DataKinds #-} -module TypeAddition where - -import GHC.TypeLits - -type instance (15 :: Nat) + (1 :: Nat) = 16 -type instance (15 :: Nat) + (2 :: Nat) = 17 -type instance (15 :: Nat) + (3 :: Nat) = 18 -type instance (15 :: Nat) + (4 :: Nat) = 19 -type instance (15 :: Nat) + (5 :: Nat) = 20 -type instance (15 :: Nat) + (6 :: Nat) = 21 -type instance (15 :: Nat) + (7 :: Nat) = 22 -type instance (15 :: Nat) + (8 :: Nat) = 23 -type instance (15 :: Nat) + (9 :: Nat) = 24 -type instance (15 :: Nat) + (10 :: Nat) = 25 -type instance (15 :: Nat) + (11 :: Nat) = 26 -type instance (15 :: Nat) + (12 :: Nat) = 27 -type instance (15 :: Nat) + (13 :: Nat) = 28 -type instance (15 :: Nat) + (14 :: Nat) = 29 -type instance (15 :: Nat) + (15 :: Nat) = 30 -type instance (15 :: Nat) + (16 :: Nat) = 31 - -type instance (1 :: Nat) + (1 :: Nat) = 2 -type instance (2 :: Nat) + (2 :: Nat) = 4 -type instance (3 :: Nat) + (3 :: Nat) = 6 -type instance (4 :: Nat) + (4 :: Nat) = 8 -type instance (5 :: Nat) + (5 :: Nat) = 10 -type instance (6 :: Nat) + (6 :: Nat) = 12 -type instance (7 :: Nat) + (7 :: Nat) = 14 -type instance (8 :: Nat) + (8 :: Nat) = 16 -type instance (9 :: Nat) + (9 :: Nat) = 18 -type instance (10 :: Nat) + (10 :: Nat) = 20 -type instance (11 :: Nat) + (11 :: Nat) = 22 -type instance (12 :: Nat) + (12 :: Nat) = 24 -type instance (13 :: Nat) + (13 :: Nat) = 26 -type instance (14 :: Nat) + (14 :: Nat) = 28 -type instance (15 :: Nat) + (15 :: Nat) = 30 \ No newline at end of file diff --git a/Signal.hs b/src/Signal.hs similarity index 96% rename from Signal.hs rename to src/Signal.hs index 58c466d..e552e7d 100644 --- a/Signal.hs +++ b/src/Signal.hs @@ -3,7 +3,7 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE UndecidableInstances #-} module Signal( - Signal, + Signal, BSignal, getSamples, duration, @@ -11,7 +11,7 @@ module Signal( Sample(..), DualVal(..), samplingRate, - -- * Basic interface + -- * Basic interface headS, tailS, consS, @@ -105,20 +105,24 @@ module Signal( Sampled(..), HasPeriod(..), HasSamples(..) - ) where + ) where import qualified Prelude as P import Prelude(Int(..),Maybe(..),Bool(..),Eq(..),Integral(..),($),(.),Num(..),Ord(..),Show ,otherwise,Floating,Fractional,Real,Read,RealFloat,RealFrac) -import Internal + import qualified Data.Vector.Unboxed as U import Data.Vector.Unboxed((!),Unbox(..)) + import Data.Stream(stream,unstream,Stream(..),Step(..),L(..)) import Data.List.Stream -import Common(HasDoubleRepresentation(..)) -import Playable -import Common -import Viewer(play) + +import HaskellViewer.Playable +import HaskellViewer.Viewer(play) + +import Signal.Common +import Signal.Common(HasDoubleRepresentation(..)) +import Signal.Internal type Sample a = (RealFrac a, RealFloat a, HasDoubleRepresentation a, Unbox a) @@ -318,9 +322,9 @@ genericReplicateS n x = Signal (genericReplicate n x) fromVectorS :: Unbox a => a -> U.Vector a -> Signal a fromVectorS d v = Signal $ unstream (repeatVector d) where - repeatVector d = Stream (nextS d) (L 0) - nextS d l@(L !i) | i < U.length v = Yield (v!i) (L (i+1)) - | otherwise = Yield d l + repeatVector d = Stream (nextS d) (L 0) + nextS d l@(L !i) | i < U.length v = Yield (v!i) (L (i+1)) + | otherwise = Yield d l {-# INLINE [0] fromVectorS #-} fromVectorBS :: Unbox a => U.Vector a -> BSignal a diff --git a/src/Signal/AudioFile.hs b/src/Signal/AudioFile.hs new file mode 100644 index 0000000..73885c9 --- /dev/null +++ b/src/Signal/AudioFile.hs @@ -0,0 +1,59 @@ +{-# LANGUAGE ConstraintKinds #-} +module Signal.AudioFile( + writeMono + , writeStereo + , readMono + ) where + +import Prelude hiding(length,map,zip,head,take) +import Data.List.Stream (map, head) +import Data.WAVE + +import Signal +import Signal.Common + +wave f c l samples = WAVE + { waveHeader = WAVEHeader { waveNumChannels = c + , waveFrameRate = floor (getF f) + , waveBitsPerSample = 32 + , waveFrames = Just l + } + , waveSamples = samples + } + +writeMono :: Sample a + => FilePath + -> Time -- ^ Sample duration + -> Sampled Time a + -> IO () +writeMono name duration signal = + let theRate = rate signal + d = floor (getT duration * getF theRate) + boundedSignal = takeS d $ (getSignal signal) + samples = map (\x -> [doubleToSample . toDouble $ x]) boundedSignal + w = wave theRate 1 d samples + in + putWAVEFile name w + +writeStereo :: (Sample left, Sample right) + => FilePath + -> Time -- ^ Duration + -> Sampled Time (left,right) + -> IO () +writeStereo name duration signal = + let theRate = rate signal + d = floor (getT duration * getF theRate) + boundedSignal = takeS d (getSignal signal) + samples = map (\(x,y) -> [doubleToSample . toDouble $ x, doubleToSample . toDouble $ y]) boundedSignal + w = wave theRate 2 d samples + in + putWAVEFile name w + +readMono :: Sample a + => FilePath + -> IO (Sampled Time a) +readMono name = do + w <- getWAVEFile name + let f = Frequency (fromIntegral $ waveFrameRate (waveHeader w)) + t = dual f + return $ Sampled t (fromListS 0 . map (fromDouble . sampleToDouble . head) . waveSamples $ w) diff --git a/Common.hs b/src/Signal/Common.hs similarity index 55% rename from Common.hs rename to src/Signal/Common.hs index 2b54616..cee5c6c 100644 --- a/Common.hs +++ b/src/Signal/Common.hs @@ -1,11 +1,11 @@ -module Common( - Time(..), - Frequency(..), - HasDoubleRepresentation(..) - ) where +module Signal.Common( + Time(..), + Frequency(..), + HasDoubleRepresentation(..) + ) where -import Internal(Time(..), Frequency(..), Dual(..)) +import Signal.Internal(Time(..), Frequency(..), Dual(..)) -- | Signals can use values which are not directly doubles (like voltage etc ...) -- Those values must be convertible into Double for display on a graphic @@ -14,9 +14,9 @@ class HasDoubleRepresentation a where fromDouble :: Double -> a instance HasDoubleRepresentation Time where - toDouble = getT - fromDouble = Time + toDouble = getT + fromDouble = Time instance HasDoubleRepresentation Frequency where - toDouble = getF - fromDouble = Frequency \ No newline at end of file + toDouble = getF + fromDouble = Frequency diff --git a/Filter.hs b/src/Signal/Filter.hs similarity index 78% rename from Filter.hs rename to src/Signal/Filter.hs index 3c64c2c..fa0ead6 100644 --- a/Filter.hs +++ b/src/Signal/Filter.hs @@ -3,30 +3,34 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE TypeOperators #-} -module Filter( +{-# LANGUAGE AllowAmbiguousTypes #-} +module Signal.Filter( FIR(..) , bode , phasePlot ) where -import Signal -import Math.Polynomial -import Common -import Noise -import Fixed +import Math.Polynomial import GHC.TypeLits -import SpecialInt import Data.Bits -import Plot + import Data.Complex +import Data.Singletons import Text.Printf +import Signal +import Signal.Common +import Signal.Noise +import Signal.Fixed +import Signal.Plot +import Signal.SpecialInt + import Debug.Trace debug a = trace (show a) a - +-- SingI (nc + ni), SingI nc, SingI ni, SingI no, SingI s, SingI r, data FIR p i o where - FIR :: (SingI (nc + ni), SingI nc, SingI ni, SingI no, SingI s, SingI r, HasDoubleRepresentation (Fixed a nc s r), Num (Fixed ag (nc + ni) s r), Num (Fixed a nc s r), Eq a, Conversion ag ao, ConvertConstraint ag ao, AMulConstraint a ag) + FIR :: (KnownNat no, KnownNat nc, KnownNat ni, KnownNat (nc + ni), SingI s, SingI r, HasDoubleRepresentation (Fixed a nc s r), Num (Fixed ag (nc + ni) s r), Num (Fixed a nc s r), Eq a, Conversion ag ao, ConvertConstraint ag ao, AMulConstraint a ag) => Poly (Fixed a nc s r) -> FIR ((Fixed ag (nc + ni) s r),(Fixed a nc s r)) (Fixed a ni s r) (Fixed ao no s r) FIRD :: Poly Double @@ -36,7 +40,7 @@ polyRepresentation :: FIR p i o -> Poly Double polyRepresentation (FIRD p) = p polyRepresentation (FIR f) = fmap toDouble f -instance Show p => Show (FIR p i o) where +instance (Show p)=> Show (FIR p i o) where show (FIR c) = show c show (FIRD d) = show d @@ -55,8 +59,8 @@ filterDWith (a:l) s | null l = mapS (a*) s | otherwise = zipWithS (+) (mapS (a*) s) (filterDWith l (delay 0 s)) filterDWith [] s = s - -_filterWith :: (AMulConstraint a ag, SingI (na + ni), SingI s, SingI r, SingI na, SingI ni, Num (Fixed a ni s r), Num (Fixed ag (na + ni) s r)) +-- , SingI (na + ni), SingI s, SingI r, SingI na, SingI ni +_filterWith :: (KnownNat na, KnownNat ni, SingI s, AMulConstraint a ag, Num (Fixed a ni s r), Num (Fixed ag (na + ni) s r)) => FIR ((Fixed ag ng s r),(Fixed a na s r)) (Fixed a ni s r) (Fixed ao no s r) -> [Fixed a na s r] -> Signal (Fixed a ni s r) @@ -65,7 +69,8 @@ _filterWith f (a:l) s | null l = mapS (amul a) s | otherwise = zipWithS (+) (mapS (amul a) s) (_filterWith f l (delay 0 s)) _filterWith _ [] s = error "Empty polynomial can't be used for filtering" -filterWith :: (Conversion ag ao, ConvertConstraint ag ao, Num (Fixed a ni s r), Num (Fixed ag (na + ni) s r), SingI r, SingI s, SingI (na + ni), SingI ni, SingI na, SingI no, AMulConstraint a ag) +-- SingI r, SingI s, SingI (na + ni), SingI ni, SingI na, SingI no, +filterWith :: (KnownNat no, KnownNat na, KnownNat ni, KnownNat (na + ni),SingI s,SingI r , Conversion ag ao, ConvertConstraint ag ao, Num (Fixed a ni s r), Num (Fixed ag (na + ni) s r), AMulConstraint a ag) => FIR ((Fixed ag ng s r),(Fixed a na s r)) (Fixed a ni s r) (Fixed ao no s r) -> [Fixed a na s r] -> Signal (Fixed a ni s r) diff --git a/Fixed.hs b/src/Signal/Fixed.hs similarity index 90% rename from Fixed.hs rename to src/Signal/Fixed.hs index e010373..e542e30 100644 --- a/Fixed.hs +++ b/src/Signal/Fixed.hs @@ -1,12 +1,13 @@ {-# LANGUAGE TypeOperators,TypeFamilies,MultiParamTypeClasses,FlexibleContexts, BangPatterns,PolyKinds, DataKinds, GADTs, GeneralizedNewtypeDeriving,DeriveDataTypeable,FlexibleInstances,ScopedTypeVariables #-} {-# LANGUAGE ConstraintKinds #-} -{-# LANGUAGE CPP #-} -{- | Fixed point arithmetic +{-# LANGUAGE CPP, TemplateHaskell #-} +{-# LANGUAGE DataKinds, PolyKinds, TypeOperators, TypeFamilies, GADTs, UndecidableInstances, FlexibleContexts, KindSignatures #-} +{- | Fixed point arithmetic Fixed point arithmetic with signed, unsigned and saturation -} -module Fixed( +module Signal.Fixed( nbFractionalBits , HasDoubleRepresentation(..) , FixedPoint(..) @@ -44,12 +45,18 @@ import qualified Data.Vector.Unboxed as U import qualified Data.Vector.Generic as G import qualified Data.Vector.Generic.Mutable as M import Control.Monad(liftM) -import Common(HasDoubleRepresentation(..)) import Data.Complex -import SpecialInt + +import Data.Singletons.TH (singletons) +import Data.Proxy (KProxy(..)) +import Data.Singletons.Prelude + import Control.DeepSeq import System.Random +import Signal.SpecialInt +import Signal.Common(HasDoubleRepresentation(..)) + import Debug.Trace debug a = trace (show a) a @@ -66,31 +73,34 @@ instance HasDoubleRepresentation Int where toDouble = fromIntegral fromDouble = floor +$(singletons [d| + data Saturation = Sat | Unsat deriving(Eq) + data Rounding = RO | NR deriving(Eq) + |]) newtype Fixed :: * -> Nat -> Saturation -> Rounding -> * where Fixed :: a -> Fixed a n sa r -data Saturation = Sat | Unsat deriving(Eq) -data Rounding = RO | NR deriving(Eq) - -newtype instance Sing (n :: Saturation) = SatC Saturation -newtype instance Sing (n :: Rounding) = RoundC Rounding - -instance SingI Sat where - sing = SatC Sat - -instance SingI Unsat where - sing = SatC Unsat - -instance SingE (Kind :: Saturation) Saturation where - fromSing (SatC n) = n - -instance SingI RO where - sing = RoundC RO - -instance SingI NR where - sing = RoundC NR - -instance SingE (Kind :: Rounding) Rounding where - fromSing (RoundC n) = n +-- newtype instance Sing (n :: Saturation) = SatC Saturation +-- newtype instance Sing (n :: Rounding) = RoundC Rounding + +-- instance SingI Sat where +-- sing = SatC Sat +-- +-- instance SingI Unsat where +-- sing = SatC Unsat +-- +-- instance SingKind Saturation where +-- type DemoteRep = Saturation +-- fromSing (SatC n) = n +-- +-- instance SingI RO where +-- sing = RoundC RO +-- +-- instance SingI NR where +-- sing = RoundC NR +-- +-- instance SingKind (KindOf Rounding) where +-- type DemoteRep = Rounding +-- fromSing (RoundC n) = n newtype instance U.MVector s (Fixed a n sat r) = MVFixed (U.MVector s a) newtype instance U.Vector (Fixed a n sat r) = VFixed (U.Vector a) @@ -350,7 +360,7 @@ instance NFData (Fixed INT n s r) where {\ instance (SingI n, SingI s, SingI r) => Random (Fixed INT n s r) where {\ randomR = genericRandomR \ ; random = genericRandom }; \ -instance (SingI n, SingI s, SingI r) => Num (Fixed INT n s r) where {\ +instance (SingI n, SingI s, SingI r, KnownNat n) => Num (Fixed INT n s r) where {\ (+) = genericOperator (+) \ ; (-) = genericOperator (-) \ ; abs = genericAbs \ @@ -360,7 +370,7 @@ instance (SingI n, SingI s, SingI r) => Num (Fixed INT n s r) where {\ instance (SingI n, SingI s, SingI r) => Bounded (Fixed INT n s r) where {\ maxBound = fromRawValue maxBound \ ; minBound = fromRawValue minBound };\ -instance (SingI n, SingI s, SingI r) => Resolution (Fixed INT n s r) where {\ +instance (SingI n, SingI s, SingI r, KnownNat n) => Resolution (Fixed INT n s r) where {\ smallestValue _ = fromRawValue 1 \ ; maxValue _ = maxBound \ ; minValue _ = minBound \ @@ -369,17 +379,17 @@ instance (SingI n, SingI s, SingI r) => Resolution (Fixed INT n s r) where {\ instance FixedPoint INT where {\ fromRawValue = Fixed \ ; toRawValue (Fixed a) = a}; \ -instance (SingI n, SingI s) => HasDoubleRepresentation (Fixed INT n s r) where {\ +instance (SingI n, SingI s, KnownNat n) => HasDoubleRepresentation (Fixed INT n s r) where {\ toDouble = genericToDouble \ ; fromDouble = genericFromDouble}; \ -instance (SingI n, SingI s, SingI r) => Fractional (Fixed INT n s r) where {\ +instance (SingI n, SingI s, SingI r, KnownNat n) => Fractional (Fixed INT n s r) where {\ (/) = genericDiv \ ; fromRational = genericFromRational}; \ -instance (SingI n,SingI s, SingI r) => Real (Fixed INT n s r) where {\ +instance (SingI n,SingI s, SingI r, KnownNat n) => Real (Fixed INT n s r) where {\ toRational = toRational . toDouble }; \ -instance (SingI n, SingI s, SingI r) => RealFrac (Fixed INT n s r) where {\ +instance (SingI n, SingI s, SingI r, KnownNat n) => RealFrac (Fixed INT n s r) where {\ properFraction = genericProperFraction }; \ -instance (SingI n, SingI s, SingI r) => Floating (Fixed INT n s r) where {\ +instance (SingI n, SingI s, SingI r, KnownNat n) => Floating (Fixed INT n s r) where {\ pi = fromDouble pi \ ; exp = fromDouble . exp . toDouble \ ; log = fromDouble . log . toDouble \ @@ -393,7 +403,7 @@ instance (SingI n, SingI s, SingI r) => Floating (Fixed INT n s r) where {\ ; asinh = fromDouble . asinh . toDouble \ ; acosh = fromDouble . acosh . toDouble \ ; atanh = fromDouble . atanh . toDouble}; \ -instance (SingI n, SingI s, SingI r) => RealFloat (Fixed INT n s r) where {\ +instance (SingI n, SingI s, SingI r, KnownNat n) => RealFloat (Fixed INT n s r) where {\ isInfinite = error ("RealFloat has no meaning for a fixed point number and is needed only because of Complex") \ ; isDenormalized = error ("RealFloat has no meaning for a fixed point number and is needed only because of Complex") \ ; isNegativeZero = error ("RealFloat has no meaning for a fixed point number and is needed only because of Complex") \ diff --git a/Generators.hs b/src/Signal/Generators.hs similarity index 63% rename from Generators.hs rename to src/Signal/Generators.hs index 2077fb4..2aec4a7 100644 --- a/Generators.hs +++ b/src/Signal/Generators.hs @@ -1,14 +1,13 @@ {-# LANGUAGE BangPatterns #-} -module Generators( - uniformSamples - , randomSamples - ) where +module Signal.Generators( + uniformSamples + , randomSamples + ) where import Prelude hiding(unfoldr) -import Common -import Internal -import System.Random -import Data.List.Stream +import System.Random +import Signal.Common +import Signal.Internal uniformSamples :: Num a => a -- ^ Sampling period @@ -24,6 +23,6 @@ randomSamples :: (Random a) -> a -> IO (Signal a) randomSamples mi ma = do - g <- newStdGen - let l = randomRs (mi,ma) g - return $ Signal l \ No newline at end of file + g <- newStdGen + let l = randomRs (mi,ma) g + return $ Signal l diff --git a/Internal.hs b/src/Signal/Internal.hs similarity index 67% rename from Internal.hs rename to src/Signal/Internal.hs index 8d0e6c6..a43b8c4 100644 --- a/Internal.hs +++ b/src/Signal/Internal.hs @@ -3,25 +3,25 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleInstances #-} -module Internal( - Signal(..) - , BSignal(..) - , duration - , nbSamples - , Time(..) - , Frequency(..) - , Dual(..) - , DualVal(..) - , samplingRate - , constSignal - , cs - , Sampled(..) - , HasPeriod(..) - , HasSamples(..) - ) where +module Signal.Internal( + Signal(..) + , BSignal(..) + , duration + , nbSamples + , Time(..) + , Frequency(..) + , Dual(..) + , DualVal(..) + , samplingRate + , constSignal + , cs + , Sampled(..) + , HasPeriod(..) + , HasSamples(..) + ) where import Prelude hiding(map,take,length,repeat,zipWith) -import Data.List.Stream +import Data.List import qualified Data.Vector.Unboxed as U import Data.Vector.Unboxed((!),Unbox(..)) import Control.Applicative @@ -35,16 +35,16 @@ type instance Dual Time = Frequency type instance Dual Frequency = Time class DualVal t where - dual :: t -> Dual t - number :: Dual t -> t -> Int + dual :: t -> Dual t + number :: Dual t -> t -> Int instance DualVal Frequency where - dual t = Time (1.0 / getF t) - number (Time t) (Frequency f) = floor (t*f) + dual t = Time (1.0 / getF t) + number (Time t) (Frequency f) = floor (t*f) instance DualVal Time where - dual t = Frequency (1.0 / getT t) - number (Frequency f) (Time t) = floor (t*f) + dual t = Frequency (1.0 / getT t) + number (Frequency f) (Time t) = floor (t*f) duration :: (Num t, Unbox a) => t -> BSignal a -> t duration period bs = fromIntegral (U.length . getSamplesBS $ bs) * period @@ -53,10 +53,10 @@ samplingRate :: (DualVal t) => t -> Dual t samplingRate = dual class HasSamples m t where - nbSamples :: (DualVal t) => m -> t -> Int + nbSamples :: (DualVal t) => m -> t -> Int instance HasSamples (Sampled t a) t where - nbSamples s d = number (rate s) d + nbSamples s d = number (rate s) d --nbSamples :: (Unbox a) => BSignal a -> Int --nbSamples bs@(BSignal s) = U.length s @@ -70,12 +70,12 @@ data Sampled t a = Sampled { samplingPeriod :: !t } class HasPeriod s where - period :: s t a -> t - rate :: DualVal t => s t a -> Dual t + period :: s t a -> t + rate :: DualVal t => s t a -> Dual t instance HasPeriod Sampled where - period s = samplingPeriod s - rate s = dual . samplingPeriod $ s + period s = samplingPeriod s + rate s = dual . samplingPeriod $ s instance Functor (Sampled t) where fmap f (Sampled t s) = Sampled t (fmap f s) @@ -85,8 +85,8 @@ instance Functor (Sampled t) where -- instance Applicative Signal where - pure a = Signal (repeat a) - (Signal f) <*> (Signal l) = Signal $ (zipWith ($) f l) + pure a = Signal (repeat a) + (Signal f) <*> (Signal l) = Signal $ (zipWith ($) f l) constSignal :: a -> Signal a constSignal a = Signal (repeat a) diff --git a/MultiRate.hs b/src/Signal/MultiRate.hs similarity index 72% rename from MultiRate.hs rename to src/Signal/MultiRate.hs index 9e1406f..6b61afa 100644 --- a/MultiRate.hs +++ b/src/Signal/MultiRate.hs @@ -1,11 +1,11 @@ -module MultiRate( - decimateS - , interpolateS - ) where +module Signal.MultiRate( + decimateS + , interpolateS + ) where import Signal -import Internal -import Data.List.Stream +import Signal.Internal +import Data.List.Stream (drop, replicate, (++)) import Prelude hiding(drop, replicate, (++),(:)) decimateS :: Int -> Signal a -> Signal a diff --git a/Noise.hs b/src/Signal/Noise.hs similarity index 95% rename from Noise.hs rename to src/Signal/Noise.hs index 151c53e..5c23f86 100644 --- a/Noise.hs +++ b/src/Signal/Noise.hs @@ -1,7 +1,7 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ConstraintKinds #-} -module Noise( +module Signal.Noise( histogram , Structure(..) , quantizationNoise @@ -9,14 +9,16 @@ module Noise( import qualified Statistics.Sample.Histogram as H import qualified Data.Vector.Unboxed as U -import Plot + import Graphics.PDF -import Common -import Generators -import Signal -import System.Random +import System.Random import Text.Printf +import Signal +import Signal.Plot +import Signal.Common +import Signal.Generators + nbBins = 20 drawHist :: Int diff --git a/Plot.hs b/src/Signal/Plot.hs similarity index 97% rename from Plot.hs rename to src/Signal/Plot.hs index 9a1cd2b..e077280 100644 --- a/Plot.hs +++ b/src/Signal/Plot.hs @@ -7,7 +7,7 @@ {- | Example implementation for displaying signals -} -module Plot( +module Signal.Plot( StyledSignal , SignalStyle(..) , PlotStyle(..) @@ -37,26 +37,31 @@ module Plot( ) where import Graphics.PDF -import Displayable -import Viewer +import Graphics.PDF.Image + +import HaskellViewer.Displayable +import HaskellViewer.Viewer + import Text.Printf import qualified Graphics.PDF as PDF(Orientation(..)) import Control.Monad(when) import Data.Maybe(isJust,fromJust) -import Signal -import Fixed(HasDoubleRepresentation(..)) -import MultiRate import Control.Monad.State.Strict -import qualified Data.Vector.Unboxed.Mutable as M -import qualified Data.Vector.Unboxed as U -import Control.Monad.ST +import qualified Data.Vector.Unboxed.Mutable as M +import qualified Data.Vector.Unboxed as U +import Control.Monad.ST import Control.Monad.Primitive import Data.Word import Data.Bits import Data.List(sortBy,unfoldr,sort) import Data.Function(on) import Data.STRef -import Common + +import Signal +import Signal.Common +import Signal.MultiRate +import Signal.Fixed(HasDoubleRepresentation(..)) + import Debug.Trace debug a = trace (show a) a @@ -465,11 +470,14 @@ data PState = PState { currentColor :: !Color , pixels :: forall s. ST s (STRef s (M.MVector s Word32)) } -data Pixmap a = Pixmap {getPixmap :: State (PState ) a} +data Pixmap a = Pixmap {getPixmap :: State (PState ) a} + +instance Applicative Pixmap where +instance Functor Pixmap where -instance Monad (Pixmap ) where - return = Pixmap . return - (Pixmap a) >>= f = Pixmap (a >>= getPixmap . f) +instance Monad (Pixmap ) where + return = Pixmap . return + (Pixmap a) >>= f = Pixmap (a >>= getPixmap . f) instance MonadState (PState ) (Pixmap ) where get = Pixmap get @@ -506,7 +514,7 @@ runPixmap width height p = mv <- readSTRef refmv U.freeze mv in - createPDFRawImage (fromIntegral width) (fromIntegral height) False $ (result finalState) + createPDFRawImageFromARGB (fromIntegral width) (fromIntegral height) False $ (result finalState) segmentedDraw :: Canvas c => ((a,b) -> Point) diff --git a/SpecialInt.hs b/src/Signal/SpecialInt.hs similarity index 99% rename from SpecialInt.hs rename to src/Signal/SpecialInt.hs index 27847b2..bc1448c 100644 --- a/SpecialInt.hs +++ b/src/Signal/SpecialInt.hs @@ -5,7 +5,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE MultiParamTypeClasses #-} -module SpecialInt( +module Signal.SpecialInt( SuperInt(..) , NumberInfo(..) , BaseValue(..) diff --git a/Spectrogram.hs b/src/Signal/Spectrogram.hs similarity index 85% rename from Spectrogram.hs rename to src/Signal/Spectrogram.hs index 7fe83f8..6fe6a6f 100644 --- a/Spectrogram.hs +++ b/src/Signal/Spectrogram.hs @@ -1,21 +1,24 @@ {-# LANGUAGE ConstraintKinds #-} -module Spectrogram( +module Signal.Spectrogram( spectrogram ) where -import Signal -import Windows import qualified Data.Vector.Unboxed as U import Data.Vector.Unboxed((!)) import Data.Complex import Data.Bits -import Common -import Transform import Graphics.PDF -import Plot + import Control.Applicative((<$>)) import Data.List(foldl1') +import Signal +import Signal.Common +import Signal.Plot +import Signal.Transform +import Signal.Windows + + import Debug.Trace debug a = trace (show a) a @@ -37,7 +40,7 @@ _spectrum n t d = U.map m . fft $ complexd prologSpect l b wi hi Nothing _ = return () -prologSpect l b wi hi (Just r) _ = do +prologSpect l b wi hi (Just r) _ = withNewContext $ do applyMatrix $ translate (l :+ b) drawXObject r @@ -47,17 +50,18 @@ genPicture :: ((Double, Double) -> Double) -> Int -> CoordinateMapping Double Double -> PDF (Maybe (PDFReference RawImage)) -genPicture value w h (plotToPixel, pixelToPlot) = Just <$> do - runPixmap w h $ do - let drawValue p = do - let pl = pixelToPlot p - v = log (1 + value pl) / log 2.0 - col = Rgb v 0 0 - setColor col 1.0 - pixel p - - mapM_ drawValue ( [ fromIntegral col :+ fromIntegral row | col <- [0..w-1], row <- [0..h-1]]) - +genPicture value w h (plotToPixel, pixelToPlot) = Just <$> + (runPixmap w h $ + mapM_ drawValue [ fromIntegral col :+ fromIntegral row | col <- [0..w-1], row <- [0..h-1]]) + where + drawValue p = do + let pl = pixelToPlot p + v = log (1 + value pl) / log 2.0 + col = Rgb v 0 0 + setColor col 1.0 + pixel p + + -- We display only up to sampling frequency / 2 because the spectrum is even. -- So, it allow a zooming a the frequency that matters instead of displaying redudant information spectrogram :: (Sample a, Show a) @@ -108,4 +112,4 @@ spectrogram signal duration window overlap = l=[] :: [[Double]] theFrames = [] :: [Double] in - signalsWithStyle False theFrames l style \ No newline at end of file + signalsWithStyle False theFrames l style diff --git a/TestCases.hs b/src/Signal/TestCases.hs similarity index 97% rename from TestCases.hs rename to src/Signal/TestCases.hs index f5f51ce..a693f56 100644 --- a/TestCases.hs +++ b/src/Signal/TestCases.hs @@ -1,12 +1,12 @@ {-# LANGUAGE DataKinds #-} -module TestCases( - runTests - ) where +module Signal.TestCases( + runTests + ) where import Test.Framework import Test.Framework.Providers.HUnit import Test.HUnit.Base -import SpecialInt +import Signal.SpecialInt import Data.Bits import Data.Word diff --git a/Trace.hs b/src/Signal/Trace.hs similarity index 96% rename from Trace.hs rename to src/Signal/Trace.hs index 535baf8..a8b1875 100644 --- a/Trace.hs +++ b/src/Signal/Trace.hs @@ -3,7 +3,7 @@ {-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE BangPatterns #-} -module Trace( +module Signal.Trace( clearTrace , traceNames , CanBeTraced @@ -13,24 +13,26 @@ module Trace( , forceSignal ) where -import Common(HasDoubleRepresentation(..)) import System.IO.Unsafe import qualified Data.Map as M import Data.IORef import Control.Applicative((<$>)) -import Signal(Signal,mapS,fromListS,takeS) -import Fixed(Resolution(..)) -import Statistics.Sample.KernelDensity -import qualified Data.Vector.Unboxed as U -import Viewer -import Plot -import Graphics.PDF -import Displayable -import Internal +import qualified Data.Vector.Unboxed as U + import Control.DeepSeq import Text.Printf +import Graphics.PDF import qualified Graphics.PDF as PDF +import Statistics.Sample.KernelDensity + +import HaskellViewer.Displayable +import HaskellViewer.Viewer +import Signal(Signal,mapS,fromListS,takeS) +import Signal.Common(HasDoubleRepresentation(..)) +import Signal.Internal +import Signal.Plot +import Signal.Fixed(Resolution(..)) import qualified Debug.Trace as T debug a = T.trace (show a) a @@ -180,4 +182,4 @@ forceSignal :: (NFData a, Show a) -> IO () forceSignal i (Signal s) = do let l = myTake i s - l `deepseq` return () \ No newline at end of file + l `deepseq` return () diff --git a/Transform.hs b/src/Signal/Transform.hs similarity index 93% rename from Transform.hs rename to src/Signal/Transform.hs index 5f461fb..14faf7a 100644 --- a/Transform.hs +++ b/src/Signal/Transform.hs @@ -7,7 +7,7 @@ {-# LANGUAGE TypeOperators #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ConstraintKinds #-} -module Transform( +module Signal.Transform( --spectrum spectrum , testFFT @@ -31,13 +31,14 @@ import Control.Monad(forM_,foldM_,when) import Data.Word import Data.Int import Data.Bits -import Fixed -import Common(Time(..),Frequency(..)) -import Windows -import Signal -import GHC.TypeLits import Foreign.C.Types -import TypeAddition + +import Signal +import Signal.Fixed +import Signal.Common(Time(..),Frequency(..)) +import Signal.Windows +import GHC.TypeLits +import Data.Singletons --import Debug.Trace @@ -140,14 +141,14 @@ _fft n sign vect = do -- Then butterfly 2 for all blocks foldM_ forAllBlocks (1 :+ 0) (filter (< step) [0,1..step]) -mac :: (SingI n, SingI r, SingI (15 + n)) +mac :: (SingI n, SingI r, SingI (15 + n), KnownNat n, KnownNat (15 + n)) => Complex (Fixed Int16 15 Sat r) -> Complex (Fixed Int16 n Sat r) -> Complex (Fixed Int16 n Sat r) -> Complex (Fixed Int32 (15 + n) Sat r) mac w y x = fmap convert x + amulc w y -msb :: (SingI n, SingI r, SingI (15 + n)) +msb :: (SingI n, SingI r, SingI (15 + n), KnownNat n, KnownNat (15 + n)) => Complex (Fixed Int16 15 Sat r) -> Complex (Fixed Int16 n Sat r) -> Complex (Fixed Int16 n Sat r) @@ -155,7 +156,7 @@ msb :: (SingI n, SingI r, SingI (15 + n)) msb w y x = fmap convert x - amulc w y -_fftFixed :: (SingI n, SingI r, SingI (15 + n)) +_fftFixed :: (SingI n, SingI r, SingI (15 + n), KnownNat n, KnownNat (15 + n)) => Int -- ^ Power of 2 -> Int -> M.MVector s (Complex (Fixed Int16 n Sat r)) @@ -218,7 +219,7 @@ class FFT a where instance FFT Double -instance (SingI n, SingI r, SingI (15 + n)) => FFT (Fixed Int16 n Sat r) where +instance (SingI n, SingI r, SingI (15 + n), KnownNat n, KnownNat (15 + n)) => FFT (Fixed Int16 n Sat r) where fft = genericfft False _fftFixed ifft = genericfft True _fftFixed @@ -226,4 +227,4 @@ testFFT :: (FFT a,Sample a) => Int -> Signal a -> U.Vector (Complex Double) testFFT n s = U.map (fmap toDouble) . fft . toVectorBS . mapBS (:+ 0) . takeVectorS n $ s testFFT1 :: Sample a => Int -> Signal a -> U.Vector (Complex Double) -testFFT1 n s = U.convert . F.fft . U.convert . toVectorBS . mapBS ((:+ 0) . toDouble) . takeVectorS n $ s \ No newline at end of file +testFFT1 n s = U.convert . F.fft . U.convert . toVectorBS . mapBS ((:+ 0) . toDouble) . takeVectorS n $ s diff --git a/VAD.hs b/src/Signal/VAD.hs similarity index 85% rename from VAD.hs rename to src/Signal/VAD.hs index 44897c4..3bedb74 100644 --- a/VAD.hs +++ b/src/Signal/VAD.hs @@ -5,7 +5,7 @@ {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FunctionalDependencies #-} -module VAD( +module Signal.VAD( vad ) where @@ -14,20 +14,23 @@ module VAD( -- import Prelude hiding(splitAt,(:),foldr1,tail,(++)) -import Internal -import Signal import qualified Data.Vector.Unboxed as U import Data.Vector.Unboxed((!),Unbox(..)) -import Data.List.Stream -import Common -import Windows -import Data.Complex -import Transform -import qualified Trace as F -import Fixed +import Data.List.Stream(tail, foldr1, foldl1', splitAt, (++)) +import Data.Complex + import GHC.TypeLits -import SpecialInt -import Data.Int +import Data.Int + +import Signal +import Signal.Common +import Signal.Fixed +import Signal.Internal +import Signal.SpecialInt +import qualified Signal.Trace as F +import Signal.Transform +import Signal.Windows +import Data.Singletons ltseF :: Sample a => Int @@ -53,7 +56,7 @@ lstdD winSize noiseEnergy lste = in 10 * log(U.sum (U.zipWith (d) lste noiseEnergy) / fromIntegral winSize) / log 10 -theTotal :: (SingI r, SingI s, SingI n) +theTotal :: (SingI r, SingI s, SingI n, KnownNat n) => Fixed Int32 n s r -> U.Vector (Fixed Int32 n s r) -> U.Vector (Fixed Int32 n s r) @@ -65,14 +68,14 @@ theTotal m lste noiseEnergy = U.sum (U.zipWith (d) lste noiseEnergy) {-# INLINE [0] theTotal #-} -lstdF :: (SingI n, SingI s, SingI r) +lstdF :: (SingI n, SingI s, SingI r, KnownNat n) => Int -> U.Vector (Fixed Int32 n s r) -> U.Vector (Fixed Int32 n s r) -> (Fixed Int32 n s r) lstdF winSize noiseEnergy lste = 10 * log(convert $ theTotal maxBound lste noiseEnergy/ fromIntegral winSize) / log 10 -getDecisionF :: (SingI n, SingI s, SingI r, SingI (n + n)) +getDecisionF :: (SingI n, SingI s, SingI r, SingI (n + n), KnownNat n, KnownNat (n + n)) => Int -> U.Vector (Fixed Int32 (n + n) s r) -> [(U.Vector (Fixed Int32 (n + n) s r), U.Vector (Fixed Int32 (n + n) s r) )] @@ -106,7 +109,7 @@ getDecisionD winSize energy [] = 0:getDecisionD winSize energy [] bandEnergy :: Complex Double -> Double bandEnergy (x :+ y) = x*x + y*y -bandEnergyF :: (SingI n, SingI s, SingI r, SingI (n + n)) => Complex (Fixed Int16 n s r) -> Fixed Int32 (n + n) s r +bandEnergyF :: (SingI n, SingI s, SingI r, SingI (n + n), KnownNat (n + n)) => Complex (Fixed Int16 n s r) -> Fixed Int32 (n + n) s r bandEnergyF (x :+ y) = amul x x + amul y y class VAD a where @@ -114,7 +117,7 @@ class VAD a where => Sampled Time a -> Sampled Time a -instance (SingI n, SingI s, SingI r, SingI (n + n)) => VAD (Fixed Int16 n s r) where +instance (SingI n, SingI s, SingI r, KnownNat n, SingI (n + n), KnownNat (n+n)) => VAD (Fixed Int16 n s r) where vad s = let winSize = 256 overlap = 20 diff --git a/Windows.hs b/src/Signal/Windows.hs similarity index 97% rename from Windows.hs rename to src/Signal/Windows.hs index 9879515..9efec0f 100644 --- a/Windows.hs +++ b/src/Signal/Windows.hs @@ -1,5 +1,5 @@ {-# LANGUAGE ConstraintKinds #-} -module Windows( +module Signal.Windows( hann , noWindow , hamming @@ -13,10 +13,10 @@ module Windows( ) where import Prelude hiding(splitAt,(++),concat,zipWith,concatMap,null,head,take) -import Common +import Signal.Common import Signal -import Internal -import Data.List.Stream +import Signal.Internal +import Data.List.Stream (take, null) import qualified Data.Vector.Unboxed as U import Data.Vector.Unboxed((!),Unbox(..)) diff --git a/stack.yaml b/stack.yaml new file mode 100644 index 0000000..3bca351 --- /dev/null +++ b/stack.yaml @@ -0,0 +1,23 @@ +resolver: lts-6.4 +packages: + +- . +#- ../stream-fusion +- location: + git: git@github.com:tolysz/stream-fusion.git + commit: e0bb1f7164ab03f936198fb69c395493572f030c +#- ../HaskellViewer +- location: + git: git@github.com:tolysz/HaskellViewer.git + commit: 4b951aaeb3bf8a322c634154aedc898b4d8a1285 + +extra-deps: +- WAVE-0.1.3 +- polynomial-0.7.2 + +allow-newer: true + +flags: {} + +extra-package-dbs: [] +