Results 1 to 5 of 5
  1. #1
    kylefrank is offline Member
    Join Date
    Jun 2010
    Posts
    3
    Rep Power
    0

    Default Converting mp3 files to binary

    Hi there,

    Is there a way that i can convert an mp3 file into binary code, and then later reconvert it to mp3.
    If this isn't possible can it be done with other audio formats?
    I've been using AudioInputStream readers and then converting them to byte arrays, this however stores chars in the array and ultimately the target file where i want binary (1001101).
    Any ideas?

  2. #2
    mrmatt1111's Avatar
    mrmatt1111 is offline Senior Member
    Join Date
    Aug 2009
    Location
    San Jose, CA, USA
    Posts
    320
    Rep Power
    5

    Default

    An .mp3 file is technically already in a binary format.

    So you want a file that has a binary representation (e.q. 1011100...)?

    Simply convert each byte to the string representation of binary then store that string to a file.
    My Hobby Project: LegacyClone

  3. #3
    kylefrank is offline Member
    Join Date
    Jun 2010
    Posts
    3
    Rep Power
    0

    Default

    ok i tried that, converted the byte array to a string, but it still displays it as characters, some i haven't even seen before...
    my theory is this, either the AudioStreamInput stores said data in a form so that its compatible with java ie converting it from raw binary...or the music file im using is actually the communication tool of 7th dimension aliens, the former being more probable.
    So how would i be able to read the data of an mp3 then store it to a byte array to display it as binary?

  4. #4
    mrmatt1111's Avatar
    mrmatt1111 is offline Senior Member
    Join Date
    Aug 2009
    Location
    San Jose, CA, USA
    Posts
    320
    Rep Power
    5

    Default

    Java Code:
    public static void showByte(byte b)
    {
       System.out.print("[");
       for( int j = 0; j < 8; j++)
       {
          System.out.print( (b&(1<<(7-j)))>0?1:0 );
       }
       System.out.print("]");
    }
    or

    Java Code:
    System.out.print("["+(b&0xf)+(b&0x0f)+(b&0x00f)+(b&0x000f)+(b&0x0000f)+(b&0x00000f)+(b&0x000000f)+(b&0x0000000f)+"] ");
    My Hobby Project: LegacyClone

  5. #5
    kylefrank is offline Member
    Join Date
    Jun 2010
    Posts
    3
    Rep Power
    0

    Default

    ok now im leaning towards the aliens...
    haha
    thanks a mil dude

Similar Threads

  1. Replies: 3
    Last Post: 07-25-2009, 01:44 PM
  2. converting image to binary code n vice versa
    By nupurashi in forum Advanced Java
    Replies: 4
    Last Post: 04-01-2009, 07:27 PM
  3. Converting a text file int binary
    By sruthi_2009 in forum New To Java
    Replies: 0
    Last Post: 03-23-2009, 03:09 PM
  4. Converting asp files to jsp
    By vrk in forum Advanced Java
    Replies: 5
    Last Post: 02-11-2009, 09:44 AM
  5. Behaving text files like binary files
    By Farzaneh in forum New To Java
    Replies: 2
    Last Post: 08-27-2008, 03:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •