Skip to content

Commit

Permalink
allow binaural option if channels >= 2
Browse files Browse the repository at this point in the history
  • Loading branch information
ddennedy committed Feb 17, 2024
1 parent 74828c0 commit 0fbe464
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/modules/spatialaudio/filter_ambisonic-decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class SpatialAudio
bool getAudio(mlt_frame frame, float *buffer, int samples, int channels)
{
bool error = false;
bool binaural = channels == 2 && mlt_properties_get_int(properties(), "binaural");
bool binaural = channels >= 2 && mlt_properties_get_int(properties(), "binaural");

// First time setup
if (binaural && !binauralizer.GetChannelCount()) {
Expand Down Expand Up @@ -158,10 +158,15 @@ class SpatialAudio
} else {
for (int i = 0; i < channels; ++i)
speakers[i] = &buffer[samples * i];
if (binaural)
if (binaural) {
binauralizer.Process(&bformat, speakers, samples);
else
if (channels > 2) {
for (int i = 2; i < channels; ++i)
::memset(speakers[i], 0, samples * sizeof(float));
}
} else {
decoder.Process(&bformat, samples, speakers);
}
}
}
return error;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/spatialaudio/filter_ambisonic-decoder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ parameters:
title: Binaural Output
description: >
This indicates whether to render as binaural instead of stereo.
This only applies when the channel count is 2.
This property overrides the "ambisonic" property.
type: boolean
default: 0
mutable: no

0 comments on commit 0fbe464

Please sign in to comment.