Created
May 4, 2026 21:13
-
-
Save Xenakios/1a533c36e100be2c0058e91429c4029f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define USE_AVX2_AMBIS | |
| #ifdef USE_AVX2_AMBIS | |
| // Process 8 channels at a time using AVX | |
| int chan = 0; | |
| for (; chan <= num_outputchans - 8; chan += 8) | |
| { | |
| // Load 8 ambisonics coefficients for each source | |
| __m256 coeffs0 = _mm256_load_ps(&ambcoeffs[chan]); // coeffs for outsample0 | |
| __m256 coeffs1 = _mm256_load_ps(&ambcoeffs[chan + 64]); // coeffs for outsample1 | |
| // Broadcast the scalar audio samples across all 8 lanes | |
| __m256 sample0 = _mm256_set1_ps(outsample0); | |
| __m256 sample1 = _mm256_set1_ps(outsample1); | |
| // Multiply-accumulate: sample * coefficients | |
| __m256 result = | |
| _mm256_fmadd_ps(sample0, coeffs0, // outsample0 * coeffs0 | |
| _mm256_mul_ps(sample1, coeffs1)); // + outsample1 * coeffs1 | |
| // Store results into the output buffer | |
| _mm256_store_ps(&outputs[i * 64 + chan], result); | |
| } | |
| // Scalar fallback for any remaining channels (if num_outputchans isn't a multiple of 8) | |
| for (; chan < num_outputchans; ++chan) | |
| { | |
| outputs[i * 64 + chan] = | |
| outsample0 * ambcoeffs[chan] + outsample1 * ambcoeffs[chan + 64]; | |
| } | |
| #else | |
| // Teemun alkuperäinen koodi | |
| for (int chan = 0; chan < num_outputchans; ++chan) | |
| { | |
| outputs[i * 64 + chan] = 0.0f; | |
| outputs[i * 64 + chan] += outsample0 * ambcoeffs[chan]; | |
| outputs[i * 64 + chan] += outsample1 * ambcoeffs[chan + 64]; | |
| } | |
| #endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment