void SoundFile::rec2play() { stream->close(); stream->open_read(filename); filteredStream->close(); filteredStream->open_read(filteredFilename); //beginning(); jumpToChunk(totalChunks()); fprintf(stderr, "filteredFilename = %s\n", filteredFilename); fprintf(stderr, "totalChunks = %d\n", totalChunks()); }
//------------------------------------------------------------------------------ void SoundFile::jumpToTime(const double & t) { jumpToChunk(chunkAtTime(t)); }
/** Preprocess the whole sound file, by looping through and processing every chunk in the file. A progress bar is displayed in the toolbar, because this can be time consuming. */ void SoundFile::preProcess() { //jumpToChunk(0); gdata->setDoingActiveAnalysis(true); myassert(firstTimeThrough == true); readChunk(bufferSize() - offset()); //readChunk(framesPerChunk()); //processNewChunk(); //printf("preProcessing\n"); //for(int j=0; j<numChannels(); j++) // channels(j)->setframesPerChunk(toRead); // Create a progress bar in the status bar to tell the user we're preprocessing MainWindow *theMainWindow = (MainWindow*) qApp->mainWidget(); QStatusBar *theStatusBar = theMainWindow->statusBar(); QLabel *message = new QLabel("Preprocessing data:", theStatusBar, "message"); //QLabel *message = new QLabel("Preprocessing data:", theMainWindow, "message"); //QProgressBar *progress = new QProgressBar(stream->totalFrames() / framesPerChunk(), theMainWindow, "progress bar"); Q3ProgressBar *progress = new Q3ProgressBar(stream->totalFrames() / framesPerChunk(), theStatusBar, "progress bar"); progress->setProgress(0); progress->setMaximumHeight(16); theStatusBar->addWidget(message); theStatusBar->addWidget(progress); message->show(); progress->show(); int frameCount = 1; int updateInterval = MAX(1, progress->totalSteps() / 50); // We'll update 50 times only //while(read_n(toRead, stream) == toRead) { // put data in channels while(readChunk(framesPerChunk()) == framesPerChunk()) { // put data in channels //printf("pos = %d\n", stream->pos); //processNewChunk(); //incrementChunkNum(); frameCount++; if (frameCount % updateInterval == 0) { progress->setProgress(progress->progress() + updateInterval); qApp->processEvents(); frameCount = 1; } } //printf("totalChunks=%d\n", totalChunks()); //printf("currentChunks=%d\n", currentChunk()); filteredStream->close(); filteredStream->open_read(filteredFilename); jumpToChunk(0); progress->setProgress(progress->totalSteps()); theStatusBar->removeWidget(progress); theStatusBar->removeWidget(message); delete progress; delete message; gdata->setDoingActiveAnalysis(false); firstTimeThrough = false; //printf("freqLookup.size()=%d\n", channels(0)->freqLookup.size()); }