Solved

MIDI Sysex Programming Question...

Posted on 2001-09-05
7
970 Views
Last Modified: 2013-12-03
I am trying to write a Windows program to communicate with a MIDI device that is connected to my PC.  However, I can't seem to get my program talking to the device.  I am new to MIDI programming and I haven't been able to find a good example.  

For now, I just want to send a Sysex message to the MIDI device and get a response back.  I have been trying this using these functions:

midiOutGetNumDevs()
midiOutGetDevCaps()
midiOutOpen()
midiInOpen()
midiInStart()

but I haven't really gotten anywhere.  Note I don't want to receive any midi audio from the device - I just want to send a request message to it and get a response.  For now, I would prefer to use CALLBACK functions.

I believe the following is what I need to send to the device:

F0 7E <chan> 06 01 F7 System inquiry message

<chan> can be 7F (all devices) and the device documentation says it will respond.  I have more sysex information on the device, but I am not sure if that is needed to solve this question.  If so, let me know and I will post as much as needed.

I *believe* that I should be using midi output device 2 and midi input device 0.
0
Comment
Question by:TomMahieu
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 9

Expert Comment

by:ShaunWilde
Comment Utility
have you looked at the MIDImon sample in the msdn ?
0
 
LVL 14

Accepted Solution

by:
AlexVirochovsky earned 300 total points
Comment Utility
0
 

Author Comment

by:TomMahieu
Comment Utility
I've taken a look at the MIDImon sample, but I haven't been able to successfully extract what I am trying to do.  I was looking for someone to point me in the right direction with a code snippet of "here is what you have to do" and leave out all of the things that are not necessary.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:TomMahieu
Comment Utility
OK, if this helps, here is basically what I am currently doing that does not work.  Anybody see what is wrong?  Everything?  ;)

void CALLBACK MidiOutProc(HMIDIOUT hmo,      
                          UINT wMsg,        
                          DWORD dwInstance,  
                          DWORD dwParam1,    
                          DWORD dwParam2)
{
    DWORD temp = dwParam1;
}
 

void CALLBACK MidiInProc(HMIDIIN hMidiIn,  
                         UINT wMsg,        
                         DWORD dwInstance,
                         DWORD dwParam1,  
                         DWORD dwParam2)
{
    DWORD temp = dwParam1;
}


void OutputSystemExclusiveMessage(void)
{
    HMIDIOUT    outHandle;
    HMIDIIN     inHandle;
    MIDIHDR     midiHdr;
    UINT        err;
    char          sysEx[] = {0xF0, 0x7E, 0x01, 0x06, 0x01, 0x07};

    DWORD outRetVal = 0;
    DWORD inRetVal = 0;
    DWORD inStartRetVal = 0;

    outRetVal = midiOutOpen(&outHandle, 2, (DWORD)MidiOutProc, 23, CALLBACK_FUNCTION);
    inRetVal = midiInOpen(&inHandle, 0, (DWORD)MidiInProc, 34, CALLBACK_FUNCTION);

    if ((MMSYSERR_NOERROR != inRetVal) || (MMSYSERR_NOERROR != outRetVal))
    {
        cout << "ERROR!" << endl;
    }
    else
    {
        inStartRetVal = midiInStart(inHandle);
    }

    if (MMSYSERR_NOERROR == inStartRetVal)
    {
        midiHdr.lpData = (char *)&sysEx[0];
        midiHdr.dwBufferLength = sizeof(sysEx);
        midiHdr.dwBytesRecorded  = sizeof(sysEx);
        midiHdr.dwFlags = 0;

        err = midiOutPrepareHeader(outHandle,  &midiHdr, sizeof(MIDIHDR));
        if (!err)
        {
            err = midiOutLongMsg(outHandle, &midiHdr, sizeof(MIDIHDR));
            if (err)
            {
                char   errMsg[120];

                midiOutGetErrorText(err, &errMsg[0], 120);
                printf("Error: %s\r\n", &errMsg[0]);
            }

            while (MIDIERR_STILLPLAYING == midiOutUnprepareHeader(outHandle, &midiHdr, sizeof(MIDIHDR)))
            {              
            }
        }

        midiOutClose(outHandle);

    }
}
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
Comment Utility
In next article
http://www.salleurl.edu/~si04990/documents/lowmidi.htm
I see working code ~ same as your's. Check out differences
and you 'll easy find problems.
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
Question(s) below appears to have been abandoned. Your options are:
 
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you. You must tell the participants why you wish to do this, and allow for Expert response.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question. Again, please comment to advise the other participants why you wish to do this.

For special handling needs, please post a zero point question in the link below and include the question QID/link(s) that it regards.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Please click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues, to track all your open and locked questions at this site.  If you are an EE Pro user, use the Power Search option to find them.

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.20178896.html
http://www.experts-exchange.com/questions/Q.20180095.html




PLEASE DO NOT AWARD THE POINTS TO ME.  
 
------------>  EXPERTS:  Please leave any comments regarding your closing recommendations if this item remains inactive another seven (7) days.
 
Thank you everyone.
 
Moondancer
Moderator @ Experts Exchange

P.S.  For any year 2000 questions, special attention is needed to ensure the first correct response is awarded, since they are not in the comment date order, but rather in Member ID order.
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
Thanks for returning and finalizing your question.  Anytime you choose to grade less than an A, please comment as to why.  This helps all involved, including others who may visit this question at a later time for help.  Some experts look at grading history before deciding to help someone, so that also may have an impact to you and how quickly your future questions are answered.

The points to you are always the same, but the points granted the expert depend upon the grade.  Using 100 points as an example.  100 at A = 400 ... 100 at B = 300 .... 100 at C = 200, so it also has a point impact to the experts.  

If the grade chosen was in error, let me know, and I can correct this.

EE Moderator
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now