LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Using Lmae with -x (https://www.linuxquestions.org/questions/linux-software-2/using-lmae-with-x-679031/)

JosephS 10-25-2008 05:24 PM

Using Lmae with -x
 
I have read the info on man lame about the -x option, but am not
understanding this. Would appreciate help.

Quote:

-x Swap bytes in the input file or output file when using --decode.
For sorting out little endian/big endian type problems. If your encodings sounds like static, try this first.
Without using -x, LAME will treat input file as native
endian.

What does swap bytes mean?
Can I use other options with -x?

Do I only use -x for decoding?
eg. arecord -f cd -t raw | lame -x - out.mp3
I found this example; isn't this for encoding to a mp3?

estabroo 10-25-2008 06:12 PM

You should only need to use -x if you the original file was encoded/recorded on a machine of different endianess and was recorded in native type. This handles swapping between little endian and big endian. Little and Big refer to the byte ordering.

For example the four bytes of an int:

4321 big endian
1234 little endian

JosephS 10-26-2008 11:30 AM

would this be wrong?
arecord -f cd -t raw | lame -x - out.mp3

I found this in man lame:
--decode
Uses LAME for decoding to a wav file. The input file can be any input type
supported by encoding, including layer II files. LAME uses a bugfixed version
of mpglib for decoding.

I'm assuming --decode would have to be in the command line and this is encoding to a
mp3, not decoding to a wave.


Does it matter what I record the wave file as (little,big,or native endian). Will this
make a difference on the mp3?

i92guboj 10-26-2008 02:11 PM

As said on the man page, you only need to use that if you only hear noise when opening the file. If it works ok there's absolutely no need to "fix" it.

Digital sound is stored in a simple way. A given value is recorded as a number, usually stored as a 16 bits number, though there are formats that use an higher resolution. That gives you 65,536 possible values. That is done a given number of times per seccond, the more samples that you take, the better the quality will be. Audio cds are sampled using 16 bits integers and 44,100 samples per second (44.1 khz).

16 bits are two bytes, so, each sample takes 2 bytes. The endianess defines how these two bytes are ordered.

For example, if we want to write the number 5030 (13a6 in hexadecimal) we would write it this way on a litle endian format:

Code:

13 A6
But on a big endian system, the most significant cyphers are written the last, so, if you wanted to write 5030 on hexadecimal numbers using a big-endian format it would be:

Code:

A6 13
Audiocds are encoded as litle endian, which means that the last cypher is the less relevant one (the same way that humans write numbers). The endianness depends on the audio format you use, and as long as your player (it doesn't matter if it's a software or a hardware one) supports it, and the header of the audio files is ok, then you should not need to worry about it.

http://wiki.multimedia.cx/index.php?..._Book_CD_Audio

i92guboj 10-26-2008 02:45 PM

Quote:

Originally Posted by JosephS (Post 3322343)
would this be wrong?
arecord -f cd -t raw | lame -x - out.mp3

I don't know how arecord formats its output. If it produces raw pcm data, then you will need to specify the endiannes, or swap it if you can only hear noise.

Quote:

I'm assuming --decode would have to be in the command line and this is encoding to a
mp3, not decoding to a wave.
I don't understand your question. --decode menas exactly what it says: it decodes any file supported my mpeglib and outputs a plain wave file.

Quote:

Does it matter what I record the wave file as (little,big,or native endian). Will this
make a difference on the mp3?
That depends on what do you mean: it it's raw pcm what arecord outputs (I don't know) then lame might not be able to identify the endianness correctly (since there will be no header with that info). That means that you might end up with noise.

If you meant "about the mp3 file endianness", I think that there will be no difference. Mp3 files use a mpeg 1 layer 3 algorythm, and that format is well defined. I don't know much about the mp3 internals, but whatever ethe format is, it is the same on any platform, otherwise it wouldn't be mp3, but something else, I guess.


All times are GMT -5. The time now is 09:29 AM.