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


C# Track.PushEvent方法代码示例

本文整理汇总了C#中Track.PushEvent方法的典型用法代码示例。如果您正苦于以下问题:C# Track.PushEvent方法的具体用法?C# Track.PushEvent怎么用?C# Track.PushEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Track的用法示例。


在下文中一共展示了Track.PushEvent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadTrack

        private int ReadTrack(ref byte[] data, int offset)
        {
            if (data.Length == offset) {
                return 0;
            }
            if (data.Length < offset + 8) {
                MyLastError = "Garbage found at end of file";
                return 0;
            }
            if (!MatchBytes (ref data, offset, "MTrk")) {
                MyLastError = "Invalid Midi file (Expected MTrk not found)";
                return -1;
            }
            int trackLength = (data [offset + 4] << 24) + (data [offset + 5] << 16) + (data [offset + 6] << 8) + data [offset + 7];
            offset += 8;
            if (offset + trackLength > data.Length) {
                MyLastError = "Invalid Midi file (Unexpected EOF)";
                return -1;
            }
            trackLength += offset;
            Track output = new Track();
            byte priorStatus = 0;
            int bytes = 0;
            while (offset < data.Length && offset < trackLength) {
                int length = ReadDuration (ref data, ref offset);
                if (offset + 2 >= data.Length) {
                    MyLastError = "Invalid Midi file (Unexpected EOF)";
                    return -1;
                }
                byte arg1 = 0, arg2 = 0;
                byte status = data [offset++];
                if ((status >> 4) < 8) {
                    //Deal with running status
                    if (priorStatus == 0) {
                        MyLastError = "Invalid Midi file (Unrecognized status code) " + offset.ToString ();
                        return -1;
                    }
                    arg1 = status;
                    if (bytes == 2) {
                        arg2 = data [offset++];
                    }
                    status = priorStatus;
                } else {
                    if ((status >> 4) < 12 || (status >> 4) == 14 || (status == 0xFF)) {
                        bytes = 2;
                    } else {
                        bytes = 1;
                    }

                    arg1 = data [offset++];
                    if (bytes == 2) {
                        arg2 = data [offset++];
                    }
                }
                priorStatus = status;
                if (priorStatus >= 0xF0) {
                    priorStatus = 0;
                }
                byte[] edata = null;
                if ((status >> 4) == 0xF) {
                    offset--;
                    int len = ReadDuration (ref data, ref offset);
                    if (offset + len <= data.Length) {
                        //Extract substring of bytes
                        edata = new byte[len];
                        for (int i = 0; i < len; ++i) {
                            edata [i] = data [offset++];
                        }
                    }
                }
                output.PushEvent (length, status, arg1, arg2, edata);
            }
            MyTracks.Add (output);
            return offset;
        }
开发者ID:Aslai,项目名称:EE-Music-Bot,代码行数:75,代码来源:Program.cs


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