7

I'm looking for a program than can:

  • merge two MP3s. E.g. I have a 5-minute track which is split in two MP3s that overlap: the 1.5 first minutes is in one MP3 file (128 kbps), and the 4 last minutes is in another MP3 (320 kbps).

And if possible:

  • choose at which timepoint of the track we merge the two MP3s
  • free
  • works on Windows 7

Right now I use Audacity to merge two MP3s but I have to do it manually so it is tedious and imprecise (I use the track to mix so I don't want to have a shorter or longer beat at the merging point as it would be annoying to beatmatch).

  • 1
    Would it be possible for you to provide two audio files? I'm pretty sure this could be done using R, particularly if you know how long the full track is supposed to be, and if you provide the files, I'd be happy to give it a try. – Jota Mar 18 '14 at 16:54
  • Thanks, sure: I converted both MP3 to 320 kbps and same BPM (129.976): mega.co.nz/… (password of the zip archive: merging). In fact ideally there are two merge points as I'm trying to replace the middle of intro middle end.mp3 by middle.mp3 (the reason is that middle.mp3 is of higher audio quality) – Franck Dernoncourt Mar 18 '14 at 20:54
  • I'm wondering if splitting the files (maybe using cue files), then merging them back may be a good way to do it. I have a rough idea on how to do it, but I need to find time to test out messing with cue files manually. – Journeyman Geek Mar 19 '14 at 6:25
  • 1
2

Using R, it can be done. However, as far as I know, you have to upsample or downsample one of the files since they have different sampling rates (i.e. 44.1 vs 48 kHz). Doing that can change the frequency properties. Here is how you can do it, though. You'll need to install two libraries: seewave and tuneR. You can either do this with the drop down menus or using install.packages(c("seewave","tuneR"))

library(seewave) # now load the libraries  
library(tuneR)

# You'll need to set your working directory to wherever the files are,
# or provide the full path (e.g. readMP3("C:/Users/You/Desktop/middle.mp3").
mid <- readMP3("middle.mp3") # readMP3 is from the tuneR package
ime <- readMP3("intro middle end.mp3")

# All the other functions here are from `seewave`.
# To upsample:
upsampime <- resamp(ime, g=48000, output="Wave") # upsample to 48 kHz 

# Here you choose how to cut the intro middle end.mp3 file, I picked from 0 seconds to 10 seconds.
# You can try upsampime here instead of ime.
# If you don't, the final audio file will be have a sample rate of 44.1 kHz.
intro <- cutw(ime, from = 0, to = 10, output="Wave")

# Choose where to cut the end part. 
# I picked  from 10 + # of seconds in "middle.mp3" to 
# the # of seconds in "intro middle end.mp3."
# Again, you should use upsampime here if you want a 48 kHz file.
end <- cutw(ime, from = 10 + length(mid)/mid@samp.rate, to = length(ime)/ime@samp.rate, output="Wave")

# Now put put intro, mid, and end together.
im <- pastew(intro, mid, at="start", output="Wave")
newime <- pastew(im, end, at="start", output="Wave")
savewav(newime, "newime.wav")

There is no way that I know of to write an .mp3 file in R. This will give you a .wav file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.