Im having problems with the reconstruction through two-channel filter bank when I use my audio files.

3 次查看(过去 30 天)
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

采纳的回答

Rollin Baker
Rollin Baker 2017-4-13
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!

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Audio Processing Algorithm Design 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by