Im having problems with the reconstruction through two-channel filter bank when I use my audio files.
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Christian Segovia
il 11 Apr 2017
Commentato: Christian Segovia
il 14 Apr 2017
Following these steps: https://es.mathworks.com/help/dsp/examples/reconstruction-through-two-channel-filter-bank.html
With the default audio, all works fine. But when I use my own audio files (audioInput = dsp.AudioFileReader('random.mp3')), the hi and lo coefficients are 0. Any idea?
This is my code, for the analysis part:
audioInput = dsp.AudioFileReader('filename.mp3'); % read the audio file
N = 99; % filters order
[LPAnalysis, HPAnalysis, LPSynthsis, HPSynthesis] = firpr2chfb(N, 0.45);
analysisFilter = dsp.SubbandAnalysisFilter(LPAnalysis, HPAnalysis);
while ~isDone(audioInput)
input = audioInput(); % Load a frame of audio
[hi, lo] = analysisFilter(input);
end
end
0 Commenti
Risposta accettata
Rollin Baker
il 13 Apr 2017
Hi Christian,
The reason you are seeing zeros for your final result is because you are overwriting all previous values for 'hi' and 'lo' every time you go through the loop. This means that when the loop terminates, the values stored in 'hi' and 'lo' will only correspond to the last frame of the audio file. If the last frame of the file has no sound in it, then it makes sense that you would see the zeros.
To avoid this, you will want to keep an array that tracks all the high and low values, and add to it as you loop through each frame. I've included some code below so you can see ho this is done:
audioInput = dsp.AudioFileReader('filename.mp3'); % read the audio file
N = 99; % filters order
[LPAnalysis, HPAnalysis, LPSynthsis, HPSynthesis] = firpr2chfb(N, 0.45);
analysisFilter = dsp.SubbandAnalysisFilter(LPAnalysis, HPAnalysis);
% Initialize hi and lo as empty cell arrays
hi = {};
lo = {};
while ~isDone(audioInput)
input = audioInput(); % Load a frame of audio
[frameHi, frameLo] = analysisFilter(input);
% Add the current frame's coefficients to the global array
hi{end + 1} = frameHi; %#ok<SAGROW>
lo{end + 1} = frameLo; %#ok<SAGROW>
end
After this code runs, 'hi' and 'lo' will be cell arrays, where each cell holds the values for a single frame.
I hope you find this helpful. Good luck on your project!
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Audio Processing Algorithm Design in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!