/// <summary> /// Gets an octave definition by the specified octave number. /// </summary> /// <param name="octave">The number of an octave.</param> /// <returns>A definition of the octave with the specified number.</returns> /// <exception cref="ArgumentOutOfRangeException"><paramref name="octave"/> is out of valid range.</exception> public static OctaveDefinition Get(int octave) { ThrowIfArgument.IsOutOfRange(nameof(octave), octave, MinOctaveNumber, MaxOctaveNumber, $"Octave number is out of [{MinOctaveNumber}, {MaxOctaveNumber}] range."); OctaveDefinition octaveDefinition; if (!_cache.TryGetValue(octave, out octaveDefinition)) { _cache.Add(octave, octaveDefinition = new OctaveDefinition(octave)); } return(octaveDefinition); }
/// <summary> /// Sets default note octave that will be used by next actions of the builder. /// </summary> /// <param name="octave">New default octave.</param> /// <returns>The current <see cref="PatternBuilder"/>.</returns> /// <remarks> /// Setting default octave is not an action and thus will not be stored in a pattern. /// </remarks> /// <exception cref="ArgumentOutOfRangeException"><paramref name="octave"/> is out of valid range.</exception> public PatternBuilder SetOctave(int octave) { _octave = OctaveDefinition.Get(octave); return(this); }