Skip to content

Unable to load Cubase project #5

@dvrehen

Description

@dvrehen

Describe the bug

Load a DAWProject file (XML format)

project = DawProject.load_project("CubaseTest.dawproject")

Using the latest version of lxml (5.3.1) in PyCharm (5.2.2 doesn't install).

To Reproduce

The project.xml inside the zipped dawproject:

<?xml version="1.0" encoding="UTF-8"?>
<Project version="1.0">
	<Application name="Cubase" version="14.0.10" />
	<Transport>
		<Tempo unit="bpm" value="120" />
		<TimeSignature numerator="4" denominator="4" />
	</Transport>
	<Structure>
		<Track contentType="tracks" id="id1" name="Input/Output" color="#9fabb8ff" />
		<Track contentType="notes" id="id2" name="Solo Violin" color="#9fabb8ff">
			<Channel role="regular" audioChannels="2" id="id3" name="Solo Violin" color="#8292a3ff" destination="id0">
				<Mute value="false" name="Mute" />
				<Pan value="0.5" unit="normalized" min="0" max="1" name="Pan" />
				<Volume value="1" unit="linear" min="0" max="2" name="Volume" />
				<Devices>
					<Vst3Plugin deviceRole="instrument" deviceName="Philharmonik 2" deviceID="D336EF6F7CF44CAC87311335EB754C58">
						<Parameters />
						<Enabled value="true" />
						<State path="plugins/763350F7-CBF5-4B22-936B-CA61D55004AD.vstpreset" external="false" />
					</Vst3Plugin>
				</Devices>
			</Channel>
		</Track>
		<Channel role="master" audioChannels="2" id="id0" name="Stereo Out" color="#8292a3ff">
			<Mute value="false" name="Mute" />
			<Pan value="0.5" unit="normalized" min="0" max="1" name="Pan" />
			<Volume value="1" unit="linear" min="0" max="2" name="Volume" />
		</Channel>
	</Structure>
	<Arrangement>
		<Lanes timeUnit="seconds">
			<Lanes track="id1" />
			<Lanes track="id2">
				<Clips>
					<Clip time="0" duration="14" name="Solo Violin" enable="true">
						<Notes>
							<Note time="0" duration="1" channel="0" key="63" vel="0.787402" rel="0" />
							<Note time="1" duration="3" channel="0" key="64" vel="0.866142" rel="0" />
							<Note time="4" duration="3" channel="0" key="66" vel="0.787402" rel="0" />
						</Notes>
					</Clip>
				</Clips>
			</Lanes>
		</Lanes>
	</Arrangement>
</Project>

In dawProject.py - from_xml stuff goes wrong it seems.

@staticmethod
def from_xml(reader, cls):
    try:
        tree = ET.parse(reader)
        root = tree.getroot()
        obj = cls()
        for child in root:
            setattr(obj, child.tag, child.text)
        return obj
    except Exception as e:
        raise IOError(e)

ET.parse raises an exception:

File "C:\Projects\PyCharm\GitHub\dawproject-py\classes\dawProject.py", line 163, in load_project
return DawProject.from_xml(DawProject.strip_bom(project_entry), Project)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Projects\PyCharm\GitHub\dawproject-py\classes\dawProject.py", line 102, in from_xml
raise IOError(e)
OSError: Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration

If I remove the xml-header "" manually from the file the parsing starts.

The root is then set properly with a Project-object, the children child.tag are correct, but the child.text seem to be empty and not setting up the necessary children objects in the project?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions