Audio get pops with Virtual Audio Cable

Hi all,
I’m trying to feed audio stream from outer apps into Cinder with the help of Virtual Audio Cable (Drivers), kinda counterparts on Windows as Soundflower on Mac.

I started with a simple program, which initializes an audio::InputDeviceNode from the Virtual Audio Device, and directly connect it to a audio::OutputDeviceNode attached to the external speaker. Unfortunately, the output sound has quite a lot pops in it. The Virtual Audio Cable driver seems to be ok, as I tried the same routine in RtAudio with WASAPI, and works fine.

The InputDeviceNode does produce overrun or underrun other than 0 during running time, actually I’ve no idea what’s going on, I just reckon it means the input and output process does not keep up in pace, am I right? I tried the same program on Mac with the exception of using Soundflower, it sounds smooth, and InputDeviceNode::getLastOverrun() / InputDeviceNode::getLastUnderrun() return 0 all the time.

Is there any setting I may ignored in audio context setup?

Thank you!

So InputDeviceNode doesn’t produce over / under runs? How about OutputDeviceNode (you can get this by typecasting the Context::getOutuput(). I know, a bit awkward at current), does it produce any xruns?

I’ve got some WASAPI improvements I need to wrap up soon, so hopefully I can test this out as well. I’ve had VB-Audio inputs working in the past but that was a couple years ago now. If you’ve got some specific test code, that would help.

cheers,
Rich

Hello Rich,

Thanks for you reply!

The InputDeviceNode in my test program DOES produce over/under runs almost every frame (in main thread).

It seems that OutputDeviceNode does not have the getLastOverrun() or getLastUnderrun() method, I tried the OutputDeviceNode::getLastClip() instead, and get 0 all the way down, which is a good sign according to the documentation.

Here is the minified code

#include "cinder/app/App.h"
#include "cinder/app/RendererGl.h"
#include "cinder/gl/gl.h"
#include "cinder/audio/audio.h"

using namespace ci;
using namespace ci::app;
using namespace std;

class AudioThroughApp : public App {
  public:
	void setup() override;
	void mouseDown( MouseEvent event ) override;
	void update() override;
	void draw() override;

	audio::InputDeviceNodeRef mInput;
	audio::OutputDeviceNodeRef mOutput;
};

void AudioThroughApp::setup()
{
	auto ctx = audio::master();

	audio::DeviceRef inputDevice, outputDevice;

#ifdef _WIN32
	inputDevice = audio::Device::findDeviceByName("CABLE Output (VB-Audio Virtual Cable)");
	if (!inputDevice) {
		console() << "CABLE Output (VB-Audio Virtual Cable) not found" << std::endl;
		::exit(1);
	}

	outputDevice = audio::Device::findDeviceByName("Headphone (Traktor Audio 2 MK2 WDM Audio)");
	if (!outputDevice) {
		console() << "Headphone (Traktor Audio 2 MK2 WDM Audio) not found" << std::endl;
		::exit(1);
	}
#else
	inputDevice = audio::Device::findDeviceByName("Soundflower (2ch)");
	if (!inputDevice) {
		console() << "Soundflower (2ch) not found" << std::endl;
		::exit(1);
	}

	outputDevice = audio::Device::findDeviceByName("Built-in Output");
	if (!outputDevice) {
		console() << "Built-in Output not found" << std::endl;
		::exit(1);
	}
#endif

	mInput = ctx->createInputDeviceNode(inputDevice, audio::Node::Format().channels(2));

	mOutput = ctx->createOutputDeviceNode(outputDevice, audio::Node::Format().channels(2));
	ctx->setOutput(mOutput);

	mInput >> mOutput;

	mInput->enable();
	ctx->enable();
}

void AudioThroughApp::mouseDown( MouseEvent event )
{
}

void AudioThroughApp::update()
{
	console() << "Input: " << mInput->getLastOverrun() << ", " << mInput->getLastUnderrun() << std::endl;
	console() << "Output: " << mOutput->getLastClip() << std::endl;
}

void AudioThroughApp::draw()
{
	gl::clear( Color( 0, 0, 0 ) ); 
}

CINDER_APP( AudioThroughApp, RendererGl )

and sample output in Debug console on Windows 10

Input: 0, 512
Output: 0
Input: 0, 1024
Output: 0
Input: 0, 2048
Output: 0
Input: 2560, 0
Output: 0
Input: 3584, 0
Output: 0

the same program runs smoothly on OSX 10.12, no under/over runs and clips at all.