Skip to content

Cubase XML: Calculating event times when tempo ramp events are used #18

Open
@orchetect

Description

@orchetect

Issue

Cubase tempo tracks can contain one or more jump or ramp tempo events. A jump is an immediate jump to a new tempo. A ramp is a gradual ramp between two tempo events.

Currently, DAWFileKit can accurately determine event start times (and timecodes) when "jump" tempo events are used exclusively. However, DAWFileKit cannot yet properly calculate event start times if one or more "ramp" tempo events are used. The time calculation that Cubase uses needs to be intuited.

Observations

The ramp is linear when in the musical domain (bars + beats). However this results in a curved ramp when in the real time domain.

For consideration, this is a Cubase project used in DAWFileKit unit tests (after being exported as a Track Archive XML file). The ramp curves can be observed in Cubase by changing the visible time scaling mode.

Bars + Beats Linear:
bars-beats-linear

Time Linear:
time-linear

Current Progress

The unit test involving the Cubase project shown above is already written, but the four marker events that overlap and trail the tempo ramps have been commented out, as they will fail currently since the calculations are not yet correct.

#warning(
"> TODO: these four asserts are correct, but will fail for now until tempo ramp events are implemented"
)
let track1event7 = track1?.events[safe: 6] as? Cubase.TrackArchive.Marker
// XCTAssertEqual(track1event7?.startTimecode.stringValue, "01:00:26:02")
_ = track1event7 // silence warning
let track1event8 = track1?.events[safe: 7] as? Cubase.TrackArchive.Marker
// XCTAssertEqual(track1event8?.startTimecode.stringValue, "01:00:29:09")
_ = track1event8 // silence warning
let track1event9 = track1?.events[safe: 8] as? Cubase.TrackArchive.Marker
// XCTAssertEqual(track1event9?.startTimecode.stringValue, "01:00:31:24")
_ = track1event9 // silence warning
let track1event10 = track1?.events[safe: 9] as? Cubase.TrackArchive.Marker
// XCTAssertEqual(track1event10?.startTimecode.stringValue, "01:50:25:07")
_ = track1event10 // silence warning

The currently incomplete calculation is found here:

case .rampToNext:
#warning("> TODO: This calculation is not accurate, it is merely approximate.")
// Cubase (and other DAWs like Logic Pro X) have mysterious tempo ramp calculation
// algorithms
// I was not able to precisely reverse engineer the algo Cubase uses
// This is as close as I could get to approximate the calculation

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions