packages feed

synthesizer-llvm-0.7: alsa/Synthesizer/LLVM/Server/Scalar/Test.hs

module Synthesizer.LLVM.Server.Scalar.Test where

import qualified Synthesizer.LLVM.Server.Scalar.Instrument as Instr
import qualified Synthesizer.LLVM.Server.Option as Option
import Synthesizer.LLVM.Server.Scalar.Run (withMIDIEvents, )
import Synthesizer.LLVM.Server.ALSA (record, put, makeNote, )
import Synthesizer.LLVM.Server.Common

import qualified Sound.ALSA.Sequencer.Event as Event
import qualified Synthesizer.MIDI.PiecewiseConstant as PC
import qualified Synthesizer.MIDI.Generic as Gen

import qualified Synthesizer.LLVM.CausalParameterized.Process as CausalP
import qualified Synthesizer.LLVM.Parameterized.Signal as SigP
import qualified Synthesizer.LLVM.Wave as WaveL
import Synthesizer.LLVM.Causal.Process (($<#), ($*), )

import qualified Synthesizer.Storable.Cut         as CutSt
import qualified Synthesizer.Storable.Signal      as SigSt
import qualified Data.StorableVector.Lazy         as SVL

import qualified Data.EventList.Relative.TimeBody  as EventList

import Control.Arrow (arr, )
import Control.Monad.Trans.State (evalState, )

import NumericPrelude.Numeric (zero, )
import Prelude hiding (Real, )


sampleRate :: Real
sampleRate =
   Option.defaultSampleRate


pitchBend0 :: IO ()
pitchBend0 = do
   osc <-
      SigP.runChunky
         ((CausalP.osciSimple WaveL.triangle $<# (zero::Real))
             $* piecewiseConstant (arr id))
   SVL.writeFile "test.f32" $
      (id :: SigSt.T Real -> SigSt.T Real) .
      osc Option.defaultChunkSize .
      evalState (PC.pitchBend Option.defaultChannel 2 (880/sampleRate)) $
      let evs = EventList.cons 100 [] evs
      in  EventList.cons 0 ([]::[Event.T]) evs

pitchBend1 :: IO ()
pitchBend1 = do
   opt <- Option.get
   osc <-
      SigP.runChunky
         ((CausalP.osciSimple WaveL.triangle $<# (zero::Real))
             $* piecewiseConstant (arr id))
   withMIDIEvents opt (record "test.f32") $ \ _size _rate ->
      (id :: SigSt.T Real -> SigSt.T Real) .
      osc Option.defaultChunkSize .
      evalState (PC.pitchBend Option.defaultChannel 2 (880/sampleRate))

pitchBend2 :: IO ()
pitchBend2 = do
   opt <- Option.get
   withMIDIEvents opt put $ \ _size _rate -> id



sequencePress :: IO ()
sequencePress = do
--   arrange <- SigStL.makeArranger
--   sound <- Instr.softString
--   sound <- Instr.softStringReleaseEnvelope
--   sound <- Instr.pingReleaseEnvelope $/ 1 $/ Option.defaultChunkSize
--   sound <- Instr.pingDur
--   sound <- Instr.pingDurTake
   let sound = Instr.dummy Option.defaultChunkSize (SampleRate sampleRate)
   SVL.writeFile "test.f32" $
      CutSt.arrange Option.defaultChunkSize $
      evalState
         (do Gen.sequence Option.defaultChannel sound) $
      let evs t =
             EventList.cons t [makeNote Event.NoteOn  60] $
             EventList.cons t [makeNote Event.NoteOff 60] $
             evs (20-t)
      in  evs 10