0001 function [sound,fs,motor]=getSynthSound(varargin)
0002
0003
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
0016
0017
0018
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,
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
0072
0073
0074
0075
0076 out=DIVA('VocalTract','synthsound',[motor;glot]);
0077 sound=out{1};
0078 fs=out{2};
0079
0080
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
0087
0088 sound(round(sum(idx(1:n))*fs:sum(idx(1:n+1))*fs))=0;
0089 end
0090
0091 end