Vixen
02b45cc4
csharp
public sealed class MusicTempoMap

How a segment's frames, beats and bars relate, across however many tempi it has.

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

Remarks

Precomputed sections, and integer frames throughout. Every change is turned into a section with a start frame, a start beat and a start bar worked out once; after that, asking where the next bar line is means finding a section and doing integer arithmetic inside it. Walking the changes on every query would be the same answer more slowly, and doing it in seconds would drift — a bar at 128 in four is 90 000 frames at 48 kHz exactly and 1.8749999 seconds inexactly.

One section is the ordinary case and costs nothing extra. Most game music is one tempo, which is why this was a single value for as long as it was; a map with no changes behaves identically and is one array of one.

Immutable once built, and built once per segment rather than per frame.

Fields and properties (3)

  • public int SampleRate

    The device rate every frame count here is in terms of.

  • public MusicTempo Tempo

    The tempo it starts at.

  • public int SectionCount

    How many tempi it has.

Methods (6)

  • public MusicTempoMap(in MusicTempo tempo, ReadOnlySpan<MusicTempoChange> changes, int sampleRate)

    A map over a segment.

  • public long BeatAt(long offset)

    Which beat an offset into the segment falls on.

  • public long BarAt(long offset)

    Which bar an offset into the segment falls in.

  • public long FrameAtBeat(long beat)

    Where a beat is, in frames from the segment's start.

  • public long NextBeat(long offset)

    The first beat line at or after an offset.

  • public long NextBar(long offset)

    The first bar line at or after an offset.

Used by (2)

  • MusicPlayerVixen.Audio
  • MusicTransportVixen.Audio