Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Burning Audio CDs - Another Way
View unanswered posts
View posts from last 24 hours

Goto page 1, 2  Next  
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
wolvenwraith
n00b
n00b


Joined: 28 Dec 2003
Posts: 67
Location: Someplace, Somewhere

PostPosted: Mon Dec 29, 2003 5:45 am    Post subject: Burning Audio CDs - Another Way Reply with quote

I found that I needed to burn albums of mp3's many times, and I hated all the GUIs out there that do it (poor ATAPI support, bad layout, etc. etc.). I am also a big fan of the powerful Linux CLI. So I hacked something up in order to solve these problems. All you need to do is put all your mp3's into one directory and run this script (I called it mp3burn and copied it into /usr/bin so I can run it anytime, it's nice to have).

Code:

#!/bin/bash
 
for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr ' ' '_'`; done
for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done
for i in *.mp3; do lame --decode $i `basename $i .mp3`.wav; done
normalize *.wav
cdrecord dev=ATAPI:0,0,0 speed=44 -pad -audio -v -gracetime=2 *.wav
rm *.wav


Note that the cdrecord line may need to be modified in order to accomadate your burner (notably the dev=, and speed= lines) and gracetime can be modified as you see it as well.

Don't forget to run chmod a+x on the file so that it is executable!

Notes: Just improved it a little bit, it now normalizes (emerge normalize) the .wav files and removes them after they're burnt. Also fixed the [Mm][Pp] thing in the first line. This little script should be pretty easy to alter if it doesn't fit you perfectly. Keep in mind too, this will change the names of you mp3's if they have spaces or caps in them.


Last edited by wolvenwraith on Mon Dec 29, 2003 8:40 pm; edited 1 time in total
Back to top
View user's profile Send private message
pem725
n00b
n00b


Joined: 26 Sep 2002
Posts: 68
Location: Tucson, AZ USA

PostPosted: Mon Dec 29, 2003 8:55 am    Post subject: Reply with quote

What do you do with the wav files after burning?

Also, you might find burncenter allows you a similar setup with a few more features. Nice work though.

Like you, I am a fan of the CLI and use abcde and burncenter as console apps - along with the usual straightforward calls to cdrecord.
_________________
Cheers,
Patrick

Do the community a favor and answer a few stranded messages. I'm off to answer one now...thanks to gentoo!
Back to top
View user's profile Send private message
d99ma
Tux's lil' helper
Tux's lil' helper


Joined: 21 Jul 2003
Posts: 148
Location: Lund, Sweden

PostPosted: Mon Dec 29, 2003 10:42 am    Post subject: Reply with quote

Perhaps you should check for [mM][pP] when removing spaces, normalize the wav files and remove them after burning. Then it would be perfect!

/Martin
Back to top
View user's profile Send private message
wolvenwraith
n00b
n00b


Joined: 28 Dec 2003
Posts: 67
Location: Someplace, Somewhere

PostPosted: Mon Dec 29, 2003 8:48 pm    Post subject: Reply with quote

Thanks for the feedback. I checked out burncenter and it seems pretty cool. However, it doesn't seem to support ATAPI burning out of the box (I didn't play with it much so I could be wrong). The other thing is I sorta like the one-liner style of this script, but that's just me :). All in all though burncenter seemed pretty nice.

Thanks to both of you for the suggestions, I made all the necessary changes to the script.
Back to top
View user's profile Send private message
Elm0
Apprentice
Apprentice


Joined: 24 Nov 2002
Posts: 281
Location: UK

PostPosted: Mon Dec 29, 2003 10:50 pm    Post subject: Reply with quote

Nice script, obviously going to be quicker than a GUI if you do this a lot, however well designed the GUI is. The beauty of linux I suppose, why be forced into one way when you can choose your path!
Back to top
View user's profile Send private message
Munck
n00b
n00b


Joined: 06 Feb 2003
Posts: 35
Location: Skive, Denmark

PostPosted: Tue Dec 30, 2003 12:56 pm    Post subject: Reply with quote

Thanks for the script. I've been looking for some easy way to do this, but I've been too lazy to write a script myself :)
_________________
Why?
- because I can !
Back to top
View user's profile Send private message
pengo
n00b
n00b


Joined: 22 Aug 2003
Posts: 53

PostPosted: Sat Jan 03, 2004 9:00 pm    Post subject: Reply with quote

Hello there! I'm new at this and have a fresh install of Gentoo. What would I need to emerge for this script to work?

Thanks for the contribution!
Back to top
View user's profile Send private message
MrNugget
Tux's lil' helper
Tux's lil' helper


Joined: 15 Nov 2003
Posts: 144
Location: Germany

PostPosted: Sat Jan 03, 2004 9:13 pm    Post subject: Reply with quote

Just "emerge cdrtools" and you'll be able to use cdrecord.
Back to top
View user's profile Send private message
dr_strange
Guru
Guru


Joined: 16 Apr 2002
Posts: 480
Location: Cambridge, UK

PostPosted: Sat Jan 03, 2004 9:13 pm    Post subject: Reply with quote

emerge cdrtools lame
Back to top
View user's profile Send private message
BakaO
n00b
n00b


Joined: 27 Sep 2003
Posts: 74

PostPosted: Wed Jan 14, 2004 9:10 pm    Post subject: Reply with quote

Hello,

your script is veyr cool, but I have 2 questions :

1-Is the 'normalize' really neccesary ? (I think if the dB levels are not the same, it is normal, no ?)

2-How can we add cd-text support ? I think it is related with the .inf files but how can we auto-generate them (form id-tag) or other method.


Thanks for all !
Back to top
View user's profile Send private message
TechSmurf
n00b
n00b


Joined: 25 Aug 2003
Posts: 29
Location: ON, Canada

PostPosted: Thu Feb 19, 2004 1:16 pm    Post subject: Thanks Reply with quote

I would just like to say, Thanks. :)
This little file saved me alot of time and work.
Keep up the good work. :D

(it worked 'right out of the box' )
Back to top
View user's profile Send private message
TheEternalVortex
Apprentice
Apprentice


Joined: 15 Oct 2002
Posts: 207
Location: San Jose, CA

PostPosted: Thu Feb 19, 2004 8:53 pm    Post subject: Reply with quote

What's the point of renaming all the files?
_________________
-- Andy
Back to top
View user's profile Send private message
metalh34d
Tux's lil' helper
Tux's lil' helper


Joined: 04 Feb 2004
Posts: 126

PostPosted: Tue Apr 27, 2004 5:29 pm    Post subject: Reply with quote

doesn't converting mp3 into a wav cause lower quality sound, or is this just the way all mp3 burning is done?
Back to top
View user's profile Send private message
icefox13
Tux's lil' helper
Tux's lil' helper


Joined: 19 Apr 2004
Posts: 78
Location: Munich, Germany

PostPosted: Tue Apr 27, 2004 5:47 pm    Post subject: Reply with quote

metalh34d wrote:
doesn't converting mp3 into a wav cause lower quality sound, or is this just the way all mp3 burning is done?


Every compressed audio file (mp3, ogg) has to be converted to wav if you make an audio-cd (not mp3-cd), because wav is the format the tracks are stored on the disc.
(But you sometimes can't see this when burning an audio-cd because the mp3s are decoded and recorded nearly simultaneously.)
Back to top
View user's profile Send private message
metalh34d
Tux's lil' helper
Tux's lil' helper


Joined: 04 Feb 2004
Posts: 126

PostPosted: Tue Apr 27, 2004 9:52 pm    Post subject: Reply with quote

I tried using the script and it didn't work very well. It only burned 2 tracks in the folder I had set to burn to cd. Also it took a very long time and it will only play in my car. Then again I'm having problems with burned cds playing on my cdroms anyway. Any help? Please?
Back to top
View user's profile Send private message
MighMoS
Guru
Guru


Joined: 24 Apr 2003
Posts: 416
Location: @ ~

PostPosted: Thu May 06, 2004 2:43 am    Post subject: Reply with quote

Could it be added to rename the files back to their originals? Or at least how would I create a script that would remove the underscores? (I have very little programming experience)
_________________
jabber: MighMoS@jabber.org

localhost # export HOME=`which heart`
Back to top
View user's profile Send private message
diegs
Tux's lil' helper
Tux's lil' helper


Joined: 06 Aug 2003
Posts: 79
Location: nyc

PostPosted: Sat May 22, 2004 4:42 am    Post subject: Reply with quote

No renaming:
Code:
  GNU nano 1.3.2           File: /home/diegs/music/burn.sh
                                                                               
#!/bin/bash
                                                                               
for i in *.[Mm][Pp]3; do lame --decode "$i" "`basename "$i" .mp3`.wav"; done
normalize *.wav
cdrecord dev=ATAPI:0,0,0 speed=24 -pad -audio -v -gracetime=0 *.wav
rm *.wav

_________________
knowledge = fv
Back to top
View user's profile Send private message
Spack
n00b
n00b


Joined: 02 Feb 2003
Posts: 32

PostPosted: Sat May 29, 2004 10:45 pm    Post subject: Reply with quote

This will handle ogg vorbis files aswell:

Code:
#!/bin/bash

for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr ' ' '_'`; done
for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done
for i in *.[Oo][Gg][Gg]; do mv "$i" `echo $i | tr ' ' '_'`; done
for i in *.[Oo][Gg][Gg]; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done
for i in *.mp3; do lame --decode $i `basename $i .mp3`.wav; done
for i in *.ogg; do oggdec $i; done
normalize *.wav
cdrecord dev=ATAPI:0,0,0 speed=44 -pad -audio -v -gracetime=2 *.wav
rm *.wav

_________________
Gentoo 2004.4
Gnome 2.8
Athlon XP 1800+ 512MB DDR
Promise SATA
Back to top
View user's profile Send private message
fireboy1919
n00b
n00b


Joined: 28 May 2002
Posts: 47

PostPosted: Thu Jul 08, 2004 2:19 am    Post subject: You've got it backwards Reply with quote

metalh34d wrote:
doesn't converting mp3 into a wav cause lower quality sound, or is this just the way all mp3 burning is done?


wav is an uncompressed, lossless temporal format - the analog of bmp files in graphics.

mp3, on the other hand, is a compressed, lossy format, and whenever you convert to it, you lose information. Even if you do not compress at all you'll degrade the signal some when you convert to mp3 because it converts it to discrete cosine space (similar to doing a discrete fourier transform), and there's some loss of signal just from converting to it and back. You always have to convert back because you we listen to audio in temporal, not frequency space. Might as well do it by converting it to wav first.

Most people cannot hear the artifacts caused by the conversion; most people can't even hear the artifacts caused by removing a chunk of the signal after this conversion.

The real thing that you have to worry about is lower sample rates, which can cause aliasing if you sample at lower than twice the frequency of the highest frequency in the signal. As long as that doesn't happen (and it's not likely if you keep the audio at CD quality - 48kHz), you probably won't have problems. Well...there are a few more possible problems, but they're a lot less likely.
Back to top
View user's profile Send private message
freebit50
n00b
n00b


