Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have multiple of usb sound card connected to my system and i want to record one certain signal for each sound card. How will I call the name of my USB sound card to work properly without having a dropdown list box on my gui. Direct assigning of sound card is what i am after. Thanks a lot!
C++
audioRecorder->setAudioInput(); // this part is my question on how will i enter the name of my usb sound card
Posted
Updated 17-Jan-16 9:40am
v2
Comments
[no name] 17-Jan-16 18:01pm    
Define "name of my usb card".
Keno Rosario 18-Jan-16 1:18am    
my Code goes like this

<pre lang="c++"> QString str1 = ui->lineEdit_8->text();
QString filename = str1 ;
QString Nfile = "N";
QString Nfilename = filename + Nfile;
audioRecorder = new QAudioRecorder(this);
QAudioEncoderSettings audioSettings;
audioSettings.setCodec("wav");
audioSettings.setQuality(QMultimedia::HighQuality);
QString input1 = "USB Pnp Sound Device";
audioRecorder->setAudioInput(input1); // set input device 1(doesn't select USB Pnp Sound)
audioRecorder->setEncodingSettings(audioSettings);
audioRecorder->setOutputLocation(QUrl::fromLocalFile(filename));
audioRecorder->record();
QString input2 = "USB Audio Device";
noiseRecorder = new QAudioRecorder(this);
noiseRecorder->setAudioInput(input2); // same goes with this
noiseRecorder->setEncodingSettings(audioSettings);
noiseRecorder->setOutputLocation(QUrl::fromLocalFile(Nfilename));
noiseRecorder->record();</pre>


1 solution

The QAudioRecorder Class[^] provides the audioInputs() function returning a list of available names. If you don't want a list box to select from these but use hard coded names, just print the list once to know the names that can be used on your system.

There is also the function audioInputDescription() which provides user friendly names of the passed device name to help deciding which device should be used.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900