Home > @d_opvt > plot.m

plot

PURPOSE ^

PLOT Plots the shape of the vocal tract

SYNOPSIS ^

function plot(vtm,X,AV,Ar,last)

DESCRIPTION ^

 PLOT  Plots the shape of the vocal tract
   This function plots the shape of the vocal tract corresponding
   to the provided articulatory positions.
   X is the matrix of articulatory inputs
   AV is a vector signifying voicing. Whenever AV is non-zero, a
   signal is drawn on the body to signify that the current utterance 
   is being voiced.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function plot(vtm,X,AV,Ar,last)
0002 % PLOT  Plots the shape of the vocal tract
0003 %   This function plots the shape of the vocal tract corresponding
0004 %   to the provided articulatory positions.
0005 %   X is the matrix of articulatory inputs
0006 %   AV is a vector signifying voicing. Whenever AV is non-zero, a
0007 %   signal is drawn on the body to signify that the current utterance
0008 %   is being voiced.
0009 
0010 % Satrajit Ghosh, SpeechLab, Boston University. (c)2001
0011 % $Header: /mnt/localhd/cvsdir/MODELLING/NEWDIVA/@d_opvt/plot.m,v 1.3 2006/10/27 16:55:48 brumberg Exp $
0012 
0013 % $NoKeywords: $
0014 
0015 % Setup globals
0016   global RELEASE
0017 
0018 %  X=X(1:8,:);
0019 
0020   if nargin<4
0021     if(size(X,1)>=8)
0022       Ar=X;
0023     else
0024       Ar=[];
0025     end
0026     last=zeros(1,size(X,2));
0027   elseif(nargin<5)
0028     last=zeros(1,size(X,2));
0029   end
0030   % In order to speed up plotting this sin function has to be taken
0031   % out of the loop
0032   fs = 10000;
0033   t = [0:1/fs:0.01]';
0034   y = sin(2*pi*t*500);
0035 
0036   % scale and shift the plot to the appropriate location and size
0037   AVval(:,1) = 275+50/0.01*t; 
0038   AVval(:,2) = 525+25*y;
0039   % Cycle through each input
0040   for i=1:size(X,2),
0041     [Ft,Bt,At,Af{i},Tf{i},P1{i},P2t] = doAM(X(1:7,i));
0042     % Draw the figure
0043     diva_drawman(P1{i},P2t,X(1,i),AV(i),AVval,last(i));    
0044     % plot area function
0045     drawAreaFunc(X(1:7,i),vtm);
0046     
0047     [TP,TL]=miniAr2Tac(Ar(:,i),X(:,i));    
0048     
0049     % plot palatotactile info
0050     %drawPalate(Ar(:,i),X(:,i));
0051     drawPalate(TP);
0052     % draw lip model
0053     %drawLips(Ar(:,i),X(:,i));
0054     drawLips(TL);
0055     hold off;
0056     
0057     drawnow;
0058   end
0059   
0060   %arm wave
0061 %   last=[1 0 1 0];
0062 %   for i=1:4,
0063 %     % Draw the figure
0064 %     diva_drawman(P1{size(X,2)},P2t,X(1,size(X,2)),AV(size(X,2)),AVval,last(i));
0065 %     % plot area function
0066 %     drawAreaFunc(X(1:7,size(X,2)),vtm);
0067 %     % plot palatotactile info
0068 %     drawPalate(Ar(:,size(X,2)),X(:,size(X,2)));
0069 %     % draw lip model
0070 %     drawLips(Ar(:,size(X,2)),X(:,size(X,2)));
0071 %     hold off;
0072     
0073 %     drawnow;
0074 %   end
0075 
0076 
0077 function drawLips(TL)%Ar,X)
0078   %[TP,TL]=miniAr2Tac(Ar,X);
0079   yoff=350;
0080   xlow=50;
0081   xhigh=270;
0082   xstep=3;
0083   %TL=9-TL;
0084   TL=8-TL;
0085   hold on;
0086   y=ones(1,3).*yoff;
0087   % Upper lip
0088   y(2)=yoff-TL*8;
0089   x=linspace(xlow,xhigh,xstep);
0090   xi=linspace(xlow,xhigh);
0091   yi=interp1(x,y,xi,'pchip');
0092   plot(xi,yi,'k','LineWidth',5);
0093   % Lower lip
0094   y(2)=yoff+TL*8;
0095   x=linspace(xlow,xhigh,xstep);
0096   xi=linspace(xlow,xhigh);
0097   yi=interp1(x,y,xi,'pchip');
0098   plot(xi,yi,'k','LineWidth',5);
0099   hold off;
0100   return
0101 
0102 function drawPalate(TP)%Ar,X)
0103 % c=1; a=a;b=b;
0104 % C=pi*sqrt(a^2+b^2);
0105 % L=C/n; % where n=2*pnode-1;
0106 % ra=(c^2*a^2*b^2);
0107 % rb=(b^2*(cos(t).^2))+(a^2*(sin(t).^2));
0108 % r=sqrt(ra./rb);
0109 % T(1)=0;
0110 % T(n)=T(n-1)+L/(r(floor(T(n-1)*10000+1)));
0111 % R=r(floor(T*10000+1));
0112 % x=R.*cos(T);
0113 % y=R.*sin(T);
0114 %  figure,hold on
0115   %[TP,TL]=miniAr2Tac(Ar,X);
0116   
0117   xoff=130;
0118   
0119   y_min=650;
0120   x_min=40;
0121   amp=50;
0122   amp_step=12;
0123   hold on
0124   yoff=250;
0125   b=[3.6 3.9 3.2 3.0 2.8 2.6 2.4 2.2 2.0];
0126   a=[3.7 3.9 3.3 2.8 2.3 1.8 1.3 0.8 0.6];
0127   c=1;
0128   cc=2;
0129   %t=0:0.0001:pi;
0130   t=pi/2;
0131   pnode=[9 8 7 5 4];
0132   j=1;
0133   theta=linspace(pi/2,3*pi/2,200);
0134   tlabel={'l1','l2','l3','l4','l5'};
0135   for i=1:1:9
0136     xt=[];
0137     yt=[];
0138     if(~mod(i,2)),
0139       xt=a(i)*sin(theta);
0140       yt=b(i)*cos(theta);
0141       xt=(xt+1)*35+xoff;
0142       yt=yt*amp+250;
0143 
0144       cstr='k';
0145     else
0146       n=pnode(j)*4;
0147       cc=2;
0148       t=pi/2;
0149       h=((a(i)-b(i))^2)/((a(i)+b(i))^2);
0150       C=pi*(a(i)+b(i))*(1+((3*h)/(10+sqrt(4-3*h))));
0151       C=C/4;
0152       L=C/n; % where n=2*pnode-1;
0153       if j<=3
0154         L=L+(.1*L);
0155       elseif j==5
0156         L=L-(.05*L);
0157       end
0158       ra=(c^2*a(i)^2*b(i)^2);
0159       rb=(b(i)^2*(cos(t)^2))+(a(i)^2*(sin(t)^2));
0160       r=sqrt(ra/rb);
0161       T=[];
0162       R=[];
0163       T(1)=t;
0164       R(1)=r;
0165       for k=2:n
0166         t=t+L/r;
0167         rb=((b(i)^2)*(cos(t)^2))+((a(i)^2)*(sin(t)^2));
0168         r=sqrt(ra/rb);
0169         if mod(k-1,4)==0
0170           T(cc)=t;
0171           R(cc)=r;
0172           cc=cc+1;
0173         end
0174       end
0175       xt=R.*cos(T);
0176       yt=-R.*sin(T);
0177       cstr='.k';      
0178       order=length(xt):-1:1;
0179       xt=xt(order);
0180       yt=yt(order);
0181       order=length(xt)-1:-1:1;
0182 
0183       xt=([xt -xt(order)]+1)*35+xoff;
0184       yt=[yt yt(order)]*amp+250;
0185 
0186       
0187       tpoints.(char(tlabel(j))).x=xt;
0188       tpoints.(char(tlabel(j))).y=yt;
0189       j=j+1;
0190 
0191     end
0192     plot(xt,yt,cstr);
0193   end
0194   j=1;
0195   TP=TP+1;
0196   for i=1:5
0197     idx=6-i;
0198     plot(tpoints.(char(tlabel(i))).x(TP(i):-1:1), ...
0199          tpoints.(char(tlabel(i))).y(TP(i):-1:1),'*r')
0200     plot(tpoints.(char(tlabel(i))).x(end+1-(TP(i):-1:1)), ...
0201          tpoints.(char(tlabel(i))).y(end+1-(TP(i):-1:1)),'*r')
0202   end
0203   hold off
0204   return
0205   
0206 function [TP,TL]=miniAr2Tac(Ar,X)
0207   if ~isempty(Ar)
0208     sizeAr2=size(Ar,2);
0209   else
0210     sizeAr2=1;
0211   end
0212   
0213   Maeda2Palate=[ 4.9750    0.3910   -1.5280    0.3720    1.7100 0; ...
0214                  3.8020    0.3940   -1.5770    0.6160    1.4490 0; ...
0215                  2.1380    0.1940   -1.4440    0.6380    0.7930 0; ...
0216                  0.3780    0.2830   -1.2290    0.6260    0.3220 0; ...
0217                  -0.4840   0.3880   -0.8910    0.7030    0.3910 0; ...
0218                  4.9190    0.2710    0.0280   -0.0040   -0.0010 -1.8114];
0219   MaedaParam=X;
0220   %size(Ar,2)
0221   T = max(min(Maeda2Palate*[ones(1,sizeAr2);MaedaParam(1:5,: )], ...
0222               repmat([9 8 7 5 4 9]',1,sizeAr2)),0);
0223   %S=[Ar;T];
0224   %T=S(9:end,:);
0225   TP=T(1:end-1);
0226   TP=floor(TP);
0227   TL=T(end);
0228   return
0229   
0230 function drawAreaFunc(X,vtm)
0231   tdata.X=X;
0232   tdata=getAreaFunc(vtm,tdata);
0233   y_min=650;
0234   x_min=40;
0235   bar_step=15;
0236   y_amp=20;
0237   hold on;
0238   for i=1:length(tdata.Af)
0239     line([x_min+i*bar_step,x_min+i*bar_step+bar_step],[y_min- ...
0240                         tdata.Af(i)*y_amp,y_min-tdata.Af(i)*y_amp], ...
0241          'color','k');
0242     if(i>1)
0243       line([x_min+i*bar_step,x_min+i*bar_step],[y_min- tdata.Af(i)* ...
0244                           y_amp,y_min-tdata.Af(i-1)* y_amp],'color','k');
0245     end
0246   end
0247   [mina mini]=min(tdata.Af);
0248   tot=length(tdata.Af);
0249   set(gca,'xtick',[],'xticklabel',[],'ytick',[],'yticklabel',[]);
0250   xlabel(sprintf('Min Area: %2.1f cm^2 Tube %d of %d',mina,mini,tot));
0251   return
0252

Generated on Tue 27-Mar-2007 12:06:24 by m2html © 2003