DAWFileKit icon indicating copy to clipboard operation
DAWFileKit copied to clipboard

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

Open orchetect opened this issue 2 years ago • 0 comments

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.

https://github.com/orchetect/DAWFileKit/blob/dbd6a1de00e365084c9c20b0b775465b5b0d4a37/Tests/DAWFileKitTests/Cubase/Cubase%20TrackArchive%20MusicalAndLinearTest.swift#L66-L84

The currently incomplete calculation is found here:

https://github.com/orchetect/DAWFileKit/blob/dbd6a1de00e365084c9c20b0b775465b5b0d4a37/Sources/DAWFileKit/Cubase/TrackArchive/TrackArchive%20Helpers.swift#L118-L123

orchetect avatar May 10 '23 22:05 orchetect