Hello Amarjeet, Take a look at AudioPlayer.toAudioBuffer ; it should be doing what you are trying to accomplish.
Regards, Frode On Thu, Nov 9, 2017 at 4:52 AM, Amarjeet Singh <[email protected]> wrote: > Hi Team, > > > I am trying to add support for Audio in IE as a Flashback. I am getting > data as a Arraybuffer (6048 ) from the audio stream. > I have written below action script which is as follows:- > > >> package >> { >> import flash.display.*; >> import flash.events.*; >> import flash.external.*; >> import flash.media.*; >> public class guacamole extends Sprite >> { >> public var sound:Sound = null; >> public var buffer:Array; >> public function guacamole() >> { >> this.buffer = []; >> super(); >> ExternalInterface.addCallback("write", this.write); >> } >> public function write(param1:String) : void >> { >> if(!this.sound) >> { >> this.sound = new Sound(); >> this.sound.addEventListener(SampleDataEvent.SAMPLE_DATA, >> this.soundGenerator); >> this.sound.play(); >> } >> this.buffer = this.buffer.concat(param1.split(" ")); >> } >> public function soundGenerator(param1:SampleDataEvent) : void >> { >> var _loc_1:int = 0; >> var _loc_2:Function = param1.data.writeFloat; >> if(this.buffer.length < 4096) >> { >> _loc_1 = 0; >> while(_loc_1 < 4096) >> { >> _loc_2(0.00); >> _loc_1++; >> } >> return; >> } >> var _loc_3:Number = Math.min(this.buffer.length, 16384); >> _loc_1 = 0; >> while(_loc_1 < _loc_3) >> { >> _loc_2(this.buffer[_loc_1]); >> _loc_1++; >> } >> this.buffer = this.buffer.slice(_loc_3, this.buffer.length); >> } >> } >> } > > > > Now I need to convert the stream of ArrayBuffer into a string of Integer > samples or Floating samples. > I need help to do that as I tried a lot but it's not working. > Please help me out to resolve the above issue or guide me to convert the > Raw PCM 16 bit Audio data to Floating samples between -1 to 1 . > > > > Thanks and Regards, > Amarjeet Singh
