• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to read headers of a audio file?

 
Rithya Lath
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone, I want to read then write all the headers of a AU audio file to another AU file. I understand different audio formats have different headers. I'm specifically dealing with AU files here. Here is the header data for a AU file, http://docs.python.org/2/library/sunau.html. I can retrieve the magic word field by using FileInputStream. Here is what I have so far.



I know there are libraries that already handle this but I need to do this without those libraries. Help is appreciated!
 
Tony Docherty
Bartender
Posts: 2971
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you know how the bytes are encoded, ie big endian or little endian, are the bytes signed etc.
Can you show an example of the bytes you need to convert to an int and the actual int value they represent.
 
Rithya Lath
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They are all 32-bit unsigned integers encoded in big-endian byte order.

Changing the System.out.print to System.out.println in the original code above would print



I'm trying to print


Here is a reference to results i'm trying to print out to the console, http://en.wikipedia.org/wiki/Au_file_format
 
Tony Docherty
Bartender
Posts: 2971
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry but I can't see how you can get those numbers from the bytes shown.
Also you seem to be missing a byte or as you have 4 bytes for the magic word and then 27 bytes which isn't divisible by 4.
 
Rithya Lath
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I must of made typos. This is what I get.



I did figure to out using this as a reference, http://stackoverflow.com/questions/4492711/java-convert-byte-to-integer

What I did was loop through the byteBuffer array by increments of four then used this in the loop



This prints out



I appreciate your help!
 
Tony Docherty
Bartender
Posts: 2971
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's some code I knocked up to do the conversion from a byte array and print out the parts:

The output is:
 
Rithya Lath
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!!
 
Tony Docherty
Bartender
Posts: 2971
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My pleasure
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic