[SOLVED] Script to automatically merge 2 wav files in 1 mp3 file
Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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).
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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.