Mci.Sequencer.Set Class

 

About Mci.Sequencer.Set Class

 

Mci.Sequencer.Set class is mainly used for setting the tempo of MIDI (*.mid) files through Mci functions.

You can visit the following link for more info about the MCI command "set":

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

 

Mci.Sequencer.Set Class Methods

 

Mci.Sequencer.Set.Tempo( ulong DeviceIndex, string Tempo) executes the MCI command "set tempo". For a PPQN-based file, Tempo argument is interpreted as BPM (Beats Per Minute). For a SMPTE-based file, Tempo argument is interpreted as FPS (Frames Per Second).

ulong DeviceIndex: device index.
string Tempo: tempo of the sequence.

 

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
Mci.Sequencer.Set.Tempo(DeviceIndex, "100");//Sets a different tempo for the MIDI file
}

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.