Home > fcn > DIVA_GUI_toolbox > getSynthSound.m

getSynthSound

PURPOSE ^

Get normalized motor trajectories - VocalTract

SYNOPSIS ^

function [sound,fs,motor]=getSynthSound(varargin)

DESCRIPTION ^

 Get normalized motor trajectories - VocalTract
 Get normalized target indices - MotorCortex

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [sound,fs,motor]=getSynthSound(varargin)
0002 % Get normalized motor trajectories - VocalTract
0003 % Get normalized target indices - MotorCortex
0004   if(nargin==0)
0005     searchIdx=DIVA('TimeStep')*(-1000:0);
0006     searchTarg=DIVA('MotorCortex','target',[],searchIdx);
0007     idx=getQueueIdx(searchTarg);
0008     motor=DIVA('VocalTract','motor',[],DIVA('TimeStep')*(-idx:0));
0009     [targ midx] = sort(searchTarg(1000-idx+1:end));
0010     idx=find(targ==0);
0011     targ(idx)=[];
0012     midx(idx)=[];
0013     motor=motor(:,midx);
0014 
0015     % Get Velocity information - AuditoryCortexCategorical
0016     % Rescale motor trajectories via velocity scaled target indices
0017 
0018     % Get Glottal information - AuditoryCortexCategorical
0019     fname = DIVA('GUI','current_file');
0020     au_info=load(fname);
0021     if(size(motor,2)~=size(au_info.Ag0,1))
0022       msize=size(motor,2)-size(au_info.Ag0,1)
0023       if(msize>0),
0024         motor(:,end-msize+1:end)=[];
0025       else
0026         au_info.Ag0(end-abs(msize)+1:end,:)=[];
0027         au_info.AgP(end-abs(msize)+1:end,:)=[];
0028         au_info.F0(end-abs(msize)+1:end,:)=[];
0029       end
0030     end
0031     motor = [motor;...
0032              au_info.Ag0(:,2)';...
0033              au_info.AgP(:,2)';...
0034              au_info.F0(:,2)'];
0035 
0036     out = DIVA('VocalTract','synthsound',motor);
0037     sound=out{1};
0038     fs = out{2};
0039   else,%specify same input to DIVA('AuditoryCortexCategorical','target',var)
0040     y=[];
0041     fs=10000;
0042     idxstart=0;
0043     glot=[];
0044     for n=1:length(varargin)
0045       if(ischar(varargin{n}))
0046         idxstart=idxstart + ...
0047                  length(DIVA('AuditoryCortexCategorical','target',varargin{n}))*DIVA('TimeStep');
0048         au_info=load([DIVA('SessionTargetFolder'),filesep,['Session_',DIVA('SessionName')],...
0049                       filesep,[varargin{n},'.mat']]);
0050         glot=[glot,[au_info.Ag0(:,2)';au_info.AgP(:,2)';au_info.F0(:,2)']];
0051         idx(n)=length(DIVA('AuditoryCortexCategorical','target',varargin{n}))*DIVA('TimeStep');
0052       else
0053         idxstart=idxstart+varargin{n};
0054         idx(n)=varargin{n};
0055         glot=[glot,[zeros(1,varargin{n}*1000);ones(1,varargin{n}*1000)*0.1;zeros(1,varargin{n}*1000)]];
0056       end
0057     end
0058     
0059     motor=DIVA('VocalTract','motor',[],...
0060                -(idxstart + ...
0061                  DIVA('SoundMap','delayToMotorCortex') + ...
0062                  DIVA('AuditoryCortexCategorical','delayToSoundMap') + ...
0063                  DIVA('MotorCortex','delayToerror_sound') + ...
0064                  DIVA('MotorCortex','delayToerror_somatosensory')):0.001:...
0065                -(1*DIVA('TimeStep')+DIVA('SoundMap','delayToMotorCortex') + ...
0066                  DIVA('AuditoryCortexCategorical','delayToSoundMap') + ...
0067                  DIVA('MotorCortex','delayToerror_sound') + ...
0068                  DIVA('MotorCortex','delayToerror_somatosensory')));
0069     x=1:size(motor,2);
0070     glot(3,:)=interp1([1 size(motor,2)/4 size(motor,2)],[90 120 80],x);
0071 %    figure,subplot(3,1,1),plot(motor');
0072 %    subplot(3,1,2),
0073 %    hold on;
0074 %    plot(glot(1,:),'b');
0075 %    plot(glot(2,:),'r');
0076     out=DIVA('VocalTract','synthsound',[motor;glot]);
0077     sound=out{1};
0078     fs=out{2};    
0079 %    subplot(3,1,3),
0080 %    hold on;
0081     cumsum(idx);
0082     idx(1:2:end)=idx(1:2:end)-.006;
0083     idx(2:2:end)=idx(2:2:end)+0.009;
0084     cumsum(idx);
0085     for n=1:2:length(idx)-1,
0086 %       line([sum(idx(1:n)) sum(idx(1:n))]*fs,[-1 1],'color','k');
0087 %       line([sum(idx(1:n+1)) sum(idx(1:n+1))]*fs,[-1 1],'color','r');
0088       sound(round(sum(idx(1:n))*fs:sum(idx(1:n+1))*fs))=0;
0089     end
0090 %    plot(sound)
0091   end

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