Skip to content

Commit

Permalink
Fix: Fix loading tssln from VST (#177)
Browse files Browse the repository at this point in the history
* Fix: Fix loading tssln from VST

* Code: gradlew ktlintFormat
  • Loading branch information
sevenc-nanashi authored Jun 28, 2024
1 parent ea8b373 commit fe6cbd0
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions core/src/main/kotlin/core/io/Tssln.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,22 @@ object Tssln {
)
}

private fun parsePluginData(pluginData: Uint8Array): ValueTree {
val pluginDataTree = parseValueTree(pluginData)
if (pluginDataTree.type.startsWith("VST")) {
val actualData = Uint8Array(pluginData.length - 48)
actualData.set(pluginData.subarray(48, pluginData.length))

return parseValueTree(actualData)
}
return pluginDataTree
}

private fun parseTracks(trackTrees: List<ValueTree>, params: ImportParams): List<Track> {
return trackTrees.mapIndexed { trackIndex, trackTree ->
val trackName = trackTree.attributes.Name.value as String
val pluginData = trackTree.attributes.PluginData.value as Uint8Array
val pluginDataTree = parseValueTree(pluginData)
val pluginDataTree = parsePluginData(pluginData)

if (pluginDataTree.type != "StateInformation") {
throw IllegalFileException.IllegalTsslnFile()
Expand Down Expand Up @@ -111,7 +122,7 @@ object Tssln {

private fun parseMasterTrack(trackTree: ValueTree): Pair<List<Tempo>, List<TimeSignature>> {
val pluginData = trackTree.attributes.PluginData.value as Uint8Array
val pluginDataTree = parseValueTree(pluginData)
val pluginDataTree = parsePluginData(pluginData)
if (pluginDataTree.type != "StateInformation") {
throw IllegalFileException.IllegalTsslnFile()
}
Expand Down

0 comments on commit fe6cbd0

Please sign in to comment.