75 lines
1.8 KiB
C#
75 lines
1.8 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace DMX2
|
|
{
|
|
public partial class MidiEventProvider : IEventProvider, IDisposable
|
|
{
|
|
|
|
IntPtr midi_seq_handle = IntPtr.Zero;
|
|
int midiport;
|
|
|
|
public MidiEventProvider ()
|
|
{
|
|
snd_seq_open(out midi_seq_handle, "default",SND_SEQ_OPEN_DUPLEX,0);
|
|
snd_seq_set_client_name(midi_seq_handle,"DMX2");
|
|
midiport = snd_seq_create_simple_port(midi_seq_handle,"dmx_ctrl",
|
|
SND_SEQ_PORT_CAP_WRITE + SND_SEQ_PORT_CAP_SUBS_WRITE,
|
|
SND_SEQ_PORT_TYPE_APPLICATION);
|
|
|
|
Info.Publish(string.Format("Midi port {0}",midiport));
|
|
}
|
|
|
|
public void Process ()
|
|
{
|
|
int i; IntPtr ev;
|
|
while ((i = snd_seq_event_input_pending(midi_seq_handle,1))>0) {
|
|
//Console.WriteLine(i);
|
|
i=snd_seq_event_input(midi_seq_handle, out ev);
|
|
snd_seq_event_t evS =(snd_seq_event_t) Marshal.PtrToStructure(ev,typeof(snd_seq_event_t));
|
|
Info.Publish(string.Format ("event {0} {1}", evS.type, evS.data_ev_ctrl.value) );
|
|
snd_seq_free_event(ev);
|
|
}
|
|
}
|
|
|
|
#region IDisposable implementation
|
|
public void Dispose ()
|
|
{
|
|
snd_seq_close(midi_seq_handle);
|
|
}
|
|
#endregion
|
|
|
|
#region IEventProvider implementation
|
|
string[] IEventProvider.GetEventList ()
|
|
{
|
|
throw new System.NotImplementedException ();
|
|
}
|
|
|
|
bool IEventProvider.Bind (string eventId, IEventTarget target)
|
|
{
|
|
throw new System.NotImplementedException ();
|
|
}
|
|
|
|
void IEventProvider.Unbind (string eventId, IEventTarget target)
|
|
{
|
|
throw new System.NotImplementedException ();
|
|
}
|
|
|
|
Gtk.Menu IEventProvider.GetProviderSubMenu (Gtk.ButtonPressEventHandler handler)
|
|
{
|
|
throw new System.NotImplementedException ();
|
|
}
|
|
|
|
string IEventProvider.MenuName {
|
|
get {
|
|
throw new System.NotImplementedException ();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|