forked from densilcabrera/psysound3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpsysound3.m
176 lines (144 loc) · 4.71 KB
/
psysound3.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
function psysound3
% PSYSOUND3
%
% This wrapper function checks to make sure PsySound3 is
% installed and then opens the GUI
% Check to see if PsySound3 is on the path
p = path;
if ~isempty(findstr(p, 'psysound3'))
try
getPsysound3Prefs; % CHECK IF PREFERENCES ARE THERE (May not be if PsySound paths added manually)
catch
configPsySound3;
end
disp('Starting PsySound3. ');
disp('Please read README File distributed with Software.');
disp('PsySound is BETA Software. Use at your own risk.');
sigV = ver('signal');
if isempty(sigV)
warning(['Signal Processing Toolbox not found. PsySound3 may ', ...
'not function correctly']);
else
fprintf('Signal Processing Toolbox OK.\n');
end
if isempty(ver('distcomp'))
warning(['Parallel Computing Toolbox not found. You wont be able to use', ...
'parallel computing features in Psysound3']);
else
fprintf('Parallel Computing ToolBox Toolbox OK.\n');
end
PsySoundGUI;
else
fprintf(['PsySound3 does not seem to be configured, configuring before proceeding.\n']);
configPsySound3;
PsySoundGUI;
end
function configPsySound3
% CONFIGPSYSOUND3
%
% Adds appropriate PsySound3 directories to the path and checks Matlab
% version. You only need to do this once.
%
% Note: You MUST be in the PsySound3 directory for this function to
% work
try
fprintf('Checking Versions... \n');
reqVer = '7.3';
% % First check required ML version
% v = ver('matlab');
%
% vPrts = getParts(v.Version);
% rvPrts = getParts(reqVer);
%
% if any(vPrts < rvPrts)
% error(['PsySound requires a minimum Matlab version of ', ...
% reqVer]);
% else
% fprintf('Matlab Version (> 7.3) OK.\n');
% end
% Warn for the signal processing toolbox
sigV = ver('signal');
if isempty(sigV)
warning(['Signal Processing Toolbox not found. PsySound3 may ', ...
'not function correctly']);
else
fprintf('Signal Processing Toolbox OK.\n');
end
if isempty(ver('distcomp'))
warning(['Parallel Computing Toolbox not found. You wont be able to use', ...
'parallel computing features in Psysound3']);
else
fprintf('Parallel Computing ToolBox Toolbox OK.\n');
end
fprintf('Setting up Paths...\n');
% This finds the path of the configPsySound3 MFILE
folderpath = fileparts(mfilename('fullpath'));
% If not the same then move to correct directory
if ~strcmp(pwd,folderpath)
cd (folderpath)
end
% Add the PsySound3 dir
addpath(pwd);
%subdirs = {'GUI', 'AudioAnalysers', 'DataAnalysers', 'dataObjects', ...
% 'dataStorage', 'utils'};
subdir = genpath(pwd);
%% Do not add .svn paths
if isunix
colons = findstr(subdir,':');
elseif ispc
colons = findstr(subdir,';');
end
boundaries = [[1 colons(1:end-1)+1]' [colons(1:end)-1]'];
direcInd = 1;
for i = 1:length(boundaries)
direc = subdir(boundaries(i,1):boundaries(i,2));
if isempty(findstr(direc,'.svn')) & isempty(findstr(direc,'PsysoundData')) % Svn folders and PsySoundData folders are useless.
subdirs(direcInd) = {subdir(boundaries(i,1):boundaries(i,2))};
direcInd = direcInd + 1;% Increment
end
end
for dr = subdirs
addpath(char(dr));
end
disp('Added PsySound3 directories to path successfully.');
disp('');
% Now save the path
if savepath,
disp(['Unable to save Matlab path. Please check write permissions ' ...
'of ', matlabroot, filesep, 'toolbox', filesep, 'local', ...
filesep, 'pathdef.m']);
disp('');
disp(' You may continue to use PsySound for this session.');
disp(' However, you will need to run this configuration script again');
disp(' the next time Matlab is restarted.');
else
disp('Matlab path saved successfuly.');
end
disp('');
catch
disp(['There was an error configuring PsySound. Please see ' ...
'below']);
rethrow(lasterror);
end
try
prefs = getPsysound3Prefs;
fprintf('Preferences already set up.\n');
catch
prefs.dataDir = [folderpath filesep 'PsySoundData'];
fprintf('Setting up Preferences...\n');
fprintf(['Setting data folder to: \t' [folderpath filesep 'PsysoundData'] '\nYou can change this using File>>Preferences in the PsySound3 GUI.\n']);
prefs.showWaitBar= 0;
prefs.multiChannelType= 1;
prefs.multiChannelSelect= 1;
prefs.combineChannels= 1;
prefs.calibrationIndex= {1; 0; 0};
prefs.calibrationLvl = '70';
setPsysound3Prefs(prefs);
end
% Subfunction to parser the version string. This is based on the
% verLessThan.m file in Matlab 7.4
function parts = getParts(V)
parts = sscanf(V, '%d.%d.%d')';
if length(parts) < 3
parts(3) = 0; % zero-fills to 3 elements
end