MIDI MCI – Giavapps MIDI

Before calling any of the following functions: ensure that the MIDI Output device used for playing MIDI Files (DeviceIndex = 0) is closed otherwise they will not work!

 

MIDI MCI Functions

 

midi_open(FileName) Opens the specified MIDI File and returns the FileIndex that you can use for all other functions.

FileName: file name.

 

midi_close(FileIndex) Closes the specified MIDI File.

FileIndex: file index.

 

midi_play(FileIndex, StartingPosition) Plays the specified MIDI File starting from the given position.

FileIndex: file index.
StartingPosition: starting position (0 = start).

 

midi_stop(FileIndex) Stops the specified MIDI File.

FileIndex: file index.

 

midi_set_bpm(FileIndex, BeatsPerMinute) Sets the given BPM (Beats Per Minute) value to the specified MIDI File.

FileIndex: file index.
BeatsPerMinute: BPM (Beats Per Minute) value.

 

midi_get_bpm(FileIndex) Returns the BPM (Beats Per Minute) value of the specified MIDI File.

FileIndex: file index.

 

midi_get_division_type(FileIndex) Returns a string with the division type (PPQN or SMPTE) of the specified MIDI File.

FileIndex: file index.

 

midi_get_length(FileIndex) Returns the length of the specified MIDI File.

FileIndex: file index.

 

midi_get_position(FileIndex) Returns the position of the specified MIDI File.

FileIndex: file index.

 

midi_is_playing(FileIndex) Returns true if the specified MIDI File is playing.

FileIndex: file index.

 

midi_is_stopped(FileIndex) Returns true if the specified MIDI File is stopped.

FileIndex: file index.

 

Media Control Interface Functions

 

mci_command(Command) Sends a command string to an MCI (Media Control Interface) device. This function is for advanced users only. For more info about MCI (Media Control Interface) commands click here.

Command: command string.

 

mci_get_last_error() Returns the last error code.

 

mci_get_last_error_string() Returns a string containing a description of the last error code.

 

Code Examples

 

Playing a MIDI File

 

midi = midi_open("midi.mid");//Opens the MIDI File and returns the FileIndex
midi_play
(midi,0);//Plays the MIDI File from starting position

 

Looping a MIDI File

 

Create Event:

 

midi = midi_open("midi.mid");
midi_play(midi,0);
alarm[0] = room_speed;

 

Alarm 0 Event:

 

len = midi_get_length(midi);
pos = midi_get_position(midi);

if(pos == len)
{
midi_play(midi,0);
}

alarm[0] = room_speed;//Loops the alarm

 

Stopping a MIDI File

 

midi_stop(midi);//Stops the MIDI File

 

I am Luigi Piscopo, also known as DJ GiDeejay / Producer / Remixer in the music world. I am a Producer with a lot of experience in photo editing, video editing, audio editing, graphic design, web design, programming and promotion.

Leave a Reply

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

*