LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 11-30-2009, 10:12 AM   #1
Jackuss
LQ Newbie
 
Registered: Dec 2008
Posts: 4

Rep: Reputation: 0
Script to automatically merge 2 wav files in 1 mp3 file


hello,

I'm not entirely new to Linux, but I am new to scripting in Bash. Can anybody help me with the following:

Short Question:

How can I automatically merge 2 wav-files into 1 mp3 file?

Explanation:

I play in a band and last saturday night we recorded some of our songs on a simple digital recording device. This device create two wav-files, 1 for the frontmicrophone and 1 for the backmicrophone.

I want to merge these files together, but since we recorded a lot of things, we got a lot of files to merge. I don't want to do all that work by hand.

Now I want to save the files in 1 directory, and I want to create a script which search for a particular pattern in a file name (eg. "MC0001F.wav" and "MC0001B.wav" so the script must search for "*F.wav" and "*B.wav"). When he found a match, he must merge those files into 1 mp3 (I guess I can use something like 'sox' for that).

Can anybody help me with this?

Thanks in advance.

Jackuss
 
Old 11-30-2009, 01:20 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950
Assuming you want to process the current directory, and that the filenames are as you gave, identical except for F.wav/B.wav, something like this should work:

Code:
for f_file in ./*F.wav; do

b_file="${f_file/F.wav/B.wav}"  #replaces "F.wav" with "B.wav" in the filename

<put sox command here with input $f_file $b_file>

done
You'll have to work out your own command to actually combine the files though, as I'm not experienced in that. I'm not even sure exactly what you want the final output to be like.
 
Old 12-01-2009, 02:10 PM   #3
Jackuss
LQ Newbie
 
Registered: Dec 2008
Posts: 4

Original Poster
Rep: Reputation: 0
<problem solved>

David The H.

Thanks for your reply, I tried it and it worked for me. For the record, This is what I did to make it work:
Code:
for f_file in ./*F.wav; do

b_file="${f_file/F.wav/R.wav}"  #replaces "F.wav" with "R.wav" in the filename

# <put sox command here with input $f_file $b_file>

soxmix $f_file $b_file -r 44100 /media/58E5-6EB7/mp3/$b_file.mp3
done
Note:The filenames didn' t end with a B but with an R. And the location where the files are places is my USBstick.

Thanks again.

Regards,

Jackuss
 
1 members found this post helpful.
Old 12-01-2009, 04:03 PM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950
Glad to hear it. Incidentally, you can use a similar parameter substitution to strip the original .wav extension off the name, before adding the .mp3.

Code:
soxmix $f_file $b_file -r 44100 /media/58E5-6EB7/mp3/${b_file%.wav}.mp3
 
Old 12-01-2009, 07:31 PM   #5
cfriisha
LQ Newbie
 
Registered: May 2009
Posts: 2

Rep: Reputation: 0
In case you want to do a really good job in terms of start finish, sync, fading, volume, etc. then Ardour is really good, but with a steep learning curve if you are not used to mixing.
 
Old 12-02-2009, 02:32 AM   #6
Jackuss
LQ Newbie
 
Registered: Dec 2008
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by cfriisha View Post
In case you want to do a really good job in terms of start finish, sync, fading, volume, etc. then Ardour is really good, but with a steep learning curve if you are not used to mixing.
Hello,cfriisha

I already use Ardour and it is indeed a great program, with some rough edges unfortunately.

The reason I wanted to create a script is that, last Saturday we recorded all our songs on an simple recording device (The "Zoom H 2" if you are interested), and recorded about 10 - 15 songs. We didn't want to mix it, just record so we could practice.

You can understand that I didn't want to manually import all the the *F.wav and *R.wav files, and then export them with a program like Ardour or Audacity.

When we want to mix our music, I think we are going to record on a multi-tracker. That way I can select all the instruments apart and mix them appropriately.

Thanks again.
 
  


Reply

Tags
merge, mp3, script, wav


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Script to Convert wav to mp3 dzollinger Linux - General 7 05-16-2008 09:37 PM
i want to convert .wav file into mp3 files in batch mode sparsh Linux - Software 6 11-20-2007 11:53 AM
merge wav files linuxhippy Slackware 6 06-01-2007 12:30 PM
Can anyone recommend some good software to convert *.wav files into *mp3 files? Tom "Techno" Earl Linux - Software 4 10-12-2006 05:03 PM
Need help writing a mp3->wav script... Vincent_Vega Linux - General 7 12-30-2004 12:10 AM


All times are GMT -5. The time now is 08:08 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration