47 mAFReader(otherSndFile.mAFReader),
48 mAFWriter(otherSndFile.mAFWriter),
49 mIOFile(otherSndFile.mIOFile),
50 mOutStream(otherSndFile.mOutStream) { }
69 else if (fmt[0] ==
'W')
103 String fname(mPath.c_str());
104 mIOFile =
new File(fname);
105 if ( ! mIOFile->exists()) {
109 AudioFormatManager formatManager;
110 formatManager.registerBasicFormats();
111 mAFReader = formatManager.createReaderFor(*mIOFile);
113 this->initFromSndfile();
121 unsigned numFrames = mAFReader->lengthInSamples;
123 this->readBufferFromFile(numFrames);
125 mCurrentFrame = mStart;
132 String fname(mPath.c_str());
133 mIOFile =
new File(fname);
134 mOutStream = mIOFile->createOutputStream();
135 StringPairArray metaDict;
136 AiffAudioFormat afmt;
141 mAFWriter = afmt.createWriterFor(mOutStream, (
double) rate, tchannels, bitDepth, metaDict, 0);
144 mAFWriter = wfmt.createWriterFor(mOutStream, (
double) rate, tchannels, bitDepth, metaDict, 0);
148 throw IOError(
"Unsupported sound file format");
169 memset(sampleBufferPtr, 0, numFrames *
sizeof(
sample));
177 currentFrame += numFrames;
180 throw IOError(
"Sound file read error");
183 if (currentFrame > (
unsigned) mStop) {
184 unsigned numFramesRemaining = currentFrame -
mStop;
185 unsigned numFramesRead = numFrames - numFramesRemaining;
188 while (numFramesRead < numFrames) {
192 currentFrame += numFramesRead;
195 unsigned bytesToClear = numFramesRemaining *
sizeof(
sample);
198 memset(sampleBufferPtr, 0, bytesToClear);
222 if (this->isCached()) {
223 mCurrentFrame = position;
224 return mCurrentFrame;
228 whenceInt = position;
231 whenceInt = mCurrentFrame - position;
234 whenceInt = duration() - position;
237 whenceInt = SEEK_CUR;
238 logMsg(
"Error: Invalid position seek flag. Used kPositionCurrent.");
242 mOutStream->setPosition(whenceInt);
243 return mCurrentFrame;
249 unsigned numFrames = inputBuffer.mNumFrames;
253 mCurrentFrame += numFrames;
256 throw IOError(
"Sound file write error");