/// <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">
        /// <para>One of the following errors occured:</para>
        /// <list type="bullet">
        /// <item>
        /// <description><paramref name="time"/> is <c>null</c>.</description>
        /// </item>
        /// <item>
        /// <description><paramref name="tempo"/> is <c>null</c>.</description>
        /// </item>
        /// </list>
        /// </exception>
        public void SetTempo(ITimeSpan time, Tempo tempo)
        {
            ThrowIfArgument.IsNull(nameof(time), time);
            ThrowIfArgument.IsNull(nameof(tempo), tempo);

            SetTempo(TimeConverter.ConvertFrom(time, TempoMap), tempo);
        }
        /// <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 <c>null</c>.</exception>
        public void SetTempo(long time, Tempo tempo)
        {
            ThrowIfTimeArgument.IsNegative(nameof(time), time);
            ThrowIfArgument.IsNull(nameof(tempo), tempo);

            TempoMap.TempoLine.SetValue(time, tempo);
        }
示例#3
0
 /// <summary>
 /// Flips the tempo map relative to the specified time.
 /// </summary>
 /// <param name="centerTime">The time the tempo map should be flipped relative to.</param>
 /// <returns>The tempo mup flipped relative to the <paramref name="centerTime"/>.</returns>
 internal TempoMap Flip(long centerTime)
 {
     return(new TempoMap(TimeDivision)
     {
         Tempo = Tempo.Reverse(centerTime),
         TimeSignature = TimeSignature.Reverse(centerTime)
     });
 }
示例#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);
        }
示例#5
0
        /// <summary>
        /// Creates an instance of the <see cref="TempoMap"/> with the specified time division and
        /// tempo using default time signature (4/4).
        /// </summary>
        /// <param name="timeDivision">Time division of the tempo map.</param>
        /// <param name="tempo">Tempo of the tempo map.</param>
        /// <returns><see cref="TempoMap"/> with the specified time division and tempo.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="timeDivision"/> is null. -or-
        /// <paramref name="tempo"/> is null.</exception>
        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);
        }
示例#6
0
 private static void SetGlobalTempo(TempoMap tempoMap, Tempo tempo)
 {
     tempoMap.Tempo.SetValue(0, tempo);
 }
 private static double GetMicroseconds(long time, Tempo tempo, short ticksPerQuarterNote)
 {
     return(time * tempo.MicrosecondsPerQuarterNote / (double)ticksPerQuarterNote);
 }