Esta página está en construcción: perdonen los errores, repeticiones y temas inacabados.
 
This page is being developed: I am sorry for errors, duplications  and unfinished subjects.
 
 
Proyecto Danzante. MIDI.midiOutShortMsg (incluido en Danzante)
 

Lo traigo de http://blog.fourthwoods.com/2011/12/23/playing-midi-files-in-windows-part-1/

 

midiOutShortMsg() also supports a running status as described in the MIDI file format specification. If running status is used, the command byte is omitted and the previously sent command byte is assumed. The lowest-order two bytes then become the data bytes and the highest-order two bytes are unused.
|  31 - 24  |  23 - 16  |  15 - 8  |  7 - 0  |
‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒
|  Unused   |  Unused   |  Data 2  |  Data 1 |

The following example demonstrates playing a single note (Middle-C) held for one second.

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
unsigned int example3()
{
    unsigned int err;
    HMIDIOUT out;
 
    err = midiOutOpen(&out, 0, 0, 0, CALLBACK_NULL);
    if (err != MMSYSERR_NOERROR)
    {
       printf("error opening default MIDI device: %d\n", err);
       return 0;
    }
    else
        printf("successfully opened default MIDI device\n");
 
    midiOutShortMsg(out, 0x00403C90);
    Sleep(1000);
    midiOutShortMsg(out, 0x00003C90);
 
    midiOutClose(out);
    return 0;
}

Note that the message parameter is in little-endian byte order. This is important because data in the MIDI file format is stored in big-endian format. When these values are read from the MIDI file they must be packed in the message in the correct order.

The lowest-order byte 0x90 is the MIDI command for note-on (play note, key down, etc…). The next byte 0x3c is the first data parameter for the note-on command. This is the actual note number for Middle-C. The next byte 0x40 is the velocity for which the note is played (e.g. how hard the key is pressed). The highest order byte is not used and is set to 0.

This message will cause the note to start playing. In order to hear the note we need to pause, in this case we call Sleep() for 1 second.

 


 
Vuelta al Principio    Última actualización: viernes, 18 de septiembre de 2015    Visitantes: contador de visitas