# HG changeset patch # User Brecht # Date 1398380011 -3600 # Node ID 4fd2842851596248b967d429540be1af687cf903 Adding listening test plus some helpful functions and scripts. diff -r 000000000000 -r 4fd284285159 aux/LR2MS.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/aux/LR2MS.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,21 @@ +function y = LR2MS(x) +% LR2MS Converts stereo audio signal to MS (mid side). +% +% by Brecht De Man at Centre for Digital Music, 4 June 2013 + +if min(size(x)) ~= 2 + error('Function LR2MS needs a stereo audio input file.'); +end + +y = zeros(size(x)); + +% M = L+R, S = L-R +y(:,1) = x(1,:) + x(2,:); % mid +y(:,2) = x(1,:) - x(2,:); % side + +% normalise if necessary +if max(max(abs(y))) >= 1 + y = y/max(max(abs(y))); +end + +end \ No newline at end of file diff -r 000000000000 -r 4fd284285159 aux/MS2LR.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/aux/MS2LR.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,16 @@ +function y = MS2LR(x) +% LR2MS Converts stereo audio signal to MS (mid side). +% +% by Brecht De Man at Centre for Digital Music, 4 June 2013 + +if size(x,2) ~= 2 + error('Function MS2LR needs a stereo audio input file.'); +end + +y = zeros(size(x)); + +% L = (M + S)/2, R = (M-S)/2 +y(:,1) = (x(:,1)+x(:,2))/2; % left channel +y(:,2) = (x(:,1)-x(:,2))/2; % right channel + +end \ No newline at end of file diff -r 000000000000 -r 4fd284285159 aux/aif2wav.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/aux/aif2wav.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,12 @@ +function aif2wav(foldername) +% AIF2WAV converts .aiff files in folder 'foldername' to .wav files. +% +% by Brecht De Man at Centre for Digital Music, 10 June 2013 + +list = dir([foldername '/*.aiff']); +for i = 1:length(list) + [x,fs] = audioread([foldername '/' list(i).name]); + audiowrite([foldername '/' list(i).name(1:end-5) '.wav'],x,fs); +end + +end \ No newline at end of file diff -r 000000000000 -r 4fd284285159 aux/batchResample.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/aux/batchResample.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,40 @@ +function [] = batchResample(foldername, fsnew, bitDepth) +% BATCH RESAMPLE converts sample rate of all files in folder. +% +% by Brecht De Man at Centre for Digital Music on 13 April 2014 + +% TODO read sampling rate without reading whole file + + if nargin <3 + bitDepth = 24; + end + + currentfolder = pwd; + cd(foldername); % go to specified folder + % go over all wav files in this folder + files = dir('*.wav'); + + % remove hidden files from list + % see http://www.mathworks.co.uk/matlabcentral/newsreader/view_thread/258220 + for k = length(files):-1:1 + fname = files(k).name; + if fname(1) == '.' + files(k) = [ ]; + end + end + + for k=1:length(files) + disp(['Reading ' files(k).name '...']); + + [audio,fs] = audioread(files(k).name); % read audio + + if fs==fsnew + warning('Sampling rate of original audio file is equal to current sampling rate'); + else + resampledAudio = resample(audio, fsnew, fs); + audiowrite([files(k).name],resampledAudio, fsnew, 'BitsPerSample', bitDepth); + end + end + cd(currentfolder); % go back to original folder + +end \ No newline at end of file diff -r 000000000000 -r 4fd284285159 aux/clipfade.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/aux/clipfade.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,50 @@ +function clipfade(folder, startTime, endTime, fs) +% CLIPFADE clips and fades a fragment [start end] of all audio files in +% a folder. +% +% folder: path to all audio files (automatically selected) +% start: start time in seconds +% end: end time in seconds +% +% by Brecht De Man at Centre for Digital Music on 25 October 2013 + +if nargin < 4 + fs = 96000; +end + +fadeTime = 1; % fade time in seconds +bitDepth = 16; +slash = '/'; % depending on OS + +%newFolder = 'Clips'; % folder where output files will be stored +% MODIFICATION: store in place, do not keep unclipped files! + +% list all audio files +list = dir([folder slash '*.wav']); + +% make new folder if not present yet +% if ~exist([folder slash newFolder], 'dir') % make output folder if not there +% mkdir(folder, newFolder); +% end + +for i = 1:length(list) + if strcmp(list(i).name, 'bounce.wav') + %disp([' ' folder slash list(i).name]); % DEBUG + + [audio,fsfile] = audioread([folder slash list(i).name], [startTime*fs+1 endTime*fs]); % read part of file + assert(fsfile == fs); % check file has expected sampling rate + + Nfade = fadeTime*fs; % make fade vector (based on sampling rate) + fadeVector = [(1:Nfade)/Nfade ones(1,length(audio)-2*Nfade) (Nfade:-1:1)/Nfade]; + + % apply fading and write to new folder + if size(audio,2) == 2 % if stereo + audiowrite([folder slash list(i).name], ... %[folder slash newFolder slash list(i).name] + [fadeVector'.*audio(:,1) fadeVector'.*audio(:,2)], fs, 'BitsPerSample', bitDepth); + else % if mono + audiowrite([folder slash list(i).name], ... %[folder slash newFolder slash list(i).name] + fadeVector'.*audio, fs, 'BitsPerSample', bitDepth); + end + + end +end \ No newline at end of file diff -r 000000000000 -r 4fd284285159 aux/finddouble.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/aux/finddouble.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,25 @@ +function finddouble(foldername) +% FINDDOUBLE spots doubles of audio files in the same folder +% +% by Brecht De Man at Centre for Digital Music on 15 July 2013 + +list = dir([foldername '\*.wav']); +sums = length(list)-1; +for i = 1:length(list) + audio = audioread([foldername '\' list(i).name]); + sums(i) = sum(sum(audio.^2)); + % find doubles in this list (method or manual) + % find corresponding audio files; print their names +end + +for i = 1:length(list) + for j = i+1:length(list) + if sums(i) == sums(j) + disp(['ERROR: ' list(i).name ' = ' list(j).name]) + end + end +end + +end + +% TODO: expand to more folders \ No newline at end of file diff -r 000000000000 -r 4fd284285159 aux/loudness_itu.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/aux/loudness_itu.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,104 @@ +function lkfs = loudness_itu(x, fs) +%LOUDNESS_ITU compute loudness (LKFS) based on ITU-R BS.1770-2 +% LOUDNESS_ITU(x, fs, mode) compute loudness based on ITU-R BS.1770-2 +% specification. x is an input signal (mono/stereo/5.1ch) with sampling +% frequency fs. +% +% Input signal has to be either in mono (M), stereo (L and R), or +% 5.1ch(L, R, C, LFE, Ls, and Rs) in respective channel order. +% +% Example: loudness calculation +% [x,fs] = wavread('soundfile.wav'); +% lkfs = LOUDNESS_ITU(x, fs); +% +% 2012-01-06 MARUI Atsushi + +% constants +blockSize = 400; % in ms +overlapSize = 0.75; % in percentage +channelWeights = [1 1 1 0 sqrt(2) sqrt(2)]; % in L, R, C, LFE, Ls, Rs order +absoluteThreshold = -70; % in dB +relativeThreshold = -10; % in dB + +% preparation +if size(x,1)~=length(x) + x = x'; +end +numch = size(x,2); + +if fs~=48000 + x = resample(x, 48000, fs); + fs = 48000; +end + +switch(numch) + case 5 + chwat = channelWeights([1 2 3 5 6]); + otherwise + chwat = channelWeights(1:numch); +end + +% K-filter +B1 = [ + 1.53512485958697 + -2.69169618940638 + 1.19839281085285 + ]; +A1 = [ + 1.0 + -1.69065929318241 + 0.73248077421585 + ]; +B2 = [ + 1.0 + -2.0 + 1.0 + ]; +A2 = [ + 1.0 + -1.99004745483398 + 0.99007225036621 + ]; +y = filter(B2,A2,filter(B1,A1,x)); + +% Mean square +numBlock = ceil(length(y)/ blockSize) + 1; +yy = zeros(numBlock * blockSize, numch); +yy(1:length(y),:) = y; +j = 0:(length(y) - blockSize)/(blockSize * (1-overlapSize)); +z = zeros(length(j), numch); +for n1 = 1:length(j) + yyy = yy(blockSize*j(n1)*(1-overlapSize)+1:blockSize*(j(n1)*(1-overlapSize)+1)+1,:); + z(n1,:) = sum(yyy .^ 2) / blockSize; +end +l = -0.691 + 10*log10(sum(repmat(chwat,length(z),1) .* z, 2)); + +% Gating (absolute) +Jg = l > absoluteThreshold; +zz = repmat(channelWeights(1:numch),length(z),1) .* z; +L_KG = -0.691 + 10*log10(chwat * sum(zz(Jg,:), 1)' / sum(Jg)); + +% Gating (relative) +Gamma_r = L_KG + relativeThreshold; +Jg = l > Gamma_r; +L_KG = -0.691 + 10*log10(chwat * sum(zz(Jg,:), 1)' / sum(Jg)); + +% OPTIONAL: draw pretty figure +if false + t = (blockSize*(j*(1-overlapSize)+1)+1)/fs; + h = plot(t, l, 'color', [.5 .5 .5]); + hold on; + h = line([t(1) t(end)], [L_KG L_KG]); + set(h, 'Color', 'b'); + set(h, 'LineStyle', '--'); + set(h, 'LineWidth', 1); + h = line([t(1) t(end)], [Gamma_r Gamma_r]); + set(h, 'Color', 'b'); + set(h, 'LineStyle', ':'); + set(gca, 'Xlim', [t(1) t(end)]); + hold off; + legend({'momentary', 'integrated', 'relative gate'}); +end + +% output +lkfs = L_KG; \ No newline at end of file diff -r 000000000000 -r 4fd284285159 aux/loudness_match.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/aux/loudness_match.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,33 @@ +function factor = loudness_match (X, fs, lkfs) +%LOUDNESS_MATCH +% LOUDNESS_MATCH (X, fs, lkfs) calculates an amplitude multiplication factor +% which equalizes a sound to match the specified loudness (in LKFS). +% +% 2010-02-23 by MARUI Atsushi + +factor = 1.0; +factorHigh = 10^(+60/20); +factorLow = 10^(-60/20); +i = 1; + +while i + s = loudness_itu(factor * X, fs); + k = (s - lkfs) / lkfs; + + fprintf('%3d: Factor %7.5f LKFS %7.3f (%6.2f%% difference)\n', i, factor, s, k*100); + i = i + 1; + + if abs(k) < 0.001 + return; + end + + if k < 0.0 + factorOld = factor; + factor = (factorLow + factor) / 2.0; + factorHigh = factorOld; + elseif k > 0.0 + factorOld = factor; + factor = (factorHigh + factor) / 2.0; + factorLow = factorOld; + end +end \ No newline at end of file diff -r 000000000000 -r 4fd284285159 aux/mono2stereo.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/aux/mono2stereo.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,19 @@ +function mono2stereo(folder) +% MONO2STEREO join any two mono files in folder ending on 'L' and 'R' to +% one stereo file +% +% by Brecht De Man at Centre for Digital Music, 22 May 2013 + +list = dir([folder '/*.wav']); +for i = 2:length(list) + if strcmp(list(i).name(1:end-4), [list(i-1).name(1:end-5) 'R']) + if strcmp(list(i-1).name(1:end-4), [list(i).name(1:end-5) 'L']) + [L,fs] = audioread([folder '/' list(i-1).name]); + R = audioread([folder '/' list(i).name]); + audiowrite([folder '/' list(i).name(1:end-5) '.wav'], [L,R], fs, 'BitsPerSample', 24); + delete([folder '/' list(i-1).name], [folder '/' list(i).name]); % delete original files + end + end +end + +end \ No newline at end of file diff -r 000000000000 -r 4fd284285159 aux/prepare2listen.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/aux/prepare2listen.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,40 @@ +function prepare2listen +% PREPARE2LISTEN equalises loudness of files to prepare for +% listening test. +% +% by Brecht De Man at Centre for Digital Music, 5 June 2013 + +folder = '/Users/Brecht/Documents/MATLAB/McGillTest2014/listeningTest/AUDIO/SR2_UnderACoveredSky/Clips/'; +newfolder = 'equalloudness'; +list = dir([folder '/*.wav']); +slash = '/'; + +% open files and calculate minimum loudness +MIN = 0; +x = struct([]); +for i = 1:length(list) + disp([folder newfolder slash list(i).name]); % DEBUG + [x{i}.audio,fs] = audioread([folder list(i).name]); + x{i}.loudness = loudness_itu(x{i}.audio, fs); + MIN = min(MIN, floor(x{i}.loudness)); % compute minimum loudness +end + +% make folder +if ~exist([folder 'equalloudness'], 'dir') % make folder 'equalloudness' if not there + mkdir(folder, 'equalloudness'); +end + +% equalise loudness +MAX = 0; +for i = 1:length(list) + x{i}.equalised = loudness_match(x{i}.audio, fs, MIN)*x{i}.audio; + MAX = max(MAX, max(max(abs(x{i}.equalised)))); +end + +% normalise (keeping relative loudness) and save +for i = 1:length(list) + audiowrite([folder newfolder '\' list(i).name], x{i}.equalised/MAX, ... + fs, 'BitsPerSample', 24); +end + +end \ No newline at end of file diff -r 000000000000 -r 4fd284285159 aux/removesilent.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/aux/removesilent.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,23 @@ +function removesilent(foldername) +% REMOVESILENT removes audiofiles in folder that are silent +% (compares maximum value against small number) +% +% by Brecht De Man at Centre for Digital Music on 15 July 2013 + +MIN = 0.001; +WARNING = 0.1; + +list = dir([foldername '/*.wav']); +for i = 2:length(list) + [audio,fs] = audioread([foldername '/' list(i-1).name]); + S = max(max(audio.^2)); % max of squared values over all channels + if S < MIN % if empty + delete([foldername '/' list(i-1).name]); % remove this audio file + fprintf('''%s'' removed (maximum squared value = %f < %f).', list(i-1).name, S, MIN); + else if S < WARNING + fprintf('''%s'': maximum squared value = %f < %f.', list(i-1).name, S, WARNING); + end + end +end + +end \ No newline at end of file diff -r 000000000000 -r 4fd284285159 aux/stereo2mono.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/aux/stereo2mono.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,34 @@ +function [] = stereo2mono(foldername) +% STEREO2MONO Turns all stereo WAV files in a specified folder into two +% mono WAV files, named origfilename_L.wav and origfilename_R.wav +% +% written by Brecht De Man at C4DM,QMUL on 26 April 2013 + +currentfolder = pwd; +cd(foldername); % go to specified folder +% go over all wav files in this folder +files = dir('*.wav'); + +% remove hidden files +% see http://www.mathworks.co.uk/matlabcentral/newsreader/view_thread/258220 +for k = length(files):-1:1 + fname = files(k).name; + if fname(1) == '.' + files(k) = [ ]; + end +end + +for k=1:length(files) + disp(['Reading' files(k).name '...']); + + % TODO: check stereo without reading file + [audio,fs] = audioread(files(k).name); % read audio + % check if stereo; if so, get channels and save as separate wavfile + if size(audio,2)==2 + audiowrite([files(k).name(1:end-4) '_L.wav'],audio(:,1),fs, 'BitsPerSample', 24); + audiowrite([files(k).name(1:end-4) '_R.wav'],audio(:,2),fs, 'BitsPerSample', 24); + end +end +cd(currentfolder); % go back to original folder + +end \ No newline at end of file diff -r 000000000000 -r 4fd284285159 listeningTest/AUDIO/counting/0.wav Binary file listeningTest/AUDIO/counting/0.wav has changed diff -r 000000000000 -r 4fd284285159 listeningTest/AUDIO/counting/1.wav Binary file listeningTest/AUDIO/counting/1.wav has changed diff -r 000000000000 -r 4fd284285159 listeningTest/AUDIO/counting/10.wav Binary file listeningTest/AUDIO/counting/10.wav has changed diff -r 000000000000 -r 4fd284285159 listeningTest/AUDIO/counting/2.wav Binary file listeningTest/AUDIO/counting/2.wav has changed diff -r 000000000000 -r 4fd284285159 listeningTest/AUDIO/counting/3.wav Binary file listeningTest/AUDIO/counting/3.wav has changed diff -r 000000000000 -r 4fd284285159 listeningTest/AUDIO/counting/4.wav Binary file listeningTest/AUDIO/counting/4.wav has changed diff -r 000000000000 -r 4fd284285159 listeningTest/AUDIO/counting/5.wav Binary file listeningTest/AUDIO/counting/5.wav has changed diff -r 000000000000 -r 4fd284285159 listeningTest/AUDIO/counting/6.wav Binary file listeningTest/AUDIO/counting/6.wav has changed diff -r 000000000000 -r 4fd284285159 listeningTest/AUDIO/counting/7.wav Binary file listeningTest/AUDIO/counting/7.wav has changed diff -r 000000000000 -r 4fd284285159 listeningTest/AUDIO/counting/8.wav Binary file listeningTest/AUDIO/counting/8.wav has changed diff -r 000000000000 -r 4fd284285159 listeningTest/AUDIO/counting/9.wav Binary file listeningTest/AUDIO/counting/9.wav has changed diff -r 000000000000 -r 4fd284285159 listeningTest/CITATION.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/CITATION.txt Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,7 @@ + +@conference{deman2014b, + Author = {Brecht De Man and Joshua D. Reiss}, + Booktitle = {136th Convention of the Audio Engineering Society}, + Month = {April}, + Title = {APE: Audio Perceptual Evaluation toolbox for MATLAB}, + Year = {2014}} diff -r 000000000000 -r 4fd284285159 listeningTest/COPYING.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/COPYING.txt Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,7 @@ +When using any part of this toolbox, please acknowledge by referencing: +B. De Man and J. D. Reiss, "APE: Audio Perceptual Evaluation toolbox for MATLAB," 136th Convention of the Audio Engineering Society, 2014. + + +"If you have code and datasets in the same repository, include +both the code licence and the relevant Creative Commons link and make +it clear which things they apply to." \ No newline at end of file diff -r 000000000000 -r 4fd284285159 listeningTest/MANUAL.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/MANUAL.txt Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,74 @@ +Manual to go with the APE Perceptual Evaluation toolbox +by Brecht De Man + +When using any part of this toolbox, please acknowledge by referencing: +B. De Man and J. D. Reiss, "APE: Audio Perceptual Evaluation toolbox for MATLAB," 136th Convention of the Audio Engineering Society, 2014. + +INTERRUPT SESSION +To end the test and close the window without finishing the test, type +>> close all force; +in the console. + + +SESSION SCRIPTS, TEST CONFIGURATION AND SOUND LISTS +To start session, type ‘launch’. +Select a session script (e.g. ‘_DEMOSCRIPT.txt’) and type your ID. +The session script references the sound list, and subsequently the method of testing and the test configuration to be used, e.g.: + +sndList _oneEight.txt % loads the sounds specified in _oneEight.txt +multiComp _multiComp.txt % loads the configuration specified in _multiComp.txt + + + + +INITIAL ORDER OF SAMPLES +Option A: random positions + + +Option B: initial positions + + + +FIXED REFERENCE AND ANCHOR SAMPLES +In the sound list, add a reference and/or anchor sample. If the reference/anchor sample should also be 'hidden', i.e. part of the samples that aren't marked as 'reference', then this sample should be featured in the sound list twice:ß +DIRECTORY: /Users/John/Music/TestAudio/ +HQreference.wav +anchor.wav +variation1.wav +variation2.wav +variation3.wav +HQreference.wav +anchor.wav + +Then, in the configuration file you can add the initial position on the scale(s), like so: +COMBINATIONS +1 position +2 position +3 position +4 position +5 position +6 reference position 100 +7 reference position 0 + +Typically, the reference samples should receive the highest possible rating, and the anchors are very low quality. + + +LOUDNESS EQUALISATION +Use the function ‘prepare2listen.m’ (which uses ‘loudness_match.m’ and ‘loudness_itu.m’) to equalise loudness of all files in a folder. Alternatively, use another loudness standard, or + + +PROBLEMS +Since the interface was originally inspired by V. Rioux’s interface (2000) but heavily deviated, some code will be redundant or not structured properly. +The toolbox is a work in progress and is the result of the design of a number of listening tests related to audio engineering and music production. It is by no means finished or bug-free, but will be continually updated. +Comments and corrections of any kind are most welcome. + + +TO ADD +The following features will be added over time, but haven't been added yet. +- Reference/anchor check: only allow submitting the rating when at least one sample is rated minimum/maximum/below a certain value/above a certain value. +- Markers outside of the scale when they haven't been used yet +- Add arbitrary percentage marks on scale (e.g. 20%, 40%, 40%, 80%) in the form of vertical lines +- Make directory in sound list a relative path +- Some sort of results sneak peak: for every test, save results to a .mat file, and provide methods for quick box plot and other analysis (for all results thus far/selection of results) +- Auto-check if a marker was even moved at all +- Modify loudness scripts: P. D. Pestana, J. D. Reiss, and A. Barbosa, “Loudness Measurement of Multitrack Audio Content Using Modifications of ITU-R BS.1770,” Audio Engineering Society Convention 134, 2013. \ No newline at end of file diff -r 000000000000 -r 4fd284285159 listeningTest/README.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/README.txt Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,10 @@ +APE Perceptual Evaluation +Listening test toolbox + +See MANUAL.txt for notes on how to use. +See CITATION.txt for referencing if you use this toolbox for your work. + +to be added: +"describes the project, includes authorship credits, +copyrights, etc and tells people to look at the COPYING and CITATION +files if they want more details." \ No newline at end of file diff -r 000000000000 -r 4fd284285159 listeningTest/_DEMOSCRIPT.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/_DEMOSCRIPT.txt Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,5 @@ +sndList _oneEight.txt +multiComp _multiComp.txt + +sndList _oneThree.txt +pairComp _pairComp.txt \ No newline at end of file diff -r 000000000000 -r 4fd284285159 listeningTest/_fourSix.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/_fourSix.txt Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,4 @@ +DIRECTORY: /Users/Brecht/Documents/MATLAB/APE/listeningTest/AUDIO/counting/ +4.wav +5.wav +6.wav \ No newline at end of file diff -r 000000000000 -r 4fd284285159 listeningTest/_multiComp.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/_multiComp.txt Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,26 @@ +NAME +multiple comparison 1D test +NBSCALES: 2 +NBSOUNDS: 8 +COMBINATIONS +1 position +2 position +3 position +4 position +5 position +6 position +7 position +8 position +SCALES +SCALE: +Clarity +LEVEL +min 0 Low +max 100 High +step 1 +SCALE: +Loudness +LEVEL +min 0 Low +max 100 High +step 1 \ No newline at end of file diff -r 000000000000 -r 4fd284285159 listeningTest/_oneEight.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/_oneEight.txt Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,9 @@ +DIRECTORY: /Users/Brecht/Documents/MATLAB/APE/listeningTest/AUDIO/counting/ +1.wav +2.wav +3.wav +4.wav +5.wav +6.wav +7.wav +8.wav \ No newline at end of file diff -r 000000000000 -r 4fd284285159 listeningTest/_oneThree.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/_oneThree.txt Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,4 @@ +DIRECTORY: /Users/Brecht/Documents/MATLAB/APE/listeningTest/AUDIO/counting/ +1.wav +2.wav +3.wav \ No newline at end of file diff -r 000000000000 -r 4fd284285159 listeningTest/_pairComp.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/_pairComp.txt Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,11 @@ +% pair comparison specifications +NAME +pair comparison test #1 +NBSOUNDS: 3 +REPETITIONS?: 1 +NBQUESTIONS: 3 +QUESTIONS +2 A +1 B +0 A=B +COMMENTS?: 1 \ No newline at end of file diff -r 000000000000 -r 4fd284285159 listeningTest/_sevenNine.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/_sevenNine.txt Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,4 @@ +DIRECTORY: /Users/Brecht/Documents/MATLAB/APE/listeningTest/AUDIO/counting/ +7.wav +8.wav +9.wav \ No newline at end of file diff -r 000000000000 -r 4fd284285159 listeningTest/_testscript.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/_testscript.txt Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,8 @@ +sndList _oneThree.txt +multiComp _multiComp.txt + +sndList _fourSix.txt +multiComp _multiComp.txt + +sndList _sevenNine.txt +multiComp _multiComp.txt \ No newline at end of file diff -r 000000000000 -r 4fd284285159 listeningTest/auxiliaries/checkin.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/auxiliaries/checkin.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,1 @@ +function [wasthere,value]=checkin(varName,defaultValue,fieldName) %checkin(varName,defaultValue,fieldName)=[wasthere,value] % % check if the variable exist or isempty % in such cases set it to the defaultvalue % and return 0 else return 1 (the variable was not there!) % value return the value (use if you want to fill an other variable... % % OBS! when no output return wasthere, when 1 output return value!!! % when 2 outputs return [wasthere,value] % Vincent Rioux (1997) % vr@ta.chalmers.se if ~exist('fieldName') fieldName=''; isField=0; else isField=1; end % --------------- DOES THE VARIABLE/FIELD NON EXIST/EMPTY ?? existexp=sprintf('exist(''%s'')',varName); isemptyexp=sprintf('isempty(%s)',varName); if ~evalin('caller',existexp) if ~nargout assignin('caller',varName,defaultValue); end wasthere=0; value=defaultValue; else % ------------------ DOES THE FIELD IS ALSO A VARIABLE ?? % ----- then set the defaultValue to the actual variable non empty value isFieldVar=0; ifFieldVar=sprintf('exist(''%s'')',fieldName); if evalin('caller',ifFieldVar) ifFieldVar=sprintf('isempty(%s)',fieldName); isFieldVar=1; if ~evalin('caller',ifFieldVar) defaultValue=evalin('caller',sprintf('%s',fieldName)); isFieldVar=1; end end % --------------- IS THE VARIABLE A STRUCTURE ?? isstructvar=sprintf('isstruct(%s)',varName); % ----------------------- NO if ~evalin('caller',isstructvar) if evalin('caller',isemptyexp) % if ~nargout % assignin('caller',varName,defaultValue); modif sept 98 % end assignin('caller',varName,defaultValue); value=evalin('caller',sprintf('%s',varName)); wasthere=0; value=defaultValue; else wasthere=1; if (isFieldVar | isField) value=defaultValue; else value=evalin('caller',sprintf('%s',varName)); end end else % ------------------------- YES isitfield=sprintf('isfield(%s,''%s'')',varName,fieldName); if evalin('caller',isitfield) fielVar=sprintf('%s.%s',varName,fieldName); isemptyField=sprintf('isempty(%s)',fielVar); FieldAlsoInputVar=sprintf('checkin(''%s'','''')',fieldName); [isFieldAlsoInputVar,value]=evalin('caller',FieldAlsoInputVar); if isFieldAlsoInputVar wasthere=2; % field was there and variable in caller workspace also -> the last WIN!!! else if evalin('caller',isemptyField) wasthere=0; value=defaultValue; else wasthere=1; value=evalin('caller',fielVar); end end else wasthere=0; value=defaultValue; end end end if nargout==1 wasthere=value; end \ No newline at end of file diff -r 000000000000 -r 4fd284285159 listeningTest/auxiliaries/combnk.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/auxiliaries/combnk.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,62 @@ +function c = combnk(v,k) +%COMBNK All combinations of the N elements in V taken K at a time. +% C = COMBNK(V,K) produces a matrix, with K columns. Each row of C has +% K of the elements in the vector V. C has N!/K!(N-K)! rows. + +% B.A. Jones 2-17-95 +% Copyright (c) 1993-98 by The MathWorks, Inc. +% $Revision: 2.8 $ $Date: 1998/05/28 20:13:55 $ + +[m, n] = size(v); + +if min(m,n) ~= 1 + error('First argument has to be a vector.'); +end + +if n == 1 + n = m; + flag = 1; +else + flag = 0; +end + +if n == k + c = v(:)'; +elseif n == k + 1 + tmp = v(:)'; + c = tmp(ones(n,1),:); + c(1:n+1:n.*n) = []; + c = reshape(c,n,n-1); +elseif k == 1 + c = v.'; +elseif n < 17 & (k > 3 | n-k < 4) + rows = 2.^(n); + ncycles = rows; + + for count = 1:n + settings = (0:1); + ncycles = ncycles/2; + nreps = rows./(2*ncycles); + settings = settings(ones(1,nreps),:); + settings = settings(:); + settings = settings(:,ones(1,ncycles)); + x(:,n-count+1) = settings(:); + end + + idx = x(find(sum(x') == k),:); + [nrows,junk]= size(idx); + [rows,cols] = find(idx'); + c = reshape(v(rows),k,nrows)'; +else + P = []; + if flag == 1, + v = v'; + end + if k < n & k > 1 + for idx = 1:n-k+1 + Q = combnk(v(idx+1:n),k-1); + P = [P; [v(ones(size(Q,1),1),idx) Q]]; + end + end + c = P; +end diff -r 000000000000 -r 4fd284285159 listeningTest/auxiliaries/eol.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/auxiliaries/eol.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,11 @@ +function eol(fid) + +% eol(fid) +% write the appropriate end of line sings for text editor - platform dependent +if findstr('PC',computer) + fwrite(fid,[13 10],'char'); +else + fprintf(fid,'\n'); +end + + diff -r 000000000000 -r 4fd284285159 listeningTest/launch.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/launch.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,129 @@ +function launch(sesScript,noTst) +% launch a session script composed of a succession of single tests +% sesScript: session script name if recalling old script (optional) +% noTst: start from specified test (optional) +% +% by Brecht De Man at Centre for Digital Music, 12 January 2014 + +% make sure you are in listening test folder +cdFolder = which('launch'); +cdFolder = cdFolder(1:end-8); % remove 'launch.m' from string +cd(cdFolder); + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Interface +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +cd0=cd; % save path + +% Choose Session +if ~exist('sesScript', 'file') % if sesScript was not provided or doesn't exist + [sesScript,cdScript]=uigetfile('*.txt','Please enter a session script'); + if ~sesScript % if still not provided + return % exit + end +else + cdScript=cd0; % folder of script is same as folder of listening test +end + + +% Enter name and check ID is not already used... +ASK=1; +reREAD=0; +while ASK + prompt={'Please enter your name or any ID : '}; + def={'myID'}; + title='ID'; + lineNo=1; + answer=inputdlg(prompt,title,lineNo,def); + if isempty(answer) + return + end + id=answer{1}; % from cell to string + + % if name already present, return to former test + d=dir('responses'); + ASK=0; + for noF=1:length(d) + name=strtok(d(noF).name,'.'); + if strcmp(name,answer) + switch lower(questdlg('This ID is already used. Do you wish to re-use it?')) + case 'yes' + cd('responses'); + ASK=0; + expre=sprintf('load %s',id); + eval(expre); + expre=sprintf('tstDat=%s.tstDat;',id); % read mat-file + eval(expre); + reREAD=1; + cd('../'); + break; + case {'no','cancel'} + ASK=1; + break; + end + end + end +end + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Read the script and create tstdat +% IF THE TEST WAS DONE ALREADY ONCE, THE .MAT FILE IS USED INSTEAD (see above) +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +if ~reREAD + cd(cdScript); + tstDat=[]; + fid=fopen(sesScript,'r'); + while ~feof(fid) % read until end of session file + lin=fgetl(fid); + [fil1,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin,'%s',1); + if COUNT + if ~strcmp(fil1(1),'%') % if not a comment + [fil2,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin(NEXTINDEX:end),'%s',1); + tstDat{end+1}.tstType=fil1; % what type of test? + tstDat{end}.tstFile=fil2; % test file? + end + end + end + fclose(fid); + + % ensure even length (sound list for every test) + if mod(length(tstDat),2) + warning('Uneven number of lines in session script. '); + % randomise order of tests + else + testPerm = randperm(length(tstDat)/2); + tstDatCopy = tstDat; + for t = 1:length(tstDat)/2 + tstDat{2*t-1} = tstDatCopy{2*testPerm(t)-1}; + tstDat{2*t} = tstDatCopy{2*testPerm(t)}; + end + end +end + +cd(cd0); % back to listening test folder + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Set session variables +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +sesDat.sesScript=sesScript; +sesDat.id=id; +sesDat.tstDat=tstDat; +sesDat.reREAD=reREAD; +sesDat.noTst=1; +sesDat.nbTst=length(tstDat); +sesDat.date=datestr(now); +sesDat.cuSndListFile=[]; +sesDat.cuSndList=[]; + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Start test +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% load the sndlist +if sesDat.noTst>1 % where were we? + sesDat.noTst=noTst-1; % IS THIS RIGHT? + sndList(sesDat); +else % always start with first test (allow changing earlier stuff if desired) + expr=sprintf('%s(sesDat);',tstDat{1}.tstType); + eval(expr); +end \ No newline at end of file diff -r 000000000000 -r 4fd284285159 listeningTest/multiComp/MmoveW.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/multiComp/MmoveW.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,21 @@ +function MmoveW(hf) + +dat=get(hf,'userdata'); + +if dat.drag + cobj=get(gcf,'currentobject'); + if strcmp(get(cobj,'tag'),'sonicon') + cpos=get(gcf,'currentpoint'); + posObj=get(cobj,'position'); + dxx=dat.dxx; + cp=cpos(1); + if (cp1-dxx) + cp=1-dxx; + end + posObj(1)=cp-posObj(3)/2; + set(cobj,'position',posObj); + end +end diff -r 000000000000 -r 4fd284285159 listeningTest/multiComp/MpushIc.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/multiComp/MpushIc.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,58 @@ +function MpushIc(hf) + +sel=get(hf,'selectiontype'); +dat=get(hf,'userdata'); +drag=dat.drag; + +obj=get(gcf,'currentobject'); +sndId=get(obj,'userdata'); + +switch sel + + case 'normal' + % BRECHT: log plays in response log + fidInd=['responses/' dat.sesDat.id,'_',dat.sesDat.sesScript]; + fid=fopen(fidInd,'a'); + fprintf(fid,'%i ', sndId); + dat.playVec(sndId,1) = 1; % check sample as 'played' + set(hf,'userdata',dat); % write dat away already here (avoid 'not all sounds played') + + set(dat.hIcon,'backgroundcolor',[.6 .9 .6]); % all icons turn green + if(obj<=dat.nbScale*(dat.nbSnd+4)+1) % value depends on number of sounds (avoid 'Stop Audio' becoming red) + set(obj,'backgroundcolor','r'); + end + playSound(dat.sesDat.cuSndList(sndId)); + + + case 'alt' % right mouse (ctrl+button) + if drag + drag=0; + else + if dat.test.sndRef + if ~isempty(find(dat.test.sndRef==sndId)) + return + end + end + drag=1; + end + + case 'open' % double-click % ? + % BRECHT: log plays in response log + fid=['responses/' dat.sesDat.id,'_',dat.sesDat.sesScript]; + fprintf(fid,'%i', sndId); + dat.vector(sndId,1) = 1; % check sample as 'played' + + obj=get(gcf,'currentobject'); + set(dat.hIcon,'backgroundcolor',[.6 .9 .6]); + set(obj,'backgroundcolor','r'); + playSound(dat.sesDat.cuSndList(get(obj,'userdata'))); + +end + +saveMultiComp(hf); + +try % in case audio is still playing when finishing + dat.drag=drag; + set(hf,'userdata',dat); +catch err +end \ No newline at end of file diff -r 000000000000 -r 4fd284285159 listeningTest/multiComp/MpushW.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/multiComp/MpushW.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,34 @@ +function MpushW(hf,typ) + +switch typ +case '2D' + sel=get(hf,'selectiontype'); + switch sel + + case 'normal' + % create a box + dat=get(hf,'userdata'); + pc=get(hf,'currentpoint'); + + %display box + pos=rbbox([pc(1) pc(2) 0 0]); + x1=pos(1); x2=pos(3)+x1; y1=pos(2); y2=pos(4)+y1; + grp=[]; + for noIc=1:length(dat.hIcon) + posIc=get(dat.hIcon(noIc),'position'); + xic=posIc(1); yic=posIc(2); + if ((xic>x1) & (xicy1) & (yic 1 + titlestr = sprintf('%d screens left',(nbTst-noTst)/2); +else if (nbTst-noTst) > 1 + titlestr = 'One screen left after this'; + else + titlestr = 'Last screen'; + end +end +set(hf,'name',titlestr); +set(gca,'position',[0 0 1 1]); +axis([0 1 0 1]); +set(gca,'yticklabel',[]); +set(gca,'xticklabel',[]); +grid off; +hp=gca; + +set(hp,'color',[.7 .7 .7]); % gray background + +% Figure-event properties +set(hf,'windowbuttonmotionfcn',sprintf('MmoveW(%d)',hf)); +set(hf,'keypressfcn',sprintf('TpushKey(%d)',hf)); + +% Define Scales and SonIcons + +nbScale=length(test.scale); +dY=1/(nbScale+3); % vertical space for each scale+text (used to be +1, now +3) +dX=1; +dyy=dY/2; % vertical space for scale and text +dxx=1/30; % vertical margins of the scale +small=dyy/10; + +% create sonicons +nbSnd=test.nbComb; + +% RANDOM POSITIONS and ALREADY PLAYED +if reREAD && isfield(sesDat.tstDat{noTst}, 'rsl') + permVec = sesDat.tstDat{noTst}.rsl.permVec; + playVec = sesDat.tstDat{noTst}.rsl.playVec; +else + permVec = randperm(nbSnd); + playVec = zeros(nbSnd,1); +end + +fidInd=['responses/' sesDat.id,'_',sesDat.sesScript]; % print permutation in response log +fid=fopen(fidInd,'a'); +fprintf(fid,'\n%s\n', 'Random permutation mapping (comments): '); +for noSnd = 1: nbSnd + fprintf(fid,'%d ', permVec(noSnd)); +end +fprintf(fid,'\n%s\n', ' '); + + +for noScale=1:nbScale + + y=1-noScale*dY; % bottom line + dyt=dyy; % was 3/2* + %display text + h='horizontalAlignment'; + v='verticalAlignment'; + text(.5,y+dyt,test.scale(noScale).name,h,'center',v,'bottom', 'FontSize', 24); % Scale name + % Level names + text(0+small,y+dyt,test.scale(noScale).level{1},h,'left',v,'bottom', 'FontSize', 24); % MINIMUM + text(1-small,y+dyt,test.scale(noScale).level{3},h,'right',v,'bottom', 'FontSize', 24); % MAXIMUM + + % Display 1D rules + y0=y; + y1=y+dyy; + hold on; + fill([dxx dxx 1-dxx 1-dxx],[y1 y0 y0 y1],[.8 .8 .8]); + + + for noSnd=1:nbSnd + + dl=(1-2*dxx)/5; %BDM used to be /nbsnd + xI=dl*noSnd/2; + dxI=dl/10; % width of a sonicon + posIc=[xI y+small dxI dyy-2*small]; + + % position the icons on the default position + % check if the individual data contains already some past results + % + if reREAD && isfield(sesDat.tstDat{noTst}, 'rsl') + posComb=sesDat.tstDat{noTst}.rsl.mat(noScale,noSnd); + else + posComb=test.posComb(noSnd,noScale); + fidInd=['responses/' sesDat.id,'_',sesDat.sesScript]; % print initial placing + fid=fopen(fidInd,'a'); + fprintf(fid,'%f ', test.posComb(noSnd,noScale)); + end + + % Calculate Icon position relative to the screen units + minx=test.scale(noScale).minn; + maxx=test.scale(noScale).maxx; + a=(1-2*dxx)/(maxx-minx); + b=dxx-a*minx; + posIc(1)=posComb*a+b-dxI/2; + + % set handles + hIc=uicontrol('style','text','string',num2str(permVec(noSnd)),'units','normalized','position',posIc); % changed by Brecht: randperm + set(hIc,'buttondownfcn',sprintf('MpushIc(%d)',hf)); + set(hIc,'backgroundcolor', [.6 .9 .6]); % set colour to green + + %%%%%%%%%%%%%%%%%%% ENABLING + set(hIc,'enable','inactive'); + set(hIc,'tag','sonicon'); + + sndId=test.comb(noSnd); + set(hIc,'userdata',sndId); + hIcon(noScale,noSnd)=hIc; + + end + fprintf(fid,'%s\n', ' '); + %shIc= set(hIc); %??? what is this here for? suppress output. + + % set the un-movable references + nbRef=length(test.sndRef); + for noRef=1:nbRef + sndRef=test.sndRef(noRef); + %%%%%%%%%%%%%%%%%%%%%% ENABLING... + set(hIcon(noScale,sndRef),'enable','off'); %% for MAC! may be 'off' for PC?? + set(hIcon(noScale,sndRef),'string','ref'); + end + + +end + + +% create Comments +hcom = struct([]); % create empty struct for comments +if reREAD && isfield(sesDat.tstDat{noTst}, 'rsl') + for noSnd = 1:nbSnd % a comment per sample + posCom=[dxx 6*dY/(nbSnd+2)+3*dY/(nbSnd+2)*(nbSnd - noSnd) 10/15 3*dY/(nbSnd+2)-small]; % [left, bottom, width, height] + commentstr = sesDat.tstDat{noTst}.rsl.hcom{noSnd}; + hcom{noSnd} = uicontrol('style','edit','max',2,'string',commentstr, ... + 'units','normalized','position',posCom, ... + 'HorizontalAlignment', 'left'); + end + + posCom=[dxx small 10/15 6*dY/(nbSnd+2)-small]; % general comments + commentstr = sesDat.tstDat{noTst}.rsl.gcom; + gcom=uicontrol('style','edit','max',2,'string',commentstr, ... + 'units','normalized','position',posCom, 'HorizontalAlignment', 'left'); + + +else % recall comments + for noSnd = 1:nbSnd % a comment per sample + posCom=[dxx 6*dY/(nbSnd+2)+3*dY/(nbSnd+2)*(nbSnd - noSnd) 10/15 3*dY/(nbSnd+2)-small]; % [left, bottom, width, height] + commentstr = sprintf('%d: ', noSnd); + hcom{noSnd} = uicontrol('style','edit','max',2,'string',commentstr, ... + 'units','normalized','position',posCom, ... + 'HorizontalAlignment', 'left'); + end + + posCom=[dxx small 10/15 6*dY/(nbSnd+2)-small]; % general comments + commentstr = sprintf('%s: ', 'General comments'); + gcom=uicontrol('style','edit','max',2,'string',commentstr, ... + 'units','normalized','position',posCom, 'HorizontalAlignment', 'left'); + +end + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% "Stop audio" button +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +posFin=[11/15 3*dY/2 3/15 3*(dY-small)/2]; % [left, bottom, width, height] +hFin=uicontrol('style','pushbutton','string','Stop audio','units','normalized','position',posFin); +set(hFin,'callback',sprintf('MpushIc(%d)',hf)); + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% "Finished" button +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +posFin=[11/15 small 3/15 3*(dY-small)/2]; % [left, bottom, width, height] +hFin=uicontrol('style','pushbutton','string','Finished','units','normalized','position',posFin); +set(hFin,'callback',sprintf('endMultiComp(%d)',hf)); + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Test timer +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +dat.t0=clock; + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Send useful datas +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +dat.dxx = dxx; %? +dat.dxI = dxI; %? +dat.hf = hf; +dat.hcom = hcom; % individual comments +dat.gcom = gcom; % general comments +dat.hIcon = hIcon; +dat.drag = 0; +dat.test = test; +dat.sesDat = sesDat; +dat.playVec = playVec; +dat.permVec = permVec; +dat.nbScale = nbScale; +dat.nbSnd = nbSnd; +set(hf,'userdata',dat) + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% clean up +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +clear all; \ No newline at end of file diff -r 000000000000 -r 4fd284285159 listeningTest/multiComp/readMultiComp.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/multiComp/readMultiComp.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,146 @@ +function tstDat=readMultiComp(testFile) + +% multiple comparison 1D specifications +% +% NAME: +% multicomp test #1 +% +% nbSCALES: 1 +% nbSOUNDS: 3 +% +% COMBINATIONS +% 1 (random position) +% 2 reference position 1 +% 3 position 3 +% +% SCALES +% +% SCALE: +% 1st scale +% MIN: 0 no amount +% MAX: 10 max amount +% STEP: 1 in between +% +% COMMENTS? 1 % ask if a comment field should be displayed (1=yes 0=no) + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%Initialization +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +tstDat.sndRef=[]; +tstDat.posComb=[]; + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% file parsing +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +fid=fopen(testFile,'r'); +while ~feof(fid) + lin=fgetl(fid); + + [word1,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin,'%s',1); + + if (~COUNT | ~strcmp(word1,'%')) + switch upper(word1) + case 'NAME' + tstDat.name=fgetl(fid); + + case 'NBSOUNDS:' + [nbComb,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin(NEXTINDEX:end),'%d',1); + tstDat.nbComb=nbComb; + + case 'NBSCALES:' + [nbScale,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin(NEXTINDEX:end),'%d',1); + tstDat.nbScale=nbScale; + + case 'COMBINATIONS' + for noComb=1:nbComb + lin=fgetl(fid); + if ~isempty(lin) + if lin(1)~='%' + [comb,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin,'%d',1); + tstDat.comb(noComb,:)=comb; + % Read the reference DATA + lin=lin(NEXTINDEX:end); + [stri,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin,'%s',1); + if findstr(lower(stri),'ref') + tstDat.sndRef(end+1)=comb(1); + lin=lin(NEXTINDEX:end); + [stri,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin,'%s',1); + end + % read the sounds default position + if findstr(lower(stri),'pos') + lin=lin(NEXTINDEX:end); + end + [posComb,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin,'%f',inf); + if ~isempty(posComb) % if it IS empty: set randomly! + tstDat.posComb(noComb,:)=posComb; + else + tstDat.posComb(noComb,:)=100*rand(1, tstDat.nbScale); % added by Brecht to allow for random placing + + end + end + end + end + %eol(fid); %BDM??? + case 'SCALES' + % check posRef length + nbRef=length(tstDat.sndRef); + for noRef=1:nbRef + if (length(tstDat.posComb(tstDat.sndRef(noRef),:))~=nbScale) + fprintf(1,'Watch out, the position of reference %d are not specified for all scale',noRef); + end + end + for noScale=1:nbScale + + while ~feof(fid) + lin=fgetl(fid); + [header,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin,'%s',1); + switch firstWord(header) + case 'SCALE:' + name=fgetl(fid); + case 'min' + lin=lin(NEXTINDEX:end); + [minn,COUNT,ERRMSG,NEXTINDEX]=sscanf(lin,'%d',1); %% + level{1}=lin(NEXTINDEX:end); %% + case 'max' + lin=lin(NEXTINDEX:end); + [maxx,COUNT,ERRMSG,NEXTINDEX]=sscanf(lin,'%d',1); %% + level{3}=lin(NEXTINDEX:end); %% + case 'step' + lin=lin(NEXTINDEX:end); + [stepp,COUNT,ERRMSG,NEXTINDEX]=sscanf(lin,'%d',1); %% + level{2}=lin(NEXTINDEX:end); %% + break + end + + end + tstDat.scale(noScale).name=name; + tstDat.scale(noScale).maxx=maxx; + tstDat.scale(noScale).minn=minn; + tstDat.scale(noScale).stepp=stepp; + tstDat.scale(noScale).level=level; + end + case 'COMMENTS?:' + [COM,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin(NEXTINDEX:end),'%d',1); + tstDat.COM=COM; + end + end +end + +fclose(fid); + + +function word=firstWord(word) + +if ~isempty(word) + if word(1)=='%' + word=''; + end +else + word=''; +end diff -r 000000000000 -r 4fd284285159 listeningTest/multiComp/saveMultiComp.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/multiComp/saveMultiComp.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,62 @@ +function saveMultiComp(hf) % called from 'endmultiComp' or whenever temporarily saved + +dat=get(hf,'userdata'); + +test=dat.test; + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Collect the results into rsl +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +rsl.gcom=strrep(get(dat.gcom,'string'), sprintf('\n'),'; '); % general comments +rsl.hcom=get(struct([]), 'struct'); % empty array of individual comments +rsl.permVec=dat.permVec; +rsl.playVec=dat.playVec; + +nbSnd=test.nbComb; +nbScale=length(test.scale); + +for noScale=1:nbScale + for noSnd=1:nbSnd + rsl.hcom{noSnd}=strrep(get(dat.hcom{noSnd}, 'string'), sprintf('\n'),'; '); % individual comments + posIc=get(dat.hIcon(noScale,noSnd),'position'); + scale=test.scale(noScale); + posx=posIc(1); + dxx=dat.dxx; + dxI=dat.dxI; + minx=scale.minn; + maxx=scale.maxx; + stepp=scale.stepp; + a=(maxx-minx)/(1-2*dxx); + b=minx-a*dxx; + nx=a*(posx+dxI/2)+b; + rsl.mat(noScale,noSnd)=nx; + end +end + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Save it +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +test=[]; +indDat=[]; +sesDat=dat.sesDat; + +test.rsl=rsl; +test.tstFile=sesDat.tstDat{dat.sesDat.noTst}.tstFile; +test.tstType=sesDat.tstDat{dat.sesDat.noTst}.tstType; +test.sndFile=sesDat.cuSndListFile; + +% Create new test data file +sesDat.tstDat{dat.sesDat.noTst}=test; + +% make temporary variable in workspace +assignin('base','multiComp',test); + +% save the individual session +indDat.id=sesDat.id; +indDat.sesScript=sesDat.sesScript; +indDat.tstDat=sesDat.tstDat; +eval(sprintf('%s=indDat;',indDat.id)); +expre=sprintf('save(''responses/%s'',''%s'')',indDat.id,indDat.id); +eval(expre); diff -r 000000000000 -r 4fd284285159 listeningTest/pairComp/PCcheck.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/pairComp/PCcheck.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,14 @@ +function PCcheck(hf,noCheck) + +dat=get(hf,'userdata'); +link=dat.test.link; +hQuest=dat.hQuest; +ha=dat.ha; +hb=dat.hb; +butCol=dat.butCol; + +if link(noCheck) + set(hQuest(link(noCheck)),'value',0); + set(ha,'backgroundcolor',butCol); % set bgcolor back to green + set(hb,'backgroundcolor',butCol); % set bgcolor back to green +end diff -r 000000000000 -r 4fd284285159 listeningTest/pairComp/PCpush.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/pairComp/PCpush.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,27 @@ +function PCpush(hf,but) + +dat=get(hf,'userdata'); +noComb=dat.noComb; +comb=dat.comb; +ha=dat.ha; +hb=dat.hb; +butCol=dat.butCol; + +switch but +case 1 % A + set(ha,'backgroundcolor','r'); + set(hb,'backgroundcolor',butCol); + fidInd=[dat.sesDat.id,'_',dat.sesDat.sesScript]; %print 'A' + fid=fopen(fidInd,'a'); + fprintf(fid,'A'); + playSound(dat.sesDat.cuSndList(comb(noComb,1))); +case 2 % Stop + wavplay(0); +case 3 % B + set(hb,'backgroundcolor','r'); + set(ha,'backgroundcolor',butCol); + fidInd=[dat.sesDat.id,'_',dat.sesDat.sesScript];%print 'B' + fid=fopen(fidInd,'a'); + fprintf(fid,'B'); + playSound(dat.sesDat.cuSndList(comb(noComb,2))); +end \ No newline at end of file diff -r 000000000000 -r 4fd284285159 listeningTest/pairComp/endPairComp.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/pairComp/endPairComp.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,157 @@ +function endPairComp(hf) + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +dat=get(hf,'userdata'); +sesDat=dat.sesDat; +reREAD=sesDat.reREAD; +rsl=dat.rsl; + +noComb=dat.noComb; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% collect datas in .rsl +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +if noComb<=dat.nbComb + if dat.nbQuest + for noQuest=1:dat.nbQuest + rsl.quest(noComb,noQuest)=get(dat.hQuest(noQuest),'value'); +% if(rsl.quest(noComb,noQuest)) +% disp(noQuest); % in case of crash +% end + end + end + if dat.nbScale + for noScale=1:dat.nbScale + rsl.scale(noComb,noScale)=get(dat.hScale(noScale),'value'); + end + end + if dat.COM + rsl.com{noComb}=get(dat.hCom,'string'); + end + + dat.rsl=rsl; + dat.noComb=noComb+1; + set(hf,'name',sprintf('%d tests left / pair #%d/%d',sesDat.nbTst-sesDat.noTst,dat.noComb,dat.nbComb)); + set(hf,'userdata',dat); + + % reLAUNCH the next pair comparison + + if noComb length(svect)-0.5*sFs % if near end + curSample = 1; + end + end + soundID = audioplayer(svect,sFs, 24); % 24 bit, default device + stop(soundID); + play(soundID, curSample); + + + % CLEAN UP + else + curSample = get(soundID,'CurrentSample'); + if length(curSample)<1 % if empty vector (first time) + curSample = 1; + else if curSample > length(snd.vect)-25000 % if near end + curSample = 1; + end + end + soundID = audioplayer(snd.vect,snd.fs, 24); % 24 bit, default device + stop(soundID); + play(soundID, curSample); + end + + % TODO after this: button back to green? + +end \ No newline at end of file diff -r 000000000000 -r 4fd284285159 listeningTest/readTestFile.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/readTestFile.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,128 @@ +function testDat=readTestFile(testFile) +fid=fopen(testFile,'r'); +testDat.sndRef=[]; + + +while ~feof(fid) + lin=fgetl(fid); + [word1,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin,'%s',1); + + if (~COUNT | ~strcmp(word1,'%')) + + switch upper(word1) + + case 'NAME' + testDat.name=fgetl(fid); + + case 'COMBINATIONS:' + [nbComb,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin(NEXTINDEX:end),'%d',1); + testDat.nbComb=nbComb; %% + testDat.posComb=[]; + + for noComb=1:nbComb + lin=fgetl(fid); + if ~isempty(lin) + if lin(1)~='%' + [comb,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin,'%d',2); + testDat.comb(noComb,:)=comb; %% + + % Read the reference DATAS + if COUNT==1 + lin=lin(NEXTINDEX:end); + [stri,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin,'%s',1); + + if findstr(lower(stri),'ref') + testDat.sndRef(end+1)=comb(1); + lin=lin(NEXTINDEX:end); + [stri,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin,'%s',1); + end + + if findstr(lower(stri),'pos') + lin=lin(NEXTINDEX:end); + end + + % read the sounds default position + [posComb,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin,'%f',inf); % position must be specified for each scale!! + if ~isempty(posComb) + testDat.posComb(noComb,:)=posComb'; + end + end + end + end + end + % tricky here! try to satisfy both comp1d and 2d + % requirements of default position of icons + % may be should decompose each case... + + posComb=testDat.posComb; + [nbComb1,nbPos]=size(posComb); + if isempty(nbComb1) + nbComb1=1; + end + if exist('nbScale') + nbPos=nbScale; + end + if nbComb1nbTst) + sesDat.noTst=noTst; + expr=sprintf('%s(sesDat)',sesDat.tstDat{noTst}.tstType); + eval(expr); +end + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Clean up +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +clear; diff -r 000000000000 -r 4fd284285159 listeningTest/soundList/durSnd.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/soundList/durSnd.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,7 @@ +function snd=durSnd(snd) + +% read the sndFile associated with its snd structure and calculate its duration + +[vect,fs]=wavread([snd.path snd.name]); +snd.dur=length(vect)/fs; +clear vect diff -r 000000000000 -r 4fd284285159 listeningTest/soundList/readSndList.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/soundList/readSndList.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,138 @@ +function [snd,listFile,index]=readSndList(listFile,DOWNLOAD,RANDO) + +% readSndList(listFile,DOWNLOAD,RANDO) = [snd,listFile,index] +% +% listFile : name of the ASCII file where all sounds are listed +% DOWNLOAD (0) : load sounds in memory? (1) +% RANDO (0) : sort sounds files in random order? (1) +% +% A soundlist consists in different .wav files name contained in an ASCII file (.txt) preceeded by an index +% - The first line may contain the path for searching all the files or a blank line +% - the ouput is a structure: +% snd(noSnd) +% .vect +% .fs +% .name +% .path +% +% +% if % or * are present, the lines are not taken into account +% if # at beginnning stop the sound list load... +% you can also put an index in front of each sounds +% +% note on directories: +% DIRECTORY: c:\dir1\ for PC +% DIRECTORY: hardisk:dir1: for MAC +% +% cf. makeSndList, playSndList + +checkin('listFile',[]); +checkin('DOWNLOAD',0); +checkin('RANDO',0); + +if isempty(listFile) + [name,pathname]=uigetfile('*.txt','Sound list?'); + if name==0 + return; + end + listFile=name; +else + pathname=''; % current directory + name=listFile; +end + +fid=fopen([pathname name],'r'); +[pathname name] % DEBUG + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% count the number of sound files and save the index list +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +index=[]; +nbSnd=0; +while ~feof(fid) + lin=fgetl(fid); + [l,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin,'%s',inf); + if ((~isempty(l)) & (l(1)~='%') & (l(1)~='*')) + if l(1)=='#' + break; + end + [direc,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin,'%s',1); + if strcmp(upper(direc),'DIRECTORY:'); + pathName=lin(NEXTINDEX+1:end); + else + nbSnd=nbSnd+1; + [ind,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin,'%d',1); + if isempty(ind) + index(nbSnd)=0; + else + index(nbSnd)=ind; + end + end + end +end + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% create the index list and snd list +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +frewind(fid); + +sndName=''; +pathName=''; +newIndex(nbSnd)=0; +index1=find(index~=0); +newIndex(index(index1))=index(index1); +emptyPlaces=find(newIndex==0); +nbL=0; + +while ~feof(fid) + lin=fgetl(fid); + [l,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin,'%s',inf); + if ((~isempty(l)) & (l(1)~='%') & (l(1)~='*')) + [direc,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin,'%s',1); + if strcmp(upper(direc),'DIRECTORY:'); + pathName=lin(NEXTINDEX+1:end); + else + nbL=nbL+1; + [name,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin,'%s',1); + [vol,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin(NEXTINDEX+2:end),'%f',1); +% if isempty(inde) +% inde=emptyPlaces(1); +% if length(emptyPlaces)~=1 +% emptyPlaces=emptyPlaces(2:end); +% end +% end +% if isempty(vol) +% vol=1; +% end + sndName{nbL}=name; + sndPath{nbL}=pathName; + sndVol{nbL}=vol; + end + end +end + +if RANDO + newSort=randperm(nbSnd); +end + +for nooSnd=1:nbSnd + if RANDO + noSnd=newSort(nooSnd); + else + noSnd=nooSnd; + end + + if DOWNLOAD + [snd(noSnd).vect,snd(noSnd).fs]=wavread([pathName sndName{nooSnd}]); + else + snd(noSnd).vect=''; + snd(noSnd).fs=''; + end + snd(noSnd).name=strtok(sndName{nooSnd},'.'); + snd(noSnd).path=sndPath{nooSnd}; + snd(noSnd).listFile=listFile; + snd(noSnd).vol=sndVol{nooSnd}; +end + +fclose(fid); \ No newline at end of file diff -r 000000000000 -r 4fd284285159 listeningTest/soundList/sndList.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/soundList/sndList.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,38 @@ +function sndList(sesDat) +% Load sound file names + +sesDat.cuSndListFile=sesDat.tstDat{sesDat.noTst}.tstFile; + +DOWNLOAD=0; % 1: store sounds in working memory; 0: load on click +sesDat.cuSndList=readSndList(sesDat.cuSndListFile,DOWNLOAD); + +dat.sesDat=sesDat; +rsl.sounds=sesDat.cuSndList; +rsl.duration=0; % duration negligible/irrelevant + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Generate report +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +fid=reportTest(sesDat,rsl,'Loading a SOUND LIST'); + +% sound list names +nbSnd=length(sesDat.cuSndList); +eol(fid); +for noSnd=1:nbSnd + fprintf(fid,'%d -- %s',noSnd,sesDat.cuSndList(noSnd).name);eol(fid) +end +eol(fid); +eol(fid); + +fclose(fid); + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Save test +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +saveTest(dat,rsl,'sndList'); + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Clean up +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +clear all; diff -r 000000000000 -r 4fd284285159 listeningTest/soundList/sndListRand.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/listeningTest/soundList/sndListRand.m Thu Apr 24 23:53:31 2014 +0100 @@ -0,0 +1,61 @@ +function sndListRand(sesDat) + +% Load the sounds files names +% but not in vector forms (for PC only!) +% cf. help readsndlist + +sesDat.cuSndListFile=sesDat.tstDat{sesDat.noTst}.tstFile; + +% % could be changed for and desactivate for MAC is files in system 7 are available +% % linux computers... +% if strcmp(computer,'PCWIN') +% LOADvect=0; +% else +% LOADvect=1; +% end + +LOADvect=0; + +if sesDat.reREAD + sesDat.cuSndList=sesDat.tstDat{sesDat.noTst}.rsl.sounds; +else + sesDat.cuSndList=readSndList(sesDat.cuSndListFile,LOADvect,1); +end + +% sesDat.noTst=sesDat.noTst+1; +% OBS suppose that there is always a next Test after a sound-list loading... + +dat.sesDat=sesDat; +rsl.sounds=sesDat.cuSndList; +rsl.duration='---'; + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% generate a small report file +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +fid=reportTest(sesDat,rsl,'Loading a SOUND LIST'); + +% sound comments +nbSnd=length(sesDat.cuSndList); +eol(fid); +for noSnd=1:nbSnd + fprintf(fid,'%d -- %s',noSnd,sesDat.cuSndList(noSnd).name);eol(fid) +end +eol(fid); +eol(fid); + +fclose(fid); + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% save test +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +saveTest(dat,rsl,'sndList'); + +%expr=sprintf('%s(sesDat);',sesDat.tstDat{sesDat.noTst}.tstType); +%eval(expr); + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Clean up +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +clear all +