How do i create a comparison loop of two signals based on their spectral centroid value, with a sliding filter dependant on outcome to balance the amended spectrum
Ältere Kommentare anzeigen
this is currently the code i have where the loop doesnt really do what i'd like, but im not sure how is best to loop it correctly. what i need is to compare spectral centroid (SC) A against spectral centroid B which has been run through a filter the reduce the fundamental frequencies. where SC B is now above SC A then a shelf filter should be run on spectrum B reducing the higher frequencies by 1db to reduce the SC down to the same (or withing a small margin of error) as SC A. ideally the shelf filter would start at the highest frequency and then slide downwards, until the SC are the same. would anybody know a reasonable way of doing this?
%% read audio file
[pop,fs] = audioread("Pop Base.wav");
%% SC of Base sound
centroidA = spectralCentroid(pop,fs);
ScA1 = mean(centroidA);
ScA = ScA1(:,1)
%% Fundamental Reduction
gain1 = -6;
slope1 = 2;
Fc1 = 50;
lowFilt = shelvingFilter(gain1,slope1,Fc1,"lowpass");
%visualize(lowFilt)
popHP = lowFilt(pop);
%outcome called popHP
%% SC of ammended Sound
centroidB = spectralCentroid(popHP,fs);
ScB1 = mean(centroidB);
ScB = ScB1(:,1)
%% loop for spectral sweeping
if ScB > ScA
% apply LP shelf filter
gain2 = -1;
slope2 = 2;
Fc2 = ScA;
highFilt = shelvingFilter(gain2,slope2,Fc2,"highpass");
%visualize(highFilt)
popLP = highFilt(popHP);
centroidB = spectralCentroid(popLP,fs);
ScB1 = mean(centroidB);
ScB = ScB1(:,1)
end
audiowrite("C:\Users\peter.wheeler\OneDrive - Acoustic Consultants\" + ...
"Documents\MATLAB\poptest.wav",popLP,fs)
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Audio Processing Algorithm Design finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!