fixed issue in waveinput where the format would be detected incorrectly
Floating point detection was backwards causing float-based audio to be detected as integer and vice versa (for >32-bit formats)
This commit is contained in:
@@ -96,16 +96,16 @@ bool WaveInput::open()
|
|||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
if (data_is_float) {
|
if (data_is_float) {
|
||||||
format = SAMPLE_FMT_S32;
|
|
||||||
} else {
|
|
||||||
format = SAMPLE_FMT_FLT;
|
format = SAMPLE_FMT_FLT;
|
||||||
|
} else {
|
||||||
|
format = SAMPLE_FMT_S32;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 64:
|
case 64:
|
||||||
if (data_is_float) {
|
if (data_is_float) {
|
||||||
format = SAMPLE_FMT_S64;
|
|
||||||
} else {
|
|
||||||
format = SAMPLE_FMT_DBL;
|
format = SAMPLE_FMT_DBL;
|
||||||
|
} else {
|
||||||
|
format = SAMPLE_FMT_S64;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -130,11 +130,20 @@ bool WaveInput::open()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WaveInput::is_open()
|
bool WaveInput::is_open() const
|
||||||
{
|
{
|
||||||
return file_.isOpen();
|
return file_.isOpen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QByteArray WaveInput::read(int length)
|
||||||
|
{
|
||||||
|
if (!is_open()) {
|
||||||
|
return QByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
return file_.read(length);
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray WaveInput::read(int offset, int length)
|
QByteArray WaveInput::read(int offset, int length)
|
||||||
{
|
{
|
||||||
if (!is_open()) {
|
if (!is_open()) {
|
||||||
@@ -155,7 +164,12 @@ void WaveInput::read(int offset, char *buffer, int length)
|
|||||||
file_.read(buffer, length);
|
file_.read(buffer, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioRenderingParams WaveInput::params()
|
bool WaveInput::at_end() const
|
||||||
|
{
|
||||||
|
return file_.atEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
const AudioRenderingParams &WaveInput::params() const
|
||||||
{
|
{
|
||||||
return params_;
|
return params_;
|
||||||
}
|
}
|
||||||
@@ -167,7 +181,7 @@ void WaveInput::close()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int WaveInput::sample_count()
|
int WaveInput::sample_count() const
|
||||||
{
|
{
|
||||||
return params_.bytes_to_samples(static_cast<int>(data_size_));
|
return params_.bytes_to_samples(static_cast<int>(data_size_));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,16 +17,19 @@ public:
|
|||||||
|
|
||||||
bool open();
|
bool open();
|
||||||
|
|
||||||
bool is_open();
|
bool is_open() const;
|
||||||
|
|
||||||
|
QByteArray read(int length);
|
||||||
QByteArray read(int offset, int length);
|
QByteArray read(int offset, int length);
|
||||||
void read(int offset, char *buffer, int length);
|
void read(int offset, char *buffer, int length);
|
||||||
|
|
||||||
AudioRenderingParams params();
|
bool at_end() const;
|
||||||
|
|
||||||
|
const AudioRenderingParams& params() const;
|
||||||
|
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
int sample_count();
|
int sample_count() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool find_str(QFile* f, const char* str);
|
bool find_str(QFile* f, const char* str);
|
||||||
|
|||||||
Reference in New Issue
Block a user