Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Implementing the SBC subband filters (analysis and synthesis) (Read 1514 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Implementing the SBC subband filters (analysis and synthesis)

Hello,

I'd like to dabble a bit with subband coding and I feel the best way for me to grasp something is to implement it.

The Bluetooth SBC codec looks like it has a neat, publicly available spec (https://www.bluetooth.com/specifications/specs/advanced-audio-distribution-profile-1-4/ - "Advanced Audio Distribution Profile 1.4"), so I'd like to implement the 8 band analysis and synthesis as a base for my experiments.

The "Advanced Audio Distribution Profile 1.4"-document includes two flow charts I'm interested in, as they appear to provide clear guidance on how to implement the filters:

SBC Analysis (from page 68):
X

SBC Synthesis (from page 66):
X

My understanding is that one can drop 8 audio samples into Analysis, get 8 subband samples, which can be dropped into Synthesis, which reconstructs the original 8 audio samples (or at least close approximations). An actual codec would quantize the subband samples to achieve compression, but without quantization, things should be nearly lossless.

That's not what I'm getting (recognizable audio, but it appears the lowest band is duplicated and "mirrored" 8 times where the other bands should be), so I suspect I misunderstand how to read the flow diagrams.

I'm unsure in Analysis starting with the step "Partial Calculation":
X
For me, it's unclear what the "sum(X[i+k*16)" is, as "X[i+k*16]" is a single value and I expect a sum to be defined over multiple elements. As such I just read this to mean that I shall sum up the contributions for all values of k:

Code: [Select]
        // Step 3: "Partial Calculation"
        for(int i = 0; i <= 15; i++) {
            double sum = 0.0;
            for(int k = 0; k <= 4; k++) {
                sum += z[i + (k * 16)];
            }
            y[i] = sum;
        }

If this is not the correct interpretation of the "sum(...)" operation, that'd explain the garbled output, otherwise I'm quite stumped on what's going wrong in my implementation.