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>
        /// <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.º 2
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.º 3
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.º 4
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.º 5
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);
        }
        /// <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.º 7
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.º 8
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;
        }
        /// <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 ?? SmfConstants.DefaultTextEncoding;

            var decodeTextCallback = settings.DecodeTextCallback;

            Text = decodeTextCallback != null
                ? decodeTextCallback(bytes, settings)
                : encoding.GetString(bytes);
        }
Exemplo n.º 10
0
 // Token: 0x06003354 RID: 13140 RVA: 0x00017349 File Offset: 0x00015549
 protected override void ReadContent(MidiReader reader, ReadingSettings settings, int size)
 {
     this.Data = reader.ReadBytes(size);
 }
Exemplo n.º 11
0
 // Token: 0x060032C3 RID: 12995 RVA: 0x00016C8C File Offset: 0x00014E8C
 internal sealed override void Read(MidiReader reader, ReadingSettings settings, int size)
 {
     this.Data = reader.ReadBytes(size);
 }