supercollider-midi 0.1.1 → 0.1.3
raw patch · 3 files changed
+51/−47 lines, 3 filesdep +data-accessor-transformersdep +opensoundcontrol-htdep +transformersdep −mtldep ~arraydep ~basedep ~containers
Dependencies added: data-accessor-transformers, opensoundcontrol-ht, transformers
Dependencies removed: mtl
Dependency ranges changed: array, base, containers, data-accessor, event-list, hosc, hsc3, midi, non-negative, random, supercollider-ht
Files
- src/Sound/SC3/MIDI/Keyboard.hs +19/−21
- src/Sound/SC3/MIDI/Wind.hs +5/−6
- supercollider-midi.cabal +27/−20
src/Sound/SC3/MIDI/Keyboard.hs view
@@ -10,43 +10,42 @@ import qualified Sound.OpenSoundControl.Transport.Monad as Trans import qualified Sound.SC3.Server.PlayEasy as SCPlay-import Sound.OpenSoundControl.Transport.Monad- (Transport, send, ) import qualified Sound.ALSA.Sequencer as AlsaMidi import qualified Sound.MIDI.Message.Channel as ChannelMsg import qualified Sound.MIDI.Message.Channel.Voice as VoiceMsg import Data.Array (Array, array, listArray, (!), )-import Data.Map (Map)+import Data.Map (Map, ) import qualified Data.Array as Array import qualified Data.Map as Map -import Control.Monad.State (StateT, evalStateT, lift, )+import Control.Monad.Trans.State (StateT, evalStateT, )+import Control.Monad.Trans.Class (lift, ) import System.Random (randomRs, mkStdGen, ) +import qualified Data.Accessor.Monad.Trans.State as AccState import qualified Data.Accessor.Container as AccCntn-import qualified Data.Accessor.MonadState as AccState import qualified Data.Accessor.Basic as Accessor import Data.Accessor.Basic ((.>)) -import Data.List (lookup, genericLength, )+import Data.List (genericLength, ) import Data.Maybe (mapMaybe, fromMaybe, ) frequency :: UGen frequency = 440 *- 2 ** ((Control KR "Pitch" 0 + Control KR "PitchBend" 0 * 2 + 3 - 72) / 12) *- (1 + (Control KR "Modulation" 0 + Control KR "Aftertouch" 0) * sinOsc KR 10 0)+ 2 ** ((control KR "Pitch" 0 + control KR "PitchBend" 0 * 2 + 3 - 72) / 12) *+ (1 + (control KR "Modulation" 0 + control KR "Aftertouch" 0) * sinOsc KR 10 0) soundPing :: UGen soundPing = sinOsc AR (2*frequency) 0 * xLine KR 1 0.1 1 PauseSynth *- 0.25 * 4 ** Control KR "Velocity" 0+ 0.25 * 4 ** control KR "Velocity" 0 programPing :: ProgramSound programPing = ProgramSound "Ping" soundPing 2@@ -60,7 +59,7 @@ soundString :: UGen soundString = let n = 5- volume = 0.25 * 4 ** Control KR "Velocity" 0 / sqrt (fromIntegral n)+ volume = 0.25 * 4 ** control KR "Velocity" 0 / sqrt (fromIntegral n) detunes = normalizeLevel 1 $ take (2*n) $ randomRs (0,0.03) $ mkStdGen 912@@ -211,10 +210,10 @@ Initialize SuperCollider in a way that all sounds are written to output buffer 0 and are simply mixed. -}-initSeparate :: Transport t => Trans.IO t ()+initSeparate :: Trans.C m => m () initSeparate =- mapM- (\p -> Trans.send (SCPlay.d_recv' (programName p) (out 0 (programUGen p))))+ mapM_+ (\p -> Trans.send (SCPlay.d_recv_synthdef (programName p) (out 0 (programUGen p)))) (Array.elems programSounds) >> (Trans.send $ g_new $ map@@ -247,10 +246,10 @@ You must provide a UGen which puts these buffers together. This can be simple mixing, but you can also apply effects to the partial sounds. -}-initEffect :: Transport t => Trans.IO t ()+initEffect :: Trans.C m => m () initEffect =- do mapM- (\p -> Trans.send (SCPlay.d_recv' (programName p)+ do mapM_+ (\p -> Trans.send (SCPlay.d_recv_synthdef (programName p) (out (Constant $ fromIntegral $ programBuffer p) (programUGen p)))) (Array.elems programSounds) @@ -262,18 +261,17 @@ (const (Trans.wait "/done" >> return ())) (Array.elems programSounds) - SCPlay.simpleSync $ SCPlay.d_recv' "Effect" $ out 0 effectUGen+ SCPlay.simpleSync $ SCPlay.d_recv_synthdef "Effect" $ out 0 effectUGen Trans.send $ s_new "Effect" effectNodeId AddToTail SCPlay.homeId [] main :: IO () main = do- withSC3 reset- SCPlay.withSC3 initEffect+ SCPlay.withSC3 $ SCPlay.reset >> initEffect - putStrLn "use 'pmidi -l' to find out the ports from where note messages can be received"- putStrLn "and connect the source with this program using 'aconnect'"+ putStrLn "use 'aconnect -i' to find out the ports from where note messages can be received"+ putStrLn "and connect the source with this program using 'aconnect' or 'patchage' or 'alsa-patch-bay'" AlsaMidi.withEvents "supercollider-midi" "supercollider-midi-listen" $ \ ll -> flip evalStateT
src/Sound/SC3/MIDI/Wind.hs view
@@ -3,23 +3,22 @@ import Sound.OpenSoundControl import Sound.SC3 as SC3-import Sound.SC3.UGen.Noise.Base as Noise+import Sound.SC3.UGen.Noise.ID as Noise import qualified Sound.ALSA.Sequencer as AlsaMidi import qualified Sound.MIDI.Message.Channel as ChannelMsg import qualified Sound.MIDI.Message.Channel.Voice as VoiceMsg -import Data.List (lookup) import Data.Maybe (mapMaybe, fromMaybe, ) sound :: UGen sound = out 0 (delayN (0.2 * rlpf- (Noise.whiteNoise (UGenId 0) AR * Control KR "Volume" 1)- (Control KR "Frequency" 400)- (Control KR "Resonance" 0.005))- 0 (MCE [0, Control KR "Phase" 0]))+ (Noise.whiteNoise (0::Int) AR * control KR "Volume" 1)+ (control KR "Frequency" 400)+ (control KR "Resonance" 0.005))+ 0 (MCE [0, control KR "Phase" 0])) controlChange :: String -> (Double -> Double) -> Int -> IO () controlChange ctrlName f value =
supercollider-midi.cabal view
@@ -1,11 +1,11 @@ Name: supercollider-midi-Version: 0.1.1+Version: 0.1.3 License: GPL License-File: LICENSE Author: Henning Thielemann <haskell@henning-thielemann.de> Maintainer: Henning Thielemann <haskell@henning-thielemann.de> Homepage: http://www.haskell.org/haskellwiki/SuperCollider-Package-URL: http://darcs.haskell.org/supercollider-midi/+Package-URL: http://code.haskell.org/~thielema/supercollider-midi/ Category: Sound Build-Type: Simple Synopsis: Demonstrate how to control SuperCollider via ALSA-MIDI@@ -18,7 +18,7 @@ which will be played upon MIDI messages that arrive through ALSA. This way you can play MIDI files using @pmidi@ or you can use your computer as MIDI expander controlled by a keyboard.-Tested-With: GHC==6.8.2+Tested-With: GHC==6.8.2, GHC==6.10.4, GHC==6.12.3 Cabal-Version: >=1.2 Build-Type: Simple @@ -27,20 +27,27 @@ Executable sc-keyboard If flag(splitBase)- Build-Depends: base >= 2, array >=0.1 && <0.2, containers >=0.1 && <0.2, random >=1.0 && <1.1+ Build-Depends:+ array >=0.1 && <0.4,+ containers >=0.1 && <0.5,+ random >=1.0 && <2.0,+ base >=2 && <5 Else- Build-Depends: base >= 1.0 && < 2+ Build-Depends:+ base >=1.0 && <2 Build-Depends:- supercollider-ht >=0.0 && <0.1,- hsc3 >=0.1 && <0.2,- hosc >=0.1 && <0.2,+ supercollider-ht >=0.1 && <0.2,+ opensoundcontrol-ht >=0.1 && <0.2,+ hsc3 >=0.8 && <0.9,+ hosc >=0.8 && <0.9, alsa-midi >=0.4 && <0.5,- midi >=0.1 && <0.2,- event-list >=0.0.6 && <0.1,- non-negative >=0.0.1 && <0.1,- data-accessor >=0.1.3 && <0.2,- mtl >=1 && <2+ midi >=0.1.3 && <0.2,+ event-list >=0.0.6 && <0.2,+ non-negative >=0.0.1 && <0.2,+ data-accessor-transformers >=0.2 && <0.3,+ data-accessor >=0.2 && <0.3,+ transformers >=0.2 && <0.3 Hs-source-dirs: src GHC-Options: -Wall -threaded@@ -48,17 +55,17 @@ Executable sc-wind If flag(splitBase)- Build-Depends: base >= 2+ Build-Depends: base >=2 Else- Build-Depends: base >= 1.0 && < 2+ Build-Depends: base >=1.0 && <2 Build-Depends:- hsc3 >=0.1 && <0.2,- hosc >=0.1 && <0.2,+ hsc3 >=0.8 && <0.9,+ hosc >=0.8 && <0.9, alsa-midi >=0.4 && <0.5,- midi >=0.1 && <0.2,- event-list >=0.0.6 && <0.1,- non-negative >=0.0.1 && <0.1+ midi >=0.1.3 && <0.2,+ event-list >=0.0.6 && <0.2,+ non-negative >=0.0.1 && <0.2 Hs-source-dirs: src GHC-Options: -Wall -threaded