From b34f1e210d69b3654893dbbc714badbe6a7e816f Mon Sep 17 00:00:00 2001 From: kevin Date: Sun, 31 Jan 2021 11:04:11 -0500 Subject: [PATCH] cwAudioBuf.h/cpp : Added version of meter() which returns an array of meter values from a device. --- cwAudioBuf.cpp | 20 +++++++++++++++++++- cwAudioBuf.h | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/cwAudioBuf.cpp b/cwAudioBuf.cpp index 45ebdb7..e8dfdee 100644 --- a/cwAudioBuf.cpp +++ b/cwAudioBuf.cpp @@ -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; const cmApCh* cp = p->devArray[devIdx].ioArray[idx].chArray + chIdx; 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; idevArray[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 ) { diff --git a/cwAudioBuf.h b/cwAudioBuf.h index e66e557..59778f0 100644 --- a/cwAudioBuf.h +++ b/cwAudioBuf.h @@ -170,6 +170,7 @@ namespace cw // Return the meter value for the requested channel. // Set flags to kInFl | kOutFl. 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. void setGain( handle_t h, unsigned devIdx, unsigned chIdx, unsigned flags, double gain );