var document;
var minSeTrack = 2;
var maxSeTrack = 5;
function main() {
if (app.name.indexOf("Audition") < 0) {
alert("Audition用のスクリプトです", "エラー", true);
return;
}
document = app.activeDocument;
if (!document) {
alert("アクティブなドキュメントがありません", "エラー", true);
return;
}
if (document.reflect.name != "MultitrackDocument") {
alert("マルチトラックセッションを選択してください", "エラー", true);
return;
}
var fileNameWithoutExt = document.path.substr(0, document.path.lastIndexOf("."));
setSeTrackActive(false);
mixdownAndSave(fileNameWithoutExt + "_noSe");
setSeTrackActive(true);
mixdownAndSave(fileNameWithoutExt + "_Se");
setSeTrackActive(true);
app.invokeCommand("File.CloseUnusedMedia");
alert("変換完了しました", "完了", false);
}
function setSeTrackActive(isActive) {
for (var i = 0; i < document.audioTracks.length; i++) {
var isMute = false;
if (minSeTrack <= i && i <= maxSeTrack) isMute = !isActive;
document.audioTracks[i].mute = isMute;
}
}
function mixdownAndSave(name) {
var num = app.documents.length;
app.invokeCommand("Multitrack.MixdownAllToNewFile");
while (num == app.documents.length) {
$.sleep(500);
}
var mixdown = app.documents[app.documents.length - 1];
saveAs(
mixdown,
new AudioFileFormat(AudioFileFormat.FORMAT_WAVE_PCM),
name + ".wav"
);
saveAs(
mixdown,
new AudioFileFormat(AudioFileFormat.FORMAT_MP3_),
name + ".mp3"
);
document.activate();
}
function saveAs(target, audioFileFormat, filename) {
var params = new WaveDocumentSaveAsParameters();
params.fileFormat = audioFileFormat;
params.includeMetadata = true;
params.sampleTypeConversion = null;
target.saveAsDocument(filename, params);
while (target.isBusy) {
$.sleep(500);
}
}
main();