Exemplo n.º 1
0
        /// <summary>
        /// Reads content of a MIDI meta event.
        /// </summary>
        /// <param name="reader">Reader to read the content with.</param>
        /// <param name="settings">Settings according to which the event's content must be read.</param>
        /// <param name="size">Size of the event's content.</param>
        protected override void ReadContent(MidiReader reader, ReadingSettings settings, int size)
        {
            var invalidMetaEventParameterValuePolicy = settings.InvalidMetaEventParameterValuePolicy;

            var formatAndHours = reader.ReadByte();

            Format = GetFormat(formatAndHours);
            Hours  = ProcessValue(GetHours(formatAndHours),
                                  nameof(Hours),
                                  MaxHours,
                                  invalidMetaEventParameterValuePolicy);
            Minutes = ProcessValue(reader.ReadByte(),
                                   nameof(Minutes),
                                   MaxMinutes,
                                   invalidMetaEventParameterValuePolicy);
            Seconds = ProcessValue(reader.ReadByte(),
                                   nameof(Seconds),
                                   MaxSeconds,
                                   invalidMetaEventParameterValuePolicy);
            Frames = ProcessValue(reader.ReadByte(),
                                  nameof(Frames),
                                  MaxFrames[Format],
                                  invalidMetaEventParameterValuePolicy);
            SubFrames = ProcessValue(reader.ReadByte(),
                                     nameof(SubFrames),
                                     MaxSubFrames,
                                     invalidMetaEventParameterValuePolicy);
        }
Exemplo n.º 2
0
        public MidiEvent Read(MidiReader reader, ReadingSettings settings, byte currentStatusByte)
        {
            var statusByte = reader.ReadByte();
            var size       = reader.ReadVlqNumber();

            //

            Type eventType;
            var  midiEvent = TryGetEventType(settings.CustomMetaEventTypes, statusByte, out eventType)
                ? (MetaEvent)Activator.CreateInstance(eventType)
                : new UnknownMetaEvent(statusByte);

            //

            var readerPosition = reader.Position;

            midiEvent.Read(reader, settings, size);

            var bytesRead   = reader.Position - readerPosition;
            var bytesUnread = size - bytesRead;

            if (bytesUnread > 0)
            {
                reader.Position += bytesUnread;
            }

            return(midiEvent);
        }
Exemplo n.º 3
0
        internal override void Read(MidiReader reader, ReadingSettings settings, int size)
        {
            var data = reader.ReadByte();

            var midiTimeCodeComponent = (byte)data.GetHead();

            if (!Enum.IsDefined(typeof(MidiTimeCodeComponent), midiTimeCodeComponent))
            {
                throw new InvalidMidiTimeCodeComponentException("Invalid MIDI Time Code component.", midiTimeCodeComponent);
            }

            Component = (MidiTimeCodeComponent)midiTimeCodeComponent;

            var componentValue = data.GetTail();

            if (componentValue > ComponentValueMasks[Component])
            {
                switch (settings.InvalidSystemCommonEventParameterValuePolicy)
                {
                case InvalidSystemCommonEventParameterValuePolicy.Abort:
                    throw new InvalidSystemCommonEventParameterValueException($"{componentValue} is invalid value for the {nameof(ComponentValue)} of {Component} of a MIDI Time Code event.", componentValue);

                case InvalidSystemCommonEventParameterValuePolicy.SnapToLimits:
                    componentValue = (FourBitNumber)ComponentValueMasks[Component];
                    break;
                }
            }

            ComponentValue = componentValue;
        }
        /// <summary>
        /// Reads content of a MIDI event.
        /// </summary>
        /// <param name="reader">Reader to read the content with.</param>
        /// <param name="settings">Settings according to which the event's content must be read.</param>
        /// <param name="size">Size of the event's content.</param>
        /// <exception cref="InvalidChannelEventParameterValueException">An invalid value for channel
        /// event's parameter was encountered.</exception>
        internal sealed override void Read(MidiReader reader, ReadingSettings settings, int size)
        {
            for (int i = 0; i < _parameters.Length; i++)
            {
                var parameter = reader.ReadByte();
                if (parameter > SevenBitNumber.MaxValue)
                {
                    switch (settings.InvalidChannelEventParameterValuePolicy)
                    {
                    case InvalidChannelEventParameterValuePolicy.Abort:
                        throw new InvalidChannelEventParameterValueException($"{parameter} is invalid value for channel event's parameter.", parameter);

                    case InvalidChannelEventParameterValuePolicy.ReadValid:
                        parameter &= SevenBitNumber.MaxValue;
                        break;

                    case InvalidChannelEventParameterValuePolicy.SnapToLimits:
                        parameter = SevenBitNumber.MaxValue;
                        break;
                    }
                }

                _parameters[i] = (SevenBitNumber)parameter;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Reads content of a <see cref="TrackChunk"/>.
        /// </summary>
        /// <remarks>
        /// Content of a <see cref="TrackChunk"/> is collection of MIDI events.
        /// </remarks>
        /// <param name="reader">Reader to read the chunk's content with.</param>
        /// <param name="settings">Settings according to which the chunk's content must be read.</param>
        /// <param name="size">Expected size of the content taken from the chunk's header.</param>
        /// <exception cref="ObjectDisposedException">Method was called after the writer's underlying stream
        /// was disposed.</exception>
        /// <exception cref="IOException">An I/O error occurred on the writer's underlying stream.</exception>
        /// <exception cref="UnexpectedRunningStatusException">Unexpected running status is encountered.</exception>
        /// <exception cref="UnknownChannelEventException">Reader has encountered an unknown channel event.</exception>
        /// <exception cref="NotEnoughBytesException">Not enough bytes to read an event.</exception>
        /// <exception cref="InvalidChannelEventParameterValueException">Value of a channel event's parameter just
        /// read is invalid.</exception>
        /// <exception cref="MissedEndOfTrackEventException">Track chunk doesn't end with End Of Track event.</exception>
        protected override void ReadContent(MidiReader reader, ReadingSettings settings, uint size)
        {
            var endReaderPosition   = reader.Position + size;
            var endOfTrackPresented = false;

            byte?currentChannelEventStatusByte = null;

            //

            while (reader.Position < endReaderPosition && !reader.EndReached)
            {
                var midiEvent = ReadEvent(reader, settings, ref currentChannelEventStatusByte);
                if (midiEvent is EndOfTrackEvent)
                {
                    endOfTrackPresented = true;
                    break;
                }

                Events.Add(midiEvent);
            }

            //

            if (settings.MissedEndOfTrackPolicy == MissedEndOfTrackPolicy.Abort && !endOfTrackPresented)
            {
                throw new MissedEndOfTrackEventException();
            }
        }
Exemplo n.º 6
0
        // Token: 0x06003230 RID: 12848 RVA: 0x00146DC0 File Offset: 0x00144FC0
        protected override void ReadContent(MidiReader reader, ReadingSettings settings, uint size)
        {
            long num  = reader.Position + (long)((ulong)size);
            bool flag = false;
            byte?b    = null;

            this.onEvents = new List <int>(1);
            while (reader.Position < num && !reader.EndReached)
            {
                MidiEvent midiEvent = this.ReadEvent(reader, settings, ref b);
                if (midiEvent != null)
                {
                    if (midiEvent is EndOfTrackEvent)
                    {
                        flag = true;
                        break;
                    }
                    this.Events.Add(midiEvent);
                }
            }
            if (settings.MissedEndOfTrackPolicy == MissedEndOfTrackPolicy.Abort && !flag)
            {
                throw new MissedEndOfTrackEventException();
            }
        }
Exemplo n.º 7
0
 // Token: 0x0600333E RID: 13118 RVA: 0x0001725C File Offset: 0x0001545C
 protected override void ReadContent(MidiReader reader, ReadingSettings settings, int size)
 {
     if (size >= 1)
     {
         this.Port = reader.ReadByte();
     }
 }
Exemplo n.º 8
0
        // Token: 0x0600332D RID: 13101 RVA: 0x00147E64 File Offset: 0x00146064
        protected override void ReadContent(MidiReader reader, ReadingSettings settings, int size)
        {
            InvalidMetaEventParameterValuePolicy invalidMetaEventParameterValuePolicy = settings.InvalidMetaEventParameterValuePolicy;

            this.Key   = (sbyte)KeySignatureEvent.ProcessValue((int)reader.ReadSByte(), "Key", -7, 7, invalidMetaEventParameterValuePolicy);
            this.Scale = (byte)KeySignatureEvent.ProcessValue((int)reader.ReadByte(), "Scale", 0, 1, invalidMetaEventParameterValuePolicy);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Reads content of a MIDI meta event.
        /// </summary>
        /// <param name="reader">Reader to read the content with.</param>
        /// <param name="settings">Settings according to which the event's content must be read.</param>
        /// <param name="size">Size of the event's content.</param>
        /// <exception cref="ArgumentOutOfRangeException">Unknown meta event cannot be read since the size is
        /// negative number.</exception>
        protected override void ReadContent(MidiReader reader, ReadingSettings settings, int size)
        {
            ThrowIfArgument.IsNegative(nameof(size),
                                       size,
                                       "Unknown meta event cannot be read since the size is negative number.");

            Data = reader.ReadBytes(size);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Reads content of a MIDI event.
        /// </summary>
        /// <param name="reader">Reader to read the content with.</param>
        /// <param name="settings">Settings according to which the event's content must be read.</param>
        /// <param name="size">Size of the event's content.</param>
        internal sealed override void Read(MidiReader reader, ReadingSettings settings, int size)
        {
            ThrowIfArgument.IsNegative(nameof(size),
                                       size,
                                       "Non-negative size have to be specified in order to read SysEx event.");

            Data = reader.ReadBytes(size);
        }
Exemplo n.º 11
0
 // Token: 0x0600334B RID: 13131 RVA: 0x000172E4 File Offset: 0x000154E4
 protected override void ReadContent(MidiReader reader, ReadingSettings settings, int size)
 {
     if (size < 2)
     {
         return;
     }
     this.Number = reader.ReadWord();
 }
Exemplo n.º 12
0
        // Token: 0x060033A7 RID: 13223 RVA: 0x00148610 File Offset: 0x00146810
        public MidiEvent Read(MidiReader reader, ReadingSettings settings, byte currentStatusByte)
        {
            int        size = reader.ReadVlqNumber();
            string     typeName;
            SysExEvent sysExEvent = StandardEventTypes.SysEx.TryGetType(currentStatusByte, out typeName) ? this.GetEvent(typeName) : null;

            sysExEvent.Read(reader, settings, size);
            return(sysExEvent);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Reads an event from the reader's underlying stream.
        /// </summary>
        /// <param name="reader">Reader to read an event.</param>
        /// <param name="settings">Settings according to which an event must be read.</param>
        /// <param name="channelEventStatusByte">Current channel event status byte used as running status.</param>
        /// <returns>Instance of the <see cref="MidiEvent"/> representing a MIDI event.</returns>
        /// <exception cref="ObjectDisposedException">Method was called after the writer's underlying stream
        /// was disposed.</exception>
        /// <exception cref="IOException">An I/O error occurred on the writer's underlying stream.</exception>
        /// <exception cref="UnexpectedRunningStatusException">Unexpected running status is encountered.</exception>
        /// <exception cref="UnknownChannelEventException">Reader has encountered an unknown channel event.</exception>
        /// <exception cref="NotEnoughBytesException">Not enough bytes to read an event.</exception>
        /// <exception cref="InvalidChannelEventParameterValueException">Value of a channel event's parameter just
        /// read is invalid.</exception>
        private MidiEvent ReadEvent(MidiReader reader, ReadingSettings settings, ref byte?channelEventStatusByte)
        {
            var deltaTime = reader.ReadVlqLongNumber();

            if (deltaTime < 0)
            {
                deltaTime = 0;
            }

            //

            var statusByte = reader.ReadByte();

            if (statusByte <= SevenBitNumber.MaxValue)
            {
                if (channelEventStatusByte == null)
                {
                    throw new UnexpectedRunningStatusException();
                }

                statusByte = channelEventStatusByte.Value;
                reader.Position--;
            }

            //

            var eventReader = EventReaderFactory.GetReader(statusByte);
            var midiEvent   = eventReader.Read(reader, settings, statusByte);

            //

            if (settings.SilentNoteOnPolicy == SilentNoteOnPolicy.NoteOff)
            {
                var noteOnEvent = midiEvent as NoteOnEvent;
                if (noteOnEvent?.Velocity == 0)
                {
                    midiEvent = new NoteOffEvent
                    {
                        DeltaTime  = noteOnEvent.DeltaTime,
                        Channel    = noteOnEvent.Channel,
                        NoteNumber = noteOnEvent.NoteNumber
                    };
                }
            }

            //

            if (midiEvent is ChannelEvent)
            {
                channelEventStatusByte = statusByte;
            }

            //

            midiEvent.DeltaTime = deltaTime;
            return(midiEvent);
        }
        public MidiEvent Read(MidiReader reader, ReadingSettings settings, byte currentStatusByte)
        {
            Type eventType;
            StandardEventTypes.SystemCommon.TryGetType(currentStatusByte, out eventType);
            var systemCommonEvent = (SystemCommonEvent)Activator.CreateInstance(eventType);

            systemCommonEvent.Read(reader, settings, MidiEvent.UnknownContentSize);
            return systemCommonEvent;
        }
Exemplo n.º 15
0
 // Token: 0x0600338E RID: 13198 RVA: 0x001480A0 File Offset: 0x001462A0
 protected override void ReadContent(MidiReader reader, ReadingSettings settings, int size)
 {
     this.Numerator   = reader.ReadByte();
     this.Denominator = (byte)Math.Pow(2.0, (double)reader.ReadByte());
     if (size >= 4)
     {
         this.ClocksPerClick           = reader.ReadByte();
         this.NumberOf32ndNotesPerBeat = reader.ReadByte();
     }
 }
Exemplo n.º 16
0
        // Token: 0x0600323F RID: 12863 RVA: 0x00147394 File Offset: 0x00145594
        protected override void ReadContent(MidiReader reader, ReadingSettings settings, uint size)
        {
            long num = reader.Length - reader.Position;

            byte[] array = reader.ReadBytes((int)((num < (long)((ulong)size)) ? num : ((long)((ulong)size))));
            if ((long)array.Length < (long)((ulong)size) && settings.NotEnoughBytesPolicy == NotEnoughBytesPolicy.Abort)
            {
                throw new NotEnoughBytesException("Chunk's data cannot be read since the reader's underlying stream doesn't have enough bytes.", (long)((ulong)size), (long)array.Length);
            }
            this.Data = array;
        }
Exemplo n.º 17
0
        /// <summary>
        /// Reads content of a MIDI meta event.
        /// </summary>
        /// <param name="reader">Reader to read the content with.</param>
        /// <param name="settings">Settings according to which the event's content must be read.</param>
        /// <param name="size">Size of the event's content.</param>
        protected override void ReadContent(MidiReader reader, ReadingSettings settings, int size)
        {
            Numerator   = reader.ReadByte();
            Denominator = (byte)Math.Pow(2, reader.ReadByte());

            if (size >= 4)
            {
                ClocksPerClick           = reader.ReadByte();
                ThirtySecondNotesPerBeat = reader.ReadByte();
            }
        }
Exemplo n.º 18
0
        // Token: 0x06003216 RID: 12822 RVA: 0x00146C5C File Offset: 0x00144E5C
        protected override void ReadContent(MidiReader reader, ReadingSettings settings, uint size)
        {
            ushort num = reader.ReadWord();

            if (settings.UnknownFileFormatPolicy == UnknownFileFormatPolicy.Abort && !Enum.IsDefined(typeof(MidiFileFormat), (int)num))
            {
                throw new UnknownFileFormatException(string.Format("File format {0} is unknown.", num), num);
            }
            this.FileFormat   = num;
            this.TracksNumber = reader.ReadWord();
            this.TimeDivision = TimeDivisionFactory.GetTimeDivision(reader.ReadInt16());
        }
Exemplo n.º 19
0
        // Token: 0x06003378 RID: 13176 RVA: 0x00147F08 File Offset: 0x00146108
        protected override void ReadContent(MidiReader reader, ReadingSettings settings, int size)
        {
            InvalidMetaEventParameterValuePolicy invalidMetaEventParameterValuePolicy = settings.InvalidMetaEventParameterValuePolicy;
            byte formatAndHours = reader.ReadByte();

            this.Format    = SmpteOffsetEvent.GetFormat(formatAndHours);
            this.Hours     = SmpteOffsetEvent.ProcessValue(SmpteOffsetEvent.GetHours(formatAndHours), "Hours", 23, invalidMetaEventParameterValuePolicy);
            this.Minutes   = SmpteOffsetEvent.ProcessValue(reader.ReadByte(), "Minutes", 59, invalidMetaEventParameterValuePolicy);
            this.Seconds   = SmpteOffsetEvent.ProcessValue(reader.ReadByte(), "Seconds", 59, invalidMetaEventParameterValuePolicy);
            this.Frames    = SmpteOffsetEvent.ProcessValue(reader.ReadByte(), "Frames", SmpteOffsetEvent.MaxFrames[this.Format], invalidMetaEventParameterValuePolicy);
            this.SubFrames = SmpteOffsetEvent.ProcessValue(reader.ReadByte(), "SubFrames", 99, invalidMetaEventParameterValuePolicy);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Reads content of a MIDI meta event.
        /// </summary>
        /// <param name="reader">Reader to read the content with.</param>
        /// <param name="settings">Settings according to which the event's content must be read.</param>
        /// <param name="size">Size of the event's content.</param>
        /// <exception cref="ArgumentOutOfRangeException">Text event cannot be read since the size is
        /// negative number.</exception>
        protected sealed override void ReadContent(MidiReader reader, ReadingSettings settings, int size)
        {
            if (size < 0)
            {
                throw new ArgumentOutOfRangeException(
                          nameof(size),
                          size,
                          "Text event cannot be read since the size is negative number.");
            }

            Text = reader.ReadString(size);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Reads content of a MIDI event.
        /// </summary>
        /// <param name="reader">Reader to read the content with.</param>
        /// <param name="settings">Settings according to which the event's content must be read.</param>
        /// <param name="size">Size of the event's content.</param>
        internal sealed override void Read(MidiReader reader, ReadingSettings settings, int size)
        {
            if (size < 0)
            {
                throw new ArgumentOutOfRangeException(
                          nameof(size),
                          size,
                          "Non-negative size have to be specified in order to read SysEx event.");
            }

            Data = reader.ReadBytes(size);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Reads content of a MIDI meta event.
        /// </summary>
        /// <param name="reader">Reader to read the content with.</param>
        /// <param name="settings">Settings according to which the event's content must be read.</param>
        /// <param name="size">Size of the event's content.</param>
        /// <exception cref="ArgumentOutOfRangeException">Unknown meta event cannot be read since the size is
        /// negative number.</exception>
        protected override void ReadContent(MidiReader reader, ReadingSettings settings, int size)
        {
            if (size < 0)
            {
                throw new ArgumentOutOfRangeException(
                          nameof(size),
                          size,
                          "Unknown meta event cannot be read since the size is negative number.");
            }

            Data = reader.ReadBytes(size);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Reads content of a <see cref="HeaderChunk"/>.
        /// </summary>
        /// <remarks>
        /// Content of a <see cref="HeaderChunk"/> is format of the file, number of track chunks and time division.
        /// </remarks>
        /// <param name="reader">Reader to read the chunk's content with.</param>
        /// <param name="settings">Settings according to which the chunk's content must be read.</param>
        /// <param name="size">Expected size of the content taken from the chunk's header.</param>
        /// <exception cref="ObjectDisposedException">Method was called after the reader's underlying stream was disposed.</exception>
        /// <exception cref="IOException">An I/O error occurred on the reader's underlying stream.</exception>
        /// <exception cref="UnknownFileFormatException">The header chunk contains unknown file format and
        /// <see cref="ReadingSettings.UnknownFileFormatPolicy"/> property of the <paramref name="settings"/> set to
        /// <see cref="UnknownFileFormatPolicy.Abort"/>.</exception>
        protected override void ReadContent(MidiReader reader, ReadingSettings settings, uint size)
        {
            var fileFormat = reader.ReadWord();

            if (settings.UnknownFileFormatPolicy == UnknownFileFormatPolicy.Abort && !Enum.IsDefined(typeof(MidiFileFormat), fileFormat))
            {
                throw new UnknownFileFormatException($"File format {fileFormat} is unknown.", fileFormat);
            }

            FileFormat   = fileFormat;
            TracksNumber = reader.ReadWord();
            TimeDivision = TimeDivisionFactory.GetTimeDivision(reader.ReadInt16());
        }
        /// <summary>
        /// Reads content of a <see cref="UnknownChunk"/>.
        /// </summary>
        /// <remarks>
        /// Content of an <see cref="UnknownChunk"/> is array of bytes.
        /// </remarks>
        /// <param name="reader">Reader to read the chunk's content with.</param>
        /// <param name="settings">Settings according to which the chunk's content must be read.</param>
        /// <param name="size">Expected size of the content taken from the chunk's header.</param>
        /// <exception cref="ObjectDisposedException">Method was called after the reader's underlying stream was disposed.</exception>
        /// <exception cref="IOException">An I/O error occurred on the reader's underlying stream.</exception>
        protected override void ReadContent(MidiReader reader, ReadingSettings settings, uint size)
        {
            var availableSize = reader.Length - reader.Position;
            var bytes         = reader.ReadBytes((int)(availableSize < size ? availableSize : size));

            if (bytes.Length < size && settings.NotEnoughBytesPolicy == NotEnoughBytesPolicy.Abort)
            {
                throw new NotEnoughBytesException("Chunk's data cannot be read since the reader's underlying stream doesn't have enough bytes.",
                                                  size,
                                                  bytes.Length);
            }

            Data = bytes;
        }
Exemplo n.º 25
0
        /// <summary>
        /// Reads content of a MIDI meta event.
        /// </summary>
        /// <param name="reader">Reader to read the content with.</param>
        /// <param name="settings">Settings according to which the event's content must be read.</param>
        /// <param name="size">Size of the event's content.</param>
        protected override void ReadContent(MidiReader reader, ReadingSettings settings, int size)
        {
            var invalidMetaEventParameterValuePolicy = settings.InvalidMetaEventParameterValuePolicy;

            Key = (sbyte)ProcessValue(reader.ReadSByte(),
                                      nameof(Key),
                                      MinKey,
                                      MaxKey,
                                      invalidMetaEventParameterValuePolicy);

            Scale = (byte)ProcessValue(reader.ReadByte(),
                                       nameof(Scale),
                                       MinScale,
                                       MaxScale,
                                       invalidMetaEventParameterValuePolicy);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Reads content of a MIDI meta event.
        /// </summary>
        /// <param name="reader">Reader to read the content with.</param>
        /// <param name="settings">Settings according to which the event's content must be read.</param>
        /// <param name="size">Size of the event's content.</param>
        /// <exception cref="ArgumentOutOfRangeException">Text event cannot be read since the size is
        /// negative number.</exception>
        protected sealed override void ReadContent(MidiReader reader, ReadingSettings settings, int size)
        {
            ThrowIfArgument.IsNegative(nameof(size),
                                       size,
                                       "Text event cannot be read since the size is negative number.");

            if (size == 0)
            {
                return;
            }

            var bytes    = reader.ReadBytes(size);
            var encoding = settings.TextEncoding ?? SmfUtilities.DefaultEncoding;

            Text = encoding.GetString(bytes);
        }
Exemplo n.º 27
0
        internal override void Read(MidiReader reader, ReadingSettings settings, int size)
        {
            var data = reader.ReadByte();

            var messageType = data.GetHead();

            // TODO: proper exception
            if (!Enum.IsDefined(typeof(MidiTimeCodeComponent), (byte)messageType))
            {
                throw new Exception();
            }

            Component = (MidiTimeCodeComponent)(byte)messageType;
            // TODO: check value and apply policy
            ComponentValue = data.GetTail();
        }
Exemplo n.º 28
0
        // Token: 0x0600339D RID: 13213 RVA: 0x001481BC File Offset: 0x001463BC
        public MidiEvent Read(MidiReader reader, ReadingSettings settings, byte currentStatusByte)
        {
            FourBitNumber head = currentStatusByte.GetHead();
            FourBitNumber tail = currentStatusByte.GetTail();
            string        typeName;

            if (!StandardEventTypes.Channel.TryGetType(head, out typeName))
            {
                throw new UnknownChannelEventException(head, tail);
            }
            ChannelEvent @event = this.GetEvent(typeName);

            @event.Read(reader, settings, -1);
            @event.Channel = tail;
            return(@event);
        }
Exemplo n.º 29
0
        // Token: 0x06003304 RID: 13060 RVA: 0x00147DE0 File Offset: 0x00145FE0
        protected sealed override void ReadContent(MidiReader reader, ReadingSettings settings, int size)
        {
            if (size <= 0)
            {
                return;
            }
            byte[]   bytes    = reader.ReadBytes(size);
            Encoding somename = SomeClass.somename;
            Encoding utf      = Encoding.UTF8;
            string   @string  = somename.GetString(bytes);

            if (@string.Contains("Ã"))
            {
                @string = utf.GetString(bytes);
            }
            this.Text = @string;
        }
Exemplo n.º 30
0
        public MidiEvent Read(MidiReader reader, ReadingSettings settings, byte currentStatusByte)
        {
            var statusByte = currentStatusByte.GetHead();
            var channel    = currentStatusByte.GetTail();

            Type eventType;

            if (!StandardEventTypes.Channel.TryGetType(statusByte, out eventType))
            {
                throw new UnknownChannelEventException(statusByte, channel);
            }

            var channelEvent = (ChannelEvent)Activator.CreateInstance(eventType);

            channelEvent.Read(reader, settings, MidiEvent.UnknownContentSize);
            channelEvent.Channel = channel;
            return(channelEvent);
        }