本文整理汇总了C#中Track.addTrackRow方法的典型用法代码示例。如果您正苦于以下问题:C# Track.addTrackRow方法的具体用法?C# Track.addTrackRow怎么用?C# Track.addTrackRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Track
的用法示例。
在下文中一共展示了Track.addTrackRow方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: loadMidi
public static void loadMidi(TextAsset midiText)
{
string[,] midiData; //Parsed Midi Data
int format; //0 = single track. 1 = multi track
int tracks; //number of tracks, should be 1
int tempo = 0; //track tempo.
int beatsPerBar = 0;
int bpm;
int ppq;
int currentClock;
int currentChannel;
int currentInstrumentCode;
int currentVelocity;
float currentMs;
string currentCommand;
//Load Data file
midiData = CSVReader.SplitCsvGrid (midiText.text);
ppq = System.Int32.Parse(midiData [5, 0]);
//Empty current track to prepare for loading
CurrentTrack = new Track();
CurrentTrack.TrackName = midiText.name;
//Load the Midi into the Track row by row;
for (int x = 0; x < midiData.GetLength(1); x += 1) {
if (!System.Int32.TryParse(midiData[1,x], out currentClock))
{
break;
}
currentCommand = midiData[2,x].Trim ();
//Get the channel/instrument info only when we have instructions to play a note
if(currentCommand == "Note_on_c"){
currentChannel = System.Int32.Parse(midiData[3,x]);
}else{
currentChannel = -1;
}
//Update tempo only once
if(currentCommand == "Tempo" && tempo == 0){
tempo = System.Int32.Parse(midiData[3,x]);
}
//Update Time Signature only once
if(currentCommand == "Time_signature" && beatsPerBar == 0){
beatsPerBar = System.Int32.Parse(midiData[3,x]);
}
//Convert ticks to Milliseconds
currentMs = tempo / 1000.0f / ppq * currentClock;
if(currentChannel == 9){
currentInstrumentCode = System.Int32.Parse(midiData[4,x]);
currentVelocity = System.Int32.Parse(midiData[5,x]);
if(currentVelocity !=0){
TrackRow trackRow = new TrackRow (currentMs, DrumKit.getInstrumentFromMidiCode(currentInstrumentCode));
CurrentTrack.addTrackRow(trackRow);
}
}
}
bpm = (int) 60000000.0f / tempo;
CurrentTrack.bpm = bpm;
CurrentTrack.beatsPerBar = beatsPerBar;
}