Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Leander Schulten
Lichtsteuerung
Commits
f069e055
Commit
f069e055
authored
Oct 06, 2019
by
Leander Schulten
Browse files
AudioManager: RtAudio:you now can select output devices as input on windows (loopback recording)
parent
ac46081d
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/audio/audiocapturemanager.cpp
View file @
f069e055
...
...
@@ -5,6 +5,16 @@
#include
"gui/oscillogram.h"
#include
<algorithm>
#ifdef AUDIO_IF_WIN
#error AUDIO_IF_WIN is already defined
#endif
#ifdef Q_OS_WIN
#define AUDIO_IF_WIN(x) x
#else
#define AUDIO_IF_WIN(x)
#endif
namespace
Audio
{
AudioCaptureManager
::
AudioCaptureManager
()
:
audiofft
(
sample
.
size
())
{
...
...
@@ -117,7 +127,7 @@ bool AudioCaptureManager::startCapturingFromInput(unsigned input) {
return
false
;
}
const
auto
di
=
rtAudio
.
getDeviceInfo
(
input
);
if
(
di
.
inputChannels
==
0
)
{
if
(
di
.
inputChannels
==
0
AUDIO_IF_WIN
(
&&
di
.
outputChannels
==
0
)
)
{
return
false
;
}
// it was a device open before now
...
...
@@ -130,11 +140,11 @@ bool AudioCaptureManager::startCapturingFromInput(unsigned input) {
}
else
{
sampleRate
=
static_cast
<
int
>
(
di
.
preferredSampleRate
);
}
initCallback
(
static_cast
<
int
>
(
di
.
inputChannels
),
sampleRate
);
initCallback
(
static_cast
<
int
>
(
di
.
inputChannels
+
di
.
outputChannels
),
sampleRate
);
RtAudio
::
StreamParameters
isp
;
isp
.
deviceId
=
input
;
isp
.
nChannels
=
di
.
inputChannels
;
isp
.
nChannels
=
di
.
inputChannels
AUDIO_IF_WIN
(
+
di
.
outputChannels
)
;
isp
.
firstChannel
=
0
;
unsigned
samplesPerFrame
=
static_cast
<
unsigned
>
(
this
->
samplesPerFrame
);
try
{
...
...
@@ -200,6 +210,20 @@ bool AudioCaptureManager::startCapturingFromCaptureLibrary() {
bool
AudioCaptureManager
::
startCapturingFromDefaultInput
()
{
stopCapturingAndWait
();
#ifdef Q_OS_WIN
// check if default output is availible
const
auto
output
=
rtAudio
.
getDefaultOutputDevice
();
if
(
output
<
rtAudio
.
getDeviceCount
())
{
const
auto
di
=
rtAudio
.
getDeviceInfo
(
output
);
if
(
di
.
isDefaultOutput
)
{
if
(
startCapturingFromInput
(
output
))
{
currentCaptureDevice
=
getIndexForDeviceName
(
di
.
name
.
c_str
());
emit
currentCaptureDeviceChanged
();
return
true
;
}
}
}
#endif
// check if default input is availible
const
auto
input
=
rtAudio
.
getDefaultInputDevice
();
if
(
input
>=
rtAudio
.
getDeviceCount
())
{
...
...
@@ -268,7 +292,7 @@ void AudioCaptureManager::updateCaptureDeviceList() {
}
for
(
unsigned
i
=
0
;
i
<
rtAudio
.
getDeviceCount
();
++
i
)
{
if
(
auto
di
=
rtAudio
.
getDeviceInfo
(
i
);
di
.
inputChannels
>
0
)
{
if
(
auto
di
=
rtAudio
.
getDeviceInfo
(
i
);
di
.
inputChannels
>
0
AUDIO_IF_WIN
(
||
di
.
outputChannels
>
0
)
)
{
captureDeviceNames
.
emplace_back
(
QString
::
fromStdString
(
di
.
name
.
c_str
()));
}
}
...
...
src/audio/audiocapturemanager.h
View file @
f069e055
...
...
@@ -117,7 +117,7 @@ public:
*/
bool
startCapturingFromCaptureLibrary
();
/**
* @brief startCapturingFromDefaultInput starts the capturing from the default input device
* @brief startCapturingFromDefaultInput starts the capturing from the default input device
. On windows from the default output.
* @return true, if the capturing stats successfully, false otherwise
*/
bool
startCapturingFromDefaultInput
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment