â ī¸ Warning â ī¸ Deprecated Code! This video tutorial contains outdated code.
đĄ If you wish to update it, any AI assistant will update the code for you in seconds.
đĄ If you wish to update it, any AI assistant will update the code for you in seconds.
Sound Amplitude Visualization Programming
This video shows how to create sound visuals that animate to the beat by creating a channel for the sound object. That way we can access the left and right peaks.
// Define the sound object and the sound channel
var snd:Sound = new Sound();
var req:URLRequest = new URLRequest("mp3_files/raquel my body.mp3");
snd.load(req);
var channel:SoundChannel;
channel = snd.play();
status_txt.text = "The song is now playing";
// Enter Frame Event
// We are going to use this for more sound control
addEventListener(Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame(event:Event):void {
leftpeak_txt.text = ""+(Math.round(channel.leftPeak * 100));
rightpeak_txt.text = ""+(Math.round(channel.rightPeak * 100));
leftBar.height = (Math.round(channel.leftPeak * 100));
rightBar.height = (Math.round(channel.rightPeak * 100));
}
// Sound completion event function and its listener
channel.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete);
function onPlaybackComplete(event:Event){
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
status_txt.text = "The song is over";
}