標題:
從樂譜中提取基音頻率matlab代碼
[打印本頁]
作者:
mingyang1996
時間:
2017-12-12 21:54
標題:
從樂譜中提取基音頻率matlab代碼
大家好,這是我們之前做的音樂識別dsp項目用到的樂譜F0提取matlab代碼,先在matlab上面仿真后再遷移到CPU上面?吹接械娜俗鰀sp用到,發(fā)在這里共享。
源程序如下:
% [x,Fs] = audioread('DJF0.wav');
% % y=abs(hilbert(x));
% % plot(y);title('解調(diào)信號');
%
% % fs=30;
% t=0:1/Fs:13.306;
% x6=x;
% x66 = hilbert(x6);
% xx = abs(x66+j*x6);
% figure(1)
% hold on
% plot(t,x6);
% plot(t,xx,'r')
% xlim([0 5])
% hold off
% % 包絡算法,未考慮邊界條件
% d = diff(x6);
% n = length(d);
% d1 = d(1:n-1);
% d2 = d(2:n);
% indmin = find(d1.*d2<0 & d1<0)+1;
% indmax = find(d1.*d2<0 & d1>0)+1;
% envmin = spline(t(indmin),x6(indmin),t);
% envmax = spline(t(indmax),x6(indmax),t);
% figure
% hold on
% plot(t,x6);
% plot(t,envmin,'r');
% plot(t,envmax,'m');
% hold off
% xlim([0 5])
clc,clear;
% c=readmidi('瀟灑走一回MIDI.mid');
c=readmidi('res.mid');
b=melcontour(c,0.25,'abs'); %% 0.25拍每個點,即每0.25beat取一個點
plot(b);%%畫出旋律輪廓(melodic contour),畫出F0;
d=midi2hz(b);%把從midi格式代表的音高轉(zhuǎn)換為頻率,基頻;
gettempo(c);%得到文件中音樂的bpm 即每分鐘多少拍;從而可以計算出每秒多少拍,即音樂頻率
%在“瀟灑走一回”音樂中,得到1beat對應2Hz,
%則在midi文件中,因為每0.25beat取1個點,則計算得到對應8Hz(合成時需要的fs)
save mydata b;
復制代碼
所有資料51hei提供下載:
tiqu.rar
(778 Bytes, 下載次數(shù): 27)
2017-12-12 21:53 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1