2013-04-10 102 views
1

我从使用wavread函数读取的单个笔记创建单个笔记。Matlab - .wav的双倍持续时间

我正在使用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? (伸展但保持正确的音符?)谢谢。

回答

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); 
+0

我已经试过'repmat'方法,但它会引发错误当您连接它,例如'样品= [f5_db; d4_short];'。并且使用第二种方法不是有利的,因为在原始音符前后有轻微的停顿,因此您在加长音符内暂停一下... – Reanimation 2013-04-10 16:18:54

+0

您确定必须用';'符号垂直连接吗?如果他们有不同的长度,你会得到错误。尝试','水平连接。你的第一个表情是什么?你能举一个例子来生成它吗? – yuk 2013-04-10 16:25:21

+0

啊,你正在使用信号处理工具箱。没有它。但是如果你在序列的开头和结尾都有暂停,你可能会从中间乘以一些序列。什么是'f5_short'大小? – yuk 2013-04-10 16:30:04