Closed jontio closed 2 years ago
The default input and output devices for DS are always identified with a device ID = 0 and the names of "Primary Sound ... Driver". And the devices that are currently the defaults will also appear in the list under their manufacturer names. That's just the way that the crappy DS system works. That said, the index for the "Primary Sound ... Driver" should always indicate itself as being the default. I reworked some of the device querying in the "newdeviceselection" branch and that is hopefully cleaned up to some extent. I'll merge that branch into master at some point in the coming months.
Ah thanks. I checked out newdeviceselection
branch ( commit 84c9928 ) and that branch returns Primary Sound Capture Driver
as the default input. So that looks good.
Using the following code...
#include <QDebug>
#include "../RtAudio.h"
void listDeviceNames()
{
RtAudio audio;
std::vector<unsigned int> ids=audio.getDeviceIds();
foreach(unsigned int id,ids)
{
qDebug()<<id<<":"<<QString::fromStdString(audio.getDeviceInfo(id).name);
}
}
int main(int argc, char *argv[])
{
Q_UNUSED(argc);
Q_UNUSED(argv);
RtAudio audio;
RtAudio::DeviceInfo info;
//list devices
qDebug()<<"Device names:";
listDeviceNames();
qDebug()<<"";
//correct output device and says it's the default output device
uint defaultOutputDevice=audio.getDefaultOutputDevice();
info=audio.getDeviceInfo(defaultOutputDevice);
qDebug()<<"default output ID:"<<info.ID<<"name:"<<QString::fromStdString(info.name)\
<<"input:"<<info.inputChannels<<"output:"<<info.outputChannels\
<<"info.isDefaultOutput"<<info.isDefaultOutput;
//correct input device and and says it's the default input device
uint defaultInputDevice=audio.getDefaultInputDevice();
info=audio.getDeviceInfo(defaultInputDevice);
qDebug()<<"default input ID:"<<info.ID<<"name:"<<QString::fromStdString(info.name)\
<<"input:"<<info.inputChannels<<"output:"<<info.outputChannels\
<<"info.isDefaultInput"<<info.isDefaultInput;
return 0;
}
I get...
Device names:
129 : "Primary Sound Driver"
130 : "Hi-Fi Cable Input (VB-Audio Hi-Fi Cable)"
131 : "Digital Audio (S/PDIF) (2- High Definition Audio Device)"
132 : "Digital Audio (HDMI) (High Definition Audio Device)"
133 : "Speakers (3- USB Advanced Audio Device)"
134 : "CABLE Input (VB-Audio Virtual Cable)"
135 : "Primary Sound Capture Driver"
136 : "Hi-Fi Cable Output (VB-Audio Hi-Fi Cable)"
137 : "CABLE Output (VB-Audio Virtual Cable)"
138 : "Microphone (3- USB Advanced Audio Device)"
default output ID: 129 name: "Primary Sound Driver" input: 0 output: 2 info.isDefaultOutput true
default input ID: 135 name: "Primary Sound Capture Driver" input: 2 output: 0 info.isDefaultInput true
Cheers, Jonti
Windows 10 with Mingw 64 bit.
Calling
getDefaultInputDevice()
from the DS API returns 0. Then getting thegetDeviceInfo
for that device returnsisDefaultInput
asfalse
.Looking at the DS API both
getDefaultInputDevice()
andgetDefaultOutputDevice()
are hard coded to return 0.Looking how DS devices are enumerated the output devices come before the input devices. I've also noticed that the first device with non zero input channels is called
Primary Sound Capture Driver
. Surely this should be returned as the default input device?Here is some code to put into the
tests
folder to demonstrate...ds_test.pro
main.cpp
The output is...
(
qmake && mingw32-make
to build BTW)I have another program that uses the input (a modem) and changing the default input of the windows settings does indeed change the device that device index
6
points to. So I think the DS API forgetDefaultInputDevice()
should be changed to something like...Does anyone have any thoughts on the matter?