AudioDeviceManager suggestion (VU Callback)


#1

Jules, could you add theese two callbacks to the AudioDeviceManger so that someone could implement a master-VU Meter, to detect the sum of all Audio-Data.
Yes i could use a FilterGraph but this will generate a overhead, and also it won’t get the current number of audiochannels (or the filtergraph has to be reconfigured everytime when the number of channels changing, which is inefficient.)

something like

virtual void AudioDeviceManager::VUCallbackInput(int numInputChannels, int numSamples, float** audioChannelData) {};
virtual void AudioDeviceManager::VUCallbackOutput(int numOutputChannels, int numSamples, float** audioChannelData); {};

and then simple add these Callbacks to void AudioDeviceManager::audioDeviceIOCallbackInt

i think this would be very easy to implement, and a big help for me…


#2

hmm… I understand the problem, but don’t like that as a solution. Subclassing the AudioDeviceManager is not something I want to encourage, so there’d need to be a more elaborate solution, and it seems like a lot of mess to me, when there are other ways to do the same thing…


#3

ok, maybe something like

AudioDeviceManager::addVUAudioThreadListener(VUAudioThreadListener*) // i use AudioThreadListener instead of Listener to clarify it won’t run at the message-thread

and then

[code]
class VUAudioThreadListener*
{
public :
virtual void VUAudioThreadListener::VUCallbackInput(int numInputChannels, int numSamples, float** audioChannelData) {};
virtual void VUAudioThreadListener::VUCallbackOutput(int numOutputChannels, int numSamples, float** audioChannelData); {};

};[/code]


#4

Why would it not just be a normal AudioIODeviceCallback ?


#5

yes ok, something like

addVUDetectorOutput(AudioIODeviceCallback* newCallback);

or extend the current method

void addAudioCallback (AudioIODeviceCallback* newCallback, acVUDetector);


#6

(and of course calling it a ‘VU’ callback would be a rather strange name, when it’s really just an ‘overall’ callback, and not something whose only purpose would be to drive one specific type of level meter!)


#7

yes yes yes :wink:

addReadOnlyOutputDetectorCallback
addReadOnlyInputDetectorCallback

however…


#8

it would also nice to use this callback for master gain - processing, or to implement a limiter to prevent clipping.

addOuputFinalizer( )


#9

If AudioIODeviceCallback is already used, why not put the output/input detectors in there?

Something like:

class MyCallbacks
{
public:
  void MonitorInput(int numInputChannels, int numSamples, const float** audioChannelData) = 0;
  void MonitorOutput(int numOutputChannels, int numSamples, const float** audioChannelData) = 0;
/* or
  void processOutput(int numOutputChannels, int numSamples, float** audioChannelData) = 0;
*/
};

class MyIOCallback : public AudioIODeviceCallback 
{
public:
  MyIOCallback()
  : callbacks(0)
  {}

  void setCallbacks(MyCallbacks* c) { callbacks = c; }

  void audioDeviceIOCallback(const float **inputChannelData, int numInputChannels, float **outputChannelData, int numOutputChannels, int numSamples)
  {
    if (callbacks !=0)
      callbacks->MonitorInput(numInputChannels, numSamples, inputChannelData);

    ioCallback(**inputChannelData, numInputChannels, **outputChannelData, numOutputChannels, numSamples);

    if (callbacks !=0)
      callbacks->MonitorOutput(numOutputChannels, numSamples, outputChannelData);
  }

  virtual void ioCallback(const float **inputChannelData, int numInputChannels, float **outputChannelData, int numOutputChannels, int numSamples)=0;

private:
  MyCallbacks* callbacks;

};

Don’t know whether this is nice programming, though. :slight_smile:

Chris