Vixen
02b45cc4
csharp
public sealed class MusicTransport

Where the music is, counted in samples the device actually produced.

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

Remarks

A window onto the device's own clock, not a clock of its own. Everything musical is a position on AudioEngine.RenderedFrames: the transport does not tick, it reads. A separate timer — a stopwatch, a frame accumulator — would drift against the samples being played, and a bar line computed from a drifting clock is a bar line in the wrong place. There is exactly one clock and the hardware owns it.

The origin moves; the clock does not. Starting a segment sets an origin, and position is measured from there — so "bar three" means bar three of this segment rather than of the session, and a transport that has been running for an hour has the same arithmetic in it as one that has just started.

Fields and properties (4)

  • public int SampleRate

    The device's rate.

  • public long Origin

    The device frame the current segment began at.

  • public MusicTempoMap Map

    How its frames, beats and bars relate, across however many tempi it has.

  • public MusicTempo Tempo

    The tempo it started at. A segment that changes tempo has more than this one.

Methods (7)

  • public MusicTransport(int sampleRate)

    Where the music is, counted in samples the device actually produced.

  • public void Start(long frame, MusicTempoMap map)

    Puts the origin at a frame, so positions are measured from there.

  • public void Start(long frame, in MusicTempo tempo)

    Puts the origin at a frame, at one unchanging tempo.

  • public long PositionAt(long frame)

    How far into the segment a device frame is, in frames.

  • public long BeatAt(long frame)

    Which beat a device frame falls on, counting from zero at the origin.

  • public long BarAt(long frame)

    Which bar a device frame falls in, counting from zero at the origin.

  • public long NextBoundary(long frame, MusicQuantize quantize, long segmentFrames = 0)

    The first frame at or after a given one that a change is allowed to land on.

Used by (3)

  • MusicPlayerVixen.Audio
  • MusicPlayerTestsVixen.Audio.Tests
  • MusicTransportTestsVixen.Audio.Tests