%   PlayBatWav.m

%   This software is protected by german copyright and international treaties.             
%   Copyright 2004 Markus Junghöfer & Peter Peyk. All Rights Reserved.                     
%                                                                                          
%   THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE        
%   NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO,    
%   WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE    
%   OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
%   TRADEMARKS OR OTHER RIGHTS. COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT,       
%   INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE      
%   OR DOCUMENTATION. 

VecFilePath='Data:IADS:Data:RandBatWav1';
NewPath='Data:IADS:LoHi46'
Vec=ReadAscii(VecFilePath)
%VecTmp=Vec;
%Vec(1:23,1)=VecTmp(randperm(23),1);
                                                                     
%Vec(24:46,1)=VecTmp(23+randperm(23),1)
%return
NFiles=length(Vec)
% for FileInd=1:NFiles
% 	if Vec(FileInd)==709 | Vec(FileInd)==225
% 		OldPath='Data:IADS:Sounds2s.wav';
% 		OldFile=[int2str(Vec(FileInd)),'.2s.wav']
% 	else
% 		OldPath='Data:IADS:Sounds4s.wav';
% 		OldFile=[int2str(Vec(FileInd)),'.4s.wav']
% 	end
% 	OldFilePath=[OldPath,filesep,OldFile]
%     ExistStatus=exist(OldFilePath)
% 	acopy(OldFilePath,NewPath);
% 	NewFile=AddZeros2CountStr(FileInd,2);
% 	NewFile=[NewFile,'.wav']
% 	CopyFilePath=[NewPath,filesep,OldFile]
%     ExistStatus=exist(OldFilePath)
% 	NewFilePath=[NewPath,filesep,NewFile]
% 	arename(CopyFilePath,NewFile)
% 	fprintf('Sound %g of %g; \n',FileInd,NFiles);
% end
% return
% cd Data:IADS:Sounds4s.wav
% [filemat, namelist, dirname] = getfilesindir('Data:IADS:Sounds4s.wav:')
% NFiles=size(filemat,1)
% for FileInd=1:NFiles
%     OldName=SepFilePath(filemat(FileInd,:))
%     NewName=OldName(7:length(OldName))
%     arename(OldName,NewName)
% end

for FileInd=1:4
%   if Vec(FileInd)==709 | Vec(FileInd)==225
% 		Path='Data:IADS:Sounds2s.wav:';
% 		File=[int2str(Vec(FileInd)),'.2s.wav']
% 	else
% 		Path='Data:IADS:Sounds4s.wav:';
% 		File=[int2str(Vec(FileInd)),'.4s.wav']
% 	end
    Path='Paul:NegPosWav:'
    if FileInd==4
        File='Neg.wav'
    elseif FileInd==1 | FileInd==3
        File='Zero10.wav'
    elseif FileInd==2
        File='Neg.wav'
    end
%File=['LoHi4s.',int2str(FileInd),'.wav']
%File=['LoHi',int2str(FileInd),'.wav']
%     if FileInd<10
%         File=['00',int2str(FileInd),'.wav']
%     elseif FileInd>9
%         File=['0',int2str(FileInd),'.wav']
%     end
    FilePath=[Path,File]
    ExistStatus=exist(FilePath)
    [Y,F,NBits]=wavread(FilePath);
	MonoStereo=size(Y,2);
	if MonoStereo==1
		YTmp=zeros(size(Y,1),2);
		YTmp(:,1)=Y;
		YTmp(:,2)=Y;
		Y=YTmp;
	end
	if FileInd==1
		Ys=Y;	
	else
		NTot=size(Ys,1)+size(Y,1);
		YTmp=zeros(NTot,2);		
		YTmp(1:NTot-size(Y,1),:)=Ys;
		YTmp(NTot-size(Y,1)+1:NTot,:)=Y;
		Ys=YTmp;
	end
    %Sound(Y,F)
	%pause(0.01)
end
wavwrite(Ys,F,NBits,[pwd,'NegZeroNeg.wav']) 
