本文整理汇总了C#中Channel.Validate方法的典型用法代码示例。如果您正苦于以下问题:C# Channel.Validate方法的具体用法?C# Channel.Validate怎么用?C# Channel.Validate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Channel
的用法示例。
在下文中一共展示了Channel.Validate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EncodeNoteOn
/// <summary>
/// Encodes a Note On short message.
/// </summary>
/// <param name="channel">The channel.</param>
/// <param name="note">The note.</param>
/// <param name="velocity">The velocity 0..127.</param>
/// <returns>A value that can be passed to midiOutShortMsg.</returns>
public static UInt32 EncodeNoteOn(Channel channel, Note note, int velocity)
{
channel.Validate();
note.Validate();
if (velocity < 0 || velocity > 127)
{
throw new ArgumentOutOfRangeException("Velocity is out of range.");
}
return (UInt32)(0x90 | ((int)channel) | ((int)note << 8) | (velocity << 16));
}
示例2: EncodeNoteOn
/// <summary>
/// Encodes a Note On short message.
/// </summary>
/// <param name="channel">The channel.</param>
/// <param name="pitch">The pitch.</param>
/// <param name="velocity">The velocity 0..127.</param>
/// <returns>A value that can be passed to midiOutShortMsg.</returns>
/// <exception cref="ArgumentOutOfRangeException">pitch is not in MIDI range.</exception>
public static UInt32 EncodeNoteOn(Channel channel, Pitch pitch, int velocity)
{
channel.Validate();
if (!pitch.IsInMidiRange())
{
throw new ArgumentOutOfRangeException("Pitch out of MIDI range.");
}
if (velocity < 0 || velocity > 127)
{
throw new ArgumentOutOfRangeException("Velocity is out of range.");
}
return (UInt32)(0x90 | ((int)channel) | ((int)pitch << 8) | (velocity << 16));
}
示例3: EncodeProgramChange
/// <summary>
/// Encodes a Program Change short message.
/// </summary>
/// <param name="channel">The channel.</param>
/// <param name="instrument">The instrument.</param>
/// <returns>A value that can be passed to midiOutShortMsg.</returns>
public static UInt32 EncodeProgramChange(Channel channel, Instrument instrument)
{
channel.Validate();
instrument.Validate();
return (UInt32)(0xC0 | (int)(channel) | ((int)instrument << 8));
}
示例4: EncodePitchBend
/// <summary>
/// Encodes a Pitch Bend short message.
/// </summary>
/// <param name="channel">The channel.</param>
/// <param name="value">The pitch bend value, 0..16383, 8192 is centered.</param>
/// <returns>A value that can be passed to midiOutShortMsg.</returns>
public static UInt32 EncodePitchBend(Channel channel, int value)
{
channel.Validate();
if (value < 0 || value > 16383)
{
throw new ArgumentOutOfRangeException("Value is out of range.");
}
return (UInt32)(0xE0 | (int)(channel) | ((value & 0x7f) << 8) |
((value & 0x3f80) << 9));
}
示例5: EncodeControlChange
/// <summary>
/// Encodes a Control Change short message.
/// </summary>
/// <param name="channel">The channel.</param>
/// <param name="control">The control.</param>
/// <param name="value">The new value 0..127.</param>
/// <returns>A value that can be passed to midiOutShortMsg.</returns>
public static UInt32 EncodeControlChange(Channel channel, Control control, int value)
{
channel.Validate();
control.Validate();
if (value < 0 || value > 127)
{
throw new ArgumentOutOfRangeException("Value is out of range.");
}
return (UInt32)(0xB0 | (int)(channel) | ((int)control << 8) | (value << 16));
}
示例6: ChannelMessage
/// <summary>
/// Protected constructor.
/// </summary>
protected ChannelMessage(DeviceBase device, Channel channel, float time)
: base(device, time)
{
channel.Validate();
this.channel = channel;
}