Joined: 26 May 2004
Posts: 56

PostPosted: Sun Jul 11, 2004 3:39 am    Post subject: Reply with quote

I love this little script!!! I was going to install k3b, but it was going to install a bunch of junk that I didn't want to wait for. This script works great, however, I added a little bit to it so cdrecord doesn't get messed on on weird filenames. I also made it so that in the end all the original files are back with no filename modifications. I also added comments. My CS teachers at school are always whining about comments and stuff.


Gotta go for a cruise with the new cd I just burned!!! Laters....

Code:

#!/bin/bash

#
# create backups so that we leave originals untouched
#
mkdir ./bak
cp *.mp3 ./bak

#
# get rid of of stuff in the filename that could fubar cdrecord
#
for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr ' ' '_'`; done
for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr -d '-'`; done
for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr -d '_'`; done
for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done
for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr -d '('`; done
for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr -d ')'`; done
for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr -d '+'`; done
for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr -d "'"`; done
for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr -d '[0-9]'`; done
# oops, stripped the 3 from mp3....gotta add it back in
for i in *.[Mm][Pp]; do mv "$i" `basename $i .mp`.mp3; done

#
# decode mp3 to wav using lame
#
for i in *.mp3; do lame --decode $i `basename $i .mp3`.wav; done

#
# normalize is a tool for adjusting the volume of audio files
# to a standard level.
#
normalize *.wav

