Tracking audio waveforms with Flash9 AS3

Source: Internet
Author: User
Actionscript 3.0 provides a new feature that uses ByteArray, Soundmixer.
The code is as follows:
function func (a:number) {
Return num * Math.sin (a);
}
function Drawfunction (func:function, Thickness:number, Color:number) {
Graphics.linestyle (thickness, color, 100);
Graphics.moveto (STAGE.STAGEHEIGHT/2-func) ((+ t)/20) * 20);
for (var i = i <= stage.stagewidth-30; i++) {
var fi = Stage.stageheight/2-func ((i + t++)/20) * 20;
Graphics.lineto (i, FI);
}
}
function Spectrum (event:event) {
Graphics.clear ();
Soundmixer.computespectrum (BA, True, 0);
num = ba.readfloat () * 10;
Drawfunction (func, 1, 0x0066cc);
}
var sound:sound = new sound ();
var Sound_channel:soundchannel;
var ba:bytearray = new ByteArray ();
var Num:number;
var t:number = 0;
Sound.load (New URLRequest ("Test.mp3"));
Sound_channel = Sound.play ();
This.addeventlistener (Event.enter_frame, Spectrum), please release the test with Flash 9/actionscript 3.0
Download (download)

PS: More cow effect please see http://theflashblog.com/?p=182
Online Help Documentation: http://livedocs.macromedia.com/flex/2/langref/package-summary.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.