var mic:Microphone = Microphone.getMicrophone();
Security.showSettings ("2");
mic.setLoopBack(true);
if (mic != null) {
mic.setUseEchoSuppression(true);
mic.addEventListener(ActivityEvent.ACTIVITY, activityHandler);
addEventListener(Event.ENTER_FRAME, loop)
}
function activityHandler(event:ActivityEvent):void {
trace("activityHandler: " + event);
}
var vr:Number = 30;
function loop(e:Event){
vr = vr * 0.98;
mc.rotation = mc.rotation +vr;
}
var timer:Timer = new Timer(100)
timer.addEventListener(TimerEvent.TIMER, timerFn)
timer.start()
function timerFn(e:TimerEvent) {
if(mic.activityLevel > 10) {
vr = mic.activityLevel/2
}
}

// 1. 재생 / 정지 / 볼륨 / 팬 / 스팩트럼 /
import com.greensock.*;
var http://www.blogger.com/URLRequest = new URLRequest("sound/Ocean05_That Black_Ocean.mp3");
var s:Sound = new Sound(url);
var sh:SoundChannel = s.play();
var startTime:Number=0;
// 재생 / 정지
pauseBtn.addEventListener(MouseEvent.CLICK, pauseSound);
playBtn.addEventListener(MouseEvent.CLICK, playSound);
function pauseSound(e:MouseEvent) {
if (sh !=null ) {
startTime = sh.position;// 현재 사운드위치 저장..
sh.stop();
sh = null;
}
}
function playSound(e:MouseEvent) {
if ( sh == null ) {
sh = s.play(startTime);
}
}
// 상황을 체크 하기 위한...부분 --------------------------
var timer:Timer = new Timer(100);
timer.addEventListener(TimerEvent.TIMER, loop);
timer.start();
function loop(e:TimerEvent) {
//Lmc.scaleY = ( sh.leftPeak )
//Rmc.scaleY = ( sh.rightPeak )
if ( sh != null ) {
var st:SoundTransform = new SoundTransform();
st.volume = mouseX / 500;
sh.soundTransform = st;
TweenLite.to(Lmc,0.3, {scaleY:sh.leftPeak});
TweenLite.to(Rmc,0.3, {scaleY:sh.rightPeak});
bar.scaleX = sh.position / s.length;//( 현재 사운드 위치/사운드 전체 길이)
computeSpec();
}
}
//----------------------------------------------------
var byteInfo:ByteArray = new ByteArray();
var holderArr:Array = new Array();
function computeSpec() {
SoundMixer.computeSpectrum(byteInfo, true);
for (var i=0; i< 256; i++) {
//holderArr[i].scaleY = byteInfo.readFloat();
holderArr[i].rotation = byteInfo.readFloat()*160 ;
holderArr[i].alpha = 1- byteInfo.readFloat() ;
}
}
for (var i=0 ; i<256; i++) {
var temp:SpecMc = new SpecMc()
temp.x = i * 3.5 + 50
temp.y = stage.stageHeight
addChild(temp)
holderArr.push(temp);

댓글 없음:
댓글 쓰기