Beispiel #1
0
        static private MidiMetaMessage ParseMidiMetaMessage(MidiFileFormatReader mffr)
        {
            MidiMetaMessage result = null;

            // Get message type
            EMetaEventType type = (EMetaEventType)mffr.ReadUInt8();

            // Get body length
            uint length = mffr.ReadVarLengthQuantity();

            switch (type)
            {
            case EMetaEventType.TrackSequenceNumber:
                result = new MidiMetaTrackSequenceNumberMessage(mffr.ReadUInt16());
                break;

            case EMetaEventType.TextEvent:
            case EMetaEventType.Copyright:
            case EMetaEventType.SequenceTrackName:
            case EMetaEventType.TrackInstrumentName:
            case EMetaEventType.Lyric:
            case EMetaEventType.Marker:
            case EMetaEventType.CuePoint:
            case EMetaEventType.ProgramName:
            case EMetaEventType.DeviceName:
            case EMetaEventType.MidiChannel:
                result = new MidiMetaTextMessage(type, mffr.ReadString(length));
                break;

            case EMetaEventType.MidiPort:
                result = new MidiMetaMidiPortMessage(mffr.ReadUInt8());
                break;

            case EMetaEventType.EndTrack:
                // No extra data for the end of track message
                result = new MidiMetaMessage(type);
                break;

            case EMetaEventType.SetTempo:
                result = new MidiMetaTempoMessage(mffr.ReadUInt24());
                break;

            case EMetaEventType.SmpteOffset:
                break;

            case EMetaEventType.TimeSignature:
                result = new MidiMetaTimeSignatureMessage(mffr.ReadUInt8(), mffr.ReadUInt8(), mffr.ReadUInt8(), mffr.ReadUInt8());
                break;

            case EMetaEventType.KeySignature:
                result = new MidiMetaKeySignatureMessage(mffr.ReadUInt8(), (mffr.ReadUInt8() != 0));
                break;

            case EMetaEventType.SequencerSpecific:
                // Read body
                byte[] body = new byte[length];
                for (int i = 0; i < length; i++)
                {
                    body[i] = mffr.ReadUInt8();
                }
                result = new MidiMetaMessage(type, body);

                break;

            default:
                throw new FormatException(string.Format("Found unknown or unsupported metaevent code {0}", type));
            }

            return(result);
        }
Beispiel #2
0
 public SerMidiMetaKeySignatureMessage(MidiMetaKeySignatureMessage msg)
     : base(msg)
 {
     this.sharpsFlats = msg.SharpsFlat;
     this.minor       = msg.Minor;
 }