Compressing and uncompresing chunks of audio data

Hello,
I am doing a project in Java, it has a server and a client, the aim of server is to read an audio file (a .WAV file, actually ) chunk by chunk and compress is it to certain quality (using both lossy and lossless techniques) as specified by the client and transmit it, the client will decompress it and play it out. I am using two ports for it, one for control signals, another for the actual audio data transmission. So far I, my application initiates the GUI, looks up servers, connects to it after finding one using the two ports, gets audio files' list and plays the clip.
playing is done by reading the wav file using FileIputStream, 128*1024 bytes at a time, writing it to socket outputstream. On client side this stream is used to create the audio format object and play the clip. Obviously, this is not the way it is to be done, correct? what's the best way of encoding that 128*1024 byte chunk so that it can be re created on client?
The code that I've got together looks something like this:
STREAMER:
dataOut = dataSocket.getOutoutStream();
fis = new FileInputStream( new File(fileName));
byte[] b = new byte[1024];
try{
while (fis.available()!=0) {
     fis.read(b);
     dataOut.write(b);
catch( .. ) {  }CLIENT:
dataIn = dataSocket.getInputStream();
try {
    while (dataIn.available()!=0) {
     play(din);
catch ( ..) { }
void play(InputStream is){
..  // here AudioInputStream object is created using getAudioInputStream(is)
..  //an AudioFoamat object is created using audioInputStream.getFormat();
//then a default audioFormat is created , changing the encoding to PCM_SIGNED and bit-dept to 16
//then using this default format, we play the audio:
//we construct an AudioInputStream using this default format. then play using this audioInputStream.
    DataLine.Info dataLineInfo = new DataLine.Info(SourceDataLine.class, audioFormat);
    SourceDataLine line = (SourceDataLine) AudioSystem.getLine(dataLineInfo);
    line.open(audioFormat);
    line.start();
byte[] abData = new byte[128*1024];
  int nBytesRead = 0
  while (nBytesRead != -1) {
     try {
      nBytesRead = audioInputStream.read(abData, 0, abData.length);
      } catch( .. ) {  }
     if (nBytesRead >= 0) {
       line.write(abData, 0, nBytesRead);
  }

thanks captfoss, yes the thing i am developing looks like RTP, i'll go through them.
now i am looking for some java codes that will convert raw audio bytes to mp3 encoded byte stream, the only things around are things from LAME project, being written entirely in C, this is not a very attractive alternative.. i would rather have clean and simple Java libraries that will encode chunks of raw audio to compressed byte streams, please help me find some such libraries,
thanks in advance,
diemond

Similar Messages

  • Using CAN bus to transport and play the stream audio data

    hello,
    Just want to build a PC-Based control network using CAN bus (Ethernet not considered).The system is separated two parts , one is the front unit(FU), and the other is the centeral unit(CU). FU performs dialing-up number to the CU , and play the stream audio media data come from CU, CU monitor the telephone call activated from FU's user , send rm or mp3 data to the FU . I'd like to know if CAN bus could realize this function? if it can , which hardware must be supplied ? Is there any suggestion that not use PBX to realize the voice (telphone) communication ? Please give an solution , your advise is greatly appreciated . Thanks.
    David

    Hi David,
    the CAN protocol essentially just gives you the ability to transfer (broadcast) up to eight data bytes across the network at a maximum data rate of 1 Mbit/s.
    There are so-called higher level (or layer) protocols that further specify the data exchange between a data producer can the consumer (DeviceNet, CANopen, etc.).
    If your application is not tied to any of those protocols, that means you have the freedom to design all (CAN) nodes of your network, you can implement your own protocol based on the eight data bytes and the arbitration ID CAN offers.
    For more information on the CAN protocol, take a look at appendix B of the NI-CAN Hardware and Software Manual, or visit the web site of CAN in Automation (CiA).
    For your particular application you would need a CAN port on both the FU and the CU (preferably high-speed physical layer) and a PCI interface CAN card for you development.
    -B2k

  • Audio capture and converting the audio data to .wav file

    hi,
    i am new to applet and javax.sound and trying to build online recorder SDK in applet. I could captured the audio data and play the sound from microphone and also store the audio data to .wav file successfully. But when try to play that file from Window Media Player, i got the message "Windows Media Player cannot play the file. The file is either corrupt or the Player does not support the format you are trying to play." I have tried it all in different way but it's not working for last 5-6 days. Is there anyone who could help me , my work is stocked b'coz of this.
    Thanks

    this is the thread in which i am storing the audio data from audio stream to .wav file
    class CaptureThread extends Thread{
                          public void run(){
                                      AudioFileFormat.Type fileType = AudioFileFormat.Type.WAVE;
                                      File audioFile = new File("junk.wav");
                                       try{
                                       final AudioFormat format = getFormat();
                                             line.open(format);
                                          line.start();
                                             AudioSystem.write(
                                              new AudioInputStream(line),
                                              fileType,audioFile);
                                        }catch (Exception e){
                                             e.printStackTrace();
                                          }//end catch
                                     }//end run
                        }//end inner class CaptureThread

  • How do I send raw video and audio data to FMLE?

    Hi,
    I have raw video and audio data on CPU memory.
    How do I send them to FMLE?
    Is there sample code or SDK?
    Thanks for your answer.

    Hi, Burzuc.
    Raw video and audio data are from a video capture board like Blackmagic Design's DeckLink or other's.
    I want to stream them after some processing by my application.
    Regards.

  • Compression and query performance in data warehouses

    Hi,
    Using Oracle 11.2.0.3 have a large fact table with bitmap indexes to the asscoiated dimensions.
    Understand bitmap indexes are compressed by default so assume cannot further compress them.
    Is this correct?
    Wish to try compress the large fact table to see if this will reduce the i/o on reads and therfore give performance benefits.
    ETL speed fine just want to increase the report performance.
    Thoughts - anyone seen significant gains in data warehouse report performance with compression.
    Also, current PCTFREE on table 10%.
    As only insert into tabel considering making this 1% to imporve report performance.
    Thoughts?
    Thanks

    First of all:
    Table Compression and Bitmap Indexes
    To use table compression on partitioned tables with bitmap indexes, you must do the following before you introduce the compression attribute for the first time:
    Mark bitmap indexes unusable.
    Set the compression attribute.
    Rebuild the indexes.
    The first time you make a compressed partition part of an existing, fully uncompressed partitioned table, you must either drop all existing bitmap indexes or mark them UNUSABLE before adding a compressed partition. This must be done irrespective of whether any partition contains any data. It is also independent of the operation that causes one or more compressed partitions to become part of the table. This does not apply to a partitioned table having B-tree indexes only.
    This rebuilding of the bitmap index structures is necessary to accommodate the potentially higher number of rows stored for each data block with table compression enabled. Enabling table compression must be done only for the first time. All subsequent operations, whether they affect compressed or uncompressed partitions, or change the compression attribute, behave identically for uncompressed, partially compressed, or fully compressed partitioned tables.
    To avoid the recreation of any bitmap index structure, Oracle recommends creating every partitioned table with at least one compressed partition whenever you plan to partially or fully compress the partitioned table in the future. This compressed partition can stay empty or even can be dropped after the partition table creation.
    Having a partitioned table with compressed partitions can lead to slightly larger bitmap index structures for the uncompressed partitions. The bitmap index structures for the compressed partitions, however, are usually smaller than the appropriate bitmap index structure before table compression. This highly depends on the achieved compression rates.

  • Compress and uncompress data size

    Hi,
    I have checked total used size from dba_segments, but I need to check compress and uncompress data size separately.
    DB is 10.2.0.4.

    I have checked total used size from dba_segments, but I need to check compress and uncompress data size separately.
    DB is 10.2.0.4.
    Unless you have actually performed any BULK inserts of data then NONE of your data is compressed.
    You haven't posted ANYTHING that suggests that ANY of your data might be compressed. For 10G compression will only be performed on NEW data and ONLY when that data is inserted using BULK INSERTS. See this white paper:
    http://www.oracle.com/technetwork/database/options/partitioning/twp-data-compression-10gr2-0505-128172.pdf
    However, data, which is modified without using bulk insertion or bulk loading techniques will not be compressed
    1. Who compressed the data?
    2. How was it compressed?
    3. Have you actually performed any BULK INSERTS of data?
    SB already gave you the answer - if data is currently 'uncompressed' it will NOT have a 'compressed size'. And if data is currently 'compressed' it will NOT have an 'uncompressed size'.
    Now our management wants that how much compressed data size is and how much uncompressed data size is?
    1. Did that 'management' approve the use of compression?
    2. Did 'management' review the tests that were performed BEFORE compression was done? Those tests would have reported the expected compression and any expected DML performance changes that compression might cause.
    The time for testing the possible benefits of compression are BEFORE you actually implement it. Shame on management if they did not do that testing already.

  • How to find data compression and speed

    1. whats the command/way for viewing how much space the data has taken on its HANA tables as oposed to the same data in disk . I mean how do people measure that there has been a  10:1 data compression.
    2. The time taken for execution, as per seen from executing a same SQL on HANA varies ( i see that when i am F8 ing the same query repeatedly) , so its not given in terms of pure cpu cycles , which would have been more absolute .
    I always thought  that there must a better way of checking the speed of execution  like checking the log which gives all data regarding executions , than just seeing the output window query executions.

    Rajarshi Muhuri wrote:
    1. whats the command/way for viewing how much space the data has taken on its HANA tables as oposed to the same data in disk . I mean how do people measure that there has been a  10:1 data compression.
    The data is stored the same way in memory as it is on disk. In fact, scans, joins etc. are performed on compressed data.
    To calculate the compression factor, we check the required storage after compression and compare it to what would be required to save the same amount of data uncompressed (you know, length of data x number of occurance for each distinct value of a column).
    One thing to note here is: compression factors must always be seen for one column at a time. There is no such measure like "table compression factor".
    > 2. The time taken for execution, as per seen from executing a same SQL on HANA varies ( i see that when i am F8 ing the same query repeatedly) , so its not given in terms of pure cpu cycles , which would have been more absolute .
    >
    > I always thought  that there must a better way of checking the speed of execution  like checking the log which gives all data regarding executions , than just seeing the output window query executions.
    Well, CPU cycles wouldn't be an absolute measure as well.
    Think about the time that is not  spend on the CPU.
    Wait time for locks for example.
    Or time lost because other processes used the CPU.
    In reality you're ususally not interested so much in the perfect execution on one query that has all resources of the system bound to it, but instead you strive to get the best performance when the system has it's typical workload.
    In the end, the actual response time is what means money to business processes.
    So that's what we're looking at.
    And there are some tools available for that. The performance trace for example.
    And yes, query runtimes will always differ and never be totally stable all the time.
    That is why performance benchmarks take averages for multiple runs.
    regards,
    Lars

  • When watching baseball highlights the video is slower than audio. I checked all my plug ins and they are up to date. suggestions?

    I have been having problems when watching video clips from news but mainly when I check the video highlights on mlb.com. The video is slower than the audio. It freezes up at times or drags.I have checked all my plug ins on firefox and they are up to date. I checked my PC for errors and cleaned it. But still having problems.

    You can check for problems with current Flash plugin versions and try these:
    *disable a possible RealPlayer Browser Record Plugin extension for Firefox and update the RealPlayer if installed
    *disable protected mode in the Flash plugin (Flash 11.3+ on Windows Vista and later)
    *disable hardware acceleration in the Flash plugin
    *http://kb.mozillazine.org/Flash#Troubleshooting

  • HT201272 I gifted an audio book to someone and they lost all their data, how can I re-send the gift or have them download the already purchased audiobook?

    I gifted an audio book to someone and they lost all their data, how can I re-send the gift or have them download the already purchased audiobook?

    You get one and only one download of audiobooks.  As always it is your responsibility to back up your content.

  • How to mix audio data from multiple streams without increasing in size?

    For example, two clients use JMF to capture audio in linear format (content type is raw)and both send the captured data to a third client where it performs mixing to generate one data stream. Suppose each source data size is S, the mixed stream (using JMF "merge") size is S+S which is not what I want. Is there any function to generte mixed stream with size S? I don't need to the capability to reverse mixed stream back to two individual source streams.
    Thanks.

    S+S, ahh an academic.
    This is actually a forest-trees issue here.
    What your doing is appending the files, which would result in a size of 2S. What you want is somthing of size S. To do this you would need a Normilized merge. I say normalized merge because thats going to give you the best result while still avoiding out of range values.
    This is easy enough to by hand if both streams S1 and S2 are of the same frequency. If they are not the same frequency, the result will be size of the larger file when convereted to whatever uniformfrequency.

  • Accidently disconnected ipod without ejecting, now it only shows recent purchases. I can see 40 gig of original library but its listed as other not audio. Is this retrievable audio data or is it lost. I have no backup what can I do to restore my ipod?

    I accidently disconected my ipod from my pc. When I plugged it back up  I only had limited access to my library. I had over 40gb of audio data that now when I go to the summary page of my pod it shows up as other, only the audio that I have recently purchased from itunes is accessible. Is the 40gb retrievable and can some one please tell me step by step what I need to do. My collection took over a year to put together and there is no backup file.

    "Other" is the measure of used space on the iPod not taken up by Audio, Video & Photos. This includes the iPod's library and artwork plus any files you may have copied to your iPod in disk mode. The overhead for the library & artwork data is typically 1-2% of the size of the media, e.g. for 1Gb of Audio & Video expect to have around 15mb of "Other". This information is needed for the iPod's operation and cannot be removed.
    If you have significantly larger amounts of "Other", not related to files you've intentionally placed on the iPod, then these are probably disconnected copies of your media files or iPod libraries left over from failed sync operations. The only way to recover the space is to do a full restore.
    If you have copies of all your media in your iTunes library this isn't a problem, but if you've been manually managing the content then you might need to try to recover the files from it first. See this post by forum regular Zevoneer on transferring files from the iPod to your computer. Some of the tools rely on the iPod having a healthy library however the manual method mentioned towards the end of the post should work regardless.
    tt2

  • "some audio data is no longer available"

    How can I resolve this file problem?
    I spent a couple of hours recording a narration as a STAP file that was about 30 minutes long. After the recording (the second action after "Empty File") I added several actions to delete unwanted portions (errors, repeats, etc.). To finalize the project I added a couple of actions (noise gate and limiter).
    Everuthing appeared and played normally... but when I opened the file this morning I noticed that there was no audio in the project... scrolling up revealed that the "Recording" was unchecked... I checked it and got the following error message:
    The action "Recording" has been disabled because some audio data is no longer available. You can replace this action with a similar action.<</div>
    Replace? Does that mean repeating the work entirely?
    Well, the file appears to be 591.8 MB in size... so it should have the audio in it.
    Is there a way to recover the original audio from this file?
    BTW, I should have exported it before closing it up... Unfortunately, not trusting your software is what I used to do with my PCs...
    :o(

    Never found the cause and did not check the package... so I decided to close the question. The event has not repeated itself as I have upgraded several times since.

  • Problem with playing audio data using Real Player

    i've seen the intruction for playing video data (.rm) using real player and it works. Then i tried to play audio data (.wav, .dat, .mp3) with real player, but it didn't work.
    These are some codes i've wrote:
    ------------------------------------------- BEGIN PL/SQL CODES---------------------------------------
    CREATE TABLE SONGS
    ( Item_ID number not null PRIMARY KEY,     
    Audio ordsys.ordaudio
    create or replace procedure load_audio(id integer, filename in varchar2) as
    obj ORDSYS.ORDAudio;
    ctx RAW(4000) := NULL;
    begin
    INSERT INTO SONGS VALUES(ID,
         ORDSYS.ORDAudio.init());
    SELECT audio into obj from Songs
    where item_id = id FOR UPDATE;
    obj.setSource('FILE','AUDIODIR', filename);     
    Obj.setDescription('A movie trailer');
    Obj.setMimeType('audio/x-pn-realaudio');
    Obj.setFormat('Real Media File Format');
    obj.import(ctx);
    UPDATE Songs
         SET audio=obj WHERE item_id=id;
    COMMIT;
    END;
    show errors;
    truncate table songs;
    exec load_audio(1,'aud1.wav');
    exec load_audio(2,'aud2.mp3');
    exec load_audio(3,'testaud.dat');
    -- just for comparison, i put a video file (.rm)
    exec load_audio(4,'autorace.rm');
    commit;
    show errors;
    create or replace procedure get_audio(
         audio_id in varchar2,
         mimetype out varchar2,
         data out blob) as
         tempBLOB BLOB;
         s varchar2(200);
    begin
    -- Deliver audio and mimetype
    select t.audio.getcontent(), t.audio.getmimetype()
    into tempBLOB, s
    from songs t where t.item_id = audio_id;
    data := tempBLOB;
    mimetype := s;
    end;
    show errors;
    ---------------------------------------- END of PL/SQL CODES-------------------------------------
    -----------------------------------MOUNTPOINT at FILESYSTEM rmsever.cfg-------------------
    <List Name="pn-oracle-audio">
    <Var Database="oracle"/>
    <Var HeaderCacheSize="2048"/>
    <Var LobFetchSize="32768"/>
    <Var MaxCachedConnections="1"/>
    <Var MountPoint="/dbaudio/"/>
    <Var Password="ZGF2aWQ="/>
    <Var ShortName="pn-oracle"/>
    <Var SQL="get_audio"/>
    <Var Username="skripsi"/>
    </List>
    ----------------------------------------End Of MOUNTPOINT----------------------------------
    then in the real player, i tried some urls :
    http://david:88/ramgen/dbaudio/1 --> it didn't work, it was said invalid path
    http://david:88/ramgen/dbaudio/2 ----> it didn't work, it was said invalid path
    http://david:88/ramgen/dbaudio/3 ----> it didn't work, it was said invalid path
    http://david:88/ramgen/dbaudio/4 ----> it worked
    did i put a wrong url?
    does the http://..../ramgen/... path is just for ram file?
    can anyone show me the way to play audio data using real player?
    Thanx before.

    Yes, realserver expects an exact mimetype.
    to make matters worse, it expects audio/x-pn-realaudio (an audio mimetype) for video!?!?!
    Seems the code inside maps multiple file extensions to some mime type. Only one is allowed.
    I have used the unix strings commands in teh plugins directory to find the exact mime type realserver is expecting. The file format plugins have this information in them.
    Larry

  • Video (or Video + Audio) Data Rate

    Wondered if anyone here might know of a software utility that has the ability to scan QuickTime compatible files and either display the video (or video + audio) data rate excursion or, as an alternative, graph the instantaneous variation in the data rate over time.

    Apple +I (show info) in QT player will show you the framerate and bitrate while playing.
    Thanks for your suggestion, Rick. However, I must point out that the data rate so displayed is simply the total average for the entire clip and not the instantaneous (i.e., constantly changing) variance with time. Preliminary observations tend to indicate the single pass H.264 algorithm begings roughly 10% under the requested data rate and quickly settles very near the target. The multipass algorithm, on the other hand, appears to begin in the vicinity of 300% above the targeed data rate and monotonically decreases throughout the remainder of the movie clip. So much for a quick qualitative analysis based on observations during the actualy encoding process.
    What I now wish to do is actually perform a bit of quantitative analysis and, based on those results, correlate actual data rates with the ability of a given H.264 multipass file to sync to an iPod. Basically, I am trying to determine whether or not a user data rate input is used as a comparator during the initial phase of multipass H.264 coding and, if so, how it is implemented. (I.e., how are the delta values handled -- linearly, exponentially, etc.) In addition, I wish to compare QT v7.0.3 with v7.0.4 clips to determine why the latter are less iPod compatible. Too, there remains a question as to whether or not any data rate information is now embedded in the clips themselves since various work arounds tried (i.e., clipping file lengths) have proven unsuccessful.

  • HT1750 My computer has no audio. It had been working and last week the audio stopped working.

    I have an Intel-based iMac and there is no audio. software: OS x 10.9.2
    I have no audio.

    There are many possible causes for this issue. Take each of the following steps that you haven't already tried.
    1. Start with the steps recommended in this support article. Don't skip any of the steps. It's the starting point for further efforts to solve the problem.
    2. Run Software Update and make sure you have a fully up-to-date installation of OS X.
    3. If you've installed an application called "Memory Clean" or any other third-party software that is supposed to "clean" or "purge" memory automatically, remove it according to the developer's instructions and restart. You should do that even if the software is not causing the problem, because it's useless.
    4. If you've installed a software equalizer called "Boom" or anything similar, update or delete it and restart.
    5. If an AirPlay device is selected for sound output from iTunes (or from other applications via third-party software such as "Airfoil"), deselect it.
    6. Launch the application "Audio MIDI Setup" by entering the first few letters of its name in a Spotlight search and selecting it in the results (it should be at the top.) Select the Output tab. If the Mute boxes are checked, uncheck them. Move the Volume sliders all the way to the right.
    7. If a red light is coming from the audio-out port, the internal switch is stuck in the position for digital output. You may be able to free it by inserting and removing a mini-stereo jack of the proper size. Inserting any kind of tool in the port may cause damage that won't be covered by your warranty.
    If there's no red light, the switch may still be stuck in the headphone position. Try to free it the same way.
    8. Disconnect all wired peripherals except keyboard and mouse, if applicable. If more than one display is connected, disconnect all extra ones. Restart and test.
    9. If you have a MacBook Air, turn off Bluetooth and restart.
    10. Start up in safe mode. Don't log in; just restart as usual when the login screen appears. When you do, make sure the words "Safe Boot" do not appear in the login screen. If they do, the system is still in safe mode and sound won't work.
    11. Reset the NVRAM.
    12. Reset the SMC.
    13. Reinstall OS X after backing up all data.
    14. Make a "Genius" appointment at an Apple Store.

Maybe you are looking for