packages feed

conductive-hsc3 0.1.1 → 0.2

raw patch · 4 files changed

+95/−163 lines, 4 filesdep +directorydep +filepathdep −MissingHdep ~basedep ~conductive-basedep ~conductive-song

Dependencies added: directory, filepath

Dependencies removed: MissingH

Dependency ranges changed: base, conductive-base, conductive-song, containers, hosc, hsc3, random

Files

Sound/Conductive/HSC3Utilities.hs view
@@ -5,7 +5,9 @@  ------------------------------------------------------------------------------ -module Sound.Conductive.HSC3Utilities where+module Sound.Conductive.HSC3Utilities +( defaultSCGroup+) where  import Sound.OpenSoundControl import Sound.SC3
− Sound/Conductive/Sampler.hs
@@ -1,141 +0,0 @@----------------------------------------------------------------------------------- Sampler.hs--- created: Sat Oct  2 01:10:27 JST 2010----------------------------------------------------------------------------------module Sound.Conductive.Sampler where--import Control.Concurrent.MVar-import Data.List-import qualified Data.Map as M-import Sound.Conductive.ConductiveBaseData-import Sound.Conductive.Generator-import Sound.Conductive.MiscListUtils-import Sound.Conductive.MusicalEnvironment-import Sound.Conductive.MVarUtils-import Sound.Conductive.Player-import Sound.Conductive.Table-import Sound.OpenSoundControl-import Sound.SC3-import System.Path.Glob-import System.Path.NameManip--data SamplerData = SamplerData-    { sampleNames :: [String]-    , sampleParameters :: MVar (M.Map [Char] Double)-    , samplerSample :: MVar (M.Map [Char] [Char])-    }--getSampleParameters-  :: SamplerData -> IO (M.Map [Char] Double)-getSampleParameters sd = wm (sampleParameters sd) id--getSamplerSamples :: SamplerData -> IO (M.Map [Char] [Char])-getSamplerSamples sd = wm (samplerSample sd) id--showSampler :: SamplerData -> IO ()-showSampler sd = let-    columns = ["sampler","sample","amp","pitch"]-    in do ss <- getSamplerSamples sd-          sp <- getSampleParameters sd-          let c1 = M.keys ss-          let c2 = M.elems ss-          let ampKeys = filter ("amp" `isSuffixOf`) $ M.keys sp-          let pKeys = filter ("pitch" `isSuffixOf`) $ M.keys sp-          let c3 = map show $ map (\x -> M.findWithDefault 0 x sp) ampKeys-          let c4 = map show $ map (\x -> M.findWithDefault 0 x sp) pKeys-          asciiTable columns "=" [c1,c2,c3,c4] "   "--loader :: (String, Int) -> IO OSC-loader (s,n) = do withSC3 (\fd -> async fd (b_allocRead n s 0 0))--sampleDef :: (String, Double) -> IO OSC-sampleDef (defName,buf) =-    let r = bufRateScale KR 10-        p = control IR "p" 1-        a = control IR "a" 1-        b1 = control IR "b1" 0-        a1 = tr_control "a1" 0-        e = envGen KR 1 1 0 1 RemoveSynth $ envPerc 0.001 1-        samplePlayer r = (playBuf 1 (Constant buf) r a1 0 NoLoop RemoveSynth)-        sampleOut = (out b1 $ (samplePlayer $ mce [p,p*1.01]) * a * e)-        i fd = do async fd (d_recv (synthdef defName sampleOut))-    in withSC3 i--loadSounds :: Int -> FilePath -> IO [String]-loadSounds startingBuffer dir = -    let buffersNNames sb ss = zip ss [sb..sb + length ss]-        name (p,n,e) = n-    in do files <- glob dir-          let b = buffersNNames startingBuffer files-          mapM loader b-          let defNames = map name $ map split3 files-          let bs = map fromIntegral [startingBuffer..startingBuffer + length defNames]-          let defNamesNBuffers = zip defNames bs-          mapM sampleDef defNamesNBuffers-          return defNames--playSample :: String -> Double -> Double -> IO ()-playSample defName a p =-    let parameters = [("a",a)-                     ,("p",p)-                      ]-    in withSC3 (\fd -> send fd (s_new defName (-1) AddToTail 1 parameters))--playSampleWithPs :: SamplerData -> [Char] -> IO ()-playSampleWithPs sd p = do-    sAmp <- wm (sampleParameters sd) $ M.findWithDefault 0 (p ++ "-amp")-    sPitch <- wm (sampleParameters sd) $ M.findWithDefault 0 (p ++ "-pitch")-    sampleName <- wm (samplerSample sd) $ M.findWithDefault "" p-    playSample sampleName sAmp sPitch--addPlaySampleAction-  :: SamplerData-     -> MVar MusicalEnvironment-     -> String-     -> IO MusicalEnvironment-addPlaySampleAction sd e p = addAction e (p,(\env pla -> playSampleWithPs sd p))--defaultParameters-  :: (Fractional t) => [Char] -> IO (MVar (M.Map [Char] t))-defaultParameters n = newMVar $ M.fromList [(n++"-amp",1.0),(n++"-pitch",1.0)]--addDefaultParameters-  :: (Fractional t) =>-     MVar (M.Map [Char] t)-     -> [Char]-     -> IO (M.Map [Char] t)-addDefaultParameters sp n = do-    wcm sp $ M.insert (n++"-amp") 1.0-    wcm sp $ M.insert (n++"-pitch") 1.0--initializeSamplePlayers-  :: SamplerData -> MVar MusicalEnvironment -> IO ()-initializeSamplePlayers sd e = do-    ss <- getSamplerSamples sd-    let ns = map fst $ M.toList ss-    let ap (s1,s2) = addNewPlayer e (s1,("default","defaultIOI",s2,0))-    mapM_ ap $ zip ns ns---- initialization loads sounds starting from scserver buffer 10--initializeSampler-  :: FilePath -> MVar MusicalEnvironment -> IO SamplerData-initializeSampler dir e = let-    startingBuffer = 10-    in do s <- loadSounds startingBuffer dir-          let sNames = map (\x -> "sampler"++x) $ map show [1..length s]-          psm <- newMVar $ M.fromList $ zip sNames s-          sp <- newMVar $ (M.empty :: (M.Map [Char] Double))-          let sd = SamplerData { sampleNames = s-                               , sampleParameters = sp-                               , samplerSample = psm-                               }-          mapM_ (addDefaultParameters (sampleParameters sd)) sNames-          mapM_ (addPlaySampleAction sd e) sNames-          initializeSamplePlayers sd e-          return sd---- changeParameter sd parameter newValue = wcm (sampleParameters sd) $ insert parameter newValue
Sound/Conductive/Synths.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------------  -- Synths.hs--- created: Sat Oct  2 00:49:51 JST 2010+-- created: Sun Sep  2 00:39:11 JST 2012  ------------------------------------------------------------------------------ @@ -13,12 +13,12 @@ import Data.Map import Data.Maybe import Sound.Conductive.ConductiveBaseData-import Sound.Conductive.Generator import Sound.Conductive.MusicalEnvironment import Sound.Conductive.Pitch import Sound.Conductive.Scale import Sound.OpenSoundControl import Sound.SC3+import Sound.SC3.ID hiding (brownNoise) import Sound.SC3.Monadic import System.Random hiding (next) @@ -147,20 +147,20 @@              ]     in withSC3 (\fd -> send fd (s_new "solo1" (-1) AddToTail 1 ps)) -playSolo1 :: MVar MusicalEnvironment -> t -> IO ()-playSolo1 e p = do -    let pg param = getDoubleGenerator e param-    fG   <- pg "soloFreq"-    fmG  <- pg "soloFMod"-    amG  <- pg "soloAMod"-    attG <- pg "soloAttack"-    durG <- pg "soloDur"-    f   <- next fG-    fm  <- next fmG-    am  <- next amG-    att <- next attG-    dur <- next durG-    solo1 (floor f) fm am att dur+-- playSolo1 :: MVar MusicalEnvironment -> t -> IO ()+-- playSolo1 e p = do +--     let pg param = getDoubleGenerator e param+--     fG   <- pg "soloFreq"+--     fmG  <- pg "soloFMod"+--     amG  <- pg "soloAMod"+--     attG <- pg "soloAttack"+--     durG <- pg "soloDur"+--     f   <- next fG+--     fm  <- next fmG+--     am  <- next amG+--     att <- next attG+--     dur <- next durG+--     solo1 (floor f) fm am att dur  subKickDef :: Int -> IO () subKickDef n = let@@ -186,3 +186,74 @@                                                        ,("f1",freq)                                                        ,("d1",dur)                                                        ,("amp",0.5)]))+------------------------------------------------------------------------------+-- trying a method for defining synths++defineSynth :: UGen -> String -> IO OSC+defineSynth func synthName = withSC3 i where+    o = out 0 func+    i fd = do async fd (d_recv (synthdef synthName o))++playSynth :: [(String, Double)] -> String -> IO ()+playSynth ps synthName = withSC3 (\fd -> send fd (s_new synthName (-1) AddToTail 1 ps))++pingDef2 :: IO OSC+pingDef2 = defineSynth (sinOsc AR (mce [(midiCPS f),(midiCPS $ f*1.005)]) 0 * e) "ping2" where+    f = control IR "f" 440+    d = control IR "d" 1+    p = envPerc 0.01 d+    e = envGen KR 1 0.1 0 1 RemoveSynth p++ping2 :: Double -> Double -> IO ()+ping2 freq dur = playSynth ps "ping2" where+    ps = [("f",freq)+         ,("d",dur)+         ]++pmTestDef :: IO OSC+pmTestDef = defineSynth (pmOsc AR f (mf * 10000) (pm * 10000) 0 * a * e) "pmTest" where+    att = control IR "att" 0.05+    cf = control IR "f" 60+    a = control IR "a" 0.5+    d = control IR "d" 1+    mf = control IR "mf" 0 +    pm'= control IR "pm" 0+    pm = line KR 0 pm' 9 DoNothing +    p = envPerc att d+    e = envGen KR 1 (1*a) 0 1 RemoveSynth p+    f = mce [(midiCPS cf),(midiCPS cf)*1.005]++pmTest :: Double -> Double -> Double -> Double -> Double -> Double -> IO ()+pmTest attack freq amp modFreq modAmp dur = playSynth ps "pmTest" where+    ps = [("att",attack)+          ,("f",freq)+          ,("a",amp)+          ,("mf",modFreq)+          ,("pm",modAmp)+          ,("d",dur)+          ]++rudeBassDef :: IO OSC+rudeBassDef = defineSynth sumSynths "rudeBass" where+    att = control IR "att" 0.05+    cf = midiCPS $ control IR "f" 60+    a = control IR "a" 0.5+    d = control IR "d" 1+    mf = control IR "mfscalar" 0 +    m = line KR cf (cf * mf) d DoNothing+    p = envPerc att d+    e = envGen KR 1 (1 * a) 0 1 RemoveSynth p+    flavorBass = syncSaw AR (mce [cf,cf*1.01] ) m * 0.1 * e+    sinSubBass = (sinOsc AR (mce [(cf * 0.5),(cf * 1.005 * 0.5)]) 0 * e)+    ff = mouseX KR 2 (cf*50) Exponential 0.1+    sumSynths = lpf (flavorBass + sinSubBass) ff++rudeBass :: Double -> Double -> Double -> Double -> Double -> IO ()+rudeBass attack freq amp modS dur = playSynth ps "rudeBass" where+    ps = [("att",attack)+          ,("f",freq)+          ,("a",amp)+          ,("mfscalar",modS)+          ,("d",dur)+          ]+
conductive-hsc3.cabal view
@@ -7,13 +7,13 @@ -- The package version. See the Haskell package versioning policy -- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for -- standards guiding when and how versions should be incremented.-Version:             0.1.1+Version:             0.2  -- A short (one-line) description of the package. Synopsis:            a library with examples of using Conductive with hsc3  -- A longer description of the package.-Description:         This library contains examples of using Conductive with hsc3. Sythndefs and convenience functions exist for a sampler and an FM synth.+Description:         This library contains examples of using Conductive with hsc3.   -- URL for the project homepage or repository. Homepage:            http://www.renickbell.net/doku.php?id=conductive-hsc3@@ -45,15 +45,15 @@ -- Extra-source-files:    -- Constraint on the version of Cabal needed to build this package.-Cabal-version:       >=1.4+Cabal-version:       >=1.6   Library   -- Modules exported by the library.-  Exposed-modules:     Sound.Conductive.Sampler, Sound.Conductive.HSC3Utilities, Sound.Conductive.Synths+  Exposed-modules:     Sound.Conductive.HSC3Utilities, Sound.Conductive.Synths      -- Packages needed in order to build this package.-  Build-depends:       base < 5, conductive-base >= 0.1 && < 0.3, conductive-song >=0.1 && < 0.2, containers >=0.3 && < 0.4, hosc >=0.8 && < 0.9, hsc3 >=0.8 && < 0.9, MissingH >= 1.1 && < 1.2 , random >= 1.0 && < 1.1+  Build-depends:       base == 4.*, conductive-base >= 0.3, conductive-song >=0.2, containers, directory, filepath, hosc, hsc3, random       -- Modules not exported by this package.   -- Other-modules: