Implementing instrument change.
authorGuerric Chupin <guerric.chupin@gmail.com>
Tue, 12 Jul 2016 16:14:16 +0000 (17:14 +0100)
committerGuerric Chupin <guerric.chupin@gmail.com>
Tue, 12 Jul 2016 16:14:16 +0000 (17:14 +0100)
src/RMCA/Main.hs
src/RMCA/Semantics.hs
src/RMCA/Translator/Controller.hs
src/RMCA/Translator/Instruments.hs [new file with mode: 0644]

index 1cef20d46656a9d471ac99d6499d4db56b21602e..fe0c52dfbc9d58135cc75914844cfaf2750df5df 100644 (file)
@@ -4,6 +4,8 @@ module Main where
 
 import Control.Concurrent
 import Data.ReactiveValue
+import Data.String
+import Data.Tuple
 import FRP.Yampa
 import Graphics.UI.Gtk
 import Graphics.UI.Gtk.Board.BoardLink
@@ -18,6 +20,7 @@ import RMCA.GUI.NoteSettings
 import RMCA.Layer.Board
 import RMCA.Layer.Layer
 import RMCA.Semantics
+import RMCA.Translator.Instruments
 import RMCA.Translator.Jack
 
 floatConv :: (ReactiveValueReadWrite a b m,
@@ -33,8 +36,6 @@ main = do
   -- Main box
   mainBox <- hBoxNew False 10
   set window [ windowTitle := "Reactogon"
-             --, windowDefaultWidth := 250
-             --, windowDefaultHeight := 500
              , containerChild := mainBox
              , containerBorderWidth := 10
              ]
@@ -47,8 +48,10 @@ main = do
   globalSep <- hSeparatorNew
   boxPackStart settingsBox globalSep PackNatural 0
 
+  layerSettingsVBox <- vBoxNew True 10
+  boxPackStart settingsBox layerSettingsVBox PackNatural 0
   layerSettingsBox <- hBoxNew True 10
-  boxPackStart settingsBox layerSettingsBox PackNatural 0
+  boxPackStart layerSettingsVBox layerSettingsBox PackNatural 0
 
   layTempoBox <- hBoxNew False 10
   boxPackStart layerSettingsBox layTempoBox PackNatural 0
@@ -78,6 +81,29 @@ main = do
   bpbButton <- spinButtonNew bpbAdj 1 0
   boxPackStart bpbBox bpbButton PackNatural 0
 
+  instrumentCombo <- comboBoxNewText
+  instrumentIndex <- mapM (\(ind,ins) ->
+                             do i <- comboBoxAppendText instrumentCombo $
+                                     fromString ins
+                                return (i, ind)) instrumentList
+  comboBoxSetActive instrumentCombo 0
+  boxPackStart layerSettingsVBox instrumentCombo PackNatural 10
+  let indexToInstr i = case (lookup i instrumentIndex) of
+        Nothing -> error "Can't get the selected instrument."
+        Just x -> x
+      instrToIndex ins = case (lookup ins $ map swap instrumentIndex) of
+        Nothing -> error "Can't retrieve the index for the instrument."
+        Just x -> x
+      instrumentComboRV = bijection (indexToInstr, instrToIndex) `liftRW`
+                          comboBoxIndexRV instrumentCombo
+{-
+  reactiveValueOnCanRead instrumentComboRV $ do
+    ins <- reactiveValueRead instrumentComboRV
+    bq <- reactiveValueRead boardQueue
+    let body = ProgramChange $ toProgram ins
+
+    reactiveValueWrite boardQueue (bq ++
+  -}
   boxPackStart settingsBox laySep PackNatural 0
 
   layPitchRV <- newCBMVarRW 1
index 4e91654d08a16563e740de997fa4c8282592b8c3..ba25abe7187b6bf2c540c5239ce0b8515e0a78bb 100644 (file)
@@ -140,8 +140,6 @@ type MIDICV = Int
 -- (Handled through subsequent translation to low-level MIDI events.)
 data MIDICVRnd = MIDICV MIDICV | MIDICVRnd deriving (Eq, Show)
 
--- TEMPORARY
-data Controller = Lol
 --
 ------------------------------------------------------------------------------
 -- Notes
index 29b62f595daa27404be8587f32c9737cf4da705a..20605e35273738df8465383ef9fee67c046b1221 100644 (file)
@@ -1,8 +1,9 @@
 module RMCA.Translator.Controller where
 
-import RMCA.Semantics
 import RMCA.Translator.Message
 
+data Controller = Lol
+
 messageToController :: Message -> Controller
 messageToController _ = Lol
 
diff --git a/src/RMCA/Translator/Instruments.hs b/src/RMCA/Translator/Instruments.hs
new file mode 100644 (file)
index 0000000..ed40fea
--- /dev/null
@@ -0,0 +1,132 @@
+module RMCA.Translator.Instruments where
+
+instrumentList :: [(Int, String)]
+instrumentList = [ (0,"AcousticGrandPiano")
+                 , (1,"BrightAcousticPiano")
+                 , (2,"ElectricGrandPiano")
+                 , (3,"Honky-tonkPiano")
+                 , (4,"ElectricPiano1")
+                 , (5,"ElectricPiano2")
+                 , (6,"Harpsichord")
+                 , (7,"Clavinet")
+                 , (8,"Celesta")
+                 , (9,"Glockenspiel")
+                 , (10,"MusicBox")
+                 , (11,"Vibraphone")
+                 , (12,"Marimba")
+                 , (13,"Xylophone")
+                 , (14,"TubularBells")
+                 , (15,"Dulcimer")
+                 , (16,"DrawbarOrgan")
+                 , (17,"PercussiveOrgan")
+                 , (18,"RockOrgan")
+                 , (19,"ChurchOrgan")
+                 , (20,"ReedOrgan")
+                 , (21,"Accordion")
+                 , (22,"Harmonica")
+                 , (23,"TangoAccordion")
+                 , (24,"AcousticGuitar(nylon)")
+                 , (25,"AcousticGuitar(steel)")
+                 , (26,"ElectricGuitar(jazz)")
+                 , (27,"ElectricGuitar(clean)")
+                 , (28,"ElectricGuitar(muted)")
+                 , (29,"OverdrivenGuitar")
+                 , (30,"DistortionGuitar")
+                 , (31,"GuitarHarmonics")
+                 , (32,"AcousticBass")
+                 , (33,"ElectricBass(finger)")
+                 , (34,"ElectricBass(pick)")
+                 , (35,"FretlessBass")
+                 , (36,"SlapBass1")
+                 , (37,"SlapBass2")
+                 , (38,"SynthBass1")
+                 , (39,"SynthBass2")
+                 , (40,"Violin")
+                 , (41,"Viola")
+                 , (42,"Cello")
+                 , (43,"Contrabass")
+                 , (44,"TremoloStrings")
+                 , (45,"PizzicatoStrings")
+                 , (46,"OrchestralHarp")
+                 , (47,"Timpani")
+                 , (48,"StringEnsemble1")
+                 , (49,"StringEnsemble2")
+                 , (50,"SynthStrings1")
+                 , (51,"SynthStrings2")
+                 , (52,"ChoirAahs")
+                 , (53,"VoiceOohs")
+                 , (54,"SynthChoir")
+                 , (55,"OrchestraHit")
+                 , (56,"Trumpet")
+                 , (57,"Trombone")
+                 , (58,"Tuba")
+                 , (59,"MutedTrumpet")
+                 , (60,"FrenchHorn")
+                 , (61,"BrassSection")
+                 , (62,"SynthBrass1")
+                 , (63,"SynthBrass2")
+                 , (64,"SopranoSax")
+                 , (65,"AltoSax")
+                 , (66,"TenorSax")
+                 , (67,"BaritoneSax")
+                 , (68,"Oboe")
+                 , (69,"EnglishHorn")
+                 , (70,"Bassoon")
+                 , (71,"Clarinet")
+                 , (72,"Piccolo")
+                 , (73,"Flute")
+                 , (74,"Recorder")
+                 , (75,"PanFlute")
+                 , (76,"Blownbottle")
+                 , (77,"Shakuhachi")
+                 , (78,"Whistle")
+                 , (79,"Ocarina")
+                 , (80,"Lead1(square)")
+                 , (81,"Lead2(sawtooth)")
+                 , (82,"Lead3(calliope)")
+                 , (83,"Lead4(chiff)")
+                 , (84,"Lead5(charang)")
+                 , (85,"Lead6(voice)")
+                 , (86,"Lead7(fifths)")
+                 , (87,"Lead8(bass+lead)")
+                 , (88,"Pad1(newage)")
+                 , (89,"Pad2(warm[disambiguationneeded])")
+                 , (90,"Pad3(polysynth)")
+                 , (91,"Pad4(choir)")
+                 , (92,"Pad5(bowed)")
+                 , (93,"Pad6(metallic)")
+                 , (94,"Pad7(halo)")
+                 , (95,"Pad8(sweep)")
+                 , (96,"FX1(rain)")
+                 , (97,"FX2(soundtrack)")
+                 , (98,"FX3(crystal)")
+                 , (99,"FX4(atmosphere)")
+                 , (100,"FX5(brightness)")
+                 , (101,"FX6(goblins)")
+                 , (102,"FX7(echoes)")
+                 , (103,"FX8(sci-fi)")
+                 , (104,"Sitar")
+                 , (105,"Banjo")
+                 , (106,"Shamisen")
+                 , (107,"Koto")
+                 , (108,"Kalimba")
+                 , (109,"Bagpipe")
+                 , (110,"Fiddle")
+                 , (111,"Shanai")
+                 , (112,"TinkleBell")
+                 , (113,"Agogo")
+                 , (114,"SteelDrums")
+                 , (115,"Woodblock")
+                 , (116,"TaikoDrum")
+                 , (117,"MelodicTom")
+                 , (118,"SynthDrum")
+                 , (119,"ReverseCymbal")
+                 , (120,"GuitarFretNoise")
+                 , (121,"BreathNoise")
+                 , (122,"Seashore")
+                 , (123,"BirdTweet")
+                 , (124,"TelephoneRing")
+                 , (125,"Helicopter")
+                 , (126,"Applause")
+                 , (127,"Gunshot")
+                 ]