cwAudioBuf.h/cpp : Added version of meter() which returns an array of meter values from a device.

This commit is contained in:
kevin 2021-01-31 11:04:11 -05:00
parent f123be0323
commit b34f1e210d
2 changed files with 20 additions and 1 deletions

View File

@ -657,7 +657,25 @@ cw::audio::buf::sample_t cw::audio::buf::meter(handle_t h, unsigned devIdx, unsi
unsigned idx = flags & kInFl ? kInApIdx : kOutApIdx; unsigned idx = flags & kInFl ? kInApIdx : kOutApIdx;
const cmApCh* cp = p->devArray[devIdx].ioArray[idx].chArray + chIdx; const cmApCh* cp = p->devArray[devIdx].ioArray[idx].chArray + chIdx;
return _cmApMeterValue(cp); return _cmApMeterValue(cp);
} }
void cw::audio::buf::meter(handle_t h, unsigned devIdx, unsigned flags, sample_t* meterA, unsigned meterN )
{
if( devIdx == kInvalidIdx )
return;
audioBuf_t* p = _handleToPtr(h);
unsigned idx = flags & kInFl ? kInApIdx : kOutApIdx;
unsigned n = std::min(meterN,channelCount(h,devIdx,flags));
for(unsigned i=0; i<n; ++i)
{
const cmApCh* cp = p->devArray[devIdx].ioArray[idx].chArray + i;
meterA[i] = _cmApMeterValue(cp);
}
}
void cw::audio::buf::setGain( handle_t h, unsigned devIdx, unsigned chIdx, unsigned flags, double gain ) void cw::audio::buf::setGain( handle_t h, unsigned devIdx, unsigned chIdx, unsigned flags, double gain )
{ {

View File

@ -170,6 +170,7 @@ namespace cw
// Return the meter value for the requested channel. // Return the meter value for the requested channel.
// Set flags to kInFl | kOutFl. // Set flags to kInFl | kOutFl.
sample_t meter(handle_t h, unsigned devIdx, unsigned chIdx, unsigned flags ); sample_t meter(handle_t h, unsigned devIdx, unsigned chIdx, unsigned flags );
void meter(handle_t h, unsigned devIdx, unsigned flags, sample_t* meterA, unsigned meterN );
// Set chIdx to -1 to apply the gain to all channels on the specified device. // Set chIdx to -1 to apply the gain to all channels on the specified device.
void setGain( handle_t h, unsigned devIdx, unsigned chIdx, unsigned flags, double gain ); void setGain( handle_t h, unsigned devIdx, unsigned chIdx, unsigned flags, double gain );