I want to get hexadecimal data from the filtered sound wave file. I have recorded voice and done noise filtering. Also the sound wave is converted to text file.Kindly help me

5 visualizzazioni (ultimi 30 giorni)
Here the entire process of code that i have done. Now i need to get hexadecimal data for the filtered sound signal that is plotted.
Fs=1000;
ch=1;
datatype='uint8';
nbits=16;
Nseconds=1;
ID=-1;
recorder=audiorecorder(Fs,nbits,ch,ID);
disp("Start Recording...");
recordblocking(recorder,Nseconds);
disp("End of recording...");
x=getaudiodata(recorder,datatype);
audiowrite('test.wav',x,Fs);
%plot graph of sound wave file
plot(x)
%save as text file
[data, fs] = audioread('test.wav');
save test.txt data -ASCII
%noise reduction
%%1) Load the 'audio_sample.wav' file in MATLAB
[sample_data, sample_rate] = audioread('test.wav');
% a. Plot the signal in time and the amplitude of its frequency
% components using the FFT.
sample_period = 1/sample_rate;
t = (0:sample_period:(length(sample_data)-1)/sample_rate);
subplot(2,2,1)
plot(t,sample_data)
title('Time Domain - Unfiltered Sound')
xlabel('Time (seconds)')
ylabel('Amplitude')
xlim([0 t(end)])
m = length(sample_data); % Original sample length.
n = pow2(nextpow2(m)); % Transforming the length so that the number of
% samples is a power of 2. This can make the transform computation
% significantly faster,particularly for sample sizes with large prime
% factors.
y = fft(sample_data, n);
f = (0:n-1)*(sample_rate/n);
amplitude = abs(y)/n;
subplot(2,2,2)
plot(f(1:floor(n/2)),amplitude(1:floor(n/2)))
title('Frequency Domain - Unfiltered Sound')
xlabel('Frequency')
ylabel('Amplitude')
% b. Listen to the audio file.
% sound(sample_data, sample_rate)
%%2) Filter the audio sample data to remove noise from the signal.
Fs = sample_rate; % Sampling Frequency (Hz)
Fn = Fs/2; % Nyquist Frequency (Hz)
Wp = 40/Fn; % Passband Frequency (Normalised)
Ws = 150/Fn; % Stopband Frequency (Normalised)
Rp = 3; % Passband Ripple (dB)
Rs = 60; % Stopband Ripple (dB)
[n,Ws] = cheb2ord(Wp,Ws,Rp,Rs); % Filter Order
[z,p,k] = cheby2(n,Rs,Ws,'low'); % Filter Design
[soslp,glp] = zp2sos(z,p,k); % Convert To Second-Order-Section For Stability
figure(3)
freqz(soslp, 2^16, Fs) % Filter Bode Plot
filtered_sound = filtfilt(soslp, glp, sample_data);
sound(filtered_sound, sample_rate)
t1 = (0:sample_period:(length(filtered_sound)-1)/sample_rate);
subplot(2,2,3)
plot(t1,filtered_sound)
title('Time Domain - Filtered Sound')
xlabel('Time (seconds)')
ylabel('Amplitude')
xlim([0 t1(end)])
m1 = length(sample_data); % Original sample length.
n1 = pow2(nextpow2(m1)); % Transforming the length so that the number of
% samples is a power of 2. This can make the transform computation
% significantly faster,particularly for sample sizes with large prime
% factors.
y1 = fft(filtered_sound, n1);
f = (0:n1-1)*(sample_rate/n1);
amplitude = abs(y1)/n1;
subplot(2,2,4)
plot(f(1:floor(n1/2)),amplitude(1:floor(n1/2)))
title('Frequency Domain - Filtered Sound')
xlabel('Frequency')
ylabel('Amplitude')
  1 Commento
Walter Roberson
Walter Roberson il 11 Giu 2021
It has been several decades since I last encountered a sound file that was stored as hexadecimal. Long before .wav files were invented. Around 1983.
It is very very unlikely that you want to read hexadecimal data from a sound file.

Accedi per commentare.

Risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by