Codecs/SpeexCodec

Speex Codec

 Speex is a new voice codec supported in Flash Player 10 and above. With the new release of flash player 10 this document explains a little about the new codec with this release.

Setting Up Flex SDk / Flex Builder

Flex SDK / Flex Builder needs to be setup to target flash player 10 playerglobal.swc which has the new features enabled.

Taken from the Adobe Open Source area  http://opensource.adobe.com/wiki/display/flexsdk/Targeting+Flash+Player+10+Beta

Get Flex 3 SDK

  • Download Flex SDK 3.0.3 or above. In Flex 3 extract into the sdks directory.
  • Make sure that you have a Flash 10 playerglobal.swc at FLEX_SDK/frameworks/libs/player/10/playerglobal.swc.

Config Flex Config To Target Flash Player 10

  • Modify FLEX_SDK/frameworks/flex-config.xml. Edit <target-player>, replacing 9.0.115 with 10.0.0:
         <target-player>10.0.0</target-player>
    
  • In <external-library-path>, edit the path-element for playerglobal.swc, replacing 9 with 10:
         <external-library-path>
           <path-element>libs/player/10/playerglobal.swc</path-element> 
         </external-library-path>
    
  • Do the same with <library-path:
         <library-path>
         <path-element>libs</path-element>
         <path-element>libs/player/10</path-element>
         <path-element>locale/{locale}</path-element>
         </library-path>
    
  • In flex builder, right click the project and choose properties, choose Flex Compiler, choose the "Configure Flex SDKs" link on the right, choose add then choose the location of the newly downloaded SDK and give it a name.
  • Back in the Flex Compiler config choose "Use a specific SDK and select in the list the Flex SDK configured previously.

Code Example

Setup the Microphone class to use the new Speex Codec.

_microphone = Microphone.getMicrophone();
if (_microphone) {
    //_microphone.setLoopBack(true);
    _microphone.codec = SoundCodec.SPEEX;
    _microphone.encodeQuality = 10;
    _microphone.rate = 44;
    _microphone.framesPerPacket = 2;
    _microphone.gain = 50;
    _microphone.setUseEchoSuppression(true);
    ns.attachAudio(_microphone);
} else {
    throw new Error("Audio Not Connected");
}

FFMpeg and Speex

According to Art Clarke subversion revision  r15028 of the FFMpeg source code has the capabilities of decoding the Speex codec from FLV files.

*  http://www.speex.org/

*  http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/media/SoundCodec.html

*  http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/media/Microphone.html