I am writing a media player with Qt, but I'm now facing some unknown situation. Actually, I'm trying to use QAudioOutput and QAudioDecoder to play high res music (24, 32 or even 64 bit audio). But QAudioFormat (the glue between all audio classes) specify a sampleType as in the following table:
| Constant | Value | Description |
|---------------------------|-------|--------------------------------|
| QAudioFormat::Unknown | 0 | Not Set |
| QAudioFormat::SignedInt | 1 | Samples are signed integers |
| QAudioFormat::UnSignedInt | 2 | Samples are unsigned intergers |
| QAudioFormat::Float | 3 | Samples are floats |
Now, the problem arise when I also set the sample size to something greater than 16bits. I now have one hypothesis that I need confirmation :
But what if there is a higher sample size (eg: 64bit audio for dsd converted to pcm). Should I assume that I still set the sample type to QAudioFormat::SignedInt but that each "sample" of 64bits is stored in two ints ? Or is it simply not supported by QtMultimedia ?
I'm open to any enlightenment 😙!
From the documentation for QAudioFormat::setSampleSize()
:
void QAudioFormat::setSampleSize(int sampleSize)
Sets the sample size to the sampleSize specified, in bits.
This is typically 8 or 16, but some systems may support higher sample sizes.
Therefore, to use 64-bit samples, you'd need to call setSampleSize(64)
. That could be called in combination with a call to setSampleType()
to specify whether the samples will be fixed-point-signed vs fixed-point-unsigned vs floating-point -- note that the values in setSampleType()
do not imply any particular sample size.
For 64-bit audio, each sample will be stored as 64 bits of data; you could access each sample as a long long int
, or alternatively as an int64_t
(or unsigned long long int
or uint64_t
for unsigned samples, or as a double
for floating-point samples).
(Of course none of this guarantees that your Qt library's QtMultimedia actually supports 64-bit samples; it may or may not, but at least the API supports telling Qt what you want :) )