Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How do I unmute the microphone?

New Here ,
Sep 06, 2017 Sep 06, 2017

I am trying to unmute the microphone to make it make it work with a Spectrum Analyser.


    import flash.display.Shape;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.SampleDataEvent;
    import flash.media.Microphone;
    import flash.media.Sound;
    import flash.media.SoundMixer;
    import flash.utils.ByteArray;

var mic:Microphone = Microphone.getMicrophone();
mic.addEventListener(SampleDataEvent.SAMPLE_DATA, micSampleDataHandler);
var _soundBytes:ByteArray = new ByteArray();
var _micBytes:ByteArray;
var _micSound:Sound;
initMic();

import SpectrumAnalyzer;

var visualization:SpectrumAnalyzer = new SpectrumAnalyzer( 550, 400);
addChild(visualization);

var soundIsOn = true();
function changeSound{
    var st:SoundTransform = new SoundTransform();
    if(soundIsOn)
    {
        st.volume = 0;
        SoundMixer.soundTransform = st;
        soundIsOn = false;
    }
    else
    {
        st.volume = 1;
        SoundMixer.soundTransform = st;
        soundIsOn = true;
    }
}


function initMic():void {
if ( mic ) {
   mic.rate = 44;
   mic.gain = 50;
  mic.setSilenceLevel(5);
  trace("Microphone available, setting up sound objects");
  initSound();
}
else {
    // no mic
}
}

function micSampleDataHandler(event:SampleDataEvent) :void {
  trace("Mic data available");
_micBytes = event.data;
_micSound.play();
}

function initSound():void {
_micSound = new Sound();
_micSound.addEventListener(SampleDataEvent.SAMPLE_DATA, soundSampleDataHandler);
}

function soundSampleDataHandler(event:SampleDataEvent):void {
trace("Sound object needs more sample data");
   for (var i:int = 0; i < 8192 && _micBytes.bytesAvailable > 0; i++) {
     var sample:Number = _micBytes.readFloat();
     event.data.writeFloat(sample);
     event.data.writeFloat(sample);
   }
}

stop();

485
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Sep 06, 2017 Sep 06, 2017

No doubt there is more going wrong, but first, this:

function changeSound{

should be:

function changeSound() {

Translate
LEGEND ,
Sep 06, 2017 Sep 06, 2017
LATEST

No doubt there is more going wrong, but first, this:

function changeSound{

should be:

function changeSound() {

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines