microphone.addEventListener (SampleDataEvent.SAMPLE_DATA) Causes output volume to decrease

I would like to record the sound of the microphone in the AIR.

It works, except that during recording, air decreases the volume of all sound set.

This reduction in volume is triggered by

microphone.addEventListener(SampleDataEvent.SAMPLE_DATA, myFunction);

It is worth noting that myFunction() can be completely empty. The output volume is still small.

How to reproduce:

// Start playing a sound
var url:String = "100Hz_44100Hz_16bit_30sec.mp3";
var urlRequest:URLRequest = new URLRequest(url);
var isound:Sound = new Sound();
isound.load(urlRequest);
isound.play();

// Set up the microphone
var microphone = Microphone.getMicrophone();
microphone.setUseEchoSuppression(false); // I have tried both ways.
microphone.setLoopBack(false); // I have tried both ways.
microphone.rate = 44;

// Start recording
microphone.addEventListener(SampleDataEvent.SAMPLE_DATA, gotMicData);
// The volume of 'isound' will now be reduced until the microphone listener is removed.
// Once the listener is removed, the volume of 'isound' returns to normal.

I don't want the volume of other sounds playing to be reduced during recording. How would I do that?

Note: I am using Windows 7.

According to me, reducing volume on recording mic is a feature of Windows 7 and nothing to do with air.

To disable this, follow these steps:

  1. Click on the Windows button
  2. Choose Control Panel
  3. Choose 'hardware and sound '.
  4. Choose "Manage audio devices" under the heading "sound."
  5. Goto, the tab 'Communication '.
  6. The value "When windows detects communications activity" to "do nothing".

Even if this setting tells it is supposed to adjust the volume when you place phone calls, you use the computer, I had reduced the volume in some programs when I activate the microphone.

Let me know if it works for you.

Edit: Heh, read another forum recent messages to see if there was anything else I could help with.  The thread "2 instances flash & Windows 7" currently somewhat below this one on the first page mentions this feature of Windows 7, even if it is originally a different question for him.

Tags: Adobe Animate

