Solved

MIDI Sysex Programming Question...

Posted on 2001-09-05
7
992 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 9

Expert Comment

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

Accepted Solution

by:
AlexVirochovsky earned 300 total points
ID: 6458009
0
 

Author Comment

by:TomMahieu
ID: 6458797
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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

Author Comment

by:TomMahieu
ID: 6459402
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
ID: 6466274
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
ID: 6845757
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
ID: 6851599
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Dir function fails on mapped drives 28 155
Changing the installation path of this MSI 5 120
Dialogbox API leak? 18 120
Need an intro to -- .Net SQL Authorization Manager 7 101
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

710 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