Click here to Skip to main content
15,899,937 members
Home / Discussions / C#
   

C#

 
AnswerRe: size of fileupload Pin
Shameel5-Sep-12 22:56
professionalShameel5-Sep-12 22:56 
AnswerRe: size of fileupload Pin
Pete O'Hanlon5-Sep-12 23:37
mvePete O'Hanlon5-Sep-12 23:37 
QuestionC# WinService starts in win7 but not in win2088 Pin
Daniel Jansson5-Sep-12 20:56
Daniel Jansson5-Sep-12 20:56 
AnswerRe: C# WinService starts in win7 but not in win2088 Pin
Bernhard Hiller5-Sep-12 21:35
Bernhard Hiller5-Sep-12 21:35 
GeneralRe: C# WinService starts in win7 but not in win2088 Pin
Daniel Jansson5-Sep-12 21:38
Daniel Jansson5-Sep-12 21:38 
GeneralRe: C# WinService starts in win7 but not in win2088 Pin
Bernhard Hiller5-Sep-12 21:49
Bernhard Hiller5-Sep-12 21:49 
AnswerRe: C# WinService starts in win7 but not in win2088 Pin
Shameel5-Sep-12 22:58
professionalShameel5-Sep-12 22:58 
AnswerRe: C# WinService starts in win7 but not in win2088 Pin
jschell6-Sep-12 12:48
jschell6-Sep-12 12:48 
QuestionC# Class for Finger Print Capture Pin
Member 23279205-Sep-12 20:25
Member 23279205-Sep-12 20:25 
AnswerRe: C# Class for Finger Print Capture Pin
Shameel5-Sep-12 20:38
professionalShameel5-Sep-12 20:38 
AnswerRe: C# Class for Finger Print Capture Pin
Thomas Duwe5-Sep-12 22:18
Thomas Duwe5-Sep-12 22:18 
QuestionPicture box click event Pin
Soni_moni5-Sep-12 19:43
Soni_moni5-Sep-12 19:43 
AnswerRe: Picture box click event Pin
Shameel5-Sep-12 20:36
professionalShameel5-Sep-12 20:36 
AnswerRe: Picture box click event Pin
DaveyM696-Sep-12 3:18
professionalDaveyM696-Sep-12 3:18 
QuestionC# MIDI controller interface. Pin
Jumpin' Jeff5-Sep-12 16:38
Jumpin' Jeff5-Sep-12 16:38 
AnswerRe: C# MIDI controller interface. Pin
DaveyM695-Sep-12 22:17
professionalDaveyM695-Sep-12 22:17 
GeneralRe: C# MIDI controller interface. Pin
Jumpin' Jeff6-Sep-12 14:26
Jumpin' Jeff6-Sep-12 14:26 
GeneralRe: C# MIDI controller interface. Pin
DaveyM697-Sep-12 0:57
professionalDaveyM697-Sep-12 0:57 
GeneralRe: C# MIDI controller interface. Pin
Jumpin' Jeff7-Sep-12 1:36
Jumpin' Jeff7-Sep-12 1:36 
GeneralRe: C# MIDI controller interface. Pin
Jumpin' Jeff7-Sep-12 12:42
Jumpin' Jeff7-Sep-12 12:42 
GeneralRe: C# MIDI controller interface. Pin
Jumpin' Jeff7-Sep-12 15:04
Jumpin' Jeff7-Sep-12 15:04 
AnswerRe: C# MIDI controller interface. Pin
DaveyM697-Sep-12 22:07
professionalDaveyM697-Sep-12 22:07 
With MIDI In, the procedure is similar. The problem is you have to prepare a MIDIHDR buffer of x size (x is up to you), add it using midiInAddBuffer and that will be returned to you through a MIM_LONGDATA message in a MidiInProc callback - dwParam1 (you will need to cast the IntPtr to int) contains the MIDIHDR (dwParam2 contains the timestamp which you probably don't need). To get a callback, you will need to set CALLBACK_FUNCTION in the dwFlags when using midiInOpen and also call midiInStart.

Checking the dwBytesRecorded (you will need to add a property to expose it) will tell you how much data there actually is in the buffer. The real data can be copied out of the buffer using Marshal.Copy. Don't forget to unprepare the buffer, free the GCHandle and the data pointer! If it is full and the last byte isn't EOX, you will need to quickly add another buffer to get the rest of the sysex data (you can add more than one buffer)!

Once you have all the data and freed everything you can stop and close the input when you're done - one issue though. You may have prepared and added a buffer(s) but received no sysex into it so it's just sitting there. To deal with these you will need to call midiInReset, get the buffers via the callback, unprepare them (and free the GCHandle and data pointer) before calling midiInClose. There is a midiInStop function, this doesn't return unused buffers. I personally call midiInReset, get the buffers in the callback (freeing and unpreparing them) and then call midiInStop to ensure compatibility with all device drivers just in case.

If you get stuck I will happily knock you up some smple code. Based on what I've already given you and this[^] you should be OK though.

Short messages are a doddle. Open, Start, receive MIM_DATA in the callback and extract the bytes from dwParam1, and once you're done Stop (or Reset then Stop) and Close.

Edit: Just checked, calling midiInClose on a MIDI In that still has buffers will not close the device. Instead the function result will be MIDIERR_STILLPLAYING.
Dave

Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.
Astonish us. Be exceptional. (Pete O'Hanlon)

BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)




modified 8-Sep-12 4:29am.

GeneralRe: C# MIDI controller interface. Pin
Jumpin' Jeff8-Sep-12 15:18
Jumpin' Jeff8-Sep-12 15:18 
GeneralRe: C# MIDI controller interface. Pin
DaveyM699-Sep-12 0:03
professionalDaveyM699-Sep-12 0:03 
GeneralRe: C# MIDI controller interface. Pin
Jumpin' Jeff10-Sep-12 1:49
Jumpin' Jeff10-Sep-12 1:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.