Created
September 21, 2013 00:33
-
-
Save benwurth/6645727 to your computer and use it in GitHub Desktop.
A simple script for Adobe After Effects that generates 10 separate null objects with keyframe data for different audio frequency bands. You can then use these nulls to set up a responsive graphical equalizer (frequency analyzer).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
//Begin Undo group | |
app.beginUndoGroup("Generate Graphical Equalizer"); | |
/*Variables:*/ | |
//How far apart each null is placed across the screen | |
var nullPlacementWidth = 0; | |
//Creates a variable that holds the selected comp | |
var curItem = app.project.activeItem; | |
//Creates an array that stores the lowpass values and the highpass values | |
var lowVals = [1,60,170,310,600,1000,3000,6000,12000,16000]; | |
var highVals = [60,170,310,600,1000,3000,6000,12000,16000,20000]; | |
//An array to hold the null objects | |
var eqNulls = []; | |
//An array to hold the audio layers with EQ data | |
var eqAudio = []; | |
//Create a variable to hold the control audio layer | |
var controlAudioLayer = null; | |
/*Functions:*/ | |
function placeNulls() | |
{ | |
nullPlacementWidth = curItem.width / divisionNumber; | |
//TODO: Write code to place nulls | |
} | |
function createNulls() | |
{ | |
for(i = 0; i <= 9; i++) | |
{ | |
//Setting the null we're currently working with | |
var curNull = eqNulls[i]; | |
//Adding the null | |
curNull = curItem.layers.addNull(); | |
//Changing the layer name | |
curNull.name = lowVals[i] + " - " + highVals[i] + " band"; | |
//Defining the effects group | |
var effectsGroup = curNull("Effects"); | |
//Adding a slider control | |
effectsGroup.addProperty("ADBE Slider Control"); | |
//Sending the layer to get the audio data from the proper eqNull | |
ampTransfer(curNull); | |
} | |
} | |
function ampTransfer(curLayer) | |
{ | |
//TODO: Add code | |
} | |
function audioDuplicate(control) | |
{ | |
for(i = 0; i <= 9; i++) | |
{ | |
//Creates a duplicate of the control | |
eqAudio[i] = control.duplicate(); | |
//Turns on the track | |
eqAudio[i].audioEnabled = true; | |
//Names the duplicate | |
eqAudio[i].name = lowVals[i] + " - " + highVals[i] + " band"; | |
//Adds the highpass | |
addHighLow(eqAudio[i], true, highVals[i]); | |
//Adds the lowpass | |
addHighLow(eqAudio[i], false, highVals[i]); | |
app.executeCommand(app.findMenuCommandId("Convert Audio to Keyframes")); | |
curItem.layer(1).name = lowVals[i] + " - " + highVals[i] + " band"; | |
//Turns the audio off so as not to interfere with the other tracks | |
eqAudio[i].audioEnabled = false; | |
} | |
} | |
function addHighLow(curLayer, highBool, freqVal) | |
{ | |
var effectsGroup = curLayer("Effects"); | |
var effectBase = effectsGroup.addProperty("ADBE Aud HiLo"); | |
//Changes the Cutoff frequency | |
// var highLowPass = curLayer.property("ADBE Effect Parade").property("ADBE Aud HiLo"); | |
if (!highBool) | |
{ | |
effectBase.property("ADBE Aud HiLo-0001").setValue(2); | |
} | |
effectBase.property("ADBE Aud HiLo-0002").setValueAtTime(0, freqVal); | |
} | |
/*Main:*/ | |
function main() | |
{ | |
//Check to see if a single layer is selected | |
if(curItem.selectedLayers.length != 1) | |
{ | |
alert("Please select ONE layer with audio."); | |
return; | |
} | |
//Check to see if curent layer is a footage layer | |
if (curItem.selectedLayers[0].matchName != "ADBE AV Layer") | |
{ | |
alert("Please select a layer with audio."); | |
return; | |
} | |
//Check to see if the current layer has a sound component | |
if (!(curItem.selectedLayers[0].hasAudio)) | |
{ | |
alert("Please select a layer with audio."); | |
} | |
//Set selected audio layer as the control audio layer | |
controlAudioLayer = curItem.selectedLayers[0]; | |
//Duplicate audio layers | |
audioDuplicate(controlAudioLayer); | |
//Create the nulls | |
//createNulls(); | |
} | |
main(); | |
//End Undo group | |
app.endUndoGroup(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment