Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

About This Guide

...

...

  • CathedralReverb.wav

  • BatteryBenson.wav

  • format_long_fir_coeffs.m

    View file
    nameformat_long_fir_coeffs.m

  • LongFIRExample.awd

    View file
    nameLongFIRExample.awd

  1. Open MATLAB and run “awe_designer” at the command prompt.

  2. Open LongFIRExample.awd in AWE Designer.

  3. Open the format_long_fir_coeffs.m script in MATLAB

  4. Run the script to process the cavern impulse response WAV file and load the coefficients of the 3 Long FIR modules. You will see the following output, which indicates that the coefficients were scaled down by 45.5 dB. This helps to prevent distortion in the filters. The actual value you see will depend on the WAV file being used.

...

  1. Place the LongFIRExample.awd file, the MATLAB format_long_fir_coeffs.m file, and the two impulse response WAV files in the same folder.

  2. Open the MATLAB application.

  3. At MATLAB’s console, run: awe_designer

    Image RemovedImage Added
  4. When AWE Designer opens, load the LongFIRExample.awd design file.

  5. In MATLAB, open the format_long_fir_coeffs.m script.

  6. Confirm that the designerFile and reverbImpulseRespWav variables are set correctly.

  7. Run the MATLAB script.

  8. If you see this message:

...

Appendix A: MATLAB Script format_long_fir_coeffs.m

% This script file loads an impulse response stored in a WAV file, formats

% the coefficients, and then sends to Audio Weaver. Make sure that you

% have the file whose name is given by the designerFile variable open in Designer.

designerFile = 'LongFIRExample.awd';

% reverbImpulseRespWav = 'CathedralRoom.wav';

reverbImpulseRespWav = 'BatteryBenson.wav';

% Get the location of this .m file on disk

str = mfilename('fullpath');

ind = find(str == filesep);

...

GSYS = get_gsys(fullfile(dirStr, designerFile));

% Get the lengths of the individual filters

L1 = GSYS.SYS.FIR1.L;

L2 = GSYS.SYS.FIR2.L;

% make sure that the size of L3 is an integer multiple of L1 + L2

wavLengthInfo = size(LR);

...

L3Length = floor(wavLength/(L1 + L2)) * (L1 + L2);

% L3PadLength is number of zeroes to add so that L3 is an integer

% multiple of (L1 + L2).

L3PadLength = L1 + L2 - wavLength + L3Length;

% Zero pad or truncate the impulse response

% LR = truncate(LR, L_total);

L = LR(:, 1);

R = LR(:, 2);

% Pick which impulse response to use

fprintf(1,'Using the left channel of %s.\n', reverbImpulseRespWav);

h = L;

zeroes = zeros(L3PadLength, 1);

fprintf(1,'Padding the impulse response %s by %d bytes.\n', reverbImpulseRespWav, L3PadLength);

h = [h; zeroes];

% Scale the impulse response. Keep the peak frequency response value at

% 0 dB

p2 = ceil(log2(length(h)));

...

Hmax = max(abs(H));

h = h / Hmax;

fprintf(1, 'Impulse response scaled by %.1f dB\n', db20(1/Hmax));

% Split into individual filters

h1 = h(1:L1);

h2 = h(L1+1:L1+L2);

h3 = h(L1+L2+1:end);

% Update the coefficients

GSYS.SYS.FIR1.coeffs = h1;

GSYS.SYS.FIR2.coeffs = h2;

% the argument FIR3.L in the awd file needs to be set manually for each

% impulse response WAV file. This try-catch code shows an error message

% if the size is not correct.

length3 = L3Length + L1 + L2;

GSYS.SYS.FIR3.L = length3;

try

GSYS.SYS.FIR3.coeffs = h3;

catch

warning('Make sure the that "L" argument of FIR3 is %d\n', length3);

return

end

% Now send the updated system to Designer

set_gsys(GSYS);

disp('Filter coefficients uploaded.');

Appendix B: References

Echothief Impulse Response Library

http://www.echothief.com/

Fast convolution by FFT

Smith, J.O. "Fourier Theorems for the DFT", in

...

with Audio Applications, Second Edition,

http://ccrma.stanford.edu/~jos/mdft/Fourier_Theorems_DFT.html,

online book, 2007 edition, accessed 02/14/2023.

...