Lab2

pdf

School

Arizona State University *

*We aren’t endorsed by this school

Course

203

Subject

Electrical Engineering

Date

Feb 20, 2024

Type

pdf

Pages

6

Uploaded by MagistrateBison4039

Report
% Convolution reverb in audio processing % Author: Chao Wang % The impulse response of a system/renue/environment is recorded % while a pseudo audio impulse is played, such as a loud clap or any loud % short bang. % The impulse responses of the Milan Opera Hall and St Nicolas Church % are downloaded from http://www.voxengo.com/files/impulses/ % The impulse responses of the Grand Canyon is downloaded from % http://eleceng.dit.ie/dorran/matlab/impulse_responses/ % % Task: Complete and run the script. % The places you need to add code start with a capitized word. close all ; clear all ; % make sure all .wav files are in the same directory of this script % all audio files are sampled at 44100Hz % import, plot and play singing recording % the two parameters returned from audioread are the signal vector and % the sampling frequency [song, fs] = audioread( 'singing.wav' ); % import the song t = [1:length(song)]/fs; % change from vector index number to time subplot(3, 1, 1) % first plot of the three plots in the plot window plot(t, song) % plot the song xlabel( 't (second)' ) ylabel( 'Relative signal strength' ) title( 'Song' ) soundsc(song, fs) % play the song pause % need to press spacebar to continue the progam to listen to next tone % USE the code segment above as an example % now import, plot and play the impulse response % import, plot and play the impulse response [impulse_response, fs_ir] = audioread( 'ScalaMilanOperaHall.wav' ); t_ir = [1:length(impulse_response)]/fs_ir; subplot(3, 1, 2) plot(t_ir, impulse_response) xlabel( 't (second)' ) ylabel( 'Relative signal strength' ) title( 'Impulse Response - ScalaMilanOperaHall' ) soundsc(impulse_response, fs_ir) pause % CONVOLUTE the audio with the system impulse responses % using the command conv(sig1, sig2) and assign the result % to a variable. The convolution could take a couple of seconds % to complete. % Generate the time t vector as shown in the example above. % Plot and play the output as shown in the example above, and % it should sounds as if it was actually recorded in those spaces % CONVOLVE the audio with the system impulse responses
output_song_milan = conv(song, impulse_response); % Generate the time vector for the output t_output_milan = [1:length(output_song_milan)]/fs; % Plot and play the output subplot(3, 1, 3) plot(t_output_milan, output_song_milan) xlabel( 't (second)' ) ylabel( 'Relative signal strength' ) title( 'Output - ScalaMilanOperaHall' ) soundsc(output_song_milan, fs) pause subplot(3, 1, 2)
StNicolasChurch % Convolution reverb in audio processing % Author: Chao Wang % The impulse response of a system/renue/environment is recorded % while a pseudo audio impulse is played, such as a loud clap or any loud % short bang. % The impulse responses of the Milan Opera Hall and St Nicolas Church % are downloaded from http://www.voxengo.com/files/impulses/ % The impulse responses of the Grand Canyon is downloaded from % http://eleceng.dit.ie/dorran/matlab/impulse_responses/ % % Task: Complete and run the script. % The places you need to add code start with a capitalized word. close all ; clear all ; % make sure all .wav files are in the same directory of this script % all audio files are sampled at 44100Hz % import, plot and play singing recording % the two parameters returned from audioread are the signal vector and % the sampling frequency [song, fs] = audioread( 'singing.wav' ); % import the song t = [1:length(song)]/fs; % change from vector index number to time subplot(3, 1, 1) % first plot of the three plots in the plot window plot(t, song) % plot the song xlabel( 't (second)' ) ylabel( 'Relative signal strength' ) title( 'Song' ) soundsc(song, fs) % play the song pause % need to press spacebar to continue the program to listen to the next tone % USE the code segment above as an example % now import, plot and play the impulse response % import, plot and play the impulse response [impulse_response, fs_ir] = audioread( 'StNicolasChurch.wav' ); t_ir = [1:length(impulse_response)]/fs_ir; subplot(3, 1, 2) plot(t_ir, impulse_response) xlabel( 't (second)' ) ylabel( 'Relative signal strength' ) title( 'Impulse Response - StNicolasChurch' ) soundsc(impulse_response, fs_ir) pause % CONVOLUTE the audio with the system impulse responses % using the command conv(sig1, sig2) and assign the result % to a variable. The convolution could take a couple of seconds % to complete. % Generate the time t vector as shown in the example above. % Plot and play the output as shown in the example above, and % it should sound as if it was actually recorded in those spaces
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
% CONVOLVE the audio with the system impulse responses output_song_ StNicolasChurch = conv(song, impulse_response); % Generate the time vector for the output t_output_ StNicolasChurch = [1:length(output_song_ StNicolasChurch )]/fs; % Plot and play the output subplot(3, 1, 3) plot(t_output_milan, output_song_milan) xlabel( 't (second)' ) ylabel( 'Relative signal strength' ) title( 'Output - StNicolasChurch' ) soundsc(output_song_milan, fs) pause subplot(3, 1, 2)
Grand Canyon % Convolution reverb in audio processing % Author: Chao Wang % The impulse response of a system/renue/environment is recorded % while a pseudo audio impulse is played, such as a loud clap or any loud % short bang. % The impulse responses of the Milan Opera Hall and St Nicolas Church % are downloaded from http://www.voxengo.com/files/impulses/ % The impulse responses of the Grand Canyon is downloaded from % http://eleceng.dit.ie/dorran/matlab/impulse_responses/ % % Task: Complete and run the script. % The places you need to add code start with a capitalized word. close all ; clear all ; % make sure all .wav files are in the same directory of this script % all audio files are sampled at 44100Hz % import, plot and play singing recording % the two parameters returned from audioread are the signal vector and % the sampling frequency [song, fs] = audioread( 'singing.wav' ); % import the song t = [1:length(song)]/fs; % change from vector index number to time subplot(3, 1, 1) % first plot of the three plots in the plot window plot(t, song) % plot the song xlabel( 't (second)' ) ylabel( 'Relative signal strength' ) title( 'Song' ) soundsc(song, fs) % play the song pause % need to press spacebar to continue the program to listen to the next tone % USE the code segment above as an example % now import, plot and play the impulse response % import, plot and play the impulse response [impulse_response, fs_ir] = audioread( 'GrandCanyon.wav' ); t_ir = [1:length(impulse_response)]/fs_ir; subplot(3, 1, 2) plot(t_ir, impulse_response) xlabel( 't (second)' ) ylabel( 'Relative signal strength' ) title( 'Impulse Response - GrandCanyon' ) soundsc(impulse_response, fs_ir) pause % CONVOLUTE the audio with the system impulse responses % using the command conv(sig1, sig2) and assign the result % to a variable. The convolution could take a couple of seconds % to complete. % Generate the time t vector as shown in the example above. % Plot and play the output as shown in the example above, and % it should sound as if it was actually recorded in those spaces
% CONVOLVE the audio with the system impulse responses output_song_GrandCanyon = conv(song, impulse_response); % Generate the time vector for the output t_output_GrandCanyon = [1:length(output_song_GrandCanyon)]/fs; % Plot and play the output subplot(3, 1, 3) plot(t_output_GrandCanyon, output_song_GrandCanyon) xlabel( 't (second)' ) ylabel( 'Relative signal strength' ) title( 'Output - GrandCanyon' ) soundsc(output_song_GrandCanyon, fs) pause subplot(3, 1, 2)
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help