File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -114,3 +114,42 @@ def print_parameter_properties(parameter):
114114 except AttributeError as e :
115115 # If the property does not exist, print an error message
116116 pprint (f"{ property_name } : Property does not exist. Error: { e } " )
117+
118+
119+ def is_vst3_xml (raw_state ):
120+ """
121+ Check if the raw state looks like VST3 XML.
122+
123+ This function checks if the 9th to 13th bytes are '<?xml' and the last byte is a null byte (0x00).
124+
125+ Args:
126+ raw_state (bytes): The raw state to check.
127+
128+ Returns:
129+ bool: True if the raw state looks like VST3 XML, False otherwise.
130+ """
131+ return (
132+ len (raw_state ) > 13 and
133+ raw_state [8 :13 ] == b'<?xml' and
134+ raw_state [- 1 ] == 0x00
135+ )
136+
137+
138+ def extract_vst3_xml (raw_state ):
139+ """
140+ Extract the XML content from the VST3 raw state if it is valid.
141+
142+ Args:
143+ raw_state (bytes): The raw state to extract XML from.
144+
145+ Returns:
146+ str or None: The extracted XML content if valid, otherwise None.
147+ """
148+ if is_vst3_xml (raw_state ):
149+ try :
150+ # Extract the bytes between the 8-byte header and the null byte
151+ xml_part = raw_state [8 :- 1 ].decode ('utf-8' )
152+ return xml_part
153+ except UnicodeDecodeError :
154+ pass
155+ return None
You can’t perform that action at this time.
0 commit comments