public ITime ConvertTo(long time, TempoMap tempoMap) { ThrowIfTimeArgument.IsNegative(nameof(time), time); ThrowIfArgument.IsNull(nameof(tempoMap), tempoMap); var ticksPerQuarterNoteTimeDivision = tempoMap.TimeDivision as TicksPerQuarterNoteTimeDivision; if (ticksPerQuarterNoteTimeDivision != null) { return(ConvertToByTicksPerQuarterNote(time, ticksPerQuarterNoteTimeDivision.TicksPerQuarterNote, tempoMap)); } ThrowIfTimeDivision.IsNotSupportedForTimeConversion(tempoMap.TimeDivision); return(null); }
public long ConvertFrom(ITime time, TempoMap tempoMap) { ThrowIfArgument.IsNull(nameof(time), time); ThrowIfArgument.IsNull(nameof(tempoMap), tempoMap); var metricTime = time as MetricTime; if (metricTime == null) { throw new ArgumentException($"Time is not an instance of the {nameof(MetricTime)}.", nameof(time)); } var ticksPerQuarterNoteTimeDivision = tempoMap.TimeDivision as TicksPerQuarterNoteTimeDivision; if (ticksPerQuarterNoteTimeDivision != null) { return(ConvertFromByTicksPerQuarterNote(metricTime, ticksPerQuarterNoteTimeDivision.TicksPerQuarterNote, tempoMap)); } ThrowIfTimeDivision.IsNotSupportedForTimeConversion(tempoMap.TimeDivision); return(0); }