20 #include <QMutexLocker> 26 m_path(source.getLocalFilename()),
32 m_updating(fileUpdating)
43 cerr <<
"WavFileReader::initialize: Failed to open file at \"" 45 << sf_strerror(
m_file) <<
")" << endl;
48 m_error = QString(
"Couldn't load audio file '%1':\n%2")
51 m_error = QString(
"Failed to open audio file '%1'")
69 int type =
m_fileInfo.format & SF_FORMAT_TYPEMASK;
71 if (type >= SF_FORMAT_FLAC || type >= SF_FORMAT_OGG) {
98 cerr <<
"WavFileReader::updateFrameCount: Failed to open file at \"" <<
m_path <<
"\" (" 99 << sf_strerror(
m_file) <<
")" << endl;
129 if (count == 0)
return;
145 if (
long(start + count) >
m_fileInfo.frames) {
149 sf_count_t readCount = 0;
153 if (sf_seek(
m_file, start, SEEK_SET) < 0) {
176 for (
int i = 0; i < count *
m_fileInfo.channels; ++i) {
178 cerr <<
"INTERNAL ERROR: WavFileReader::getInterleavedFrames: " << i <<
" >= " <<
m_bufsiz << endl;
191 if (sf_command(0, SFC_GET_FORMAT_MAJOR_COUNT, &count,
sizeof(count))) {
192 extensions.insert(
"wav");
193 extensions.insert(
"aiff");
194 extensions.insert(
"aifc");
195 extensions.insert(
"aif");
200 for (
int i = 0; i < count; ++i) {
202 if (!sf_command(0, SFC_GET_FORMAT_MAJOR, &info,
sizeof(info))) {
203 QString ext = QString(info.extension).toLower();
204 extensions.insert(ext);
209 extensions.insert(
"ogg");
218 std::set<QString> extensions;
220 return (extensions.find(extension.toLower()) != extensions.end());
226 return (type ==
"audio/x-wav" ||
227 type ==
"audio/x-aiff" ||
228 type ==
"audio/basic");
QString getExtension() const
Return the file extension for this file, if any.
WavFileReader(FileSource source, bool fileUpdating=false)
std::vector< float > SampleBlock
static bool supportsExtension(QString ext)
static bool supportsContentType(QString type)
static bool supports(FileSource &source)
FileSource is a class used to refer to the contents of a file that may be either local or at a remote...
static void getSupportedExtensions(std::set< QString > &extensions)
virtual void getInterleavedFrames(int start, int count, SampleBlock &frames) const
Must be safe to call from multiple threads with different arguments on the same object at the same ti...
QString getContentType() const
Return the MIME content type of this file, if known.