25 #include <QTextStream> 39 m_sampleRate(sampleRate),
48 path = dir.filePath(QString(
"written_%1.wav")
49 .arg((intptr_t)
this));
51 cerr <<
"WritableWaveFileModel: Failed to create temporary directory" << endl;
61 cerr <<
"WritableWaveFileModel: Error in creating WAV file writer: " <<
m_writer->
getError() << endl;
71 cerr <<
"WritableWaveFileModel: Error in creating wave file reader" << endl;
79 cerr <<
"WritableWaveFileModel: Error in creating wave file model" << endl;
112 #ifdef DEBUG_WRITABLE_WAVE_FILE_MODEL 117 cerr <<
"ERROR: WritableWaveFileModel::addSamples: writer failed: " <<
m_writer->
getError() << endl;
123 static int updateCounter = 0;
126 #ifdef DEBUG_WRITABLE_WAVE_FILE_MODEL 127 SVDEBUG <<
"WritableWaveFileModel::addSamples(" << count <<
"): calling updateFrameCount (initial)" << endl;
130 }
else if (++updateCounter == 100) {
131 #ifdef DEBUG_WRITABLE_WAVE_FILE_MODEL 132 SVDEBUG <<
"WritableWaveFileModel::addSamples(" << count <<
"): calling updateFrameCount (periodic)" << endl;
160 if (completion == 100) {
189 double *buffer)
const 197 int start,
int count,
198 float **buffers)
const 201 return m_model->
getData(fromchannel, tochannel, start, count, buffers);
214 int &blockSize)
const 221 WritableWaveFileModel::Range
231 QString extraAttributes)
const 240 QString(
"type=\"writablewavefile\" file=\"%1\" channels=\"%2\" %3")
virtual void toXml(QTextStream &out, QString indent="", QString extraAttributes="") const
Stream this exportable object out to XML on a text stream.
int getChannelCount() const
virtual Model * clone() const
Return a copy of this model.
std::vector< Range > RangeBlock
Reader for audio files using libsndfile.
virtual void getSummaries(int channel, int start, int count, RangeBlock &ranges, int &blockSize) const
Return ranges from the given start frame, corresponding to the given number of underlying sample fram...
bool isOK() const
Return true if the model was constructed successfully.
int getFrameCount() const
void modelChangedWithin(int startFrame, int endFrame)
Emitted when a model has been edited (or more data retrieved from cache, in the case of a cached mode...
virtual void setCompletion(int completion)
virtual void toXml(QTextStream &stream, QString indent="", QString extraAttributes="") const
Stream this exportable object out to XML on a text stream.
static QString encodeEntities(QString)
static TempDirectory * getInstance()
bool isReady(int *) const
Return true if the model has finished loading or calculating all its data, for a model that is capabl...
virtual int getData(int channel, int start, int count, float *buffer) const
Get the specified set of samples from the given channel of the model in single-precision floating-poi...
void setStartFrame(int startFrame)
WritableWaveFileModel(int sampleRate, int channels, QString path="")
void modelChanged()
Emitted when a model has been edited (or more data retrieved from cache, in the case of a cached mode...
Model is the base class for all data models that represent any sort of data on a time scale based on ...
virtual void getSummaries(int channel, int start, int count, RangeBlock &ranges, int &blockSize) const
Return ranges from the given start frame, corresponding to the given number of underlying sample fram...
FileSource is a class used to refer to the contents of a file that may be either local or at a remote...
virtual Range getSummary(int channel, int start, int count) const
Return the range from the given start frame, corresponding to the given number of underlying sample f...
virtual int getSummaryBlockSize(int desired) const
virtual QString getError() const
int getChannelCount() const
Return the number of distinct channels for this model.
virtual Range getSummary(int channel, int start, int count) const
Return the range from the given start frame, corresponding to the given number of underlying sample f...
bool writeSamples(float **samples, int count)
virtual QString getError() const
void setStartFrame(int startFrame)
virtual int getData(int channel, int start, int count, float *buffer) const
Get the specified set of samples from the given channel of the model in single-precision floating-poi...
bool isOK() const
Return true if the model was constructed successfully.
virtual bool addSamples(float **samples, int count)
Call addSamples to append a block of samples to the end of the file.
virtual int getSummaryBlockSize(int desired) const