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)/[email protected], to = length(ime)/[email protected], 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.
merging
). In fact ideally there are two merge points as I'm trying to replace the middle ofintro middle end.mp3
bymiddle.mp3
(the reason is thatmiddle.mp3
is of higher audio quality)