LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-25-2008, 04:24 PM   #1
JosephS
Member
 
Registered: Jun 2007
Distribution: Debian Jessie, Bunsenlabs
Posts: 586

Rep: Reputation: 38
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?
 
Old 10-25-2008, 05:12 PM   #2
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,126
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
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
 
Old 10-26-2008, 10:30 AM   #3
JosephS
Member
 
Registered: Jun 2007
Distribution: Debian Jessie, Bunsenlabs
Posts: 586

Original Poster
Rep: Reputation: 38
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?
 
Old 10-26-2008, 01:11 PM   #4
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 404Reputation: 404Reputation: 404Reputation: 404Reputation: 404
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
 
Old 10-26-2008, 01:45 PM   #5
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 404Reputation: 404Reputation: 404Reputation: 404Reputation: 404
Quote:
Originally Posted by JosephS View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration