Use the internal MIDI synthesizer.

Use the internal MIDI synthesizer.

midiOutShortMsg

See version :

Pas de dépendances

Download :

#include <stdio.h>
#include <windows.h>

#pragma comment(lib,"Winmm.lib")

unsigned long changer_instrument(int channel,int numinstrument)
{
    return channel|0xC0|(numinstrument<<8);
}

unsigned long appuyer_touche(int channel,int note,int force)
{
    return channel|0x90|(note<<8)|(force<<16);
}

unsigned long relacher_touche(int channel,int note,int force)
{
    return channel|0x80|(note<<8)|(force<<16);
}

int main()
{
    int i;
    HMIDIOUT hMidiOut;
    midiOutOpen(&hMidiOut, 0, 0, 0, CALLBACK_NULL);

    midiOutShortMsg(hMidiOut, changer_instrument(0,0));
    midiOutShortMsg(hMidiOut, changer_instrument(1,50));
    midiOutShortMsg(hMidiOut, appuyer_touche(0,50,50));
    midiOutShortMsg(hMidiOut, appuyer_touche(1,80,30));
    
    Sleep(2000);

     midiOutShortMsg(hMidiOut, relacher_touche(1,80,50));
    
    Sleep(1000);

    for(i=0;i<127;i++)
    {
        printf("%d\r",i);
        midiOutShortMsg(hMidiOut, changer_instrument(0,i));
        midiOutShortMsg(hMidiOut, appuyer_touche(0,70,30));
        Sleep(500);
    }

    midiOutClose(hMidiOut);

    return 0;
}



Explanations

	No explanations yet.