Ejemplo n.º 1
0
 public MIDITrack()
 {
     MidiEvents        = new List <MIDIEvent>();
     MidiMarkers       = new List <MIDIMarker>();
     CurrentEventIndex = 0;
     LastCommand       = 0;
     AbsTime           = 0;
     Info          = new MIDITrackInfo();
     CurrentMarker = null;
 }
Ejemplo n.º 2
0
        protected void ProcessMIDITrack(MIDITrack track)
        {
            ProcessMidiTrackInfo(ref track.Info);
            track.AbsTime           = 0;
            track.LastCommand       = 0;
            track.CurrentEventIndex = 0;

            MIDIMarker marker = new MIDIMarker();

            marker.StartIndex   = track.MidiEvents.Count();
            marker.Name         = "Init";
            marker.Section      = StyleSections.Init;
            track.CurrentMarker = marker;
            track.MidiMarkers.Add(marker);

            ProcessMidiEvents(track);
            if (track.CurrentMarker != null)
            {
                track.CurrentMarker.StopIndex = track.MidiEvents.Count() - 1;
            }
        }
Ejemplo n.º 3
0
        protected byte[] GetMessageDataForCommand(MIDITrack track)
        {
            //Meta
            if (track.LastCommand == 0xFF)
            {
                byte   type   = Common.GetByte(ref ByteBuff, ref currentOffset);
                byte[] b      = GetVarData();
                byte[] result = new byte[b.Length + 1];
                result[0] = type;
                Array.Copy(b, 0, result, 1, b.Length);

                if (type == 0x06)
                {
                    if (track.CurrentMarker != null)
                    {
                        track.CurrentMarker.StopIndex = track.MidiEvents.Count() - 1;
                    }
                    string name = Encoding.Default.GetString(b);
                    if (name != "SFF1" && name != "SInt")
                    {
                        MIDIMarker marker = new MIDIMarker();
                        marker.StartIndex   = track.MidiEvents.Count();
                        marker.Name         = name;
                        track.CurrentMarker = marker;
                        track.MidiMarkers.Add(marker);
                    }
                }
                if (type == 0x03)
                {
                    StyleName = Encoding.Default.GetString(b);
                }



                return(result);
            }
            else
            //SysEx
            if (track.LastCommand == 0xF0)
            {
                return(GetVarData());
            }
            else
            if (track.LastCommand == 0xF7)
            {
                throw new NotImplementedException();
            }
            else
            // Channel message
            if (Common.IsMasked(track.LastCommand, 0x8) || Common.IsMasked(track.LastCommand, 0x9) || Common.IsMasked(track.LastCommand, 0xA) || Common.IsMasked(track.LastCommand, 0xB) || Common.IsMasked(track.LastCommand, 0xE))
            {
                return(new byte[2] {
                    Common.GetByte(ref ByteBuff, ref currentOffset), Common.GetByte(ref ByteBuff, ref currentOffset)
                });
            }
            else
            if (Common.IsMasked(track.LastCommand, 0xC) || Common.IsMasked(track.LastCommand, 0xD))
            {
                return(new byte[1] {
                    Common.GetByte(ref ByteBuff, ref currentOffset)
                });
            }
            return(new byte[0]);
        }