-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#5 Now matlab scripts run correctly with modern matlab #6
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,15 @@ | |
%% Test/demo hacking for CARFAC_SAI Matlab stuff: | ||
|
||
clear variables | ||
clear_old_files = true; | ||
|
||
[status, msg, msgID] = mkdir('frames'); | ||
|
||
if (status && clear_old_files && strcmp(msgID, 'MATLAB:MKDIR:DirectoryExists')) | ||
disp("Clearing old frames"); | ||
delete('frames/*'); | ||
end | ||
|
||
system('mkdir frames'); | ||
|
||
%% | ||
|
||
|
@@ -32,8 +39,8 @@ | |
error('wav file not found') | ||
end | ||
|
||
wav_fn | ||
[file_signal, fs] = wavread(wav_fn); | ||
disp(wav_fn) | ||
[file_signal, fs] = audioread(wav_fn); | ||
|
||
% if fs == 44100 | ||
% file_signal = (file_signal(1:2:end-1, :) + file_signal(2:2:end, :)) / 2; | ||
|
@@ -64,9 +71,5 @@ | |
%% | ||
png_name_pattern = 'frames/frame%05d.png'; | ||
MakeMovieFromPngsAndWav(round(frame_rate), png_name_pattern, ... | ||
wav_fn, ['CARFAC_SAI_movie_', wav_fn(1:end-4), '.mpg']) | ||
|
||
%% | ||
system('rm -r frames'); | ||
|
||
wav_fn, [wav_fn(1:end-4), '.mpg']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use something like |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,36 +24,32 @@ | |
|
||
tic | ||
|
||
file_signal = wavread('../test_data/binaural_test.wav'); | ||
file_signal = audioread('../test_data/binaural_test.wav'); | ||
file_signal = file_signal(9000+(1:15000)); % trim for a faster test | ||
|
||
itd_offset = 22; % about 1 ms | ||
test_signal = [file_signal((itd_offset+1):end), ... | ||
file_signal(1:(end-itd_offset))] / 10; | ||
|
||
CF_struct = CARFAC_Design; % default design | ||
|
||
% Run stereo test: | ||
n_ears = 2 | ||
CF_struct = CARFAC_Init(CF_struct, n_ears); | ||
n_ears = 2; | ||
CF_struct = CARFAC_Design(n_ears); % default design with 2 ears | ||
CF_struct = CARFAC_Init(CF_struct); | ||
|
||
[CF_struct, nap_decim, nap] = CARFAC_Run(CF_struct, test_signal, agc_plot_fig_num); | ||
|
||
% Display results for 2 ears: | ||
for ear = 1:n_ears | ||
smooth_nap = nap_decim(:, :, ear); | ||
figure(ear + n_ears) % Makes figures 3 and 4 | ||
image(63 * ((smooth_nap)' .^ 0.5)) | ||
|
||
% Rectify since nap can go slightly negative. | ||
image(63 * (max(0, smooth_nap)' .^ 0.5)); | ||
Comment on lines
+44
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dick: should we rectify NAP like this or shift it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just saw Dick's comment in another thread, so this should be OK. |
||
colormap(1 - gray); | ||
end | ||
|
||
toc | ||
|
||
% Show resulting data, even though M-Lint complains: | ||
CF_struct | ||
CF_struct.CAR_state | ||
CF_struct.AGC_state | ||
CF_struct; | ||
min_max = [min(nap(:)), max(nap(:))] | ||
min_max_decim = [min(nap_decim(:)), max(nap_decim(:))] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes the behavior of previous code: the previous code always deletes all the images but this one won't delete the images after the computation. Maybe let's move the deletion to the end of the computation?