10#include <audioclient.h>
68 wfx.Format.nSamplesPerSec =
format.sampleRate();
69 wfx.Format.wBitsPerSample = wfx.Samples.wValidBitsPerSample =
format.bytesPerSample()*8;
70 wfx.Format.nChannels =
format.channelCount();
71 wfx.Format.nBlockAlign = (wfx.Format.wBitsPerSample / 8) * wfx.Format.nChannels;
72 wfx.Format.nAvgBytesPerSec = wfx.Format.nBlockAlign * wfx.Format.nSamplesPerSec;
73 wfx.Format.cbSize = 0;
76 wfx.Format.wFormatTag = WAVE_FORMAT_IEEE_FLOAT;
77 wfx.SubFormat = KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
79 wfx.Format.wFormatTag = WAVE_FORMAT_PCM;
80 wfx.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
83 if (
format.channelCount() > 2) {
84 wfx.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
85 wfx.Format.cbSize = 22;
87 : DWORD(
format.channelConfig());
96 out.setSampleRate(
in.nSamplesPerSec);
97 out.setChannelCount(
in.nChannels);
98 if (
in.wFormatTag == WAVE_FORMAT_PCM) {
99 if (
in.wBitsPerSample == 8)
101 else if (
in.wBitsPerSample == 16)
103 else if (
in.wBitsPerSample == 32)
105 }
else if (
in.wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
106 if (
in.cbSize >= 22) {
107 auto wfe =
reinterpret_cast<const WAVEFORMATEXTENSIBLE &
>(
in);
108 if (wfe.SubFormat == KSDATAFORMAT_SUBTYPE_IEEE_FLOAT)
113 }
else if (
in.wFormatTag == WAVE_FORMAT_IEEE_FLOAT) {
127 if (SUCCEEDED(mediaType->GetUINT32(MF_MT_AUDIO_NUM_CHANNELS, &
val))) {
130 qWarning() <<
"Could not determine channel count from IMFMediaType";
134 if (SUCCEEDED(mediaType->GetUINT32(MF_MT_AUDIO_CHANNEL_MASK, &
val))) {
139 if (SUCCEEDED(mediaType->GetUINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, &
val))) {
142 UINT32 bitsPerSample = 0;
143 mediaType->GetUINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, &bitsPerSample);
146 if (SUCCEEDED(mediaType->GetGUID(MF_MT_SUBTYPE, &subType))) {
147 if (subType == MFAudioFormat_Float) {
149 }
else if (bitsPerSample == 8) {
151 }
else if (bitsPerSample == 16) {
153 }
else if (bitsPerSample == 32){
162 ComPtr<IMFMediaType> mediaType;
169 mediaType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio);
171 mediaType->SetGUID(MF_MT_SUBTYPE, MFAudioFormat_Float);
173 mediaType->SetGUID(MF_MT_SUBTYPE, MFAudioFormat_PCM);
176 mediaType->SetUINT32(MF_MT_AUDIO_NUM_CHANNELS, UINT32(
format.channelCount()));
179 mediaType->SetUINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, UINT32(
format.sampleRate()));
180 auto alignmentBlock = UINT32(
format.bytesPerFrame());
181 mediaType->SetUINT32(MF_MT_AUDIO_BLOCK_ALIGNMENT, alignmentBlock);
182 auto avgBytesPerSec = UINT32(
format.sampleRate() *
format.bytesPerFrame());
183 mediaType->SetUINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, avgBytesPerSec);
184 mediaType->SetUINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, UINT32(
format.bytesPerSample()*8));
185 mediaType->SetUINT32(MF_MT_ALL_SAMPLES_INDEPENDENT, TRUE);
193 UINT32 framesPadding = 0;
194 if (SUCCEEDED(client->GetCurrentPadding(&framesPadding)))
195 return framesPadding;
202 UINT32 bufferFrameCount = 0;
203 if (SUCCEEDED(client->GetBufferSize(&bufferFrameCount)))
204 return bufferFrameCount;
Combined button and popup list for selecting options.
std::optional< quint32 > audioClientFramesInUse(IAudioClient *client)
Q_MULTIMEDIA_EXPORT QAudioFormat mediaTypeToFormat(IMFMediaType *mediaType)
std::optional< quint32 > audioClientFramesAllocated(IAudioClient *client)
ComPtr< IMFMediaType > formatToMediaType(QWindowsMediaFoundation &, const QAudioFormat &format)
QAudioFormat waveFormatExToFormat(const WAVEFORMATEX &in)
bool formatToWaveFormatExtensible(const QAudioFormat &format, WAVEFORMATEXTENSIBLE &wfx)
QAudioFormat::ChannelConfig maskToChannelConfig(UINT32 mask, int count)
Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR uint qPopulationCount(quint32 v) noexcept
GLenum GLenum GLsizei count
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLint GLsizei GLsizei GLenum format
static UINT32 channelConfigToMask(QAudioFormat::ChannelConfig config)
static QT_BEGIN_NAMESPACE QAudioFormat::AudioChannelPosition channelFormatMap[]
QFuture< QSet< QChar > > set
[10]
QTextStream out(stdout)
[7]