How to play sound from a proprietary format

I would like to convert a small java applet to flex as3
The current applet connects  to a remote server to receive audio in a proprietry compressed and encrypted format using a tcp connection (the data is encoded as text)
It then decrypts, decompresses the audio and uses java sound to play it.
Looking at the as3 classes all I could find is a sound object that seems to only play mp3 audio and a urlrequest object that is used to download (what about streaming) mp3 audio from a server.
I am looking for a simple sample that will incorporate retreving data from a server (perhaps using the http service) into e.g. a byte array, and playing pcm audio from a byte array.
Ideally it would be a small set of files (1?) that I can compile using mxmlc; I am not good with IDEs, linux command line is my thing
Thanks

Maciek, many thanks!
Here's sample code showing how to stream audio in arbitrary format and play it
// File: Player.as
// When running from local storage (during developement)
// compile mxmlc -use-network=false Player.as
// otherwise loading the local raw audio file fails with error 2148
// The input audio format is 16 bit little endian 44.1Khz mono.
package
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.media.Sound;
    import flash.media.SoundChannel;
    import flash.events.Event;
    import flash.events.SampleDataEvent;
    import flash.net.URLRequest;
    import flash.net.URLStream;
    public class Player extends Sprite
        private var sourceUri:String = "audio.44.raw";
        private var sound:Sound = new Sound();
        private var soundChannel:SoundChannel = new SoundChannel();
        private var playing:Boolean;
        private var stream:URLStream;
        private var request:URLRequest;
        private var statusLine:TextField = new TextField();
        public function Player()
            statusLine.width = 400;
            statusLine.text = "Starting...";
            addChild(statusLine);
            getAudio();
            start();
        public function getAudio():void
            stream = new URLStream();
            request = new URLRequest(sourceUri);
            try {
                stream.load(request);
            } catch (error:Error) {
                statusLine.text = "Failed to load " + request.url + " : " + err!
        private function playCallback(event:SampleDataEvent):void
            var value:Number;
            var i:int, cnt:int;
            // Input is 16bit PCM, each sample occupies 2 bytes
            cnt = stream.bytesAvailable / 2;
            if (cnt >= 8192 || playing) {
                playing = true;
                statusLine.text = request.url + " : playing...";
                if (cnt > 8192)
                    cnt = 8192;
                for (i = 0; i < cnt; i++) {
                    // Convert 16bit little edndian pcm samples to numbers
                    value = stream.readUnsignedByte() + 256 * stream.readUnsign!
                    if (value > 32767)
                        value -= 65536;
                    value /= 10000; //Adjust the volume
                    // Input is mono, write to both channels
                    event.data.writeFloat(value);
                    event.data.writeFloat(value);
                if (cnt < 2048)
                    statusLine.text = request.url + " : done...";              !
            else {
                // Wait until enough data is bufferred
                statusLine.text = request.url + " : buffering...";
                for (i = 0; i < 8192; i++) {
                    event.data.writeFloat(0);
                    event.data.writeFloat(0);
        private function start():void
            soundChannel.stop();
            sound.removeEventListener(SampleDataEvent.SAMPLE_DATA,playCallback);
            playing = false;
            sound.addEventListener(SampleDataEvent.SAMPLE_DATA,playCallback);
            soundChannel = sound.play();

Similar Messages

  • How to output sound from Zen Neeon to speaker without using

    how to output sound from Zen Neeon to speaker directly?
    as far as i know, i can only play content in my mp3 player using speaker with usb cable connected to pc
    i just wonder how i play using "play" button in mp3 player and the sound will output to speaker directly?
    need extra line-in cable?

    my speaker system is subwoofer,but i not very sure it's 2. system.
    the cable from the speaker is slightly too big to connect to the player headphone jack. and no sound come out after i play.
    why?

  • How to play videos from cnn?

    how to play videos from cnn?

    cnn.com   listenlive.eu    sites for news and music but its saves on phone and can't open it. I think they are in wmp.   is there a player that play and open different formats?

  • How to play music from iPod through Windows Media Player

    I don't want to insult anyone's intelligence .... but just in case anyone hasn't yet figured it out, here's how to play music from your iPod on a computer that does not have iTunes installed:
    On your computer, connect the iPod to iTunes and click on it's name. Then under the general tab, check "allow disk use". Your iPod will then act as a USB hard drive and will then show up as a drive in My Computer. Now all you need to do is to create a Music folder on it and then copy all your music to it!
    Your iPod's USB hard drive should show up under My Computer on most Windows computers. Therefore providing the computer has Windows Media Player installed, you will be able to play all your music on it! This saves you having to bother with portable/travel speakers, some of which sound terrible anyway!

    UKNightOwl wrote:
    ... providing the computer has Windows Media Player installed, ...
    ... This saves you having to bother with portable/travel speakers,
    Mains lead for the computer is a bit of a problem on the bus though!

  • How to play sound in servlet program

    How to play sound when a page is gernerated? Thank you for any suggestion.

    Why would you want to do that? Remember that the servlet runs on the web server, which is probably in a room full of computers. Nobody will be there to hear it, and if somebody does hear it they will just think it is a problem.
    Perhaps you wanted to play a sound when the page is loaded in the browser? That's an HTML/Javascript/browser question that might get an answer in a forum about those topics.

  • Playing sound from multiple applications?

    Hi, I recently started using Arch and I'm loving it but I have one problem. My ALSA can only play sound from one application at a time, so I have to use pulseaudio for the others. But pulseaudio doesn't recognize my mic so I can't remove ALSA. ALSA just says "device busy" or something. And yes I tried to search before posting but didn't find an answer.
    Thanks

    This is what I found from the logs:
    Jul 18 21:38:34 arch pulseaudio[946]: alsa-sink.c: ALSA woke us up to write new data to the device, but there was actually nothing to write!
    Jul 18 21:38:34 arch pulseaudio[946]: alsa-sink.c: Most likely this is a bug in the ALSA driver 'snd_hda_intel'. Please report this issue to the ALSA developers.
    Jul 18 21:38:34 arch pulseaudio[946]: alsa-sink.c: We were woken up with POLLOUT set -- however a subsequent snd_pcm_avail() returned 0 or another value < min_avail.
    Jul 19 00:53:54 arch pulseaudio[946]: alsa-sink.c: Error opening PCM device front:0: Device or resource busy
    Jul 19 00:53:54 arch pulseaudio[946]: alsa-sink.c: Error opening PCM device front:0: Device or resource busy
    Jul 19 21:59:22 arch pulseaudio[963]: alsa-sink.c: ALSA woke us up to write new data to the device, but there was actually nothing to write!
    Jul 19 21:59:22 arch pulseaudio[963]: alsa-sink.c: Most likely this is a bug in the ALSA driver 'snd_hda_intel'. Please report this issue to the ALSA developers.
    Jul 19 21:59:22 arch pulseaudio[963]: alsa-sink.c: We were woken up with POLLOUT set -- however a subsequent snd_pcm_avail() returned 0 or another value < min_avail.
    Jul 20 02:35:47 arch pulseaudio[963]: alsa-sink.c: Error opening PCM device front:0: Device or resource busy
    Jul 20 02:35:47 arch pulseaudio[963]: alsa-sink.c: Error opening PCM device front:0: Device or resource busy
    Jul 20 12:22:05 arch pulseaudio[981]: alsa-sink.c: Error opening PCM device front:0: Device or resource busy
    Jul 20 12:22:05 arch pulseaudio[981]: alsa-sink.c: Error opening PCM device front:0: Device or resource busy
    Jul 20 12:22:05 arch pulseaudio[981]: alsa-sink.c: Error opening PCM device front:0: Device or resource busy
    Jul 21 01:25:49 arch pulseaudio[953]: alsa-sink.c: ALSA woke us up to write new data to the device, but there was actually nothing to write!
    Jul 21 01:25:49 arch pulseaudio[953]: alsa-sink.c: Most likely this is a bug in the ALSA driver 'snd_hda_intel'. Please report this issue to the ALSA developers.
    Jul 21 01:25:49 arch pulseaudio[953]: alsa-sink.c: We were woken up with POLLOUT set -- however a subsequent snd_pcm_avail() returned 0 or another value < min_avail.
    Jul 21 14:33:44 arch pulseaudio[973]: alsa-sink.c: Error opening PCM device front:0: Device or resource busy
    Jul 21 14:33:44 arch pulseaudio[973]: alsa-sink.c: Error opening PCM device front:0: Device or resource busy
    Jul 21 14:33:44 arch pulseaudio[973]: alsa-sink.c: Error opening PCM device front:0: Device or resource busy
    Jul 22 01:58:04 arch pulseaudio[973]: alsa-sink.c: Error opening PCM device front:0: Device or resource busy
    Jul 22 01:58:04 arch pulseaudio[973]: alsa-sink.c: Error opening PCM device front:0: Device or resource busy
    Jul 22 02:20:11 arch pulseaudio[973]: alsa-sink.c: Error opening PCM device front:0: Device or resource busy
    Jul 22 02:20:11 arch pulseaudio[973]: alsa-sink.c: Error opening PCM device front:0: Device or resource busy
    Jul 22 02:48:30 arch pulseaudio[973]: alsa-sink.c: Error opening PCM device front:0: Device or resource busy
    Jul 23 00:21:44 arch pulseaudio[973]: alsa-sink.c: ALSA woke us up to write new data to the device, but there was actually nothing to write!
    Jul 23 00:21:44 arch pulseaudio[973]: alsa-sink.c: Most likely this is a bug in the ALSA driver 'snd_hda_intel'. Please report this issue to the ALSA developers.
    Jul 23 00:21:44 arch pulseaudio[973]: alsa-sink.c: We were woken up with POLLOUT set -- however a subsequent snd_pcm_avail() returned 0 or another value < min_avail.
    Jul 23 11:43:46 arch pulseaudio[973]: alsa-sink.c: Error opening PCM device front:0: Device or resource busy
    Jul 23 11:43:46 arch pulseaudio[973]: alsa-sink.c: Error opening PCM device front:0: Device or resource busy
    Jul 23 11:43:56 arch pulseaudio[973]: alsa-sink.c: Error opening PCM device front:0: Device or resource busy
    Jul 24 03:05:32 arch pulseaudio[954]: alsa-sink.c: ALSA woke us up to write new data to the device, but there was actually nothing to write!
    Jul 24 03:05:32 arch pulseaudio[954]: alsa-sink.c: Most likely this is a bug in the ALSA driver 'snd_hda_intel'. Please report this issue to the ALSA developers.
    Jul 24 03:05:32 arch pulseaudio[954]: alsa-sink.c: We were woken up with POLLOUT set -- however a subsequent snd_pcm_avail() returned 0 or another value < min_avail.
    And yes I have gstreamer.
    Last edited by nerdster (2011-07-26 00:35:45)

  • How to play song from one iPhone to another iPhone via Bluethooth?

    How to play song from one iPhone to another iPhone via Bluethooth and AirPlay?

    You don't. Such is not supported.

  • My iPad (4th gen) will not play sound from videos played via Facebook. Anybody have suggestions?

    My iPad (4th gen) will not play sound from videos played via Facebook. Anybody have suggestions?
    I've restarted my iPad, there are no available updates that I am aware of.

    Try reset iPad
    Hold down the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears
    Note: Data will not be affected.

  • How can I play sound from my MacBook Pro through my iMac?

    I have a MacBook pro which I am looking to use for only iTunes or Spotify for the time being but the iMac built in speakers are better.
    I am internet sharing from an ethernet on my iMac and the Macbook pro is connected to the shared network.
    Can I play music from Spotify on my macbook pro but out of my iMac speakers?
    Thanks
    James

    For sound, try the audio output port and connecting to the RCA  audio input ports on your Pioneer receiver.  Use something like this:
    http://eshop.macsales.com/item/OWC/PODCONNECTOR/
    Ciao.

  • How to play movies from Accer DD Hard Drive

    I've had my computer for less then 2 weeks and i haven't been able to install all of the major apps in order for certain things to run on my computer. How do i play movies from my external hard drive. I keep having a pop up on saying "QuickTime Player can't open "Bad Grandpa.avi". To see if additional software is available that will enable QuickTime Player to open the movie, click Tell Me More." I have installed QuickPlayer 7 but i am still recieving that pop up message. I have an Accer DD Hard drive. 

    AVI, a windows formatted move. can't be played by QT. Toe AVI's on your mac see:
    http://www.iskysoft.com/topic-snow-leopard/how-to-play-avi-with-quicktime-on-mac .html

  • How to play sound in midlet midp1.0

    how to play a sound (wav format) in midp1.0?
    help needed regarding nokia api.

    well i think ur specified location might be wrong.
    also check out some other ways:
    i hope this might help u.
    1.
    import javax.microedition.lcdui.*;
    import javax.microedition.media.*;
    import javax.microedition.media.control.*;
    import java.io.*;
    import java.util.*;
    public class mainsound {
    public Player player;
    public mainsound(String s){
    try{
    InputStream is = getClass().getResourceAsStream(s);
    player = Manager.createPlayer(is,"audio/AMR");
    player.addPlayerListener(new Listener());
    player.prefetch();
    catch(Exception e){System.out.println("Media Error" + e);}
    class Listener implements PlayerListener {
         public void playerUpdate(Player p, String event, Object eventData) {
              if (event == END_OF_MEDIA) {
              try {
              p.start();
              } catch (MediaException me) { }
    2.
    public void soundview()
    byte abyte0[]=a("024A3A45D0040029286185985504D04D06186987107107106185985504D0450710690610610000");
    Sound sound = new Sound(abyte0, 1);
    sound.init(abyte0, 1);
    sound.play(1);
    public static byte[] a(String s1)
    s1.toUpperCase();
    byte abyte0[] = new byte[s1.length() / 2];
    int i1 = 0;
    int j1 = 0;
    for(int l1 = s1.length() / 2; l1 > 0; l1--)
    int k1;
    if(s1.charAt(j1) >= '0' && s1.charAt(j1) <= '9')
    k1 = s1.charAt(j1) - 48;
    else
    k1 = (s1.charAt(j1) - 65) + 10;
    k1 *= 16;
    if(s1.charAt(j1 + 1) >= '0' && s1.charAt(j1 + 1) <= '9')
    k1 += s1.charAt(j1 + 1) - 48;
    else
    k1 += (s1.charAt(j1 + 1) - 65) + 10;
    abyte0[i1] = (byte)k1;
    j1 += 2;
    i1++;
    return abyte0;

  • Bluetooth Headset does not play sound from ipad touch 4th gen. ipod touch 4th gen. although it does pair ok! Please help!

    HM1200, BH99b, JabraBT2045 bluetooth headsets do not play music from ipad, ipod touch 4th generation, although it does pair ok. Why is that if it is compatable, why it does not play any music or sound via bluetooth headsets.  When I pair the headsets to Mac it does play music via bleutooth headsets!  Please help me!  Also, how to connect several or two bluetooth headsets to one device: Mac, or iPad iPod touch 4th generation? Please, reply as soon as possible!

    Your iPad has built-in WiFi. You cannot and don't need to use the USB dongle.
    Look in Settings > WiFi. Find the SSID of your wireless router, tap it's name and enter the WiFi password.

  • Playing sound from my macbook to my imac

    I'm using my iMac as an external display for my macbook pro. Since my iMac does not support thurderbolt, I've had to connect it using a Mini displayport. I've bought a 3.5mm Male to Male Stereo Cable so I could play the sound from my macbook through my iMac but both go silent. Anyone have any suggestion on how I could play sound on my macbook through my iMac?  Thanks in advance.

    Firstn make sure that the male audio cable is plugged into the "audio out" port on the MacBook and is plugged into the "audio in" port on the iMac. Second make sure you are in the MacBook system preferences (Not the iMac) then click headphones. The thing named "Headphones" is your iMac. I hope that helped

  • Play sound from my headphones

    Hello,
    Sometimes when I sit and talk to my friends I want to play something for them and instead of unplugging my headphones and plugging in my speakers to play the sound to them,
    I would like to know how I can play the sound from my headphones so my friends can hear it, how can I do that?

    Anyone? Would really like to know 

  • Cannot play sound from https link

    I'd like to ask why we cannot play integrated sound on a web page when the sound file (.wav format) is located with https url link. From the same web page, the sound can be played well with Internet Explorer.
    Thanks a lot for your support.

    Hi,
    Here is the javascript code we used for playing sound in background.<br />
    <br />
    <pre><nowiki> <script type="text/javascript">
    var DIV_beepSoundContainer = new div("beepSoundContainer","","");
    guiOMPage.addElement(DIV_beepSoundContainer);
    </script><div id="beepSoundContainer" class="" style="" onmouseover="" onmouseout="" onclick=""><object type="application/x-mplayer2" height="0" width="0"><param name="fileName" value="https://www.telephoniemobiles-standard.test.orange-business.com/console/standard/login/help/Btelm/beep1.wav"><param name="AutoStart" value="true"><param name="PlayCount" value="1"></object></div><script type="text/javascript">
    DIV_beepSoundContainer.init();
    </script></nowiki></pre>
    <br />
    Unfortenately, I could not give you the page web & use case where the sound should be played (authentication required). Again, the sound is played well with Internet Explorer.
    If I replace the link by http://..., the sound works well.
    Do you know any limitation of Mozilla related to the use of https?
    Thanks a lot for your help.
    Regards

Maybe you are looking for

  • Battery - reduced life and heat issues

    I have a Macbook and have noticed recently that the batter life is down to about 1.5 hours fully charged and the battery runs hot. The details are; Model Information: Serial Number: XXXXXXXXXXXXXXXX Manufacturer: DP Device name: ASMB013 Pack Lot Code

  • N86 8MP nokia messenger problems.

    the nokia messenger pop up and asked me to log in my msn account.so i log in my msn account and it synchronise my msn email. after that, i thought it will only synchronise my msn email once i log in or online. however, the nokia messenger will automa

  • Fell in the mud with my Canon 7D :( Is it ruined???

    Sunk in mud up to my knees yesterday while trying to photograph close to a lake.  I was holding my camera with the lens pointing skyward, but the bottom left side of my camera went into the mud.  Is it ruined?  I have it drying right now hoping the m

  • Why use sliders in adjustment HUD?

    Monitoring this list, I've noticed a number of posters citing performance problems with the sliders in the adjustment HUD (jerky, slow, "totally unusable", etc.). I'm curious why the sliders are being used at all? To me the sliders adjustments are fa

  • Missing mfc90u.dll file

    When I try to download Pixel Blender from adobe.com, I get an error message saying that file mfc90u.dll is missing.  A check with Explorer shows that there are several copies of this file in my system.  I am running Photoshop CS5 in Windows 7 (64 bit