Skip to content

Commit

Permalink
Use an iterator to iterate over the channel orders
Browse files Browse the repository at this point in the history
  • Loading branch information
kcat committed Mar 4, 2024
1 parent 313318e commit 7821288
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions core/voice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1207,13 +1207,13 @@ void Voice::prepare(DeviceBase *device)
/* Even if storing really high order ambisonics, we only mix channels for
* orders up to the device order. The rest are simply dropped.
*/
uint num_channels{(mFmtChannels == FmtUHJ2 || mFmtChannels == FmtSuperStereo) ? 3 :
(mFmtChannels == FmtMonoDup) ? 2 :
ChannelsFromFmt(mFmtChannels, std::min(mAmbiOrder, device->mAmbiOrder))};
uint num_channels{(mFmtChannels == FmtMonoDup) ? 2
: (mFmtChannels == FmtUHJ2 || mFmtChannels == FmtSuperStereo) ? 3
: ChannelsFromFmt(mFmtChannels, std::min(mAmbiOrder, device->mAmbiOrder))};
if(num_channels > device->MixerChannelsMax) UNLIKELY
{
ERR("Unexpected channel count: %u (limit: %zu, %d:%d)\n", num_channels,
device->MixerChannelsMax, mFmtChannels, mAmbiOrder);
ERR("Unexpected channel count: %u (limit: %zu, %s : %d)\n", num_channels,
device->MixerChannelsMax, NameFromFormat(mFmtChannels), mAmbiOrder);
num_channels = device->MixerChannelsMax;
}
if(mChans.capacity() > 2 && num_channels < mChans.capacity())
Expand Down Expand Up @@ -1307,8 +1307,10 @@ void Voice::prepare(DeviceBase *device)
*/
else if(mAmbiOrder && device->mAmbiOrder > mAmbiOrder)
{
const uint8_t *OrderFromChan{Is2DAmbisonic(mFmtChannels) ?
AmbiIndex::OrderFrom2DChannel.data() : AmbiIndex::OrderFromChannel.data()};
auto OrdersSpan = Is2DAmbisonic(mFmtChannels)
? al::span<const uint8_t>{AmbiIndex::OrderFrom2DChannel}
: al::span<const uint8_t>{AmbiIndex::OrderFromChannel};
auto OrderFromChan = OrdersSpan.cbegin();
const auto scales = AmbiScale::GetHFOrderScales(mAmbiOrder, device->mAmbiOrder,
device->m2DMixing);

Expand Down

0 comments on commit 7821288

Please sign in to comment.