Skip to content

Commit

Permalink
Merge pull request #37 from sfregosi/dev
Browse files Browse the repository at this point in the history
Dev wispr fix updates
  • Loading branch information
sfregosi authored Mar 4, 2024
2 parents b12dc36 + e49e31e commit 624cb78
Show file tree
Hide file tree
Showing 222 changed files with 24,759 additions and 197 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ agate/draft/
*.cnf
!basestation.cnf
!agate_config_example.cnf
!pmarConvert_config_example.cnf
!pmarConvert_example.cnf
!wisprConvert_example.cnf


# R STUFF #
Expand Down
2 changes: 1 addition & 1 deletion agate/agate.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function agate(missionCnf)
% S. Fregosi <[email protected]> <https://github.com/sfregosi>
%
% FirstVersion: 06 April 2023
% Updated: 01 June 2023
% Updated: 04 March 2024
%
% Created with MATLAB ver.: 9.13.0.2166757 (R2022b) Update 4
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down
78 changes: 78 additions & 0 deletions agate/convertAcoustics/ConvertSoundFile-230629/convertDir.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
% Convert all of the files in a directory to another file format. inTemplate
% determines what files are converted, and outExt determines the output format.

nOutputBits = 16; % you can override below
outExt = '.wav'; % determines output format; you can override below
chans = NaN; % this means read all channels; you can override below
chanStr = ''; % appended to output file name; you can override below
nStrip = 0; % strip this many chars from old filename; can override
if (1)
% WISPR files from bench testing in Hawaii.
% inDir = 'C:\Dave\Hawaii_gliders\operation\sg679_HI_Apr2023\230502\ascent\';
inDir = 'E:\sg679_MHI_May2023\raw_acoustic_data\upper_ascent\left';
% outDir = fullfile(inDir, 'WAV'); % create this first - not auto created
outDir = 'F:\sg679_MHI_May2023\wav\';
inTemplate = '*.dat';
nOutputBits = 24;
elseif (0)
% Files from DCLDE 2022 for Pseudorca det/class.
inDir = 'C:\Dave\sounds\Pseudorca_Hawaii_DCLDE\det\FLAC\cuvier\';
outDir = inDir;

% Enable ONE of the lines below. The first one ('*.flac') handles most
% cases, and the rest of the lines are for handling exceptional cases. Note
% that 'chans' uses CHANNEL NUMBERING STARTING AT 0, so 'chans=4' will get
% what is often elsewhere called channel 5. This channel appears best for
% most 1705 (R/V Lasker) and 1706 (Sette) files.
chans = 4; inTemplate = '*.flac'; % handles most files
%chans = 3; inTemplate = '1706_20170913*.flac';
%chans = 3; inTemplate = '1706_20170918*.flac';
%chans = 3; inTemplate = '1706_20170919*.flac';
% A few files have only 3 channels. The first channel appears best.
%chans = 0; inTemplate = '1706_20170828*.flac';
%chans = 0; inTemplate = '1706_20170829*.flac';
%chans = 0; inTemplate = '1706_2017090*.flac';
%chans = 0; inTemplate = '1706_20170903*.flac';
%chans = 0; inTemplate = '1706_20170904*.flac';
%chans = 0; inTemplate = '1706_20170905*.flac';
%chans = 4; inTemplate = '1706_FLAC_1706_2017091*.flac';%
chanStr = ['-ch' num2str(chans+1)];
elseif (0)
inTemplate = '*.flac';
inDir = 'C:\dave\sounds\GoM2018_HDR\';
outDir = 'C:\dave\sounds\GoM2018_HDR\';
elseif (0)
inTemplate = '*.DAT';
inDir = 'C:\dave\airguns\detectorTest\';
outDir = 'C:\dave\airguns\detectorTest\';
elseif (0)
inTemplate = 'wispr_*.flac';
nOutputBits = 24;
nStrip = 6; % for new filename, strip 6 characters from old filename
inDir = 'C:\dave\LADC-GEMM\data2017\sounds\';
outDir = 'C:\dave\LADC-GEMM\data2017\sounds\';
end

