Skip to content

Instantly share code, notes, and snippets.

@SomeoneSom
Last active February 15, 2022 22:28
Show Gist options
  • Save SomeoneSom/51860a3ff472d52d5142662fcca8d891 to your computer and use it in GitHub Desktop.
Save SomeoneSom/51860a3ff472d52d5142662fcca8d891 to your computer and use it in GitHub Desktop.
a tool for making cassette songs in fmod a bit easier
// folder = folder event is in (should already exist)
// event = event name to add notes to (should already exist)
// files = base name for files, the numbering will be based off what audacity auto exports, should include asset folder if needed
// filesnum = how many audio files you have (aka max number on the exported split audio files)
// to use:
// event should be a copy of a vanilla cassette event minus the vanilla sixteenth_note parameter (if needed) and placed in the folder.
// this event should also have the sixteenth_note parameter you want to use.
// all wav files should be already imported into the project
// then, copy the entirety of this file into the fmod console (Window -> Console)
// now, you should be able to use the function inside the console
// a few notes:
// this finds the parameter to used based on a minimum of 1 and a maximum of filesnum.
// the track that the sound files are places on is the first track in the event
// the numbering is based on 'files-(file number with leading zero if less than 10).wav'. you can change this if needed
function autoCassette(folder, event, files, filesnum) {
var mef = studio.project.workspace.relationships.masterEventFolder.destinations[0];
var index = -1;
for (var i = 0; i < mef.items.length; i++) {
if (mef.items[i].entity == "EventFolder" && mef.items[i].name == folder) {
index = i;
}
}
if (index == -1) {
return "Couldn't find folder!";
}
var nef = mef.items[index];
index = -1;
for (var i = 0; i < nef.items.length; i++) {
if (nef.items[i].entity == "Event" && nef.items[i].name == event) {
index = i;
}
}
if (index == -1) {
return "Couldn't find event!";
}
var eventUsed = nef.items[index];
index = -1;
for (var i = 0; i < eventUsed.parameters.length; i++) {
if (eventUsed.parameters[i].preset.minimum == 1 && eventUsed.parameters[i].preset.maximum == (filesnum + 1)) {
index = i;
}
}
if (index == -1) {
return "Couldn't find suitable parameter!";
}
var parameter = eventUsed.parameters[index];
var track = eventUsed.groupTracks[0];
console.log("Parameter and track found, beginning importing audio files");
for (var i = 1; i <= filesnum; i++) {
var filename = files + (i < 10 ? '-0' : '-') + i.toString() + '.wav';
var newSound = track.addSound(parameter, "SingleSound", i, 1);
newSound.audioFile = studio.project.importAudioFile(filename);
}
return "Done!";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment