Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qtaudio.h
Go to the documentation of this file.
1
// Copyright (C) 2024 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
5
#
ifndef
QTAUDIO_H
6
#
define
QTAUDIO_H
7
8
#
if
0
9
#
pragma
qt_class
(
QtAudio
)
10
#
endif
11
12
#
include
<
QtMultimedia
/
qaudio
.
h
>
13
#
include
<
QtCore
/
qspan
.
h
>
14
15
#
include
<
functional
>
16
#
include
<
QtCore
/
q20type_traits
.
h
>
17
18
QT_BEGIN_NAMESPACE
19
20
namespace
QtAudioPrivate
{
21
22
////////////////////////////////////////////////////////////////////////////////////////////////////
23
24
template
<
typename
SampleType
>
25
using
AudioSinkCallbackType
=
std
::
function
<
void
(
QSpan
<
SampleType
>)>;
26
27
template
<
typename
SampleType
>
28
using
AudioSourceCallbackType
=
std
::
function
<
void
(
QSpan
<
const
SampleType
>)>;
29
30
using
AudioSinkCallback
=
31
std
::
variant
<
AudioSinkCallbackType
<
float
>,
AudioSinkCallbackType
<
uint8_t
>,
32
AudioSinkCallbackType
<
int16_t
>,
AudioSinkCallbackType
<
int32_t
>>;
33
34
using
AudioSourceCallback
=
35
std
::
variant
<
AudioSourceCallbackType
<
float
>,
AudioSourceCallbackType
<
uint8_t
>,
36
AudioSourceCallbackType
<
int16_t
>,
AudioSourceCallbackType
<
int32_t
>>;
37
38
////////////////////////////////////////////////////////////////////////////////////////////////////
39
40
template
<
typename
F,
typename
Enabler =
void
>
41
struct
GetSampleType
;
42
43
template
<
typename
F
>
44
struct
GetSampleType
<
45
F
,
46
std
::
enable_if_t
<
std
::
disjunction_v
<
std
::
is_invocable_r
<
void
,
F
,
QSpan
<
float
>>,
47
std
::
is_invocable_r
<
void
,
F
,
QSpan
<
const
float
>>>>>
48
:
q20
::
type_identity
<
float
>
49
{
50
};
51
52
template
<
typename
F
>
53
struct
GetSampleType
<
54
F
,
55
std
::
enable_if_t
<
std
::
disjunction_v
<
std
::
is_invocable_r
<
void
,
F
,
QSpan
<
uint8_t
>>,
56
std
::
is_invocable_r
<
void
,
F
,
QSpan
<
const
uint8_t
>>>>>
57
:
q20
::
type_identity
<
uint8_t
>
58
{
59
};
60
61
template
<
typename
F
>
62
struct
GetSampleType
<
63
F
,
64
std
::
enable_if_t
<
std
::
disjunction_v
<
std
::
is_invocable_r
<
void
,
F
,
QSpan
<
int16_t
>>,
65
std
::
is_invocable_r
<
void
,
F
,
QSpan
<
const
int16_t
>>>>>
66
:
q20
::
type_identity
<
int16_t
>
67
{
68
};
69
70
template
<
typename
F
>
71
struct
GetSampleType
<
72
F
,
73
std
::
enable_if_t
<
std
::
disjunction_v
<
std
::
is_invocable_r
<
void
,
F
,
QSpan
<
int32_t
>>,
74
std
::
is_invocable_r
<
void
,
F
,
QSpan
<
const
int32_t
>>>>>
75
:
q20
::
type_identity
<
int32_t
>
76
{
77
};
78
79
////////////////////////////////////////////////////////////////////////////////////////////////////
80
81
template
<
typename
T
>
82
constexpr
inline
bool
is_std_function_v
=
false
;
83
template
<
typename
T
>
84
constexpr
inline
bool
is_std_function_v
<
std
::
function
<
T
>> =
true
;
85
template
<
typename
T
>
86
constexpr
inline
bool
is_function_pointer_v
=
87
std
::
conjunction_v
<
std
::
is_pointer
<
T
>,
std
::
is_function
<
std
::
remove_pointer_t
<
T
>>>;
88
89
template
<
typename
F>
90
constexpr
bool
isNonnullFunction
(
const
F &f)
91
{
92
if
constexpr
(is_std_function_v<F> || is_function_pointer_v<F>)
93
return
bool
(f);
94
else
95
return
true
;
// assume callable is non-null
96
}
97
98
template
<
typename
F
,
typename
...
T
>
99
constexpr
inline
bool
isInvokableWithSpan
=
100
std
::
disjunction_v
<
std
::
is_invocable_r
<
void
,
F
,
QSpan
<
T
>>...>;
101
102
////////////////////////////////////////////////////////////////////////////////////////////////////
103
104
}
// namespace QtAudioPrivate
105
106
namespace
QtAudio
{
107
108
template
<
typename
F
>
109
constexpr
inline
bool
isAudioSourceCallback
=
110
QtAudioPrivate
::
isInvokableWithSpan
<
F
,
const
float
,
const
uint8_t
,
const
int16_t
,
111
const
int32_t
>;
112
113
template
<
typename
F
>
114
constexpr
inline
bool
isAudioSinkCallback
=
115
QtAudioPrivate
::
isInvokableWithSpan
<
F
,
float
,
uint8_t
,
int16_t
,
int32_t
>;
116
117
template
<
typename
Callback
>
118
using
if_audio_source_callback
=
std
::
enable_if_t
<
isAudioSourceCallback
<
Callback
>,
bool
>;
119
120
template
<
typename
Callback
>
121
using
if_audio_sink_callback
=
std
::
enable_if_t
<
isAudioSinkCallback
<
Callback
>,
bool
>;
122
123
}
// namespace QtAudio
124
125
QT_END_NAMESPACE
126
127
#
endif
// QTAUDIO_H
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
QtAudioPrivate
Definition
qtaudio.h:20
QtAudioPrivate::is_std_function_v< std::function< T > >
constexpr bool is_std_function_v< std::function< T > >
Definition
qtaudio.h:84
QtAudioPrivate::is_std_function_v
constexpr bool is_std_function_v
Definition
qtaudio.h:82
QtAudioPrivate::isNonnullFunction
constexpr bool isNonnullFunction(const F &f)
Definition
qtaudio.h:90
QtAudioPrivate::isInvokableWithSpan
constexpr bool isInvokableWithSpan
Definition
qtaudio.h:99
QtAudioPrivate::is_function_pointer_v
constexpr bool is_function_pointer_v
Definition
qtaudio.h:86
QtAudio::if_audio_source_callback
std::enable_if_t< isAudioSourceCallback< Callback >, bool > if_audio_source_callback
Definition
qtaudio.h:118
QtAudio::isAudioSourceCallback
constexpr bool isAudioSourceCallback
Definition
qtaudio.h:109
QtAudio::convertVolume
float convertVolume(float volume, VolumeScale from, VolumeScale to)
Converts an audio volume from a volume scale to another, and returns the result.
Definition
qtaudio.cpp:99
QtAudio::isAudioSinkCallback
constexpr bool isAudioSinkCallback
Definition
qtaudio.h:114
operator<<
QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition
qdir.cpp:2620
LOG100
#define LOG100
Definition
qtaudio.cpp:12
QtAudioPrivate::GetSampleType
Definition
qtaudio.h:41
qtmultimedia
src
multimedia
audio
qtaudio.h
Generated on
for Qt by
1.18.0