1

wavread我正在从使用该函数读取的单个笔记创建单独的笔记。

我正在使用该resample功能来创建这些笔记。例如:

    f5  = resample(a,440,698); %creates note.
    f5_short  = f5(dur:Hz);    %creates duration of note (ie 1 sec)
    f5_hf  = f5_short(dur:Hz/2); %creates note of half duration

上面的代码似乎运行良好。不幸的是,我在创建“双音符”时遇到了麻烦......我不想只演奏两次同一个音符,我尝试了以下方法:

    f5_db  = f5_short(dur*2:Hz); %exceeds size of matrix
    f5_db  = f5_short(dur:Hz*2); %exceeds size of matrix
    f5_db  = resample(f5_short,Hz*2,330); %tried upSampling it and although lengths it, note becomes deeper.

什么是最简单的为什么在不更改音符的情况下将非 / wav 的长度加倍?(伸展但保持正确的音符?)谢谢。

4

1 回答 1

2

您需要将 的大小加倍f5_short,而不是对其进行索引:

f5_db = repmat(f5_short, 2, 1);

要不就

f5_db = [f5_short; f5_short];

如果你在开头和结尾都有停顿f5_short,但中间的顺序是不变的,你可以重现中间以获得双音符。像这样的东西:

f5_short_len = length(f5_short);
f5_short_mid = floor(f5_short_len/2);
f5_db = [f5_short(1:f5_short_mid,:); ...
         repmat(f5_short(f5_short_mid,:),f5_short_len,1); ...
         f5_short(f5_short_mid+1:f5_short_len,:)];

如果要删除暂停;

f5_short = repmat(f5_short(f5_short_mid),f5_short_len,1);
f5_db = repmat(f5_short, 2, 1);
于 2013-04-10T16:14:06.847 回答