【问题标题】:How to overlap two sounds in matlab如何在matlab中重叠两个声音
【发布时间】:2017-04-01 11:25:02
【问题描述】:

我正在尝试在 Matlab 中构建声音注释器。

此注释器的要求之一是能够获取录音样本(或预先录制的文件),然后将其添加到现有文件的顶部。

假设我有第一个文件:

[y,Fs] = audioread(filename);

和第二个文件

[x,Fs2] = audioread(filename2);

第一个文件可以是音乐剪辑,第二个文件只是一些录制的评论。有没有一种方法可以使用第一个文件作为基础创建一个新的声音文件,然后在某个时间(假设在第 2 分钟,第 3 秒)在其上添加第二个文件,这样您就可以听到音乐和录音?

【问题讨论】:

    标签: matlab audio-processing


    【解决方案1】:

    首先确保您的信号具有相同的采样频率

    x2 = resample(x, Fs, Fs2);
    

    之后,您可以简单地将两个信号相加。

    offset = (2 * 60 + 3) * Fs;
    output = y;
    output(offset:offset+length(x2);:) = output(offset:offset+length(x2);:) + x2
    

    您可能想要应用增益来控制两个录音的音量以及整体音量。

    output = music_volume * y;
    output(offset:offset+length(x2);:) = (output(offset:offset+length(x2);:) + commentary_volume * x2);
    output = volume * output;
    

    【讨论】:

      猜你喜欢
      • 2012-08-04
      • 2021-12-04
      • 1970-01-01
      • 2010-12-17
      • 1970-01-01
      • 1970-01-01
      • 2016-01-04
      • 2015-07-04
      • 1970-01-01
      相关资源
      最近更新 更多