Mci.Sequencer Class

 

About Mci.Sequencer Class

 

Mci.Sequencer class is mainly used for controlling playback of external MIDI (*.mid) files through Mci functions.

You can visit the following link for more info about the MCI commands listed on this page:

https://msdn.microsoft.com/en-us/library/windows/desktop/dd743373(v=vs.85).aspx

 

Mci.Sequencer Class Methods

 

Mci.Sequencer.Open( string FileName ) executes the MCI command "open". This function opens a device as "type sequencer" and returns a valid DeviceIndex which you can use with all other Mci.* functions or 0 otherwise.

string FileName: full path to a MIDI (*.mid) file name.

 

Mci.Sequencer.IsOpen( ulong DeviceIndex ) returns true if the given device is open and false if not.

ulong DeviceIndex: device index.

 

Mci.Sequencer.OpenCount( ) returns the amount of open devices.

 

Mci.Sequencer.Close( ulong DeviceIndex ) executes the MCI command"close". This function closes an open device and frees memory occupied. Note that when you call Mci.Deinitialize() function Giavapps MIDI will close all open devices for you automatically.

ulong DeviceIndex: device index.

 

Mci.Sequencer.Play( ulong DeviceIndex ) executes the MCI command "play".

ulong DeviceIndex: device index.

 

Mci.Sequencer.PlayFrom( ulong DeviceIndex, string FromPosition) executes the MCI command "play from position".

ulong DeviceIndex: device index.
string FromPosition: specifies a starting position for the playback.

 

Mci.Sequencer.PlayFromTo( ulong DeviceIndex, string FromPosition, string ToPosition) executes the MCI command "play from position to position".

ulong DeviceIndex: device index.
string FromPosition: specifies a starting position for the playback.
string ToPosition: specifies an ending position for the playback.

 

Mci.Sequencer.Stop( ulong DeviceIndex ) executes the MCI command "stop".

ulong DeviceIndex: device index.

 

Mci.Sequencer.Pause( ulong DeviceIndex ) executes the MCI command "pause".

ulong DeviceIndex: device index.

 

Mci.Sequencer.Seek( ulong DeviceIndex, string ToPosition) executes the MCI command "seek to position".

ulong DeviceIndex: device index.
string ToPosition: specifies the position to stop the seek.

 

Mci.Sequencer.SeekToStart( ulong DeviceIndex) executes the MCI command "seek to start".

ulong DeviceIndex: device index.

 

Mci.Sequencer.SeekToEnd( ulong DeviceIndex) executes the MCI command "seek to end".

ulong DeviceIndex: device index.

 

Code Example

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Giavapps.MIDI;

public class CodeExample : MonoBehaviour
{

private string FileName = "mymidi.mid";
private ulong DeviceIndex;

void Awake()
{
Mci.Initialize();//Initializes Mci
DeviceIndex = Mci.Sequencer.Open(FileName);//Opens the specified MIDI file into the MCI MIDI Sequencer for playback
}

void Update()
{

//Checks if space key is pressed
if(Input.GetKeyDown(KeyCode.Space))
{
Mci.Sequencer.Play(DeviceIndex);//Plays the MIDI file
}

}

void OnApplicationQuit()
{
Mci.Deinitialize();//Deinitializes Mci
}

}

 

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.

Comments are closed.