Similar Questions

  • Satellite Pro U400-SP2804 - Microphone is not listed in the volume control

    Hello
    I can't listen to the microphone from the speaker, because does not appear micro in the Volume control

    On the start menu< control="" panel="">< audio="" devices="">< advanced="" properties="">< volume="" control="">< properties="">

    Mixing: Conexant HD Audio output

    Volume controls:
    Volume control
    Wave
    SW
    CD

    But n - t apeear option microphone or line

    My sound card is Conexant High Definition SmartAudio 221

    I was reading, and I think the problem is: it doesn't have a key in the windows registry value, someone help me, thanks

    I did: reinstall the driver, uninstall the driver and put another card sound, change the operating system, works wth 2 sound cards, portable computer, import registry values from the other laptop. but does not solve the problem.

    My problem appears with Winodws XP 2002 SP3 and Windows Vista professional

    Hello

    The port microphone or line is not because you are looking for this audio * output parameters.
    The microphone is a device of entry so it s not who listed there.

    If you go into the volume settings > options > properties you can switch to HD Audio input.
    Now you can change the volume of the microphone! :)

    Good bye

  • How to decrease the output volume of the .wav file to a speaker attached to the output NI 9263 module

    Hello

    I found an example of http://zone.ni.com/devzone/cda/epd/p/id/4182 and edited for my purposes. On this basis, I have 16-bit mono speech files with sampling rate of 16 kHz for a speaker attached to the output NI 9263 module. However, this forum is without volume control and the result is extremely strong. I have attached photos of my diagrams below.

    NDS read Wave File.vi returns a 1 d mono 16‑bit whole array. I multiplied this table by a command button, so I could adjust the constant which I multiply with the table 1 d as I thought that the size of integers are related to the amplitude of the signal. However, reducing the constant only reduces the quality of the word and is still very strong.

    Is it the right approach to reduce the volume? And if not, what? Thanks in advance

    Yawei7 wrote:

    I thought that the size of integers are related to the amplitude of the signal.

    It's quite right...!
    And your approach is perfect...!

  • microphone laptop Acer too low output level. How can I increase it?

    This situation is occurring after that windows 7 has been reinstalled in my laptop. I don't know how to increase the volume.

    Hello
    To adjust the volume of your microphone in Windows 7, follow these steps:
    a.Click Start, type mmsys.cpl in the search box and press ENTER.
    transfer the sound dialog box, click the record of .
    c Microphone and then click on properties of .
    Note make sure that the work appears under Microphone. If the job does not appear, click Microphone, and then click set as default.
    d.In The Microphone properties dialog box, click the tab Custom.
    e.Select or uncheck the Amp Microphone .
    f the levels of tab.
    g.Adjust the volume slider to the level you want, and then click OK.
    h.Click OK to close the sound dialog box.

  • How can I change my plug in microphone to my headphone/speaker output?

    Green (headphone/speaker output or whatever output) is broken and the rose (entry/micro) is not if I want to connect my headset in that no broken. I use the latest realtek drivers. I am using Windows 7 64 bit and it is an emachines laptop with only 2 jacks, microphone and headphones.

    Hello

    It is not possible to get the sound of the Microphone plug.

    Please contact the manufacturer of the computer.

    Contact technical support

    http://secure3.TX.Acer.com/findsystem/FindSystem.aspx?title=contact+support&brand=eMachines

  • My speakers and microphone are in interaction causing a high pitch sound

    Whenever I use Skype my microphone and speakers are in interaction with a sharp Summit sound makes it difficult for me to converse with friends.

    Ask http://forum.skype.com/

  • error coming (event: FooterEvent): void strange event.

    error came to form this line

    private void speakItHandler(event:FooterEvent):void

    {

    microphone.addEventListener (SampleDataEvent.SAMPLE_DATA, sampleDataHandler)

    }

    the complete code

    package

    {

    com.kevinhoyt.components import. *;

    import flash.display.Sprite;

    import flash.display.StageAlign;

    import flash.display.StageScaleMode;

    import flash.events. *;

    import flash.events.MouseEvent;

    import flash.events.SampleDataEvent;

    import flash.media.MediaType;

    import flash.media.Microphone;

    import flash.media.Sound;

    import flash.utils.ByteArray;

    import flash.events.Event;

    import flash.events.MouseEvent;

    import flash.events.

    /**

    * Document class LiveFeed application.

    * IPhone with Flash sample application development

    *

    * @author Rich Wagner

    *

    */

    SerializableAttribute public class SpeakItHearIt extends Sprite

    {

    private var ftr:Footer;

    private var ttl:Title;

    private var lbl:Label;

    private var microphone: Microphone;

    private var soundBytes:ByteArray;

    /**

    * Constructor

    *

    */

    public void SpeakItHearIt()

    {

    stage.scaleMode = StageScaleMode.NO_SCALE;

    internship. Align = StageAlign.TOP_LEFT;

    stage.scaleMode = StageScaleMode.NO_SCALE;

    internship. Align = StageAlign.TOP_LEFT;

    TTL = new title ("SpeakItHearIt");

    addChild (ttl);

    LBL = new Label ("record something and then hear it");

    LBL.x = 9;

    LBL.y = 52;

    addChild (lbl);

    FTR = new foot of page ("Speak It", "Hear It");

    FTR.y = 683;

    ftr.addEventListener (FooterEvent.OK, speakItHandler);

    ftr.addEventListener (FooterEvent.CANCEL, hearItHandler);

    addChild (ftr);

    Camera support?

    If (Microphone.isSupported)

    {

    micro = Microphone.getMicrophone ();

    microphone.setSilenceLevel (0, 4000);

    microphone.gain = 100;

    microphone.rate = 44;

    soundBytes = new ByteArray();

    LBL. Text = "ready to record and play back";

    }

    on the other

    {

    LBL. Text = 'Unable to access Microphone.';

    }

    }

    /**

    * Click on the talk button called

    *

    @param event

    *

    */

    private void speakItHandler(event:FooterEvent):void

    {

    microphone.addEventListener (SampleDataEvent.SAMPLE_DATA, sampleDataHandler)

    }

    /**

    * Called Hear button click

    *

    @param event

    *

    */

    private void hearItHandler(event:FooterEvent):void

    {

    microphone.removeEventListener (SampleDataEvent.SAMPLE_DATA, sampleDataHandler);

    soundBytes.position = 0;

    var sound: Sound = new Sound();

    sound.addEventListener (SampleDataEvent.SAMPLE_DATA, playbackSampleHandler);

    Sound.play();

    }

    /**

    * Starts the recording session

    *

    @param event

    *

    */

    private void sampleDataHandler(event:SampleDataEvent):void

    {

    While (Event.Data.bytesAvailable)

    {

    Sample number: var = event.data.readFloat ();

    soundBytes.writeFloat (sample);

    }

    }

    /**

    * Reads the audio data in memory

    *

    @param event

    *

    */

    private void playbackSampleHandler(event:SampleDataEvent):void

    {

    for (var i: int = 0; i < 8192 & & soundBytes.bytesAvailable > 0; i ++)

    {

    Sample number: var = soundBytes.readFloat ();

    event.data.writeFloat (sample);

    event.data.writeFloat (sample);

    }

    }

    }

    }

    Contact kevin hoyt or read about the use of its components.

  • Problem with microphone on iOS - bug or bad code?

    Hi all

    It seems that the use of the micro class freezes my Flex app. I provided the code below, but here is an overview:

    • This only happens on iOS - specifically my iPhone 4. I have not seen this problem on Android devices.
    • My code alternated recording and records don't not - 5 seconds to one, then 5 seconds of each other, then repeat over and over again.
    • I have reduced this to a 'minimum' example (see code below) which does this. It does not use data etc. coming the Microphone is not create or fill a ByteArray.
    • The application always crashes. In some cases, this happens when he worked only 2-3 minutes, in all cases, it happens in half an hour. I did 10 sets of tests and the average is 15 minutes.

    My application is a language learning app and recording and playback of the voice of the user is an important feature. It allows the user to hear how their pronunciation matches that of a native speaker. When recording / reading is marketed the software repeatedly plays a few sound recordings, the voice of the user, it reads, the more audio plays, etc.. In other words, it includes features similar to the minimal case code I included here. Users often use this feature 30 minutes or more. It is therefore a problem.

    I'm doing something wrong in my code? Just checking before I report it as a bug.

    You can download an FXP from here if you are interested:

    http://www.Brightworks.com/downloads/RecordingTest.FXP

    Alternatively, the important code is below. This is the display (only) of the sample application.

    Thank you

    Douglas

    Douglas McCarroll

    Brightworks, Inc.

    320.300.0220

    <? XML version = "1.0" encoding = "utf - 8"? >

    < s:View xmlns:fx = " " http://ns.Adobe.com/MXML/2009 "

    xmlns:s = "library://ns.adobe.com/flex/spark".

    creationComplete = "onCreationComplete().

    title = "Test recording" >

    < fx:Declarations >

    < / fx:Declarations >

    < fx:Script >

    <! [CDATA]

    private var _isRecording:Boolean;

    private var _iterationCount:uint = 0;

    private var _microphone:Microphone;

    private var _recordedSeconds:uint = 0;

    private var _timer:Timer;

    private function onCreationComplete (): void

    {

    NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;

    }

    private void doNextPhase(event:TimerEvent_=_null):void

    {

    _isRecording =! _isRecording;

    If (_isRecording)

    {

    _iterationCount ++;

    displayOutput ("Recording");

    _microphone = Microphone.getMicrophone ();

    _microphone.rate = 44;

    _microphone.gain = 50;

    _microphone.setSilenceLevel (0, 2000);

    _microphone.addEventListener (SampleDataEvent.SAMPLE_DATA, onNewRecordingSampleData);

    }

    on the other

    {

    _recordedSeconds += 5;

    displayOutput ("Pausing");

    _microphone. RemoveEventListener (SampleDataEvent.SAMPLE_DATA, onNewRecordingSampleData);

    _microphone = null;

    }

    }

    private void onNewRecordingSampleData(event:SampleDataEvent):void

    {

    }

    private void displayOutput(phase:String):void

    {

    var freeMemoryMB:int = Math.round (System.freeMemory / (1024 * 1024));

    var privateMemoryMB:int = Math.round (System.privateMemory / (1024 * 1024));

    var totalMemoryNumberMB:int = Math.round (System.totalMemoryNumber / (1024 * 1024));

    phaseLabel.text = "Phase:"+ phase; "

    iterationLabel.text = "iteration:"+ _iterationCount; "

    recordedSecondsLabel.text = ' seconds saved: "+ _recordedSeconds;"

    freeMemoryLabel.text = "System.freeMemory MB:"+ freeMemoryMB; "

    privateMemoryLabel.text = "System.privateMemory MB:"+ privateMemoryMB; "

    totalMemoryNumberLabel.text = "System.totalMemoryNumber MB:"+ totalMemoryNumberMB; "

    }

    private function startTimer (): void

    {

    _Timer = new Timer (5000, 0);

    _Timer.addEventListener (TimerEvent.TIMER, doNextPhase);

    _Timer.start ();

    }

    private function onStartRecordingButtonClick (): void

    {

    If ((Microphone.getMicrophone ()))

    {

    startRecordingButton.enabled = false;

    startTimer();

    doNextPhase();

    }

    on the other

    {

    phaseLabel.text = 'No Mic' available;

    }

    }

    []] >

    < / fx:Script >

    < s:VGroup height = "100%".

    Width = '100% '.

    paddingBottom = "20".

    paddingLeft = "20".

    paddingRight = "20".

    paddingTop = "20" >

    < s:Label id = "phaseLabel".

    Width = "100%" / >

    < s:Label id = "iterationLabel".

    Width = "100%" / >

    < s:Label id = "recordedSecondsLabel".

    Width = "100%" / >

    < s:Label id = "freeMemoryLabel".

    Width = "100%" / >

    < s:Label id = "privateMemoryLabel".

    Width = "100%" / >

    < s:Label id = "totalMemoryNumberLabel".

    Width = "100%" / >

    < / s:VGroup >

    < s:HGroup width = '100% '.

    horizontalAlign = "center".

    Low = "10" >

    < s:Button id = "startRecordingButton".

    label = "Start Recording"

    a click = "onStartRecordingButtonClick()".

    Width = "60%" / >

    < / s:HGroup >

    < / s:View >

    The problem has been resolved with 3.8.0.730!

    http://forums.adobe.com/message/5399512#5399512 ;-)

    Thank you Adobe!

  • Record mic using SampleDataEvent only works on some computers.

    I did a swf file that records your microphone and allows you to read.  I load the soundBytes in a float and re-read the float.  It works fine on the computer, that I developed it on (in IE, Chrome and Firefox).  It does not work on my second laptop.  And a few people in some forums have said that is not no longer works.

    Here is the file.  http://www.buttonbeats.com/images/MicCapture.html

    Here's the code.  I need some plugins in addition to the flashplayer?

    micRec.addEventListener (MouseEvent.CLICK, recordMic);

    function recordMic(event:MouseEvent) {}
    micRec.x = - 250;
    stopRecord.x = 0;
    const DELAY_LENGTH:int = 4000;


    var mic:Microphone = Microphone.getMicrophone ();
    mic.setSilenceLevel (0, DELAY_LENGTH);
    MIC.gain = 80;
    MIC.rate = 40;

    mic.addEventListener (SampleDataEvent.SAMPLE_DATA, micSampleDataHandler);

    stopRecord.addEventListener (MouseEvent.CLICK, SREC);


    var soundBytes:ByteArray = new ByteArray();

    function micSampleDataHandler(event:SampleDataEvent):void
    {
    While (Event.Data.bytesAvailable)
    {
    Sample number: var = event.data.readFloat ();
    soundBytes.writeFloat (sample);
    }
    }

    function SREC(event:MouseEvent):void
    {

    stopRecord.x = - 250;

    mic.removeEventListener (SampleDataEvent.SAMPLE_DATA, micSampleDataHandler);
    soundBytes.position = 0;
    var sound: Sound = new Sound();
    sound.addEventListener (SampleDataEvent.SAMPLE_DATA, playbackSampleHandler);
    soundPlay.addEventListener (MouseEvent.CLICK, SP1);
    function SP1(event:MouseEvent) {}
    soundBytes.position = 0;
    Sound.play();
    }
    }

    function playbackSampleHandler(event:SampleDataEvent):void
    {
    for (var i: int = 0; i < 8192 & & soundBytes.bytesAvailable > 0; i ++)
    {
    Sample number: var = soundBytes.readFloat ();
    event.data.writeFloat (sample);
    event.data.writeFloat (sample);
    }
    }
    }

    you need fp 10.  What version of problematic player?

  • Audio recording with surveillance microphone

    Hi friends!

    The past months I have been studying if posible for recording mic s of entry to the stream server, at same time, you can ear your voice in real time.

    I used:

    mic.setLoopBack (true)

    But it s very late since you talk until you hear your voice.

    Do you think is possible to micro real-time with flash player?

    I try also:


    mic.addEventListener (SampleDataEvent.SAMPLE_DATA, micSampleDataHandler);

    Savings info mic in table, use it as a sound to play at same time... The idea is good, but there is lag yet :-(

    I need a solution to all browsers and OS: Mac and Windows (linux is not enough...)

    Can someone help me please? Dou you think it is posible?

    Thank you. Best regards

    Jose Ramon Leon Somovilla

    Hi Jose,

    You might want this repost on the Flash Pro forums.  Flash Player forum is generally used by end users and you will find a wider audience developer out there.

    Flash Player Pro Forums

    Thank you

    Chris

  • SOUND_COMPLETE event trigger does not properly. Help, please.

    I know SOUND_COMPLETE event should be put after channel.play (). I don't know why it does not work. It only works if I play the song in the channel, but not songOut. The question is if I put the song in the channel that the equalizer does not work even if I add SampleDataEvent. Please help me.

    flash.media.Sound; import to import flash.events.MouseEvent;

    Import fl.controls.Slider;

    Import fl.events.SliderEvent;

    import flash.utils.ByteArray;

    import flash.events.SampleDataEvent;

    import flash.net.URLLoader;

    import flash.events.Event;

    import flash.net.URLRequest;

    import flash.media.SoundChannel;

    import equalizer;

    import flash.media.SoundTransform;

    External callers.

    ExternalInterface.addCallback("IsStatic",IsStatic) ("playStop", playStopCaller);

    ExternalInterface.addCallback("IsStatic",IsStatic) ("getPlaylist", getPlaylistCaller);

    ExternalInterface.addCallback("IsStatic",IsStatic) ("eqChange", eqChangeCaller);

    ////////////////////////////////////////////////////////

    ////////////////////////Listeners ////////////////////////

    addEventListener (Event.ENTER_FRAME, update, false, 0, true);

    addEventListener (Event.ENTER_FRAME, getPlaylistX, false, 0, true);

    playBtn.addEventListener (MouseEvent.CLICK, playButtonHandler);

    stopBtn.addEventListener (MouseEvent.CLICK, stopButtonHandler);

    //////////////////////////////////////////////////////////

    //////////////////includes//////////////////////

    EQ: Equalizer var = new Equalizer();

    var eqVector:Vector. < number > = new Vector. < number > ();

    eqVector [0] = 0;

    eqVector [1] = 0;

    eqVector [2] = 0;

    eqVector [3] = 0;

    eqVector [4] = 0;

    eqVector [5] = 0;

    eqVector [6] = 0;

    eqVector [7] = 0;

    eqVector [8] = 0;

    eqVector [9] = 0;

    eqVector [10] = 0;

    eqVector [11] = 0;

    eqVector [12] = 0;

    eqVector [13] = 0;

    eqVector [14] = 0;

    var ba: ByteArray;

    var song: Sound;

    var songOut:Sound;

    var _samples:ByteArray;

    var _sampleBufferL:Vector. < number > = new Vector. < number > ();

    var _sampleBufferR:Vector. < number > = new Vector. < number > ();

    var volumeAdjust:SoundTransform = new SoundTransform();

    var playlistLength:Number = 0;

    var playlist:Array;

    var playTest:Array = new Array("media/sounds/test1.mp3","media/sounds/test2.mp3","media/sounds/test3.mp3");

    var channel: SoundChannel;

    const BUFFER_SIZE:int = 2048; size of the output buffer

    const MIN_SAFETY_BUFFER:int = 1024; minimum collected entry before the beginning of the output

    var songName:String;

    var currentSong:Number = 0;

    var songUrl:URLRequest;

    ////////////////////////////////////////////////

    function playStopCaller(t:String):void {}

    If (t == "0") {}

    stopSong();

    }

    on the other

    If (t == "1") {}

    songName = new String();

    songName = playlist [currentSong];

    songUrl = new URLRequest (songName);

    playSong();

    }

    }

    function playButtonHandler(event:MouseEvent):void {}

    songName = new String();

    songName = playlist [currentSong];

    songUrl = new URLRequest (songName);

    playSong();

    }

    function stopButtonHandler(event:MouseEvent):void {}

    stopSong();

    }

    function rhyme (): void {}

    volumeAdjust.volume = 0.5

    Equalizer. Preamp = 0.5;

    song = new Sound();

    song.addEventListener (Event.COMPLETE, loadCompleteSong);

    Song.Load (songUrl);

    }

    function stopSong (): void {}

    Channel.Stop ();

    channel.removeEventListener (Event.SOUND_COMPLETE, checkTiming);

    }

    slider1.addEventListener (SliderEvent.CHANGE, slider1Handler);

    slider2.addEventListener (SliderEvent.CHANGE, slider2Handler);

    slider3.addEventListener (SliderEvent.CHANGE, slider3Handler);

    slider4.addEventListener (SliderEvent.CHANGE, slider4Handler);

    slider5.addEventListener (SliderEvent.CHANGE, slider5Handler);

    slider6.addEventListener (SliderEvent.CHANGE, slider6Handler);

    slider7.addEventListener (SliderEvent.CHANGE, slider1Handler);

    slider8.addEventListener (SliderEvent.CHANGE, slider2Handler);

    slider9.addEventListener (SliderEvent.CHANGE, slider3Handler);

    slider10.addEventListener (SliderEvent.CHANGE, slider4Handler);

    slider11.addEventListener (SliderEvent.CHANGE, slider5Handler);

    slider12.addEventListener (SliderEvent.CHANGE, slider6Handler);

    slider13.addEventListener (SliderEvent.CHANGE, slider4Handler);

    slider14.addEventListener (SliderEvent.CHANGE, slider5Handler);

    slider15.addEventListener (SliderEvent.CHANGE, slider6Handler);

    volSlider.addEventListener (SliderEvent.CHANGE, volSliderHandler);

    function slider1Handler(event:SliderEvent):void {}

    eqVector [0] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function slider2Handler(event:SliderEvent):void {}

    eqVector [1] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function slider3Handler(event:SliderEvent):void {}

    eqVector [2] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function slider4Handler(event:SliderEvent):void {}

    eqVector [3] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function slider5Handler(event:SliderEvent):void {}

    eqVector [4] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function slider6Handler(event:SliderEvent):void {}

    eqVector [5] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function slider7Handler(event:SliderEvent):void {}

    eqVector [6] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function slider8Handler(event:SliderEvent):void {}

    eqVector [7] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function slider9Handler(event:SliderEvent):void {}

    eqVector [8] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function slider10Handler(event:SliderEvent):void {}

    eqVector [9] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function slider11Handler(event:SliderEvent):void {}

    eqVector [10] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function slider12Handler(event:SliderEvent):void {}

    eqVector [11] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function slider13Handler(event:SliderEvent):void {}

    eqVector [13] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function slider14Handler(event:SliderEvent):void {}

    eqVector [14] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function slider15Handler(event:SliderEvent):void {}

    eqVector [15] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function volSliderHandler(event:SliderEvent):void {}

    volumeAdjust.volume = event.value/100;

    channel.soundTransform = volumeAdjust;

    }

    function sampleData(event:SampleDataEvent):void {}

    _SAMPLES = new ByteArray();

    var len:Number = song.extract (_samples, BUFFER_SIZE),

    i: int = 0,

    l:number,

    r: Number;

    If (len < BUFFER_SIZE) {}

    Len += song.extract(_samples,BUFFER_SIZE-len,0);

    }

    _SAMPLES.position = 0;

    While (I < BUFFER_SIZE) {}

    l = equalizer.applyFilter (_samples.readFloat ());

    r = equalizer.applyFilter (_samples.readFloat ());

    event.data.writeFloat (l);

    event.data.writeFloat (r);

    i ++ ;

    }

    }

    function loadCompleteSong(event:_Event):void {}

    songOut = new Sound();

    songOut.addEventListener (SampleDataEvent.SAMPLE_DATA, sampleData);

    Channel = songOut.play ();

    channel.addEventListener (Event.SOUND_COMPLETE, checkTiming);

    }

    function Update($e:Event):void

    {

    BA = new ByteArray();

    SoundMixer.computeSpectrum (ba, true);

    var eq1:Number = 0;

    var eq2:Number = 0;

    var eq3:Number = 0;

    var eq4:Number = 0;

    var eq5:Number = 0;

    var eq6:Number = 0;

    var eq7:Number = 0;

    var eq8:Number = 0;

    for (var i = 0; i < 64; i ++) {}

    EQ1 += b [i];

    }

    for (i = 64; i < 128; i ++) {}

    EQ2 += b [i];

    }

    for (i = 128; i < 192; i ++) {}

    EQ3 += b [i];

    }

    for (i = 192; i < 256; i ++) {}

    EQ4 += b [i];

    }

    for (i = 256; i < 320; i ++) {}

    EQ5 += b [i];

    }

    for (i = 320; i < 384; i ++) {}

    EQ6 += b [i];

    }

    for (i = 384; i < 448; i ++) {}

    EQ7 += b [i];

    }

    for (i = 448; i < 512; i ++) {}

    Eq8 += b [i];

    }

    If {(eq1/64 < 100)}

    var fxNr1:Number = eq1/64;

    }

    on the other

    fxNr1 = 100;

    If {(eq2/64 < 100)}

    var fxNr2:Number = eq2/64;

    }

    on the other

    fxNr2 = 100;

    If {(EQ 3/64 < 100)}

    var fxNr3:Number = eq3/64;

    }

    on the other

    fxNr3 = 100;

    If {(eq4/64 < 100)}

    var fxNr4:Number = eq4/64;

    }

    on the other

    fxNr4 = 100;

    If {(EQ 5/64 < 100)}

    var fxNr5:Number = eq5/64;

    }

    on the other

    fxNr5 = 100;

    If {(eq6/64 < 100)}

    var fxNr6:Number = eq6/64;

    }

    on the other

    fxNr6 = 100;

    If {(eq7/64 < 100)}

    var fxNr7:Number = eq7/64;

    }

    on the other

    fxNr7 = 100;

    If {(QE8/64 < 100)}

    var fxNr8:Number = eq8/64;

    }

    on the other

    fxNr8 = 100;

    var eqz1:Number = Math.abs (Math.round (fxNr1));

    var eqz2:Number = Math.abs (Math.round (fxNr2));

    var eqz3:Number = Math.abs (Math.round (fxNr3));

    var eqz4:Number = Math.abs (Math.round (fxNr4));

    var eqz5:Number = Math.abs (Math.round (fxNr5));

    var eqz6:Number = Math.abs (Math.round (fxNr6));

    var eqz7:Number = Math.abs (Math.round (fxNr7));

    var eqz8:Number = Math.abs (Math.round (fxNr8));

    ExternalInterface.call("saveglobalscore",score) ("as3_getEq", eqz1, eqz2, eqz3, eqz4, eqz5, eqz6, eqz7, eqz8);

    }

    function getPlaylistCaller(x:Array) {}

    playlist = x;

    var playlistLength = playlist.length;

    }

    function getPlaylistX (event): void {}

    playlist = playTest;

    playlistLength = playlist.length;

    trace (playlist. Length);

    }

    nextBtn.addEventListener (MouseEvent.CLICK, nextSongHandler);

    prevBtn.addEventListener (MouseEvent.CLICK, prevSongHandler);

    function nextSongHandler(event:MouseEvent):void {}

    If (currentSong < playlistLength-1) {}

    currentSong ++;

    songName = new String();

    songName = playlist [currentSong];

    songUrl = new URLRequest (songName);

    stopSong();

    playSong();

    }

    on the other

    If (currentSong == playlistLength - 1) {}

    currentSong = 0;

    songName = new String();

    songName = playlist [currentSong];

    songUrl = new URLRequest (songName);

    stopSong();

    playSong();

    }

    }

    function prevSongHandler(event:MouseEvent):void {}

    If (currentSong > 0) {}

    -currentSong;

    songName = new String();

    songName = playlist [currentSong];

    songUrl = new URLRequest (songName);

    stopSong();

    playSong();

    }

    on the other

    if(currentSong == 0) {}

    currentSong = playlistLength - 1;

    songName = new String();

    songName = playlist [currentSong];

    songUrl = new URLRequest (songName);

    stopSong();

    playSong();

    }

    }

    function checkTiming(event:Event):void {}

    ExternalInterface.call("saveglobalscore",score) ("console.log", "intra aici.");

    channel.removeEventListener (Event.SOUND_COMPLETE, checkTiming);

    If (currentSong < playlistLength-1) {}

    currentSong ++;

    songName = new String();

    songName = playlist [currentSong];

    songUrl = new URLRequest (songName);

    stopSong();

    playSong();

    }

    on the other

    If (currentSong == playlistLength - 1) {}

    currentSong = 0;

    songName = new String();

    songName = playlist [currentSong];

    songUrl = new URLRequest (songName);

    stopSong();

    playSong();

    }

    }

    use:

    flash.media.Sound; import to import flash.events.MouseEvent;

    Import fl.controls.Slider;

    Import fl.events.SliderEvent;

    import flash.utils.ByteArray;

    import flash.events.SampleDataEvent;

    import flash.net.URLLoader;

    import flash.events.Event;

    import flash.net.URLRequest;

    import flash.media.SoundChannel;

    import equalizer;

    import flash.media.SoundTransform;

    External callers.

    ExternalInterface.addCallback("IsStatic",IsStatic) ("playStop", playStopCaller);

    ExternalInterface.addCallback("IsStatic",IsStatic) ("getPlaylist", getPlaylistCaller);

    ExternalInterface.addCallback("IsStatic",IsStatic) ("eqChange", eqChangeCaller);

    ////////////////////////////////////////////////////////

    ////////////////////////Listeners ////////////////////////

    addEventListener (Event.ENTER_FRAME, update, false, 0, true);

    addEventListener (Event.ENTER_FRAME, getPlaylistX, false, 0, true);

    playBtn.addEventListener (MouseEvent.CLICK, playButtonHandler);

    stopBtn.addEventListener (MouseEvent.CLICK, stopButtonHandler);

    //////////////////////////////////////////////////////////

    //////////////////includes//////////////////////

    EQ: Equalizer var = new Equalizer();

    var eqVector:Vector. = new Vector. ();

    eqVector [0] = 0;

    eqVector [1] = 0;

    eqVector [2] = 0;

    eqVector [3] = 0;

    eqVector [4] = 0;

    eqVector [5] = 0;

    eqVector [6] = 0;

    eqVector [7] = 0;

    eqVector [8] = 0;

    eqVector [9] = 0;

    eqVector [10] = 0;

    eqVector [11] = 0;

    eqVector [12] = 0;

    eqVector [13] = 0;

    eqVector [14] = 0;

    var ba: ByteArray;

    var song: Sound;

    var songOut:Sound;

    var _samples:ByteArray;

    var _sampleBufferL:Vector. = new Vector. ();

    var _sampleBufferR:Vector. = new Vector. ();

    var volumeAdjust:SoundTransform = new SoundTransform();

    var playlistLength:Number = 0;

    var playlist:Array;

    var playTest:Array = new Array ("media/sounds/test1.mp3","media/sounds/test2.mp3", "media/sounds test3.mp3");

    var channel: SoundChannel;

    const BUFFER_SIZE:int = 2048; size of the output buffer

    const MIN_SAFETY_BUFFER:int = 1024; minimum collected entry before the beginning of the output

    var songName:String;

    var currentSong:Number = 0;

    var songUrl:URLRequest;

    ////////////////////////////////////////////////

    function playStopCaller(t:String):void {}

    If (t == "0") {}

    stopSong();

    }

    on the other

    If (t == "1") {}

    songName = new String();

    songName = playlist [currentSong];

    songUrl = new URLRequest (songName);

    playSong();

    }

    }

    function playButtonHandler(event:MouseEvent):void {}

    songName = new String();

    songName = playlist [currentSong];

    songUrl = new URLRequest (songName);

    playSong();

    }

    function stopButtonHandler(event:MouseEvent):void {}

    stopSong();

    }

    function rhyme (): void {}

    volumeAdjust.volume = 0.5

    Equalizer. Preamp = 0.5;

    song = new Sound();

    song.addEventListener (Event.COMPLETE, loadCompleteSong);

    Song.Load (songUrl);

    }

    function stopSong (): void {}

    Channel.Stop ();

    channel.removeEventListener (Event.SOUND_COMPLETE, checkTiming);

    }

    slider1.addEventListener (SliderEvent.CHANGE, slider1Handler);

    slider2.addEventListener (SliderEvent.CHANGE, slider2Handler);

    slider3.addEventListener (SliderEvent.CHANGE, slider3Handler);

    slider4.addEventListener (SliderEvent.CHANGE, slider4Handler);

    slider5.addEventListener (SliderEvent.CHANGE, slider5Handler);

    slider6.addEventListener (SliderEvent.CHANGE, slider6Handler);

    slider7.addEventListener (SliderEvent.CHANGE, slider1Handler);

    slider8.addEventListener (SliderEvent.CHANGE, slider2Handler);

    slider9.addEventListener (SliderEvent.CHANGE, slider3Handler);

    slider10.addEventListener (SliderEvent.CHANGE, slider4Handler);

    slider11.addEventListener (SliderEvent.CHANGE, slider5Handler);

    slider12.addEventListener (SliderEvent.CHANGE, slider6Handler);

    slider13.addEventListener (SliderEvent.CHANGE, slider4Handler);

    slider14.addEventListener (SliderEvent.CHANGE, slider5Handler);

    slider15.addEventListener (SliderEvent.CHANGE, slider6Handler);

    volSlider.addEventListener (SliderEvent.CHANGE, volSliderHandler);

    function slider1Handler(event:SliderEvent):void {}

    eqVector [0] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function slider2Handler(event:SliderEvent):void {}

    eqVector [1] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function slider3Handler(event:SliderEvent):void {}

    eqVector [2] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function slider4Handler(event:SliderEvent):void {}

    eqVector [3] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function slider5Handler(event:SliderEvent):void {}

    eqVector [4] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function slider6Handler(event:SliderEvent):void {}

    eqVector [5] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function slider7Handler(event:SliderEvent):void {}

    eqVector [6] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function slider8Handler(event:SliderEvent):void {}

    eqVector [7] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function slider9Handler(event:SliderEvent):void {}

    eqVector [8] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function slider10Handler(event:SliderEvent):void {}

    eqVector [9] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function slider11Handler(event:SliderEvent):void {}

    eqVector [10] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function slider12Handler(event:SliderEvent):void {}

    eqVector [11] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function slider13Handler(event:SliderEvent):void {}

    eqVector [13] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function slider14Handler(event:SliderEvent):void {}

    eqVector [14] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function slider15Handler(event:SliderEvent):void {}

    eqVector [15] = number (event.value) / 100;

    equalizer.eqGains = eqVector;

    }

    function volSliderHandler(event:SliderEvent):void {}

    volumeAdjust.volume = event.value/100;

    channel.soundTransform = volumeAdjust;

    }

    function sampleData(event:SampleDataEvent):void {}

    _SAMPLES = new ByteArray();

    var len:Number = song.extract (_samples, BUFFER_SIZE),

    i: int = 0,

    l:number,

    r: Number;

    If (len< buffer_size="" )="">

    Len += song.extract(_samples,BUFFER_SIZE-len,0);

    }

    _SAMPLES.position = 0;

    While (i< buffer_size)="">

    l = equalizer.applyFilter (_samples.readFloat ());

    r = equalizer.applyFilter (_samples.readFloat ());

    event.data.writeFloat (l);

    event.data.writeFloat (r);

    i ++ ;

    }

    }

    function loadCompleteSong(event:_Event):void {}

    Channel = song.play ();

    channel.addEventListener (Event.SOUND_COMPLETE, checkTiming);

    song.addEventListener (SampleDataEvent.SAMPLE_DATA, sampleData);

    }

    function Update($e:Event):void

    {

    BA = new ByteArray();

    SoundMixer.computeSpectrum (ba, true);

    var eq1:Number = 0;

    var eq2:Number = 0;

    var eq3:Number = 0;

    var eq4:Number = 0;

    var eq5:Number = 0;

    var eq6:Number = 0;

    var eq7:Number = 0;

    var eq8:Number = 0;

    for (var i = 0; i)<>

    EQ1 += b [i];

    }

    for (i = 64; I)<>

    EQ2 += b [i];

    }

    for (i = 128; I)<>

    EQ3 += b [i];

    }

    for (i = 192; I)<>

    EQ4 += b [i];

    }

    for (i = 256; I)<>

    EQ5 += b [i];

    }

    for (i = 320; I)<>

    EQ6 += b [i];

    }

    for (i = 384; I)<>

    EQ7 += b [i];

    }

    for (i = 448; I)<>

    Eq8 += b [i];

    }

    if(EQ1/64)<>

    var fxNr1:Number = eq1/64;

    }

    on the other

    fxNr1 = 100;

    if(EQ2/64)<>

    var fxNr2:Number = eq2/64;

    }

    on the other

    fxNr2 = 100;

    if(EQ3/64)<>

    var fxNr3:Number = eq3/64;

    }

    on the other

    fxNr3 = 100;

    if(EQ4/64)<>

    var fxNr4:Number = eq4/64;

    }

    on the other

    fxNr4 = 100;

    if(EQ5/64)<>

    var fxNr5:Number = eq5/64;

    }

    on the other

    fxNr5 = 100;

    if(EQ6/64)<>

    var fxNr6:Number = eq6/64;

    }

    on the other

    fxNr6 = 100;

    if(EQ7/64)<>

    var fxNr7:Number = eq7/64;

    }

    on the other

    fxNr7 = 100;

    if(eq8/64)<>

    var fxNr8:Number = eq8/64;

    }

    on the other

    fxNr8 = 100;

    var eqz1:Number = Math.abs (Math.round (fxNr1));

    var eqz2:Number = Math.abs (Math.round (fxNr2));

    var eqz3:Number = Math.abs (Math.round (fxNr3));

    var eqz4:Number = Math.abs (Math.round (fxNr4));

    var eqz5:Number = Math.abs (Math.round (fxNr5));

    var eqz6:Number = Math.abs (Math.round (fxNr6));

    var eqz7:Number = Math.abs (Math.round (fxNr7));

    var eqz8:Number = Math.abs (Math.round (fxNr8));

    ExternalInterface.call("saveglobalscore",score) ("as3_getEq", eqz1, eqz2, eqz3, eqz4, eqz5, eqz6, eqz7, eqz8);

    }

    function getPlaylistCaller(x:Array) {}

    playlist = x;

    var playlistLength = playlist.length;

    }

    function getPlaylistX (event): void {}

    playlist = playTest;

    playlistLength = playlist.length;

    trace (playlist. Length);

    }

    nextBtn.addEventListener (MouseEvent.CLICK, nextSongHandler);

    prevBtn.addEventListener (MouseEvent.CLICK, prevSongHandler);

    function nextSongHandler(event:MouseEvent):void {}

    If (currentSong<>

    currentSong ++;

    songName = new String();

    songName = playlist [currentSong];

    songUrl = new URLRequest (songName);

    stopSong();

    playSong();

    }

    on the other

    If (currentSong == playlistLength - 1) {}

    currentSong = 0;

    songName = new String();

    songName = playlist [currentSong];

    songUrl = new URLRequest (songName);

    stopSong();

    playSong();

    }

    }

    function prevSongHandler(event:MouseEvent):void {}

    If (currentSong > 0) {}

    -currentSong;

    songName = new String();

    songName = playlist [currentSong];

    songUrl = new URLRequest (songName);

    stopSong();

    playSong();

    }

    on the other

    if(currentSong == 0) {}

    currentSong = playlistLength - 1;

    songName = new String();

    songName = playlist [currentSong];

    songUrl = new URLRequest (songName);

    stopSong();

    playSong();

    }

    }

    function checkTiming(event:Event):void {}

    ExternalInterface.call("saveglobalscore",score) ("console.log", "intra aici.");

    channel.removeEventListener (Event.SOUND_COMPLETE, checkTiming);

    If (currentSong<>

    currentSong ++;

    songName = new String();

    songName = playlist [currentSong];

    songUrl = new URLRequest (songName);

    stopSong();

    playSong();

    }

    on the other

    If (currentSong == playlistLength - 1) {}

    currentSong = 0;

    songName = new String();

    songName = playlist [currentSong];

    songUrl = new URLRequest (songName);

    stopSong();

    playSong();

    }

    }

    and you will need a crossdomain permissions file if your sound is loading from another domain.

  • How to encode a record Audio of AS3 in PHP

    I am trying to build a way to encode data AS3 audio recording in WAV in PHP. I used a library of WAV in AS3 coders previously, but a record 2 minutes would take 4 to 6 minutes on mobile, depending on the device. So I need to encode to WAV (or any other format that would make usable) in PHP to take the load of the application.

    I have transated this encoder of Thibault Imbert to PHP. See the translation:

    function encode($samples, $channels = 2, $bits = 16, $rate = 44100){
        $data = create($samples);
        $length = strlen($data);
        $bytes = createHeaders($length, $channels, $bits, $rate);
        $bytes .= $data;
        return $bytes;
    }
    
    
    function create($samples) {
        $newBytes = '';
        $bytes = unpack("f*", $samples);
    
        foreach ($bytes as $value) {
            $newBytes .= pack("V*",$value * 0x7FFF);
        }
        return $newBytes;
    }
    
    
    function createHeaders($length, $channels = 2, $bits = 16, $rate = 44100) {
        $RIFF = "RIFF";
        $WAVE = "WAVE";
        $FMT = "fmt ";
        $DATA = "data";
        $header  = '';
        $header .= $RIFF;
        $header .= pack("I*", $length + 44);
        $header .= $WAVE;
        $header .= $FMT;
        $header .= pack("I*", 16);
        $header .= pack("v*", 1);
        $header .= pack("v*", $channels);
        $header .= pack("I*", $rate);
        $header .= pack("I*", ( $rate * $channels * ($bits >> 3)));
        $header .= pack("v*", ($channels * ($bits >> 3)));
        $header .= pack("v*", $bits);
        $header .= $DATA;
        $header .= pack("I*", $length);
        return $header;
    }
    
    

    Which will create a file readable by the right length (if the headers are obviously correct), but there is only silence when it is played. If I change the package size in 'create()' to ' f * ' (instead of unsigned 32-bit little endian int, float), I get static and I can faintly hear the sound in the background. I can't solve this multiplier to clear up the static method, however. (EDIT: before it is mentioned, I know the asterisk is not necessary for most, if not all of the package formats.) It was something that I tried to see if she could fix things and I never removed it)

    The file itself is created as if:

    private function start():void {
              if ( !mic ) {
                        this.mic = Microphone.getMicrophone();
                        this.mic.rate = 44;
                        this.mic.setSilenceLevel( 0, 10000 );
                        this.recording = new ByteArray();
              }
            this.recording.length = 0; //reset byte array in case this is not first recording
              this.mic.addEventListener( SampleDataEvent.SAMPLE_DATA, this.saveSample );
    }
    
    private function saveSample( e:SampleDataEvent ):void {
              while( e.data.bytesAvailable ) {
                        var byte:Number = e.data.readFloat();
                        this.recording.writeFloat( byte );
              }
    }
    
    public function stopRecording():void {
              var file:File = File.applicationStorageDirectory.resolvePath( "audio-recording.wav" );
              this.fs.open( file, FileMode.WRITE );
              this.fs.writeBytes( this.recording );
              this.fs.close();
    }
    

    I'm trying to encode the file is saved in stopRecording(). At this point, I don't know what to do. I tried to translate an other encoder as well, but that seemed to run through the memory as if it was nothing.

    Does anyone have any suggestions as to what is the problem? The two encoders work very well in AS3. Is this a problem with the write file? Problem with writing the audio data in the byte array? Any suggestions will be useful

    So I was unable to find a way to do this via PHP, but I have figure out how do it in a way that is effective and freaking fast in AS3. I realized that the slow fuse of encoding has been a loop in the byte array, read each individual byte, manipulating and write it to another array of bytes. This is an inefficient process, but necessary if you want to ignore the encoder of the recorder. The key was not abstract and rather to encode on the fly, like recording that happens.

    If you record like this:

    private function saveSample( e:SampleDataEvent ):void {
              e.data.position = 0;
              while( e.data.bytesAvailable ) {
                        this.recording.writeShort( e.data.readFloat() * (0x7fff) );
              }
    }
    

    It's the encoding that Thibault Imbert wrote as you do a necessary task (pulling the data from the stream and saving it to a byte array).

    With this, the data is written as it is necessary and sufficient to add the headers to make a WAV file.

    this.recording.position = 0;
    this.recording = this.writeHeaders( this.recording, 1 );
    
    private function writeHeaders( data:ByteArray, channels:int=2, bits:int=16, rate:int=44100 ):ByteArray {
              data.position = 0;
    
              var bytes:ByteArray = new ByteArray();
              bytes.length = 0;
              bytes.endian = Endian.LITTLE_ENDIAN;
    
              bytes.writeUTFBytes( "RIFF" );
              bytes.writeInt( uint( data.length + 44 ) );
              bytes.writeUTFBytes( "WAVE" );
              bytes.writeUTFBytes( "fmt " );
              bytes.writeInt( uint( 16 ) );
              bytes.writeShort( uint( 1 ) );
              bytes.writeShort( channels );
              bytes.writeInt( rate );
              bytes.writeInt( uint( rate * channels * ( bits >> 3 ) ) );
              bytes.writeShort( uint( channels * ( bits >> 3 ) ) );
              bytes.writeShort( bits );
              bytes.writeUTFBytes( "data" );
              bytes.writeInt( data.length );
              bytes.writeBytes( data );
              bytes.position = 0;
              return bytes;
    }
    

    And oila. It's a valid WAV file created without delay after the end of the recording (while I was previously known a delay of 3 times the length of the record on my Nexus 4). I know that's not a very popular topic (Google, Adobe, these forums and StackOverflow were pretty useless to try to solve this problem), but I hope that this solution will help someone along the line.

    EDIT: afterwards, make sure that the ByteArray you save in has its endian Endian.LITTLE_ENDIAN property immediately after instantiation. WAV files require this format and are unreadable if is not set to one.

  • proofreading and micro bytearray mix

    Hello, I need your help

    I have a record demand for micro and I mix another sound of the song. For this step is ok I can record on my desk and the mix is good.

    But I like to listen to my mix of bytearray. And even then, I have a problem.

    The sound is very slow... and not even my file to save.

    My code:

    var epos: Number = 0

    ByteArray in which audio data is stored microphone

    var soundBytes:ByteArray = new ByteArray();

    Gets the default microphone

    var mic:Microphone = Microphone.getMicrophone ();

    Security.showSettings ("microphone");

    function init() {}

    Sets the minimum entry level that should be considered sound

    mic.setSilenceLevel (0);

    The amount by which the microphone amplifies the signal.

    MIC.gain = 50;

    The rate at which the microphone picks up sound, in kHz.

    MIC.rate = 44;

    }

    function called when you click on Start button Save

    function startRecord (): void

    {

    mic.addEventListener (SampleDataEvent.SAMPLE_DATA, micSampleDataHandler);

    }

    function called when you click stop record button

    function stopRecord (): void

    {

    mic.removeEventListener (SampleDataEvent.SAMPLE_DATA, micSampleDataHandler);

    }

    function micSampleDataHandler(event:SampleDataEvent):void

    {

    var temp: ByteArray = new ByteArray()

    var mdata:ByteArray = event.data

    var l:Number = mdata.bytesAvailable

    sound_kar. Extract (temp, l/4, EPOS);

    Temp.position = 0

    var b:Number = temp.bytesAvailable

    EPOS += l/4

    var s1, s2, s3:Number

    While (mdata.bytesAvailable)

    {

    S3 = mdata.readFloat ();

    S1 = 0

    S2 = 0

    If (temp.bytesAvailable > = 8) {}

    S1 = Temp.readFloat)

    S2 = Temp.readFloat)

    }

    mixTracks (s1, s2, s3);

    }

    }

    function mixTracks(l:Number,r:Number,m:Number):void

    {

    the function that mixes the audio microphone with background sound...

    var sampleT1_L:Number;

    var sampleT1_R:Number;

    var sampleT2:Number;

    var trackL:Number;

    var trackR:Number;

    sampleT1_L = l;

    sampleT1_R = r;

    sampleT2 = m;

    trackL = (sampleT1_L + sampleT2);

    trackR = (sampleT1_R + sampleT2);

    trackL = trackL > 1? 1:trackL;

    trackR = trackR > 1? 1:trackR;

    trackL trackL = <-1? -1:trackL;

    trackR trackR = <-1? -1:trackR;

    mixedTrack.writeFloat (trackL);

    mixedTrack.writeFloat (trackR);

    }

    Mixture of proofreading:

    mixedTrack.position = 0;

    soundPlay.addEventListener (SampleDataEvent.SAMPLE_DATA, playbackSampleHandler);

    channelPlay = soundPlay.play ();

    function playbackSampleHandler(event:SampleDataEvent):void

    {

    If (! mixedTrack.bytesAvailable > 0) //if end; return

    return;

    for (var i: int = 0; i < 8192 /(44/44); i ++) {}

    Sample number: var = 0;

    If (mixedTrack.bytesAvailable > 0)

    example = mixedTrack.readFloat ();

    write the sample, that is, play

    for (var j: int = 0; j < int ((44.0/44) * 2); j ++) {//4 to 22 kHz? for 8 khz}

    event.data.writeFloat (sample);

    }

    }

    }

    Can you help me to re-read my mixture in bytearray?

    Thank you very much

    Oeann

    OK, I found my problem and is ok... If this can help you:

    function playbackSampleHandler(event:SampleDataEvent):void

    {

    for (var i: int = 0; i < 8192="" &&="" mixedtrack.bytesavailable=""> 0; i ++)

    {

    mixedTrack.position = int (position) * 8;

    position += 1;

    Sample number: var = mixedTrack.readFloat ();

    event.data.writeFloat (sample);

    event.data.writeFloat (sample);

    }

    }

    Nice day

  • Access to Android MIC problem

    I read the micro class, and I can't understand why this code does not draw anything:

    var mic:Microphone = Microphone.getMicrophone ();

    MIC.gain = 100;

    MIC.rate = 44;

    mic.setSilenceLevel (0, 6000);

    mic.addEventListener (SampleDataEvent.SAMPLE_DATA, micSampleDataHandler);

    private void micSampleDataHandler(event:SampleDataEvent):void {}

    log ("Recording");

    }

    According to the adobe help files that it is alls that is necessary to actually speak into the microphone and do know that you do.  But I can't micSampleDataHandler to fire all whispering, talk or scream into the phone.

    Am I missing something?

    On Android, you must set the permission to RECORD_AUDIO to access the microphone.

  • SoundChannel event.sound_complete does not? Help?

    Hello

    For some reason, my soundchannel event.sound_complete does not work. In fact, my class is to import its in and to allow the use to change their volumes and sound technology.

    This is the tutorial for speed

    http://blog.Andre-Michelle.com/2009/pitch-MP3/

    Right now, what I want to do is to auto loop back the song once the song ended the game, but I saw troubled do. No matter which, can help me?

    The code will pass by the SoundForward() function

    Inside, it will trigger _mp3.addEventListener (Event.COMPLETE, complete);

    and the activity function Rollback() will.

    Inside, it will trigger a _soundChannel.addEventListener (Event.SOUND_COMPLETE, loopMusic);

    but then the function fires once the song ended he played.

    Benson

    Thank you

    ------------------------------------------------------------------------------------------ -----

    {package examples

    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.SampleDataEvent;
    import flash.media.Sound;
    import flash.media.SoundChannel;
    import flash.net.URLRequest;
    import flash.utils.ByteArray;

    SerializableAttribute public class SoundForward extends Sprite
    {
    private const blockSize:int = 3072;

    private var _mp3:Sound;
    private var _sound:Sound;
    private var _soundChannel:SoundChannel;

    private var _target:ByteArray;
    private var _position:Number;
    private var _rate:Number;
    private var _stop:Boolean;


    private var _pausePoint:Number;

    public void SoundForward (url: String, stop: Boolean)
    {
    _target = new ByteArray();

    _mp3 = new Sound();
    _mp3.addEventListener (Event.COMPLETE, complete);
    _mp3. Load (new URLRequest (url));

    _stop = stop;

    _pausePoint = 0;
    _position = 0.0;
    _rate = 1.0;

    _sound = new Sound();
    _sound.addEventListener (SampleDataEvent.SAMPLE_DATA, sampleData);

    _soundChannel = new SoundChannel();

    }

    private void complete(event:Event):void
    {
    _soundChannel = _sound.play ();
    _soundChannel.addEventListener (Event.SOUND_COMPLETE, loopMusic);
    }

    private void sampleData(event:SampleDataEvent):void
    {
    Reuse instead of leisure
    _target.position = 0;

    Shortcut
    var data: ByteArray = event.data;
    var scaledBlockSize:Number = blockSize * _rate;
    var positionInt:int = _position;
    var alpha: Number = _position - positionInt;

    var positionTargetNum:Number = alpha;
    var positionTargetInt:int = - 1;

    need var: int = Math.ceil (scaledBlockSize) + 2;
    var read: int = _mp3.extract (_target, need, positionInt);

    var n: int = read is need? blockSize: read / _rate;

    var l0:Number;
    var r0:Number;
    var l1:Number;
    var r1:Number;

    for (var i: int = 0; i < n; ++ i)
    {
    If (int (positionTargetNum)! = positionTargetInt)
    {
    positionTargetInt = positionTargetNum;

    Reading objective FIXED position
    _target.position = positionTargetInt < < 3.

    Read Stero two samples for linear INTERPOLATION
    L0 = _target.readFloat ();
    R0 = _target.readFloat ();

    L1 = _target.readFloat ();
    R1 = _target.readFloat ();
    }

    Write amplitudes interpolated streaming
    data.writeFloat (l0 + alpha * (l1 - l0));
    data.writeFloat (r0 + alpha * (r1 - r0));

    Increase the position of the target
    positionTargetNum += _rate;

    FRACTION OF THE INCREASE AND THE CLAMP BETWEEN 0 AND 1
    += Alpha _rate;
    While (alpha > = 1.0)-alpha;
    }

    -FILL the REST OF THE flow of DATA WITH zeros
    If (I < blockSize)
    {
    While (I < blockSize)
    {
    data.writeFloat (0,0);
    data.writeFloat (0,0);

    ++ i ;
    }
    }

    -INCREASE SOUND POST
    _position += scaledBlockSize;
    }

    private void loopMusic(e:Event):void
    {
    trace ("AB");
    }

    }
    }

    Use the code that I have suggested.  You should have only one sound (_mp3) instance in your code.

Maybe you are looking for