Thanks! That does make sense, and dump() and document() were very helpful. I did end up implementing something like this as a workaround.
That’s really cool, because it’s now almost possible to stream the audio an event over http, by batch converting all the sounds to programmer sounds and loading in sound assets that were fetched separately at runtime.
Right now I’m just using Ctrl+z to undo the changes after I build my project, but is there any reason I can’t just convert everything back to single sounds programmatically?
const properties = [
'triggerProbability',
'triggerConditionMode',
'triggerConditionMode',
'color',
'isAsync',
'isCutoff',
'start',
'length',
'color',
'isAsync',
'isCutoff',
'start',
'length',
'delayType',
'minimumTimeDelay',
'maximumTimeDelay',
'quantizationInterval',
'startOffset',
'timelockedOffset',
'voiceStealing',
'maxVoices',
'name',
'volume',
'pitch',
'looping',
'playCount'
];
const relationships = [
'automators',
'modulators',
'snapshotProperties',
'customBindings',
'selector',
'triggerConditions',
'fadeInCurve',
'fadeOutCurve',
'relatedFadeCurves',
'audioTrack',
'parameter',
'playPercentage',
'owner',
];
studio.project.model.SingleSound.findInstances({
searchContext: eventContext
}).map(function(sound) {
const audioFile = sound.relationships.audioFile.destinations[0];
const name = audioFile.assetPath.split('/').slice(1).join('/');
const programmerSound = studio.project.create('ProgrammerSound');
programmerSound.relationships.placeholder.add(audioFile);
properties.forEach(function(property) {
programmerSound[property] = sound[property];
});
programmerSound.properties.name.setValue(name);
relationships.forEach(function(relationship) {
sound.relationships[relationship].destinations.forEach(function(destination) {
programmerSound.relationships[relationship].add(destination);
});
});
if (sound.relationships.audioTrack.destinations.length > 0) {
sound.relationships.audioTrack.destinations[0].relationships.modules.remove(sound);
} else {
sound.relationships.owner.destinations[0].relationships.sounds.remove(sound);
}
studio.project.deleteObject(sound);
});