module Sound.MIDI.Example.ControllerRamp where
import qualified Sound.MIDI.File as MidiFile
import qualified Sound.MIDI.File.Save as Save
import qualified Sound.MIDI.File.Event as Event
import qualified Sound.MIDI.Message.Channel as ChannelMsg
import qualified Sound.MIDI.Message.Channel.Voice as VoiceMsg
import qualified Data.EventList.Relative.TimeBody as EventList
import qualified Data.ByteString.Lazy as B
example :: MidiFile.T
example :: T
example =
let chan :: Channel
chan = ControllerValue -> Channel
ChannelMsg.toChannel ControllerValue
0
in Type -> Division -> [Track] -> T
MidiFile.Cons Type
MidiFile.Parallel (Tempo -> Division
MidiFile.Ticks Tempo
10)
[forall a b. [(a, b)] -> T a b
EventList.fromPairList forall a b. (a -> b) -> a -> b
$
forall a b. (a -> b) -> [a] -> [b]
map (\ControllerValue
x -> (ElapsedTime
50, T -> T
Event.MIDIEvent (Channel -> Body -> T
ChannelMsg.Cons Channel
chan (T -> Body
ChannelMsg.Voice (T -> ControllerValue -> T
VoiceMsg.Control T
VoiceMsg.mainVolume ControllerValue
x)))))
[ControllerValue
0..ControllerValue
127]]
main :: IO ()
main :: IO ()
main =
FilePath -> ByteString -> IO ()
B.writeFile FilePath
"controller-ramp.mid"
(T -> ByteString
Save.toByteString T
example)