首页 > 其他分享 >【共振峰跟踪】通过平均不同分辨率的方法跟踪共振峰,基于时频lpc的频谱图的MATLAB仿真

【共振峰跟踪】通过平均不同分辨率的方法跟踪共振峰,基于时频lpc的频谱图的MATLAB仿真

时间:2022-12-18 17:23:01浏览次数:60  
标签:fmap tmp .- idx tpts plot 跟踪 lpc 共振

1.软件版本

MATLAB2021a

 

2.本算法理论知识

通过平均不同分辨率的方法跟踪共振峰,基于时频lpc的频谱图。此外,它还决定了语音信号的基音轮廓

3.核心代码

function [fmap,pt2] = ftrack(y,fs)


bDisplay = 1;

Fsamps = 256; % sampling resolution in frequency dimension
Tsamps = round(length(y)/18000*256); % sampling resolution in time dimension


tmp_img1 = zeros(Fsamps,Tsamps);
ct = 0;

numiter = 8; % number of iterations to run. seemed like a good number



for i=2.^(8-8*exp(-linspace(1.5,10,numiter)/1.4)),
% Determine the time-frequency distribution at the current

fix(length(y)/round(i))
round(i)
[tmp_img1,ft1,pt1] = lpcsgram(y,fix(length(y)/round(i)),round(i),fs);

% Get the dimensions of the output time-frequency image
[M,N] = size(tmp_img1);

% Create a grid of the final resolution
[xi,yi] = meshgrid(linspace(1,N,Tsamps),linspace(1,M,Fsamps));

% Interpolate returned TF image to final resolution
tmp_img2 = interp2(tmp_img1,xi,yi);

ct = ct+1;

% Interpolate formant tracks and pitch tracks
pt2(:,ct) = interp1([1:length(pt1)]',pt1(:),linspace(1,length(pt1),Tsamps)');
ft2(:,:,ct) = interp1(linspace(1,length(y),fix(length(y)/round(i)))',Fsamps*ft1',linspace(1,length(y),Tsamps)')';

% Normalize
tmp_img3(:,:,ct) = tmp_img2/max(tmp_img2(:));

if bDisplay,
subplot(221);imagesc(tmp_img1);axis xy;
subplot(222);imagesc(tmp_img2);axis xy;
subplot(223);imagesc(squeeze(mean(tmp_img3,3)));axis xy;
drawnow;
end;
end

% Determine mean tfr image and formant track
tmp_img4 = squeeze(mean(tmp_img3,3)); % tfr
ft3 = squeeze(nanmean(permute(ft2,[3 2 1]))); %

if bDisplay,
subplot(224);imagesc(tmp_img4);axis xy;
hold on;
plot(ft3,'y');
end;

% convert fmnts to image
tmap = repmat([1:Tsamps]',1,3);
idx = find(~isnan(sum(ft3,2)));
fmap = ft3(idx,:);
tmap = tmap(idx,:);
% filter formant tracks to remove noise
[b,a] = butter(9,0.1);
fmap = round(filtfilt(b,a,fmap));
pt3 = nanmean(pt2');
pt3 = (pt3-nanmin(pt3))/(nanmax(pt3)-nanmin(pt3));

% Rescaling is done after display code
if bDisplay,
imap = zeros(Fsamps,Tsamps);
ind = sub2ind(size(imap),fmap(:),tmap(:));
imap(ind) = 1;

tpts = tmap(:,1);

figure;
subplot(221);
imagesc(imap);axis xy;hold on;
plot(tpts,fmap(:,1),tpts,fmap(:,2),tpts,fmap(:,3));
idx = [1:5]';
plot(tpts(idx),fmap(idx,1),'.-',tpts(idx),fmap(idx,2),'.-',tpts(idx),fmap(idx,3),'.-');

subplot(222);

% Create a wider formant track
anisomask = anisodiff(imap,6,50,0.01,1);

imagesc(anisomask>0);axis xy;hold on;
plot(tpts,fmap(:,1),tpts,fmap(:,2),tpts,fmap(:,3));
idx = [1:5]';
plot(tpts(idx),fmap(idx,1),'.-',tpts(idx),fmap(idx,2),'.-',tpts(idx),fmap(idx,3),'.-');

subplot(223);
imagesc(tmp_img4);axis xy;hold on;
plot(tpts,fmap(:,1),'r',tpts,fmap(:,2),'r',tpts,fmap(:,3),'r');
idx = [1:5]';
plot(tpts(idx),fmap(idx,1),'.-',tpts(idx),fmap(idx,2),'.-',tpts(idx),fmap(idx,3),'.-');

subplot(224);
imagesc(tmp_img4.*(anisomask>0));axis xy;hold on;
plot(tpts,fmap(:,1),'r-',tpts,fmap(:,2),'r-',tpts,fmap(:,3),'r-');
% idx = [1:5]';
% plot(tpts(idx),fmap(idx,1),'.-',tpts(idx),fmap(idx,2),'.-',tpts(idx),fmap(idx,3),'.-');
plot(256*pt3,'y.-');
end;

% Rescale to Actual Formants and take the mean of pitch tracks
fmap = (fs/2)*(fmap/256);
pt2 = nanmean(pt2');

4.操作步骤与仿真结论

 

 

 

 

 

 D201

标签:fmap,tmp,.-,idx,tpts,plot,跟踪,lpc,共振
From: https://www.cnblogs.com/matlabfpga/p/16990602.html

相关文章

  • [OpenCV实战]16 使用OpenCV实现多目标跟踪
    目录​​1背景介绍​​​​2基于MultiTracker的多目标跟踪​​​​2.1创建单个对象跟踪器​​​​2.2读取视频的第一帧​​​​2.3在第一帧中确定我们跟踪的对象​​​......
  • [OpenCV实战]15 基于深度学习的目标跟踪算法GOTURN
    目录​​1什么是对象跟踪和GOTURN​​​​2在OpenCV中使用GOTURN​​​​3GOTURN优缺点​​​​4参考​​在这篇文章中,我们将学习一种基于深度学习的目标跟踪算法GOTURN......
  • [OpenCV实战]14 使用OpenCV实现单目标跟踪
    目录​​1背景​​​​1.1什么是目标跟踪​​​​1.2跟踪与检测​​​​2OpenCV的目标跟踪函数​​​​2.1函数调用​​​​2.2函数详解​​​​2.3综合评价​​​​......
  • 《安富莱嵌入式周报》第295期:世界杯球员和足球实时跟踪,开源手持矢量网络分析仪,自制柔
    往期周报汇总地址:http://www.armbbs.cn/forum.php?mod=forumdisplay&fid=12&filter=typeid&typeid=104 视频版:https://www.bilibili.com/video/BV1s14y1N7BB/1、开......
  • Bug管理与跟踪
    缺陷的管理与跟踪1:缺陷的定义缺陷不光是产品出现bug,宕机等情况才叫缺陷,缺陷还包括当产品不满足用户需求时也叫缺陷还有当测试用例的预期结果于实际结果,不相同时也叫缺陷......
  • Ocelot 集成Butterfly 实现分布式跟踪
    微服务,通常都是用复杂的、大规模分布式集群来实现的。微服务构建在不同的软件模块上,这些软件模块,有可能是由不同的团队开发、可能使用不同的编程语言来实现、有可能布在了几......
  • Oracle 跟踪文件trc,trm
    oracle的日志文件有以下几种:警告日志,trace日志,audit日志,redo日志,归档日志a.警告日志:也就是alertlog,使用初始化参数showparameterbackgroud_dump_dest查看b.trace日......
  • redis 状态 跟踪 参数值
    1查看客户端连接信息通过执行clientlist命令来查看客户端连接信息,每行都代表一个客户端127.0.0.1:6379>clientlistid=3addr=127.0.0.1:58752fd=7name=age=19951id......
  • 中小企业都在用哪些项目进度跟踪系统?
    国内外优秀的项目跟踪管理软件有:1、软件项目跟踪管理PingCode;2、通用项目跟踪管理Worktile;3、小型团队项目跟踪管理Asana;4、基于桌面的项目跟踪软件MicrosoftProject;5、适......
  • Python如何动态监控跟踪文件内容?
    需求:Python如何动态监控跟踪文件内容?写个小工具模仿linux中的tail来监控文件更新的内容?解答:利用文件的指针f.seek(0,2)importtimewithopen("a.txt",mode="r......