Skip to content

Instantly share code, notes, and snippets.

@znxkznxk1030
Created May 11, 2017 16:29
Show Gist options
  • Save znxkznxk1030/b4c1cbc738af61cceb7e1eaf66a22b17 to your computer and use it in GitHub Desktop.
Save znxkznxk1030/b4c1cbc738af61cceb7e1eaf66a22b17 to your computer and use it in GitHub Desktop.
sound specgram
clc; % Clear the command window.
clear; % Clear workspace variable
close all; % Clear figure windows
% original file
file_name = 'input_sound.snd';
file_id = fopen(file_name ,'r');
file_info = dir(file_name);
file_size = file_info.bytes;
input__ = fread(file_id, file_size, 'int16');
% low pass filter file
Lfile_name = 'output_sound1.snd';
file_id = fopen(file_name ,'r');
file_info = dir(file_name);
file_size = file_info.bytes;
low_input = fread(file_id, file_size, 'int16');
% high pass filter file
file_name = 'output_sound2.snd';
file_id = fopen(file_name ,'r');
file_info = dir(file_name);
file_size = file_info.bytes;
high_input = fread(file_id, file_size, 'int16');
% plot & specgram
% original file
figure; plot(input__);
title('input sound plot');
figure; specgram(input__);
title('input sound specgram ');
% low pass filter file
figure; plot(low_input);
title('low-pass sound plot');
figure; specgram(low_input);
title('low-pass sound specgram ');
% high pass filter file
figure; plot(high_input);
title('high-pass sound plot');
figure; specgram(high_input);
title('high-pass sound specgram ');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment