1+
12#load " ../.paket/load/net472/fsnative.fsx"
23#load " ../.paket/load/net472/RtMidi.Core.fsx"
34#r @" C:\dev\src\gitlab.com\gauthier\Midinette\build\Debug\AnyCPU\netstandard2.0\Midinette.dll"
5+ #r @" C:\dev\src\gitlab.com\gauthier\Midinette\build\Debug\AnyCPU\netstandard2.0\Midinette.Elektron.dll"
46#r @" C:\dev\src\gitlab.com\gauthier\Midinette\build\Debug\AnyCPU\netstandard2.0\Midinette.Platform.RtMidi.dll"
7+ #load @" C:\dev\src\gitlab.com\gauthier\ElektronControl\ToolLib\PrettyPrint.fs"
8+ open Elektron.MachineDrum
9+ open Midi
510open RtMidi.Core .Devices
11+ open RtMidi.Core .Devices .Nrpn
12+ open Elektron
13+ open Elektron.MonoMachine
14+ open System
615
716open fsnative
817open fsnative.Internals
@@ -24,27 +33,149 @@ match library with
2433
2534open Midinette.Platform
2635let platform = Midinette.Platform.RtMidi.RtMidiMidinettePlatformImpl()
27- let iplatform = platform :> IMidiPlatform< IDeviceInfo, Midi.MidiEvent< int64>, int64, Midi.MidiMessage>
36+ let iplatform = platform :> IMidiPlatform< int64>
37+
38+
39+
40+
41+
42+
43+
44+
45+
46+
47+
48+
49+
50+
51+
52+
53+
54+
55+
56+
57+ //////////////////// MD
58+ let mdOut = ( iplatform.InputDevices |> Array.filter ( fun d -> d.Name = " machinedrum-out " )).[ 0 ] |> iplatform.GetMidiInput |> Option.get
59+ let mdIn = ( iplatform.OutputDevices |> Array.filter ( fun d -> d.Name = " machinedrum-in " )).[ 0 ] |> iplatform.GetMidiOutput |> Option.get
60+
61+ mdOut.ChannelMessageReceived.Add( fun m -> printfn " [%20i ] channel message: %A " m.Timestamp m.Message)
62+ mdOut.SystemMessageReceived.Add( fun m -> printfn " [%20i ] system message: %A " m.Timestamp m.Message)
63+ mdOut.RealtimeMessageReceived.Add( fun m -> printfn " [%20i ] realtime message: %A " m.Timestamp m.Message)
64+ mdOut.SysexReceived.Add( fun bytes -> printfn " sysex message: %A " bytes)
65+
66+ mdOut.Open ( 1024 * 1024 )
67+ mdIn.Open ( 1024 * 1024 ) 0
68+
69+ let md = new MachineDrum<_>( mdOut, mdIn, ( fun () -> platform.Now))
70+
71+
72+ Elektron.MachineDrum.mdDetection
73+ ( fun () -> platform.Now)
74+ [| mdOut|]
75+ [| mdIn|]
76+ None
77+ ( fun md ->
78+ printfn " inPort: %s " md.MidiInPort.DeviceInfo.Name
79+ printfn " outPort: %s " md.MidiOutPort.DeviceInfo.Name
80+ )
81+
82+
83+ let mdListener = new MachineDrumEventListener<_>( md, ( fun () -> platform.Now))
84+
85+
86+
87+
88+ mdListener.Event.Add( fun e -> printfn " [%20i ] MD EVENT: %A " e.Timestamp e.Message)
89+
90+
91+
92+
93+
94+
95+
96+
97+
98+
99+ //////////////////// MONOMACHINE
100+ let monoOut = ( iplatform.InputDevices |> Array.filter ( fun d -> d.Name = " monomachine-out " )).[ 0 ] |> iplatform.GetMidiInput |> Option.get
101+ let monoIn = ( iplatform.OutputDevices |> Array.filter ( fun d -> d.Name = " monomachine-in " )).[ 0 ] |> iplatform.GetMidiOutput |> Option.get
102+
103+
104+
105+
106+
107+
108+ monoOut.ChannelMessageReceived.Add( fun m -> printfn " [%20i ] channel message: %A " m.Timestamp m.Message)
109+ monoOut.SystemMessageReceived.Add( fun m -> printfn " [%20i ] system message: %A " m.Timestamp m.Message)
110+ monoOut.RealtimeMessageReceived.Add( fun m -> printfn " [%20i ] realtime message: %A " m.Timestamp m.Message)
111+ monoOut.SysexReceived.Add( fun bytes -> printfn " sysex message: %A " bytes)
112+ monoOut.Open ( 1024 * 1024 )
113+ monoIn.Open ( 1024 * 1024 ) 0
114+ let getNow () = platform.Now
115+ let monomachine = new MonoMachine.MonoMachine<_,_>( monoOut, monoIn, getNow)
116+ let evtl = new MonoMachineEventListener<_>( getNow, monomachine)
117+ evtl.Event.Add( fun e ->
118+ match e.Message with
119+ | Sysex data -> printfn " [%20i ] mnm:" e.Timestamp; PrettyPrint.printBytes data
120+ | _ -> printfn " [%20i ] mnm: %A " e.Timestamp e.Message
121+ )
122+
123+ monomachine.CurrentGlobalSettings
124+ monomachine.DumpPattern 0 uy
125+ let ( Some ( Kit ( kit ))) = monomachine.DumpKit 16 uy
126+ let ( Some ( Pattern ( pattern ))) = monomachine.DumpPattern 0 uy
127+ pattern
128+ |> Elektron.Platform.dataToByte
129+ kit.unpacked.[ 0xb .. 0xb + 6 ]
130+
131+
132+
133+
134+
135+ monomachine.MidiInPort.WriteMessage 0 L ( Midi.MidiMessage.NoteOn 0x00 uy 0x64 uy 100 uy)
136+ monomachine.MidiInPort.WriteMessage 0 L ( Midi.MidiMessage.NoteOff 0x00 uy 0x64 uy 100 uy)
137+ monomachine.DumpPattern 0 uy
138+ let globalsysex =
139+ """
140+ f0 00 20 3c 03 00 50 03 01 00 12 08 00 02 06 07
141+ 02 01 54 03 02 03 01 05 00 09 00 0a 0b 0c 0d 0e
142+ 01 02 00 07 0a 01 02 07 0a 01 00 02 07 0a 01 02
143+ 07 0a 00 01 02 07 0a 01 02 07 21 0a 06 01 00 64
144+ 40 03 00 00 0b 17 23 2f 3b 47 0b 53 5f 6b 17 77
145+ 40 7f 52 20 10 41 00 01 02 00 20 7f 05 00 11 30
146+ 0e 30 00 5b f7
147+ """ .Split([| ' ' ; '\n' |], StringSplitOptions.RemoveEmptyEntries)
148+ |> Array.map ( fun s -> Convert.ToByte( s, 16 ))
149+
150+ monomachine.DumpKit 0 uy
151+ let ( MonoMachineSysexResponse.Kit ( kit ) ) = MonoMachineSysexResponse.BuildResponse globalsysex
152+ kit.unpacked.Length
153+
154+ let gdata =
155+ ArraySegment( globalsysex, 0xa , ( Array.length globalsysex) - 15 )
156+ |> Seq.toArray
157+ |> Elektron.Platform.dataToByte
158+ // |> PrettyPrint.printBytes
159+ gdata.Length
160+ PrettyPrint.printBytes ( Elektron.Platform.dataToByte a)
161+ PrettyPrint.printBytes globalsysex
162+
163+
28164
29- let monoOut =
30- ( iplatform.InputDevices |> Array.filter ( fun d -> d.Name = " monomachine-out " )).[ 0 ]
31- |> iplatform.GetMidiInput
32165
33- monoOut.Value.ChannelMessageReceived.Add( fun m -> printfn " [%20i ] channel message: %A " m.Timestamp m.Message)
34- monoOut.Value.SystemMessageReceived.Add( fun m -> printfn " [%20i ] system message: %A " m.Timestamp m.Message)
35- monoOut.Value.RealtimeMessageReceived.Add( fun m -> printfn " [%20i ] realtime message: %A " m.Timestamp m.Message)
36- monoOut.Value.SysexReceived.Add( fun bytes -> printfn " sysex message: %A " bytes)
37- monoOut.Value.Open ( 1024 * 1024 )
38166let mdm = global .RtMidi.Core.MidiDeviceManager.Default
39167mdm.GetAvailableMidiApis()
40168
41- let rtmin = ( mdm.InputDevices |> Seq.find ( fun d -> d.Name = " monomachine -out " )) .CreateDevice()
169+ let rtmin = ( mdm.InputDevices |> Seq.find ( fun d -> d.Name = " machinedrum -out " )) .CreateDevice()
42170
43- rtmin.InputDevice.Message.Add( fun bytes -> printfn " inputmessage %A " bytes)
44- rtmin.add_ Nrpn ( NrpnMessageHandler( fun a n -> printfn " [%20i ] nrpn %A %i %i " platform.Now n.Channel n.Parameter n.Value))
171+ rtmin.InputDevice.Message.Add( fun bytes -> printfn " ===========" ; PrettyPrint.printBytes bytes)
172+ //rtmin.add_Nrpn (NrpnMessageHandler(fun a n -> printfn "[%20i] nrpn %A %i %i" platform.Now n.Channel n.Parameter n.Value))
173+
45174rtmin.Open()
46175mdm.OutputDevices
47176
177+ rtmin.SetNrpnMode NrpnMode.On
178+
48179
49180
50181let e : RtMidi.Core.Unmanaged.Devices.RtMidiInputDevice = null
0 commit comments