alsa-gui-0.0: src/mode.hs
module Main where
import Common
import qualified Sound.MIDI.Message.Channel.Mode as Mode
import qualified Sound.MIDI.Message.Channel as ChannelMsg
import qualified Sound.MIDI.ALSA as MidiAlsa
import qualified Sound.ALSA.Sequencer.Event as Event
import qualified Sound.ALSA.Sequencer as SndSeq
import Graphics.UI.WX
(Prop((:=)), set, get, selection, command, on,
button, close, container, hfloatCentre, widget,
layout, margin, column, spinCtrl, text, )
import qualified Graphics.UI.WX as WX
makeGUI :: Sequencer SndSeq.OutputMode -> IO ()
makeGUI sequ = do
f <- WX.frame [text := "MIDI Mode"]
p <- WX.panel f []
allNotesOff <- button p [text := "All Notes Off"]
allSoundOff <- button p [text := "All Sound Off"]
chan <- spinCtrl p 0 15 []
let getChan = fmap ChannelMsg.toChannel $ get chan selection
set allNotesOff [
on command := getChan >>=
\c -> sendMode sequ c Mode.AllNotesOff
]
set allSoundOff [
on command := getChan >>=
\c -> sendMode sequ c Mode.AllSoundOff
]
quit <- button p [text := "Quit", on command := close f]
set f [layout := container p $ margin 10 $
column 5 $ map hfloatCentre [
widget allNotesOff,
widget allSoundOff,
widget chan,
widget quit]]
sendMode :: Sequencer SndSeq.OutputMode -> ChannelMsg.Channel -> Mode.T -> IO ()
sendMode h chan mode = do
sendEvent h $
Event.CtrlEv Event.Controller $ MidiAlsa.modeEvent chan mode
main :: IO ()
main =
withSequencer "Mode" $ WX.start . makeGUI