orchetect / dawfilekit Goto Github PK
View Code? Open in Web Editor NEWA Swift library for reading and writing common import/export file formats between popular DAW applications.
License: MIT License
A Swift library for reading and writing common import/export file formats between popular DAW applications.
License: MIT License
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.
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.
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.
The currently incomplete calculation is found here:
DAWFileKit/Sources/DAWFileKit/Cubase/TrackArchive/TrackArchive Helpers.swift
Lines 118 to 123 in dbd6a1d
Not yet released, but it was announced that the next update to Pro Tools (perhaps 2023.5 or 2023.6) will have a new feature called Track Markers.
Once the update is released, hopefully there will be a way to import/export these markers and then add support to DAWFileKit to extract them in addition to the already-existing session markers.
In Pro Tools during Export → Session Info as Text, if the text encoding is set to TextEdit (which is the default selection), it lossily converts various non-standard/extended characters in text strings (such as Marker name / comments).
Character | Description | Exported | Notes |
---|---|---|---|
– | U+2013, En Dash | Ð | |
— | U+2014, Em Dash | Ñ | Keyboard input character substitution on macOS |
’ | U+2019, Right Single Quote | Õ | Sometimes when copying from Microsoft Word; should be an apostrophe |
… | U+2026, Ellipsis | É | Keyboard input character substitution on macOS |
T R A C K L I S T I N G
M A R K E R S L I S T I N G
# LOCATION TIME REFERENCE UNITS NAME COMMENTS
1 01:00:00:00 480000 Samples Test Ellipsis…
2 01:01:00:00 3360000 Samples Test Em Dash —
3 01:02:00:00 6240000 Samples Test En Dash –
4 01:03:00:00 9120000 Samples Right Side Quote’s Not An Apostrophe
T R A C K L I S T I N G
M A R K E R S L I S T I N G
# LOCATION TIME REFERENCE UNITS NAME COMMENTS
1 01:00:00:00 480000 Samples Test EllipsisÉ
2 01:01:00:00 3360000 Samples Test Em Dash Ñ
3 01:02:00:00 6240000 Samples Test En Dash Ð
4 01:03:00:00 9120000 Samples Right Side QuoteÕs Not An Apostrophe
https://www.avid.com/resource-center/whats-new-in-pro-tools-202312
Pro Tools 2023.12 adds new marker features such as multiple marker rulers and improved marker window ("memory location" window) filtering and filter presets.
It also adds more control over how markers on tracks and markers in rulers are imported and exported - but only to/from Pro Tools sessions it seems. And its session file format remains fairly proprietary and unreadable/unwritable.
For interchange with other software, there seems to be no new features. We are still limited to:
It would be worth checking to see if the session info text file's format has changed in any way with the new updates.
The last update round, Pro Tools introduced track markers (#20) and it did not alter the text file formatting at all. Track markers are merged with ruler markers and exported in the same single marker list in the text file, without any additional information regarding their usage or associated track name from the session.
sync-clip
rolesmc-clip
rolesanalysis-marker
fcpxml
ExtractionSettings
to allow filtering out elements that are either partially or fully out-of-bounds, and therefore not visible on the main timelineabsoluteStart
to inTime
. Add outTime
property to context
, calculated from inTime + duration.Frame rate scaling for clips using conform-rate
child element.
As support for timeline/media frame rate pairs are added, this table will be updated. (Project rates in the 1st column and media rates in subsequent columns.)
Project rate | 23.98 | 24 | 25 | 29.97 | 29.97d | 30 | 50 | 59.94 | 60 |
---|---|---|---|---|---|---|---|---|---|
23.98 | N/A | ? | X | ? | ? | ? | ? | ||
24 | X | N/A | X | X | |||||
25 | N/A | ||||||||
29.97 | X | ? | N/A | ? | ? | ? | ? | ||
29.97d | X | X | N/A | ||||||
30 | X | X | N/A | ||||||
50 | N/A | ||||||||
59.94 | X | X | N/A | ||||||
60 | X | X | N/A |
X
= implemented and unit tested
?
= should work in theory, being reciprocals of already-tested rate pairs, but have not been explicitly unit tested
resources
parameter in inits and force them to parse exclusively from the XML, including parsing out resources when necessaryTimecode
can result in subframe aliasing where Final Cut Pro shows timecode for elements (markers, captions, keywords, etc.) 1-2 subframes off
CMTime
or Fraction
and convert to Timecode
ad-hocdebugDescription
output for Any*
enum cases, etc.Sendable
note
is a child element for clips, but an attribute for annotationsframeDuration
, in which case we would need to add frame rate info for each one of these to derive it0
lanes extend past clip(s) beneath themRelated to #22, out of curiosity I poked around at the clipboard content Final Cut Pro uses when copying markers from the application.
It may be possible to add methods to DAWFileKit to read/write FCP clipboard contents.
FCP uses the following UTI type:
extension NSPasteboard.PasteboardType {
/// Final Cut Pro's pasteboard UTI type. The content is a binary plist.
static let finalCutPro = Self("com.apple.flexo.proFFPasteboardUTI")
}
The content of the data is a binary plist. Converted to XML, this is what it looks like:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ffpasteboardcopiedtypes</key>
<dict>
<key>pb_anchoredObject</key>
<dict>
<key>count</key>
<integer>1</integer>
</dict>
</dict>
<key>ffpasteboardobject</key>
<data>
<!-- base64-encoded data -->
</data>
<key>kffmodelobjectIDs</key>
<array/>
</dict>
The ffpasteboardobject
data blob contains a binary plist payload encoded by NSKeyedArchiver
.
The root object is NSDictionary
so it should be possible to deserialize the archive into a dictionary. It's not immediately apparent if the dictionary structure is similar to FCP XML.
It definitely contains the selected markers from Final Cut Pro marker list and their details (start, duration, name).
However, attempting to directly unarchive the data will produce errors because proprietary FCP classes are included in the archived data.
try NSKeyedUnarchiver.unarchivedObject(
ofClasses: [NSDictionary.self, NSMutableArray.self],
from: data
)
Error Domain=NSCocoaErrorDomain Code=4864 "*** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (FFAnchoredCollection) for key (NS.objects) because no class named "FFAnchoredCollection" was found; the class needs to be defined in source code or linked in from a library (ensure the class is part of the correct target).
I'm not sure if Apple's ProExtension
framework (which contains some FCP objects) has these classes. Worth checking out.
This means it may be necessary to manually parse the archived data, or at least selectively unarchive its children instead of attempting to unarchive the entire root dictionary. (It does not seem practical to try to model all known proprietary class types for the unarchiver to use.)
Pro Tools allows them to be inserted or pasted from the clipboard when editing markers (in both marker name and comment text).
Add support for reading and authoring MusicXML.
Support for markers will be the main priority.
A bit of testing is needed to determine if precise timing information can be derived.
For example, a MusicXML xml file exported from Digital Performer 10 is summarized below.
<direction>
element with inner element <words>
are used.<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 3.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise>
<identification>
<creator type="composer">Steffan Andrews</creator>
<rights>© Steffan Andrews</rights>
<encoding>
<software>Digital Performer 10.13 86175</software>
<encoding-date>2021-02-06</encoding-date>
<supports attribute="new-system" element="print" type="no" value="yes"/>
<supports attribute="new-page" element="print" type="no" value="yes"/>
<supports element="accidental" type="yes"/>
<supports element="beam" type="yes"/>
<supports element="stem" type="no"/>
</encoding>
</identification>
<part-list>
<part-group number="2" type="start">
<group-symbol>bracket</group-symbol>
<group-barline>yes</group-barline>
</part-group>
<score-part id="P0">
<part-name>MIDI-1</part-name>
<part-abbreviation>MI.1</part-abbreviation>
</score-part>
<part-group number="2" type="stop"/>
</part-list>
<part id="P0">
<measure number="1">
<attributes>
<divisions>480</divisions>
<key>
<fifths>0</fifths>
<mode>major</mode>
</key>
<time>
<beats>4</beats>
<beat-type>4</beat-type>
</time>
<staves>1</staves>
<clef number="1">
<sign>G</sign>
<line>2</line>
</clef>
<transpose>
<diatonic>0</diatonic>
<chromatic>0</chromatic>
<octave-change>0</octave-change>
</transpose>
</attributes>
<note>
<rest measure="yes"/>
<duration>1920</duration>
<voice>1</voice>
<staff>1</staff>
</note>
<direction placement="above">
<direction-type>
<metronome>
<beat-unit>quarter</beat-unit>
<per-minute>120.00</per-minute>
</metronome>
</direction-type>
<offset>-1920</offset>
<voice>1</voice>
<staff>1</staff>
<sound tempo="120.00"/>
</direction>
</measure>
<measure number="2">
<note>
<rest measure="yes"/>
<duration>1920</duration>
<voice>1</voice>
<staff>1</staff>
</note>
</measure>
<!-- ... (snipped: empty measures 3 through 1800 which are identical to measure 2) ... -->
<measure number="1801">
<note>
<rest measure="yes"/>
<duration>1920</duration>
<voice>1</voice>
<staff>1</staff>
</note>
<direction placement="above">
<direction-type>
<words>Unlocked Marker 1_00_00_00</words>
</direction-type>
<offset>-1920</offset>
<voice>1</voice>
<staff>1</staff>
</direction>
<direction placement="above">
<direction-type>
<words>Locked Marker 1_00_01_00</words>
</direction-type>
<offset>-960</offset>
<voice>1</voice>
<staff>1</staff>
</direction>
</measure>
<measure number="1802">
<note>
<rest measure="yes"/>
<duration>1920</duration>
<voice>1</voice>
<staff>1</staff>
</note>
<barline location="right">
<bar-style>light-heavy</bar-style>
</barline>
</measure>
</part>
</score-partwise>
Look into finding a cross-platform solution for read/write of XML files.
XML is used by Cubase's Track Archive XML file format.
(XMLNode
/ XMLDocument
are part of Foundation but only available on macOS.)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.