Beispiel #1
0
        /// <summary>
        /// Sets new tempo that will last from the specified time until next change of tempo.
        /// </summary>
        /// <param name="time">Time to set the new tempo at.</param>
        /// <param name="tempo">New tempo that will last from the specified time until next change
        /// of tempo.</param>
        /// <exception cref="ArgumentNullException"><paramref name="time"/> is null. -or-
        /// <paramref name="tempo"/> is null.</exception>
        public void SetTempo(ITimeSpan time, Tempo tempo)
        {
            ThrowIfArgument.IsNull(nameof(time), time);
            ThrowIfArgument.IsNull(nameof(tempo), tempo);

            SetTempo(TimeConverter.ConvertFrom(time, TempoMap), tempo);
        }
Beispiel #2
0
        /// <summary>
        /// Sets new tempo that will last from the specified time until next change of tempo.
        /// </summary>
        /// <param name="time">Time to set the new tempo at.</param>
        /// <param name="tempo">New tempo that will last from the specified time until next change
        /// of tempo.</param>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="time"/> is negative.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="tempo"/> is null.</exception>
        public void SetTempo(long time, Tempo tempo)
        {
            ThrowIfTimeArgument.IsNegative(nameof(time), time);
            ThrowIfArgument.IsNull(nameof(tempo), tempo);

            TempoMap.Tempo.SetValue(time, tempo);
        }
Beispiel #3
0
        /// <summary>
        /// Creates an instance of the <see cref="TempoMap"/> with the specified tempo using
        /// default time division (96 ticks per quarter note).
        /// </summary>
        /// <param name="tempo">Tempo of the tempo map.</param>
        /// <returns><see cref="TempoMap"/> with the specified tempo.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="tempo"/> is null.</exception>
        public static TempoMap Create(Tempo tempo)
        {
            ThrowIfArgument.IsNull(nameof(tempo), tempo);

            var tempoMap = Default.Clone();

            tempoMap.Tempo.SetValue(0, tempo);

            return(tempoMap);
        }
Beispiel #4
0
        /// <summary>
        /// Creates an instance of the <see cref="TempoMap"/> with the specified tempo using
        /// default time division (96 ticks per quarter note).
        /// </summary>
        /// <param name="tempo">Tempo of the tempo map.</param>
        /// <returns><see cref="TempoMap"/> with the specified tempo.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="tempo"/> is null.</exception>
        public static TempoMap Create(Tempo tempo)
        {
            ThrowIfArgument.IsNull(nameof(tempo), tempo);

            var tempoMap = Default.Clone();

            SetGlobalTempo(tempoMap, tempo);

            return(tempoMap);
        }
Beispiel #5
0
        public static TempoMap Create(TimeDivision timeDivision, Tempo tempo)
        {
            ThrowIfArgument.IsNull(nameof(timeDivision), timeDivision);
            ThrowIfArgument.IsNull(nameof(tempo), tempo);

            var tempoMap = new TempoMap(timeDivision);

            SetGlobalTempo(tempoMap, tempo);

            return(tempoMap);
        }
 private static double GetMicroseconds(long time, Tempo tempo, short ticksPerQuarterNote)
 {
     return(time * tempo.MicrosecondsPerQuarterNote / (double)ticksPerQuarterNote);
 }
Beispiel #7
0
 private static void SetGlobalTempo(TempoMap tempoMap, Tempo tempo)
 {
     tempoMap.Tempo.SetValue(0, tempo);
 }