public MidiTimeCodeEvent(MidiTimeCodeComponent component, FourBitNumber componentValue) { ThrowIfArgument.IsInvalidEnumValue(nameof(component), component); Component = component; ComponentValue = componentValue; }
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; }
// Token: 0x060033B0 RID: 13232 RVA: 0x00148648 File Offset: 0x00146848 public void Write(MidiEvent midiEvent, MidiWriter writer, WritingSettings settings, bool writeStatusByte) { if (writeStatusByte) { Type type = midiEvent.GetType(); byte number; StandardEventTypes.Channel.TryGetStatusByte(type, out number); FourBitNumber channel = ((ChannelEvent)midiEvent).Channel; byte value = DataTypesUtilities.Combine((FourBitNumber)number, channel); writer.WriteByte(value); } midiEvent.Write(writer, settings); }
/// <summary> /// Initializes a new instance of the <see cref="MidiTimeCodeEvent"/> with the specified /// time code component and its value. /// </summary> /// <param name="component">MIDI time code component.</param> /// <param name="componentValue">Value of <paramref name="component"/>.</param> /// <exception cref="InvalidEnumArgumentException"><paramref name="component"/> specified an /// invalid value.</exception> public MidiTimeCodeEvent(MidiTimeCodeComponent component, FourBitNumber componentValue) { ThrowIfArgument.IsInvalidEnumValue(nameof(component), component); var maximumComponentValue = ComponentValueMasks[component]; ThrowIfArgument.IsGreaterThan(nameof(componentValue), componentValue, maximumComponentValue, $"Component's value is greater than maximum valid one which is {maximumComponentValue}."); Component = component; ComponentValue = componentValue; }
// 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); }
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(); }
/// <summary> /// Initializes a new instance of the <see cref="UnknownChannelEventException"/> with the /// specified status byte and channel. /// </summary> /// <param name="statusByte">Status byte of an unknown channel event.</param> /// <param name="channel">Channel of an unknown channel event.</param> public UnknownChannelEventException(FourBitNumber statusByte, FourBitNumber channel) : this() { StatusByte = statusByte; Channel = channel; }
/// <summary> /// Merges two four-bit numbers into one byte. /// </summary> /// <param name="head"><see cref="FourBitNumber"/> representing left part of resulting number.</param> /// <param name="tail"><see cref="FourBitNumber"/> representing right part of resulting number.</param> /// <returns>Single byte made of four-bit halfs.</returns> public static byte Combine(FourBitNumber head, FourBitNumber tail) { return((byte)((head << 4) | tail)); }
/// <summary> /// Gets an instance of the <see cref="ControlChangeEvent"/> corresponding to the specified controller. /// </summary> /// <param name="controlName"><see cref="ControlName"/> to get an event for.</param> /// <param name="controlValue">Controller value to set to event.</param> /// <param name="channel">Channel an event should be created for.</param> /// <returns>An instance of the <see cref="ControlChangeEvent"/> corresponding to the <paramref name="controlName"/>.</returns> /// <exception cref="InvalidEnumArgumentException"><paramref name="controlName"/> specified an invalid value.</exception> public static ControlChangeEvent GetControlChangeEvent(this ControlName controlName, SevenBitNumber controlValue, FourBitNumber channel) { ThrowIfArgument.IsInvalidEnumValue(nameof(controlName), controlName); return(new ControlChangeEvent(controlName.AsSevenBitNumber(), controlValue) { Channel = channel }); }
// Token: 0x06003471 RID: 13425 RVA: 0x000181A0 File Offset: 0x000163A0 public static byte Combine(FourBitNumber head, FourBitNumber tail) { return((byte)((int)head << 4 | (int)tail)); }