Vixen
02b45cc4
csharp
public readonly record struct MusicTempo

How fast the music is, and how it is counted.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Everything is derived in frames, not seconds. A bar at 128 beats a minute is 1.875 seconds, which is 90 000 frames at 48 kHz exactly; expressed in seconds and converted later it is 1.8749999 and the error compounds every bar until a four-minute track has drifted audibly against a loop it was supposed to sit on. Integers of frames do not drift.

Written new MusicTempo() and never default, as every options type here is: the sensible values live in the initialisers, and a default is a tempo of zero beats a minute — which is not slow music, it is arithmetic that divides by nothing.

The bottom of the time signature is deliberately absent. What a beat is — a crotchet, a quaver — is a question about notation, and this only needs to know how long one lasts and how many make a bar.

Fields and properties (4)

  • public float BeatsPerMinute

    The tempo.

  • public int BeatsPerBar

    The top of the time signature — four for common time, three for a waltz.

  • public float SecondsPerBeat

    How long one beat lasts, in seconds.

  • public float SecondsPerBar

    How long one bar lasts, in seconds.

Methods (3)

  • public MusicTempo()

    How fast the music is, and how it is counted.

  • public long FramesPerBeat(int sampleRate)

    How many device frames one beat lasts.

  • public long FramesPerBar(int sampleRate)

    How many device frames one bar lasts.

Used by (9)

  • MusicPlayerVixen.Audio
  • MusicPlayerTestsVixen.Audio.Tests
  • MusicSegmentVixen.Audio
  • MusicSegmentAssetVixen.Audio
  • MusicTempoChangeVixen.Audio
  • MusicTempoMapVixen.Audio
  • MusicTransportVixen.Audio
  • MusicTransportTestsVixen.Audio.Tests
  • SectionVixen.Audio