Generating sound by multiplying the whole frequency spectrum

3 vues (au cours des 30 derniers jours)
Petros Tsitouras
Petros Tsitouras le 10 Août 2019
Hello everyone, I have analyzed an audio signal and found the fundamental frequency of a note and I multiply this frequency in order to generate other notes. But in a secondary level, I would like to multiply the whole frequency spectrum of the note, not just the fundamental ( to make a more complete sound).
%% _____________________________________________Audio Production
clear all
close all
clc
%___________________Load Audio Signal Analysis Outputs
load('SpecA1.mat') %Frequency Spectrum after the audio analysis / replaced the fundamental frequency
%_________________________________________Ratio Inputs
A = input('Enter a new numerator for the ratio (must be a real, positive number): \A1->(1) \A3->(4) \A4->(3) \A5->(2) \n...');
B = input('Enter a new denominator for the ratio (must be a real, positive number): \A1->(1) \A3->(3) \A4->(2) \A5->(1) \n...');
F=A/B*SpecA1; %multiplication of spectrum
%_____________Generating Damped Oscillation Sound Wave
Fs=44100;
f = linspace(1/Fs, 1000, 2^12);
x = zeros(Fs*4, 1);
delay = round(Fs/F);
b = abs(firls(42, [0 10/delay 20/delay 1], [0 0 1 1]));
a = [1 zeros(1, delay) -0.5 -0.5];
[H,W] = freqz(b, a, f, Fs);
Hf=20*log10(abs(H));
%___________Plotting Frequency Spectrum & Fundamentals
figure;
plot(W, Hf);
title('Spectrum Analysis of Artificial Note');
xlabel('Frequency (Hz)');
ylabel('Amplitude');
xlim([0 1000])
hold on
[pks, locs]=findpeaks(Hf, 'MinPeakProminence', 40, 'MinPeakDistance', F-10);
ylv = ylim;
plot([1;1]*W(locs), ylv(:)*ones(size(pks)))
text(W(locs(1)), pks(1)/2, sprintf('\\leftarrow %.1f Hz = Fundamental Frequency',W(locs(1))), 'HorizontalAlignment','left');
hold off
zi = rand(max(length(b),length(a))-1,1);
note = filter(b, a, x, zi);
%_________________________________Play Artificial Note
sound(note,Fs);
%______________________________________________________________End
I am not sure as to what modifications I have to make in order to make this multiplied spectrum be audible.
Thank you very much in advance!

Réponses (0)

Catégories

En savoir plus sur Audio Processing Algorithm Design dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by