Exemplo n.º 1
0
        /// <summary>
        /// Gets Program Change event corresponding to the specified General Sound percussion set.
        /// </summary>
        /// <param name="percussionSet"><see cref="GeneralSoundPercussionSet"/> to get event for.</param>
        /// <param name="channel">Channel event should be created for.</param>
        /// <returns>Program Change event corresponding to the <paramref name="percussionSet"/>.</returns>
        /// <exception cref="InvalidEnumArgumentException"><paramref name="percussionSet"/> specified an invalid value.</exception>
        public static MidiEvent GetProgramEvent(this GeneralSoundPercussionSet percussionSet, FourBitNumber channel)
        {
            ThrowIfArgument.IsInvalidEnumValue(nameof(percussionSet), percussionSet);

            return(new ProgramChangeEvent(percussionSet.AsSevenBitNumber())
            {
                Channel = channel
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets MIDI events sequence to switch to the specified General Sound percussion set.
        /// </summary>
        /// <param name="percussionSet"><see cref="GeneralSoundPercussionSet"/> to get events for.</param>
        /// <param name="channel">Channel events should be created for.</param>
        /// <returns>MIDI events sequence to switch to the <paramref name="percussionSet"/>.</returns>
        /// <exception cref="InvalidEnumArgumentException"><paramref name="percussionSet"/> specified an invalid value.</exception>
        public static IEnumerable <MidiEvent> GetPercussionSetEvents(this GeneralSoundPercussionSet percussionSet, FourBitNumber channel)
        {
            ThrowIfArgument.IsInvalidEnumValue(nameof(percussionSet), percussionSet);

            return(new[]
            {
                ControlName.BankSelect.GetControlChangeEvent((SevenBitNumber)RhythmChannelBankMsb, channel),
                ControlName.LsbForBankSelect.GetControlChangeEvent((SevenBitNumber)0, channel),
                percussionSet.GetProgramEvent(channel)
            });
        }
Exemplo n.º 3
0
        /// <summary>
        /// Converts <see cref="GeneralSoundPercussionSet"/> to the corresponding value of the
        /// <see cref="SevenBitNumber"/> type.
        /// </summary>
        /// <param name="percussionSet"><see cref="GeneralSoundPercussionSet"/> to convert to <see cref="SevenBitNumber"/>.</param>
        /// <returns><see cref="SevenBitNumber"/> representing the <paramref name="percussionSet"/>.</returns>
        /// <exception cref="InvalidEnumArgumentException"><paramref name="percussionSet"/> specified an invalid value.</exception>
        public static SevenBitNumber AsSevenBitNumber(this GeneralSoundPercussionSet percussionSet)
        {
            ThrowIfArgument.IsInvalidEnumValue(nameof(percussionSet), percussionSet);

            return((SevenBitNumber)(byte)percussionSet);
        }