Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix monitoring for objects sharing input audio #258

Merged
merged 7 commits into from
Dec 14, 2023

Conversation

firthm01
Copy link
Contributor

@firthm01 firthm01 commented Nov 1, 2023

Original issue;
The SceneGainsCalculator class just kept a single pair of gains tables (vector of vectors, one for diffuse and one for direct feeds) for all items (i.e, AudioObjects).
The SceneGainsCalculator::update method would iterate through all items in the store and run the addOrUpdateItem method to set the gains for the item in the gains tables (direct_ and diffuse_ members). Likewise the removeItem method would zero affected entries in the tables. Due to this "overwrite" behaviour, it meant that input sharing between objects was not possible. The last item to be processed in the store would overwrite gains set by any previous item which is also using those input channels.

Solution:
Each item keeps it's own pair of gains tables in the existing ItemRouting struct. These tables are only big enough for the item channel count for efficiency, rather than being sized to fit the total input and output channel count. When the backend requests the gain matrices, these are built at the point of request by summing all of the gain tables for all of the items in to an Eigen::MatrixXf which is initialised to zero, using the addToEigenMat free func. Note that the input channels when summing in to the matrix are offset by the starting channel number of the item.
This isolation of gains tables means we don't need to concern ourselves with what other items might be affected when the routing of one item changes, because their tables are calculated independently. This means we can get rid of the flagOverlaps which would previously set all items to "changed" to ensure the entire gains table was rebuilt.

Note that the first commit of this PR corrects some terminology (var names) in existing code before work commenced as it led to some confusion when implementing the new system.

Closes #257

@firthm01 firthm01 self-assigned this Nov 1, 2023
@firthm01 firthm01 force-pushed the fix257-monitoring-shared-inputs-main branch from 572a892 to fc1905f Compare November 3, 2023 15:15
@firthm01
Copy link
Contributor Author

firthm01 commented Nov 3, 2023

Force push was rebase on main (128 ch support)

Var names were incorrect. The outer vector of the vec arg lists output channels, and the inner vector lists input channels. Output channels become rows in the eigen matrix, and input channels become columns.
Just incorrect naming of vars - the logic is fine.
flagOverlaps was used to ensure all overlapping (or previously overlapping) objects had their gains recalculated. This is not necessary anymore as each object has it's gain matrix calculated separately and so is unaffected by routing changes of other objects. They are only summed when the entire matrix is requested in order to perform the audio processing.
@firthm01 firthm01 force-pushed the fix257-monitoring-shared-inputs-main branch from fc1905f to b38444b Compare December 12, 2023 17:43
@firthm01
Copy link
Contributor Author

Force push was rebase on main (CI fix)

Copy link
Contributor

@rsjbailey rsjbailey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, a big improvement on flagging the overlaps.

@firthm01 firthm01 merged commit 642e4f6 into main Dec 14, 2023
6 checks passed
@firthm01 firthm01 deleted the fix257-monitoring-shared-inputs-main branch December 14, 2023 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Monitoring plugins not properly supporting shared inputs
2 participants