extLen = length(pathExt(inTemplate)); % also strip this many chars from end
fileList = dir(fullfile(inDir, inTemplate));
for fi = 1 : length(fileList)
% Figure out names of input and output files.
inName = fileList(fi).name;
outName = pathFile([inName(nStrip+1 : end-extLen-1) chanStr outExt]);
printf('%3d/%-3d %s', fi, length(fileList), inName)
inFullName = fullfile(inDir, inName);
outFullName = fullfile(outDir, outName);

% Read old file, write new file.
[x,r] = soundIn(inFullName, 0, inf, chans);
if (nOutputBits > 16)
% audiowrite expects sample values in the range of (-1,1].
if ~isempty(x)
audiowrite(outFullName, x / 2^(nOutputBits-1), r, 'BitsPerSample', nOutputBits);
elseif isempty(x)
error('File %s is empty. Skipping...\n', inName);
end
else
soundOut(outFullName, x, r); % only does 16 bits!!!
end
end
210 changes: 210 additions & 0 deletions agate/convertAcoustics/ConvertSoundFile-230629/convertFig.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
function fig = convertFig()
% This is the machine-generated representation of a Handle Graphics object
% and its children. Note that handle values may change when these objects
% are re-created. This may cause problems with any callbacks written to
% depend on the value of the handle at the time the object was saved.
% This problem is solved by saving the output as a FIG-file.
%
% To reopen this object, just type the name of the M-file at the MATLAB
% prompt. The M-file and its associated MAT-file must be on your path.
%
% NOTE: certain newer features in MATLAB may not have been saved in this
% M-file due to limitations of this format, which has been superseded by
% FIG-files. Figures which have been annotated using the plot editor tools
% are incompatible with the M-file/MAT-file format, and should be saved as
% FIG-files.

load convertFig

h0 = figure('Color',[0.8 0.8 0.8], ...
'Colormap',mat0, ...
'FileName','C:\Dave\matlab\MellFilter\convertFig.m', ...
'MenuBar','none', ...
'Name','Resampling filter response', ...
'NumberTitle','off', ...
'PaperPosition',[18 180 576.0000000000001 432.0000000000002], ...
'PaperUnits','points', ...
'Position',[371 253 672 504], ...
'Tag','convertFig', ...
'ToolBar','none');
h1 = axes('Parent',h0, ...
'Box','on', ...
'CameraUpVector',[0 1 0], ...
'CameraUpVectorMode','manual', ...
'Color',[1 1 1], ...
'ColorOrder',mat1, ...
'Position',mat2, ...
'Tag','Axes1', ...
'XColor',[0 0 0], ...
'XLim',[0 200], ...
'XLimMode','manual', ...
'YColor',[0 0 0], ...
'YLim',[-140 5], ...
'YLimMode','manual', ...
'ZColor',[0 0 0]);
h2 = line('Parent',h1, ...
'Color',[0 0 1], ...
'Tag','Axes1Line1', ...
'XData',mat3, ...
'YData',mat4);
h2 = text('Parent',h1, ...
'Color',[0 0 0], ...
'HandleVisibility','off', ...
'HorizontalAlignment','center', ...
'Position',[99.61240310077518 8.879598662207343 17.32050807568877], ...
'String','Frequency response of resampling filter', ...
'Tag','Axes1Text4', ...
'VerticalAlignment','bottom');
set(get(h2,'Parent'),'Title',h2);
h2 = text('Parent',h1, ...
'Color',[0 0 0], ...
'HandleVisibility','off', ...
'HorizontalAlignment','center', ...
'Position',mat5, ...
'String','frequency, Hz', ...
'Tag','Axes1Text3', ...
'VerticalAlignment','cap');
set(get(h2,'Parent'),'XLabel',h2);
h2 = text('Parent',h1, ...
'Color',[0 0 0], ...
'HandleVisibility','off', ...
'HorizontalAlignment','center', ...
'Position',[-17.44186046511628 -68.22742474916389 17.32050807568877], ...
'Rotation',90, ...
'String','dB', ...
'Tag','Axes1Text2', ...
'VerticalAlignment','baseline');
set(get(h2,'Parent'),'YLabel',h2);
h2 = text('Parent',h1, ...
'Color',[0 0 0], ...
'HandleVisibility','off', ...
'HorizontalAlignment','right', ...
'Position',[-31.3953488372093 18.57859531772576 17.32050807568877], ...
'Tag','Axes1Text1', ...
'Visible','off');
set(get(h2,'Parent'),'ZLabel',h2);
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'Callback','convertSoundFile(''doIt'')', ...
'ListboxTop',0, ...
'Position',[299.7931034482759 9.310344827586208 77.58620689655174 60.82758620689656], ...
'String','OK, use this filter', ...
'Tag','Pushbutton1');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'Callback','convertSoundFile(''nChange'')', ...
'ListboxTop',0, ...
'Position',mat6, ...
'String','40', ...
'Style','edit', ...
'Tag','nEdit', ...
'TooltipString','Longer filters have a sharper cut-off but take more execution time');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'HorizontalAlignment','right', ...
'ListboxTop',0, ...
'Position',[138.4137931034483 27.31034482758621 65.79310344827587 12.41379310344828], ...
'String','filter length factor', ...
'Style','text', ...
'Tag','StaticText1', ...
'TooltipString','Longer filters have a sharper cut-off but take more execution time');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'Callback','convertSoundFile(''ratioChange'')', ...
'Position',[41.58620689655173 8.689655172413795 80.68965517241381 58.96551724137932], ...
'String',['1 / 1';'2 / 3';'3 / 4';'4 / 5'], ...
'Style','listbox', ...
'Tag','ratioList', ...
'Value',4);
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'HorizontalAlignment','right', ...
'ListboxTop',0, ...
'Position',mat7, ...
'String','actual sampling rate', ...
'Style','text', ...
'Tag','StaticText1', ...
'TooltipString',mat8);
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'Enable','off', ...
'ListboxTop',0, ...
'Position',mat9, ...
'String','80', ...
'Style','edit', ...
'Tag','actualSRate', ...
'TooltipString',mat10);
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'HorizontalAlignment','right', ...
'ListboxTop',0, ...
'Position',[138.4137931034483 13.03448275862069 65.79310344827587 12.41379310344828], ...
'String','execution time:', ...
'Style','text', ...
'Tag','StaticText1', ...
'TooltipString',mat11);
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'Enable','off', ...
'ListboxTop',0, ...
'Position',mat12, ...
'String','0.00144', ...
'Style','edit', ...
'Tag','timing', ...
'TooltipString',mat13);
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'HorizontalAlignment','left', ...
'ListboxTop',0, ...
'Position',mat14, ...
'String','x real time', ...
'Style','text', ...
'Tag','StaticText1');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'HorizontalAlignment','left', ...
'ListboxTop',0, ...
'Position',[248.896551724138 26.06896551724138 47.79310344827587 12.41379310344828], ...
'String','= 401 points', ...
'Style','text', ...
'Tag','nPointsText');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'Enable','off', ...
'ListboxTop',0, ...
'Position',mat15, ...
'String','80', ...
'Style','edit', ...
'Tag','targetSRate', ...
'TooltipString','This is the sampling rate you asked for.');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'HorizontalAlignment','right', ...
'ListboxTop',0, ...
'Position',mat16, ...
'String','target sampling rate', ...
'Style','text', ...
'Tag','StaticText1', ...
'TooltipString','This is the sampling rate you asked for.');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'HorizontalAlignment','left', ...
'ListboxTop',0, ...
'Position',[16.13793103448276 69.51724137931036 124.7586206896552 12.41379310344828], ...
'String','Interpolate/decimate factors:', ...
'Style','text', ...
'Tag','StaticText1');
if nargout > 0, fig = h0; end
Loading

0 comments on commit 624cb78

Please sign in to comment.