当前位置: 首页>>代码示例>>C#>>正文


C# Track.addTrackRow方法代码示例

本文整理汇总了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;
    }
开发者ID:simphax,项目名称:ar-drum-coach,代码行数:76,代码来源:TrackManager.cs


注:本文中的Track.addTrackRow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。