开发者

How to concatenate two .wav files in R?

How do I concatenate two .wav files in R?

I've checked sound and audio packages and I still don't know 开发者_如何学Chow to do it.


Have you tried appendSample(s1, s2, ...) with saveSample(s, filename, overwrite) in sound package (CRAN) ?

appendSample:

Description:
    Append two or more Sample objects or wav files.
Usage:
    appendSample(s1, s2, ...)
Arguments:
    s1, s2, ... Sample objects, or the names of wav files.
Details:
    If the samples have different sample parameters (bits, rate and channels),
    the command fitSampleParameters is called to adjust them before the sample
    are appended.
Value:
    a Sample object with the samples played one after the other.

saveSample:

Description:
    Save a Sample object to disk as a wav file.
Usage:
    saveSample(s, filename, overwrite=FALSE)
Arguments:
    s           a Sample object.
    filename    a string giving the path and the name of the destination file.
    overwrite   logical. If FALSE and filename already exists, an error
                will be reported. Otherwise the old file will be deleted.

Example commands:

> sample = appendSample('/home/grzegorz/file1.wav', '/home/grzegorz/file2.wav')
> saveSample(sample, '/home/grzegorz/output.wav', overwrite=FALSE)

I downloaded two sample wav files and it works (wavs are concatenated). Of course you need to install sound library to do that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