コード例 #1
0
ファイル: PatternBuilder.cs プロジェクト: dodohee/drywetmidi
        /// <summary>
        /// Repeats the specified number of previous actions.
        /// </summary>
        /// <param name="actionsCount">Number of previous actions to repeat.</param>
        /// <param name="repetitionsCount">Count of repetitions.</param>
        /// <returns>The current <see cref="PatternBuilder"/>.</returns>
        /// <remarks>
        /// Note that <see cref="SetNoteLength(ILength)"/>, <see cref="SetOctave(int)"/>,
        /// <see cref="SetStep(ILength)"/> and <see cref="SetVelocity(SevenBitNumber)"/> are not
        /// actions and will not be repeated since default values applies immidiately on next actions.
        /// </remarks>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="actionsCount"/> is
        /// negative. -or- <paramref name="actionsCount"/> is greater than count of existing actions. -or-
        /// <paramref name="repetitionsCount"/> is negative.</exception>
        public PatternBuilder Repeat(int actionsCount, int repetitionsCount)
        {
            ThrowIfArgument.IsNegative(nameof(actionsCount), actionsCount, "Actions count is negative.");
            ThrowIfArgument.IsGreaterThan(nameof(actionsCount),
                                          actionsCount,
                                          _actions.Count,
                                          "Actions count is greater than existing actions count.");
            ThrowIfArgument.IsNegative(nameof(repetitionsCount), repetitionsCount, "Repetitions count is negative.");

            return(RepeatActions(actionsCount, repetitionsCount));
        }
コード例 #2
0
        /// <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;
        }