module Sound.MIDI.Example.ControllerRamp {- Main -} 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 = Int -> Channel
ChannelMsg.toChannel Int
0
   in  Type -> Division -> [Track] -> T
MidiFile.Cons Type
MidiFile.Parallel (Tempo -> Division
MidiFile.Ticks Tempo
10)
          [[(ElapsedTime, T)] -> Track
forall a b. [(a, b)] -> T a b
EventList.fromPairList ([(ElapsedTime, T)] -> Track) -> [(ElapsedTime, T)] -> Track
forall a b. (a -> b) -> a -> b
$
           (Int -> (ElapsedTime, T)) -> [Int] -> [(ElapsedTime, T)]
forall a b. (a -> b) -> [a] -> [b]
map (\Int
x -> (ElapsedTime
50, T -> T
Event.MIDIEvent (Channel -> Body -> T
ChannelMsg.Cons Channel
chan (T -> Body
ChannelMsg.Voice (T -> Int -> T
VoiceMsg.Control T
VoiceMsg.mainVolume Int
x)))))
               [Int
0..Int
127]]

main :: IO ()
main :: IO ()
main =
   FilePath -> ByteString -> IO ()
B.writeFile FilePath
"controller-ramp.mid"
      (T -> ByteString
Save.toByteString T
example)