c# - Issue with loaded Midi.Net DLL -
lately i'm having issues in different applications have made. of these applications use midi-controller send midi-notes lighting desk. issue same of these applications.
in runtime, when i'm working on application, occurs complete application freezes. don't warningmessages, nor debugger popping tell me what's wrong. occurs when want play midi-note. thing can @ point, reboot entire machine, not funny.
because application hangs , don't debugging information, i'm has dll use send midi-notes , there's issue there or in way have implemented dll.
i've posted code below , appreciate it, if tell me i'm doing wrong?
this de code in mainform initializing midi
miditools midi; private void initmidi() { midi = new miditools(); midi.enabled = true; }
the initmidi() called inside form_load-function.
the code play midi-note is:
midi.playnote(22,0)
below code inside miditools-class file
using midi; namespace miditest { class miditools { public bool enabled { get; set; } outputdevice outputdevice = outputdevice.installeddevices[1]; channel selectedchannel = channel.channel16; int velocity = 127; private void playnote(int notenumber, int delay) { // convert note note selectednote = (note)notenumber; if (enabled) { thread.sleep(delay); console.writeline(datetime.now.tostring("hh:mm:ss note: ") + selectednote.tostring()); outputdevice.open(); outputdevice.sendnoteon(selectedchannel, selectednote, velocity); outputdevice.close(); } } } }
the midi-library downloaded link: https://midi-dot-net.googlecode.com/files/midi-dot-net_src_1.0.5.zip
in past i've tried multiple ways of fixing problem. i've tried inserting bigger delay, i've tried cueing messages in list , processing them 1 one prevent midinote being asked play wile note still being sent, none of helped.
in 98% of cases works, it's freezes on me. i'm using m-audio midisport controller. (http://www.m-audio.com/products/view/midisport-4x4-anniversary-edition) has happened on other controllers.
so appreciated.
best regards, kenneth
Comments
Post a Comment