#
# let us burn!!!
#
cdrecord dev=ATAPI:0,0,0 speed=16 -pad -audio -v -gracetime=2 *.wav

#
# get rid of temp files and restore originals
#
rm *.wav
rm *.mp3
mv ./bak/*.mp3 ./
rm -rf ./bak

Back to top
View user's profile Send private message
AGM
Apprentice
Apprentice


Joined: 02 Nov 2002
Posts: 171

PostPosted: Sun Jul 11, 2004 8:38 am    Post subject: Reply with quote

You could also check out bashburn, that's what I use. It's very cool.
Back to top
View user's profile Send private message
MighMoS
Guru
Guru


Joined: 24 Apr 2003
Posts: 416
Location: @ ~

PostPosted: Sun Jul 11, 2004 4:13 pm    Post subject: Reply with quote

Rather than moving all these files back and forth, wouldn't just using symlinks be easier?
_________________
jabber: MighMoS@jabber.org

localhost # export HOME=`which heart`
Back to top
View user's profile Send private message
freebit50
n00b
n00b


Joined: 26 May 2004
Posts: 56

PostPosted: Mon Jul 12, 2004 5:29 am    Post subject: Reply with quote

Quote:

Rather than moving all these files back and forth, wouldn't just using symlinks be easier?
Code:

Probrably. I am a newb and didn't think of it. On the other hand, when I was doing the testing, for the 16 songs that I used to fill a cd, all the moving around seemed instantanious.
Back to top
View user's profile Send private message
agnitio
Tux's lil' helper
Tux's lil' helper


Joined: 17 Apr 2004
Posts: 136

PostPosted: Thu Jul 15, 2004 7:33 pm    Post subject: Reply with quote

Why not use [:upper:] and [:lower:] insead of [A-Z] and [a-z] so that it works for non-english characters as well.
Back to top
View user's profile Send private message
cottonmouth
Tux's lil' helper
Tux's lil' helper


Joined: 24 Jan 2004
Posts: 105

PostPosted: Sat Sep 11, 2004 12:08 pm    Post subject: Reply with quote

freebit50 wrote:
I also added comments. My CS teachers at school are always whining about comments and stuff.
Very nice. I don't know shell-scripting, but your comments make unintelligble bash-code much more understandable. Thanks!

Programming is about communication and exchange of ideas between people, the machine is just the medium. Code for people, not for machines.

Or, as the Yukihiro Matsumoto said:
Quote:
Code is an expression of the thoughts, attitudes, and ideas of the programmer. By reading code, you can not only figure out what particular task the programmers were trying to accomplish and understand how they did it, but you can also gain insight into how they were thinking. This is the reason that reading code makes programmers better.


Matsumoto created Ruby, and no matter if you're interested in the language, his philosophy is enriching for all developers, no matter how skilled one is or which language one works in. Read more here
_________________
Answer an unanswered post
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum