sv1-devel Mailing List for Sonic Visualiser (Page 46)
Brought to you by:
cannam
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
(7) |
May
(140) |
Jun
(112) |
Jul
(33) |
Aug
(15) |
Sep
(2) |
Oct
(6) |
Nov
(7) |
Dec
(6) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(22) |
Feb
(12) |
Mar
(68) |
Apr
(38) |
May
(33) |
Jun
(32) |
Jul
(15) |
Aug
(36) |
Sep
(4) |
Oct
(34) |
Nov
(22) |
Dec
(75) |
2008 |
Jan
(12) |
Feb
(58) |
Mar
(16) |
Apr
(8) |
May
(13) |
Jun
(7) |
Jul
(2) |
Aug
(3) |
Sep
(2) |
Oct
(3) |
Nov
(1) |
Dec
(4) |
2009 |
Jan
|
Feb
(19) |
Mar
(32) |
Apr
(1) |
May
(2) |
Jun
(4) |
Jul
(11) |
Aug
(7) |
Sep
(6) |
Oct
(3) |
Nov
(3) |
Dec
(8) |
2010 |
Jan
(8) |
Feb
(3) |
Mar
(2) |
Apr
|
May
(6) |
Jun
(5) |
Jul
(13) |
Aug
(7) |
Sep
(1) |
Oct
(10) |
Nov
(4) |
Dec
(2) |
2011 |
Jan
|
Feb
|
Mar
(6) |
Apr
(3) |
May
(2) |
Jun
|
Jul
(3) |
Aug
(3) |
Sep
(5) |
Oct
(4) |
Nov
(1) |
Dec
|
2012 |
Jan
(1) |
Feb
|
Mar
(1) |
Apr
(2) |
May
(1) |
Jun
(1) |
Jul
(2) |
Aug
(2) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
(2) |
2013 |
Jan
(1) |
Feb
(5) |
Mar
(12) |
Apr
(4) |
May
(2) |
Jun
|
Jul
(5) |
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(6) |
2014 |
Jan
|
Feb
(13) |
Mar
|
Apr
(2) |
May
(2) |
Jun
|
Jul
|
Aug
(1) |
Sep
(1) |
Oct
(1) |
Nov
(1) |
Dec
(1) |
2016 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
(2) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
(1) |
Nov
|
Dec
|
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
(1) |
2019 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(3) |
Dec
(5) |
2021 |
Jan
(4) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <ca...@us...> - 2006-04-29 19:20:36
|
Revision: 170 Author: cannam Date: 2006-04-29 12:20:28 -0700 (Sat, 29 Apr 2006) ViewCVS: http://svn.sourceforge.net/sv1/?rev=170&view=rev Log Message: ----------- * just a comment fix Modified Paths: -------------- sonic-visualiser/trunk/layer/SpectrogramLayer.h Modified: sonic-visualiser/trunk/layer/SpectrogramLayer.h =================================================================== --- sonic-visualiser/trunk/layer/SpectrogramLayer.h 2006-04-28 17:10:09 UTC (rev 169) +++ sonic-visualiser/trunk/layer/SpectrogramLayer.h 2006-04-29 19:20:28 UTC (rev 170) @@ -218,22 +218,15 @@ BinDisplay m_binDisplay; bool m_normalizeColumns; - // At the moment we cache one unsigned char per bin for the - // magnitude -- which is nothing like precise enough to allow us - // to subsequently adjust gain etc without recalculating the - // cached values -- plus optionally one unsigned char per bin for - // phase-adjusted frequency. - - // To speed up redrawing after parameter changes, we would like to - // cache magnitude in a way that can have gain applied afterwards - // and can determine whether something is a peak or not, and also - // cache phase rather than only phase-adjusted frequency so that - // we don't have to recalculate if switching between phase and - // magnitude displays. + // We would like to cache magnitude in a way that can have gain + // applied afterwards and can determine whether something is a + // peak or not, and also cache phase rather than only + // phase-adjusted frequency so that we don't have to recalculate + // if switching between phase and magnitude displays. At the same + // time, we don't want to waste too much memory. // This implies probably 16 bits for a normalized magnitude (in - // dB?) and at most 16 bits for phase. 16 or 32 bits per bin - // instead of 8 or 16. + // dB?) and at most 16 bits for phase. // Each column's magnitudes are expected to be stored normalized // to [0,1] with respect to the column, so the normalization This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ca...@us...> - 2006-04-28 17:10:19
|
Revision: 169 Author: cannam Date: 2006-04-28 10:10:09 -0700 (Fri, 28 Apr 2006) ViewCVS: http://svn.sourceforge.net/sv1/?rev=169&view=rev Log Message: ----------- * Add progress dialog for MP3 import Modified Paths: -------------- sonic-visualiser/trunk/fileio/MP3FileReader.cpp sonic-visualiser/trunk/fileio/MP3FileReader.h Modified: sonic-visualiser/trunk/fileio/MP3FileReader.cpp =================================================================== --- sonic-visualiser/trunk/fileio/MP3FileReader.cpp 2006-04-28 12:52:17 UTC (rev 168) +++ sonic-visualiser/trunk/fileio/MP3FileReader.cpp 2006-04-28 17:10:09 UTC (rev 169) @@ -27,6 +27,7 @@ #include <iostream> #include <QApplication> +#include <QProgressDialog> MP3FileReader::MP3FileReader(QString path, bool showProgress, CacheMode mode) : CodedAudioFileReader(mode), @@ -35,6 +36,11 @@ m_frameCount = 0; m_channelCount = 0; m_sampleRate = 0; + m_fileSize = 0; + m_bitrateNum = 0; + m_bitrateDenom = 0; + m_frameCount = 0; + m_cancelled = false; struct stat stat; if (::stat(path.toLocal8Bit().data(), &stat) == -1 || stat.st_size == 0) { @@ -42,6 +48,8 @@ return; } + m_fileSize = stat.st_size; + int fd; if ((fd = ::open(path.toLocal8Bit().data(), O_RDONLY, 0)) < 0) { m_error = QString("Failed to open file %1 for reading.").arg(path); @@ -55,7 +63,12 @@ return; } - if (showProgress) QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + if (showProgress) { + m_progress = new QProgressDialog + (QObject::tr("Decoding MP3 file..."), + QObject::tr("Stop"), 0, 100); + m_progress->hide(); + } if (!decode(mm, stat.st_size)) { m_error = QString("Failed to decode file %1.").arg(path); @@ -65,7 +78,10 @@ if (isDecodeCacheInitialised()) finishDecodeCache(); - if (showProgress) QApplication::restoreOverrideCursor(); + if (showProgress) { + delete m_progress; + m_progress = 0; + } ::munmap(mm, stat.st_size); } @@ -110,18 +126,53 @@ struct mad_pcm *pcm) { DecoderData *data = (DecoderData *)dp; + return data->reader->accept(header, pcm); +} +enum mad_flow +MP3FileReader::accept(struct mad_header const *header, + struct mad_pcm *pcm) +{ int channels = pcm->channels; int frames = pcm->length; + if (header) { + m_bitrateNum += header->bitrate; + m_bitrateDenom ++; + } + if (frames < 1) return MAD_FLOW_CONTINUE; - data->reader->m_channelCount = channels; - data->reader->m_frameCount += frames; - data->reader->m_sampleRate = pcm->samplerate; + if (m_channelCount == 0) { + m_channelCount = channels; + m_sampleRate = pcm->samplerate; + } + + if (m_bitrateDenom > 0) { + double bitrate = m_bitrateNum / m_bitrateDenom; + double duration = double(m_fileSize * 8) / bitrate; + double elapsed = double(m_frameCount) / m_sampleRate; + double percent = ((elapsed * 100.0) / duration); + int progress = int(percent); + if (progress < 1) progress = 1; + if (progress > 99) progress = 99; + if (progress > m_progress->value()) { + m_progress->setValue(progress); + m_progress->show(); + m_progress->raise(); + qApp->processEvents(); + if (m_progress->wasCanceled()) { + m_cancelled = true; + } + } + } - if (!data->reader->isDecodeCacheInitialised()) { - data->reader->initialiseDecodeCache(); + if (m_cancelled) return MAD_FLOW_STOP; + + m_frameCount += frames; + + if (!isDecodeCacheInitialised()) { + initialiseDecodeCache(); } for (int i = 0; i < frames; ++i) { @@ -132,19 +183,18 @@ sample = pcm->samples[ch][i]; } float fsample = float(sample) / float(MAD_F_ONE); -// data->reader->m_data.push_back(fsample); - data->reader->addSampleToDecodeCache(fsample); + addSampleToDecodeCache(fsample); } if (! (i & 0xffff)) { // periodically munlock to ensure we don't exhaust real memory // if running with memory locked down - MUNLOCK_SAMPLEBLOCK(data->reader->m_data); + MUNLOCK_SAMPLEBLOCK(m_data); } } if (frames > 0) { - MUNLOCK_SAMPLEBLOCK(data->reader->m_data); + MUNLOCK_SAMPLEBLOCK(m_data); } return MAD_FLOW_CONTINUE; @@ -153,7 +203,7 @@ enum mad_flow MP3FileReader::error(void *dp, struct mad_stream *stream, - struct mad_frame *frame) + struct mad_frame *) { DecoderData *data = (DecoderData *)dp; Modified: sonic-visualiser/trunk/fileio/MP3FileReader.h =================================================================== --- sonic-visualiser/trunk/fileio/MP3FileReader.h 2006-04-28 12:52:17 UTC (rev 168) +++ sonic-visualiser/trunk/fileio/MP3FileReader.h 2006-04-28 17:10:09 UTC (rev 169) @@ -22,6 +22,8 @@ #include <mad.h> +class QProgressDialog; + class MP3FileReader : public CodedAudioFileReader { public: @@ -33,7 +35,13 @@ protected: QString m_path; QString m_error; + size_t m_fileSize; + double m_bitrateNum; + size_t m_bitrateDenom; + QProgressDialog *m_progress; + bool m_cancelled; + struct DecoderData { unsigned char const *start; @@ -42,6 +50,7 @@ }; bool decode(void *mm, size_t sz); + enum mad_flow accept(struct mad_header const *, struct mad_pcm *); static enum mad_flow input(void *, struct mad_stream *); static enum mad_flow output(void *, struct mad_header const *, struct mad_pcm *); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ca...@us...> - 2006-04-28 12:52:27
|
Revision: 168 Author: cannam Date: 2006-04-28 05:52:17 -0700 (Fri, 28 Apr 2006) ViewCVS: http://svn.sourceforge.net/sv1/?rev=168&view=rev Log Message: ----------- * Fix failure to pull out values and durations when copying from a layer Modified Paths: -------------- sonic-visualiser/trunk/layer/NoteLayer.cpp sonic-visualiser/trunk/layer/TimeValueLayer.cpp sonic-visualiser/trunk/main/MainWindow.cpp Modified: sonic-visualiser/trunk/layer/NoteLayer.cpp =================================================================== --- sonic-visualiser/trunk/layer/NoteLayer.cpp 2006-04-28 12:19:09 UTC (rev 167) +++ sonic-visualiser/trunk/layer/NoteLayer.cpp 2006-04-28 12:52:17 UTC (rev 168) @@ -766,7 +766,7 @@ for (NoteModel::PointList::iterator i = points.begin(); i != points.end(); ++i) { if (s.contains(i->frame)) { - Clipboard::Point point(i->frame, i->label); + Clipboard::Point point(i->frame, i->value, i->duration, i->label); to.addPoint(point); } } Modified: sonic-visualiser/trunk/layer/TimeValueLayer.cpp =================================================================== --- sonic-visualiser/trunk/layer/TimeValueLayer.cpp 2006-04-28 12:19:09 UTC (rev 167) +++ sonic-visualiser/trunk/layer/TimeValueLayer.cpp 2006-04-28 12:52:17 UTC (rev 168) @@ -1067,7 +1067,7 @@ for (SparseTimeValueModel::PointList::iterator i = points.begin(); i != points.end(); ++i) { if (s.contains(i->frame)) { - Clipboard::Point point(i->frame, i->label); + Clipboard::Point point(i->frame, i->value, i->label); to.addPoint(point); } } Modified: sonic-visualiser/trunk/main/MainWindow.cpp =================================================================== --- sonic-visualiser/trunk/main/MainWindow.cpp 2006-04-28 12:19:09 UTC (rev 167) +++ sonic-visualiser/trunk/main/MainWindow.cpp 2006-04-28 12:52:17 UTC (rev 168) @@ -1180,6 +1180,9 @@ Pane *currentPane = m_paneStack->getCurrentPane(); if (!currentPane) return; + //!!! if we have no current layer, we should create one of the most + // appropriate type + Layer *layer = currentPane->getSelectedLayer(); if (!layer) return; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ca...@us...> - 2006-04-28 12:19:23
|
Revision: 167 Author: cannam Date: 2006-04-28 05:19:09 -0700 (Fri, 28 Apr 2006) ViewCVS: http://svn.sourceforge.net/sv1/?rev=167&view=rev Log Message: ----------- * fix long-standing failure to silence layers that have been deleted * fix deadlock in WaveFileModel::cacheFilled * fixes and speedups to new CodedAudioFileReader * trap signals in main, clean up temporary directory Modified Paths: -------------- sonic-visualiser/trunk/audioio/AudioCallbackPlaySource.cpp sonic-visualiser/trunk/audioio/AudioGenerator.cpp sonic-visualiser/trunk/fileio/CodedAudioFileReader.cpp sonic-visualiser/trunk/fileio/CodedAudioFileReader.h sonic-visualiser/trunk/fileio/MP3FileReader.cpp sonic-visualiser/trunk/fileio/OggVorbisFileReader.cpp sonic-visualiser/trunk/main/MainWindow.cpp sonic-visualiser/trunk/main/main.cpp sonic-visualiser/trunk/model/WaveFileModel.cpp Modified: sonic-visualiser/trunk/audioio/AudioCallbackPlaySource.cpp =================================================================== --- sonic-visualiser/trunk/audioio/AudioCallbackPlaySource.cpp 2006-04-27 17:29:19 UTC (rev 166) +++ sonic-visualiser/trunk/audioio/AudioCallbackPlaySource.cpp 2006-04-28 12:19:09 UTC (rev 167) @@ -96,6 +96,8 @@ void AudioCallbackPlaySource::addModel(Model *model) { + if (m_models.find(model) != m_models.end()) return; + bool canPlay = m_audioGenerator->addModel(model); m_mutex.lock(); Modified: sonic-visualiser/trunk/audioio/AudioGenerator.cpp =================================================================== --- sonic-visualiser/trunk/audioio/AudioGenerator.cpp 2006-04-27 17:29:19 UTC (rev 166) +++ sonic-visualiser/trunk/audioio/AudioGenerator.cpp 2006-04-28 12:19:09 UTC (rev 167) @@ -159,7 +159,7 @@ const SparseOneDimensionalModel *sodm = dynamic_cast<const SparseOneDimensionalModel *>(model); if (sodm) { - program = "cowbell"; + program = "tap"; } const NoteModel *nm = dynamic_cast<const NoteModel *>(model); Modified: sonic-visualiser/trunk/fileio/CodedAudioFileReader.cpp =================================================================== --- sonic-visualiser/trunk/fileio/CodedAudioFileReader.cpp 2006-04-27 17:29:19 UTC (rev 166) +++ sonic-visualiser/trunk/fileio/CodedAudioFileReader.cpp 2006-04-28 12:19:09 UTC (rev 167) @@ -26,16 +26,17 @@ m_initialised(false), m_cacheFileWritePtr(0), m_cacheFileReader(0), - m_cacheChannelBuffer(0), - m_cacheChannelBufferIndex(0) + m_cacheWriteBuffer(0), + m_cacheWriteBufferIndex(0), + m_cacheWriteBufferSize(16384) { } CodedAudioFileReader::~CodedAudioFileReader() { if (m_cacheFileWritePtr) sf_close(m_cacheFileWritePtr); - delete m_cacheFileReader; - delete m_cacheChannelBuffer; + if (m_cacheFileReader) delete m_cacheFileReader; + if (m_cacheWriteBuffer) delete[] m_cacheWriteBuffer; } void @@ -43,7 +44,8 @@ { if (m_cacheMode == CacheInTemporaryFile) { - m_cacheChannelBuffer = new float[m_channelCount]; + m_cacheWriteBuffer = new float[m_cacheWriteBufferSize * m_channelCount]; + m_cacheWriteBufferIndex = 0; try { QDir dir(TempDirectory::instance()->getPath()); @@ -84,13 +86,17 @@ case CacheInTemporaryFile: - //!!! need to write in bigger blocks, match bit depth of original file + m_cacheWriteBuffer[m_cacheWriteBufferIndex++] = sample; - m_cacheChannelBuffer[m_cacheChannelBufferIndex++] = sample; - if (m_cacheChannelBufferIndex == m_channelCount) { + if (m_cacheWriteBufferIndex == + m_cacheWriteBufferSize * m_channelCount) { + //!!! check for return value! out of disk space, etc! - sf_writef_float(m_cacheFileWritePtr, m_cacheChannelBuffer, 1); - m_cacheChannelBufferIndex = 0; + sf_writef_float(m_cacheFileWritePtr, + m_cacheWriteBuffer, + m_cacheWriteBufferSize); + + m_cacheWriteBufferIndex = 0; } break; @@ -111,9 +117,26 @@ switch (m_cacheMode) { case CacheInTemporaryFile: + + if (m_cacheWriteBufferIndex > 0) { + //!!! check for return value! out of disk space, etc! + sf_writef_float(m_cacheFileWritePtr, + m_cacheWriteBuffer, + m_cacheWriteBufferIndex / m_channelCount); + } + + if (m_cacheWriteBuffer) { + delete[] m_cacheWriteBuffer; + m_cacheWriteBuffer = 0; + } + + m_cacheWriteBufferIndex = 0; + sf_close(m_cacheFileWritePtr); m_cacheFileWritePtr = 0; + m_cacheFileReader = new WavFileReader(m_cacheFileName); + if (!m_cacheFileReader->isOK()) { std::cerr << "ERROR: CodedAudioFileReader::finishDecodeCache: Failed to construct WAV file reader for temporary file: " << m_cacheFileReader->getError().toStdString() << std::endl; delete m_cacheFileReader; Modified: sonic-visualiser/trunk/fileio/CodedAudioFileReader.h =================================================================== --- sonic-visualiser/trunk/fileio/CodedAudioFileReader.h 2006-04-27 17:29:19 UTC (rev 166) +++ sonic-visualiser/trunk/fileio/CodedAudioFileReader.h 2006-04-28 12:19:09 UTC (rev 167) @@ -50,8 +50,9 @@ QString m_cacheFileName; SNDFILE *m_cacheFileWritePtr; WavFileReader *m_cacheFileReader; - float *m_cacheChannelBuffer; - size_t m_cacheChannelBufferIndex; + float *m_cacheWriteBuffer; + size_t m_cacheWriteBufferIndex; + size_t m_cacheWriteBufferSize; // frames }; #endif Modified: sonic-visualiser/trunk/fileio/MP3FileReader.cpp =================================================================== --- sonic-visualiser/trunk/fileio/MP3FileReader.cpp 2006-04-27 17:29:19 UTC (rev 166) +++ sonic-visualiser/trunk/fileio/MP3FileReader.cpp 2006-04-28 12:19:09 UTC (rev 167) @@ -63,7 +63,7 @@ return; } - finishDecodeCache(); + if (isDecodeCacheInitialised()) finishDecodeCache(); if (showProgress) QApplication::restoreOverrideCursor(); Modified: sonic-visualiser/trunk/fileio/OggVorbisFileReader.cpp =================================================================== --- sonic-visualiser/trunk/fileio/OggVorbisFileReader.cpp 2006-04-27 17:29:19 UTC (rev 166) +++ sonic-visualiser/trunk/fileio/OggVorbisFileReader.cpp 2006-04-28 12:19:09 UTC (rev 167) @@ -76,7 +76,7 @@ m_fishSound = 0; oggz_close(oggz); - finishDecodeCache(); + if (isDecodeCacheInitialised()) finishDecodeCache(); if (showProgress) { delete m_progress; Modified: sonic-visualiser/trunk/main/MainWindow.cpp =================================================================== --- sonic-visualiser/trunk/main/MainWindow.cpp 2006-04-27 17:29:19 UTC (rev 166) +++ sonic-visualiser/trunk/main/MainWindow.cpp 2006-04-28 12:19:09 UTC (rev 167) @@ -2681,6 +2681,30 @@ MainWindow::layerInAView(Layer *layer, bool inAView) { std::cerr << "MainWindow::layerInAView(" << layer << "," << inAView << ")" << std::endl; + + // Check whether we need to add or remove model from play source + Model *model = layer->getModel(); + if (model) { + if (inAView) { + m_playSource->addModel(model); + } else { + bool found = false; + for (int i = 0; i < m_paneStack->getPaneCount(); ++i) { + Pane *pane = m_paneStack->getPane(i); + if (!pane) continue; + for (int j = 0; j < pane->getLayerCount(); ++j) { + Layer *pl = pane->getLayer(j); + if (pl && pl->getModel() == model) { + found = true; + break; + } + } + if (found) break; + } + if (!found) m_playSource->removeModel(model); + } + } + setupExistingLayersMenu(); updateMenuStates(); } Modified: sonic-visualiser/trunk/main/main.cpp =================================================================== --- sonic-visualiser/trunk/main/main.cpp 2006-04-27 17:29:19 UTC (rev 166) +++ sonic-visualiser/trunk/main/main.cpp 2006-04-28 12:19:09 UTC (rev 167) @@ -23,6 +23,7 @@ #include "base/TempDirectory.h" #include <iostream> +#include <signal.h> #ifdef Q_WS_X11 #include <X11/Xlib.h> @@ -75,11 +76,30 @@ //!!! catch trappable signals, cleanup temporary directory etc //!!! check for crap left over from previous run +static QMutex cleanupMutex; + +static void +signalHandler(int /* signal */) +{ + // Avoid this happening more than once across threads + + cleanupMutex.lock(); + std::cerr << "signalHandler: cleaning up and exiting" << std::endl; + TempDirectory::instance()->cleanup(); + exit(0); // without releasing mutex +} + int main(int argc, char **argv) { QApplication application(argc, argv); + // I have absolutely no idea whether this works on win32 as well + signal(SIGINT, signalHandler); + signal(SIGTERM, signalHandler); + signal(SIGHUP, signalHandler); + signal(SIGQUIT, signalHandler); + #ifdef Q_WS_X11 XSetErrorHandler(handle_x11_error); #endif @@ -125,7 +145,7 @@ int rv = application.exec(); std::cerr << "application.exec() returned " << rv << std::endl; + cleanupMutex.lock(); TempDirectory::instance()->cleanup(); - return rv; } Modified: sonic-visualiser/trunk/model/WaveFileModel.cpp =================================================================== --- sonic-visualiser/trunk/model/WaveFileModel.cpp 2006-04-27 17:29:19 UTC (rev 166) +++ sonic-visualiser/trunk/model/WaveFileModel.cpp 2006-04-28 12:19:09 UTC (rev 167) @@ -349,12 +349,13 @@ void WaveFileModel::fillCache() { - QMutexLocker locker(&m_mutex); + m_mutex.lock(); m_updateTimer = new QTimer(this); connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(fillTimerTimedOut())); m_updateTimer->start(100); m_fillThread = new RangeCacheFillThread(*this); connect(m_fillThread, SIGNAL(finished()), this, SLOT(cacheFilled())); + m_mutex.unlock(); m_fillThread->start(); } @@ -375,11 +376,12 @@ void WaveFileModel::cacheFilled() { - QMutexLocker locker(&m_mutex); + m_mutex.lock(); delete m_fillThread; m_fillThread = 0; delete m_updateTimer; m_updateTimer = 0; + m_mutex.unlock(); emit modelChanged(); cerr << "WaveFileModel::cacheFilled" << endl; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ca...@us...> - 2006-04-27 17:29:53
|
Revision: 166 Author: cannam Date: 2006-04-27 10:29:19 -0700 (Thu, 27 Apr 2006) ViewCVS: http://svn.sourceforge.net/sv1/?rev=166&view=rev Log Message: ----------- * Add file open/save operations to main toolbar * Allow opening any sort of file from toolbar file open function * First cut at on-disc cacheing for decoded mp3/ogg files * Permit un-snapped selection by holding Shift Modified Paths: -------------- sonic-visualiser/trunk/base/System.h sonic-visualiser/trunk/base/TempDirectory.cpp sonic-visualiser/trunk/fileio/AudioFileReaderFactory.cpp sonic-visualiser/trunk/fileio/MP3FileReader.cpp sonic-visualiser/trunk/fileio/MP3FileReader.h sonic-visualiser/trunk/fileio/OggVorbisFileReader.cpp sonic-visualiser/trunk/fileio/OggVorbisFileReader.h sonic-visualiser/trunk/layer/SpectrogramLayer.cpp sonic-visualiser/trunk/main/MainWindow.cpp sonic-visualiser/trunk/main/MainWindow.h sonic-visualiser/trunk/main/main.cpp sonic-visualiser/trunk/sonic-visualiser.pro sonic-visualiser/trunk/sonic-visualiser.qrc sonic-visualiser/trunk/widgets/AudioDial.cpp sonic-visualiser/trunk/widgets/Fader.cpp sonic-visualiser/trunk/widgets/Pane.cpp Added Paths: ----------- sonic-visualiser/trunk/fileio/CodedAudioFileReader.cpp sonic-visualiser/trunk/fileio/CodedAudioFileReader.h sonic-visualiser/trunk/icons/filenew-22.png sonic-visualiser/trunk/icons/fileopen-22.png sonic-visualiser/trunk/icons/filesave-22.png sonic-visualiser/trunk/icons/filesaveas-22.png Modified: sonic-visualiser/trunk/base/System.h =================================================================== --- sonic-visualiser/trunk/base/System.h 2006-04-27 11:49:34 UTC (rev 165) +++ sonic-visualiser/trunk/base/System.h 2006-04-27 17:29:19 UTC (rev 166) @@ -45,7 +45,7 @@ #define MLOCK(a,b) ::mlock((a),(b)) #define MUNLOCK(a,b) (::munlock((a),(b)) ? (::perror("munlock failed"), 0) : 0) -#define MUNLOCK_SAMPLEBLOCK(a) do { const float &b = *(a).begin(); MUNLOCK(&b, (a).capacity() * sizeof(float)); } while(0); +#define MUNLOCK_SAMPLEBLOCK(a) do { if (!(a).empty()) { const float &b = *(a).begin(); MUNLOCK(&b, (a).capacity() * sizeof(float)); } } while(0); #define DLOPEN(a,b) dlopen((a).toStdString().c_str(),(b)) #define DLSYM(a,b) dlsym((a),(b)) Modified: sonic-visualiser/trunk/base/TempDirectory.cpp =================================================================== --- sonic-visualiser/trunk/base/TempDirectory.cpp 2006-04-27 11:49:34 UTC (rev 165) +++ sonic-visualiser/trunk/base/TempDirectory.cpp 2006-04-27 17:29:19 UTC (rev 166) @@ -70,7 +70,8 @@ if (m_tmpdir != "") return m_tmpdir; - QDir systemTempDir = QDir::temp(); +//!!! QDir tempDirBase = QDir::temp(); + QDir tempDirBase = QDir::home(); // Generate a temporary directory. Qt4.1 doesn't seem to be able // to do this for us, and mkdtemp is not standard. This method is @@ -98,8 +99,8 @@ QString candidate = QString("sv_%1").arg(suffix); - if (QDir::temp().mkpath(candidate)) { - m_tmpdir = systemTempDir.filePath(candidate); + if (tempDirBase.mkpath(candidate)) { + m_tmpdir = tempDirBase.filePath(candidate); break; } @@ -108,7 +109,7 @@ if (m_tmpdir == "") { throw DirectoryCreationFailed(QString("temporary subdirectory in %1") - .arg(systemTempDir.canonicalPath())); + .arg(tempDirBase.canonicalPath())); } return m_tmpdir; Modified: sonic-visualiser/trunk/fileio/AudioFileReaderFactory.cpp =================================================================== --- sonic-visualiser/trunk/fileio/AudioFileReaderFactory.cpp 2006-04-27 11:49:34 UTC (rev 165) +++ sonic-visualiser/trunk/fileio/AudioFileReaderFactory.cpp 2006-04-27 17:29:19 UTC (rev 166) @@ -51,7 +51,8 @@ #ifdef HAVE_OGGZ #ifdef HAVE_FISHSOUND - reader = new OggVorbisFileReader(path, true); + reader = new OggVorbisFileReader(path, true, + OggVorbisFileReader::CacheInTemporaryFile); if (reader->isOK()) return reader; if (reader->getError() != "") err = reader->getError(); delete reader; @@ -59,7 +60,8 @@ #endif #ifdef HAVE_MAD - reader = new MP3FileReader(path, true); + reader = new MP3FileReader(path, true, + MP3FileReader::CacheInTemporaryFile); if (reader->isOK()) return reader; if (reader->getError() != "") err = reader->getError(); delete reader; Added: sonic-visualiser/trunk/fileio/CodedAudioFileReader.cpp =================================================================== --- sonic-visualiser/trunk/fileio/CodedAudioFileReader.cpp (rev 0) +++ sonic-visualiser/trunk/fileio/CodedAudioFileReader.cpp 2006-04-27 17:29:19 UTC (rev 166) @@ -0,0 +1,162 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Sonic Visualiser + An audio file viewer and annotation editor. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2006 Chris Cannam. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + +#include "CodedAudioFileReader.h" + +#include "WavFileReader.h" +#include "base/TempDirectory.h" + +#include <iostream> +#include <QDir> + +CodedAudioFileReader::CodedAudioFileReader(CacheMode cacheMode) : + m_cacheMode(cacheMode), + m_initialised(false), + m_cacheFileWritePtr(0), + m_cacheFileReader(0), + m_cacheChannelBuffer(0), + m_cacheChannelBufferIndex(0) +{ +} + +CodedAudioFileReader::~CodedAudioFileReader() +{ + if (m_cacheFileWritePtr) sf_close(m_cacheFileWritePtr); + delete m_cacheFileReader; + delete m_cacheChannelBuffer; +} + +void +CodedAudioFileReader::initialiseDecodeCache() +{ + if (m_cacheMode == CacheInTemporaryFile) { + + m_cacheChannelBuffer = new float[m_channelCount]; + + try { + QDir dir(TempDirectory::instance()->getPath()); + m_cacheFileName = dir.filePath(QString("decoded_%1.wav") + .arg((intptr_t)this)); + + SF_INFO fileInfo; + fileInfo.samplerate = m_sampleRate; + fileInfo.channels = m_channelCount; + fileInfo.format = SF_FORMAT_WAV | SF_FORMAT_FLOAT; + + m_cacheFileWritePtr = sf_open(m_cacheFileName.toLocal8Bit(), + SFM_WRITE, &fileInfo); + + if (!m_cacheFileWritePtr) { + std::cerr << "CodedAudioFileReader::initialiseDecodeCache: failed to open cache file \"" << m_cacheFileName.toStdString() << "\" (" << m_channelCount << " channels, sample rate " << m_sampleRate << " for writing, falling back to in-memory cache" << std::endl; + m_cacheMode = CacheInMemory; + } + } catch (TempDirectory::DirectoryCreationFailed f) { + std::cerr << "CodedAudioFileReader::initialiseDecodeCache: failed to create temporary directory! Falling back to in-memory cache" << std::endl; + m_cacheMode = CacheInMemory; + } + } + + if (m_cacheMode == CacheInMemory) { + m_data.clear(); + } + + m_initialised = true; +} + +void +CodedAudioFileReader::addSampleToDecodeCache(float sample) +{ + if (!m_initialised) return; + + switch (m_cacheMode) { + + case CacheInTemporaryFile: + + //!!! need to write in bigger blocks, match bit depth of original file + + m_cacheChannelBuffer[m_cacheChannelBufferIndex++] = sample; + if (m_cacheChannelBufferIndex == m_channelCount) { + //!!! check for return value! out of disk space, etc! + sf_writef_float(m_cacheFileWritePtr, m_cacheChannelBuffer, 1); + m_cacheChannelBufferIndex = 0; + } + break; + + case CacheInMemory: + m_data.push_back(sample); + break; + } +} + +void +CodedAudioFileReader::finishDecodeCache() +{ + if (!m_initialised) { + std::cerr << "WARNING: CodedAudioFileReader::finishDecodeCache: Cache was never initialised!" << std::endl; + return; + } + + switch (m_cacheMode) { + + case CacheInTemporaryFile: + sf_close(m_cacheFileWritePtr); + m_cacheFileWritePtr = 0; + m_cacheFileReader = new WavFileReader(m_cacheFileName); + if (!m_cacheFileReader->isOK()) { + std::cerr << "ERROR: CodedAudioFileReader::finishDecodeCache: Failed to construct WAV file reader for temporary file: " << m_cacheFileReader->getError().toStdString() << std::endl; + delete m_cacheFileReader; + m_cacheFileReader = 0; + } + break; + + case CacheInMemory: + // nothing to do + break; + } +} + +void +CodedAudioFileReader::getInterleavedFrames(size_t start, size_t count, + SampleBlock &frames) const +{ + if (!m_initialised) return; + + switch (m_cacheMode) { + + case CacheInTemporaryFile: + if (m_cacheFileReader) { + m_cacheFileReader->getInterleavedFrames(start, count, frames); + } + break; + + case CacheInMemory: + { + frames.clear(); + if (!isOK()) return; + if (count == 0) return; + + // slownessabounds + + for (size_t i = start; i < start + count; ++i) { + for (size_t ch = 0; ch < m_channelCount; ++ch) { + size_t index = i * m_channelCount + ch; + if (index >= m_data.size()) return; + frames.push_back(m_data[index]); + } + } + } + } +} + Added: sonic-visualiser/trunk/fileio/CodedAudioFileReader.h =================================================================== --- sonic-visualiser/trunk/fileio/CodedAudioFileReader.h (rev 0) +++ sonic-visualiser/trunk/fileio/CodedAudioFileReader.h 2006-04-27 17:29:19 UTC (rev 166) @@ -0,0 +1,57 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Sonic Visualiser + An audio file viewer and annotation editor. + Centre for Digital Music, Queen Mary, University of London. + This file copyright 2006 Chris Cannam. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + +#ifndef _CODED_AUDIO_FILE_READER_H_ +#define _CODED_AUDIO_FILE_READER_H_ + +#include "AudioFileReader.h" + +#include <sndfile.h> + +class WavFileReader; + +class CodedAudioFileReader : public AudioFileReader +{ +public: + virtual ~CodedAudioFileReader(); + + enum CacheMode { + CacheInTemporaryFile, + CacheInMemory + }; + + virtual void getInterleavedFrames(size_t start, size_t count, + SampleBlock &frames) const; + +protected: + CodedAudioFileReader(CacheMode cacheMode); + + void initialiseDecodeCache(); // samplerate, channels must have been set + void addSampleToDecodeCache(float sample); + void finishDecodeCache(); + bool isDecodeCacheInitialised() const { return m_initialised; } + + CacheMode m_cacheMode; + SampleBlock m_data; + bool m_initialised; + + QString m_cacheFileName; + SNDFILE *m_cacheFileWritePtr; + WavFileReader *m_cacheFileReader; + float *m_cacheChannelBuffer; + size_t m_cacheChannelBufferIndex; +}; + +#endif Modified: sonic-visualiser/trunk/fileio/MP3FileReader.cpp =================================================================== --- sonic-visualiser/trunk/fileio/MP3FileReader.cpp 2006-04-27 11:49:34 UTC (rev 165) +++ sonic-visualiser/trunk/fileio/MP3FileReader.cpp 2006-04-27 17:29:19 UTC (rev 166) @@ -28,7 +28,8 @@ #include <QApplication> -MP3FileReader::MP3FileReader(QString path, bool showProgress) : +MP3FileReader::MP3FileReader(QString path, bool showProgress, CacheMode mode) : + CodedAudioFileReader(mode), m_path(path) { m_frameCount = 0; @@ -62,6 +63,8 @@ return; } + finishDecodeCache(); + if (showProgress) QApplication::restoreOverrideCursor(); ::munmap(mm, stat.st_size); @@ -72,27 +75,6 @@ } -void -MP3FileReader::getInterleavedFrames(size_t start, size_t count, - SampleBlock &frames) const -{ - frames.clear(); - if (!isOK()) return; - if (count == 0) return; - - // slownessabounds - - size_t channels = getChannelCount(); - - for (size_t i = start; i < start + count; ++i) { - for (size_t ch = 0; ch < channels; ++ch) { - size_t index = i * channels + ch; - if (index >= m_data.size()) return; - frames.push_back(m_data[index]); - } - } -} - bool MP3FileReader::decode(void *mm, size_t sz) { @@ -138,6 +120,10 @@ data->reader->m_frameCount += frames; data->reader->m_sampleRate = pcm->samplerate; + if (!data->reader->isDecodeCacheInitialised()) { + data->reader->initialiseDecodeCache(); + } + for (int i = 0; i < frames; ++i) { for (int ch = 0; ch < channels; ++ch) { @@ -146,7 +132,8 @@ sample = pcm->samples[ch][i]; } float fsample = float(sample) / float(MAD_F_ONE); - data->reader->m_data.push_back(fsample); +// data->reader->m_data.push_back(fsample); + data->reader->addSampleToDecodeCache(fsample); } if (! (i & 0xffff)) { Modified: sonic-visualiser/trunk/fileio/MP3FileReader.h =================================================================== --- sonic-visualiser/trunk/fileio/MP3FileReader.h 2006-04-27 11:49:34 UTC (rev 165) +++ sonic-visualiser/trunk/fileio/MP3FileReader.h 2006-04-27 17:29:19 UTC (rev 166) @@ -18,27 +18,22 @@ #ifdef HAVE_MAD -#include "AudioFileReader.h" +#include "CodedAudioFileReader.h" #include <mad.h> -class MP3FileReader : public AudioFileReader +class MP3FileReader : public CodedAudioFileReader { public: - MP3FileReader(QString path, bool showProgress); + MP3FileReader(QString path, bool showProgress, CacheMode cacheMode); virtual ~MP3FileReader(); virtual QString getError() const { return m_error; } - - virtual void getInterleavedFrames(size_t start, size_t count, - SampleBlock &frames) const; protected: QString m_path; QString m_error; - SampleBlock m_data; - struct DecoderData { unsigned char const *start; Modified: sonic-visualiser/trunk/fileio/OggVorbisFileReader.cpp =================================================================== --- sonic-visualiser/trunk/fileio/OggVorbisFileReader.cpp 2006-04-27 11:49:34 UTC (rev 165) +++ sonic-visualiser/trunk/fileio/OggVorbisFileReader.cpp 2006-04-27 17:29:19 UTC (rev 166) @@ -31,7 +31,9 @@ static int instances = 0; -OggVorbisFileReader::OggVorbisFileReader(QString path, bool showProgress) : +OggVorbisFileReader::OggVorbisFileReader(QString path, bool showProgress, + CacheMode mode) : + CodedAudioFileReader(mode), m_path(path), m_progress(0), m_fileSize(0), @@ -74,6 +76,8 @@ m_fishSound = 0; oggz_close(oggz); + finishDecodeCache(); + if (showProgress) { delete m_progress; m_progress = 0; @@ -85,27 +89,6 @@ std::cerr << "OggVorbisFileReader::~OggVorbisFileReader(" << m_path.toLocal8Bit().data() << "): now have " << (--instances) << " instances" << std::endl; } -void -OggVorbisFileReader::getInterleavedFrames(size_t start, size_t count, - SampleBlock &frames) const -{ - frames.clear(); - if (!isOK()) return; - if (count == 0) return; - - // slownessabounds - - size_t channels = getChannelCount(); - - for (size_t i = start; i < start + count; ++i) { - for (size_t ch = 0; ch < channels; ++ch) { - size_t index = i * channels + ch; - if (index >= m_data.size()) return; - frames.push_back(m_data[index]); - } - } -} - int OggVorbisFileReader::readPacket(OGGZ *, ogg_packet *packet, long, void *data) { @@ -150,6 +133,7 @@ &fsinfo, sizeof(FishSoundInfo)); reader->m_channelCount = fsinfo.channels; reader->m_sampleRate = fsinfo.samplerate; + reader->initialiseDecodeCache(); } if (nframes > 0) { @@ -158,7 +142,8 @@ for (long i = 0; i < nframes; ++i) { for (size_t c = 0; c < reader->m_channelCount; ++c) { - reader->m_data.push_back(frames[c][i]); + reader->addSampleToDecodeCache(frames[c][i]); +// reader->m_data.push_back(frames[c][i]); } } Modified: sonic-visualiser/trunk/fileio/OggVorbisFileReader.h =================================================================== --- sonic-visualiser/trunk/fileio/OggVorbisFileReader.h 2006-04-27 11:49:34 UTC (rev 165) +++ sonic-visualiser/trunk/fileio/OggVorbisFileReader.h 2006-04-27 17:29:19 UTC (rev 166) @@ -19,30 +19,25 @@ #ifdef HAVE_OGGZ #ifdef HAVE_FISHSOUND -#include "AudioFileReader.h" +#include "CodedAudioFileReader.h" #include <oggz/oggz.h> #include <fishsound/fishsound.h> class QProgressDialog; -class OggVorbisFileReader : public AudioFileReader +class OggVorbisFileReader : public CodedAudioFileReader { public: - OggVorbisFileReader(QString path, bool showProgress); + OggVorbisFileReader(QString path, bool showProgress, CacheMode cacheMode); virtual ~OggVorbisFileReader(); virtual QString getError() const { return m_error; } - virtual void getInterleavedFrames(size_t start, size_t count, - SampleBlock &frames) const; - protected: QString m_path; QString m_error; - SampleBlock m_data; - FishSound *m_fishSound; QProgressDialog *m_progress; size_t m_fileSize; Added: sonic-visualiser/trunk/icons/filenew-22.png =================================================================== (Binary files differ) Property changes on: sonic-visualiser/trunk/icons/filenew-22.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: sonic-visualiser/trunk/icons/fileopen-22.png =================================================================== (Binary files differ) Property changes on: sonic-visualiser/trunk/icons/fileopen-22.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: sonic-visualiser/trunk/icons/filesave-22.png =================================================================== (Binary files differ) Property changes on: sonic-visualiser/trunk/icons/filesave-22.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: sonic-visualiser/trunk/icons/filesaveas-22.png =================================================================== (Binary files differ) Property changes on: sonic-visualiser/trunk/icons/filesaveas-22.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: sonic-visualiser/trunk/layer/SpectrogramLayer.cpp =================================================================== --- sonic-visualiser/trunk/layer/SpectrogramLayer.cpp 2006-04-27 11:49:34 UTC (rev 165) +++ sonic-visualiser/trunk/layer/SpectrogramLayer.cpp 2006-04-27 17:29:19 UTC (rev 166) @@ -142,7 +142,7 @@ list.push_back(tr("Window Type")); list.push_back(tr("Window Size")); list.push_back(tr("Window Overlap")); - list.push_back(tr("Normalize")); + list.push_back(tr("Normalize Columns")); list.push_back(tr("Bin Display")); list.push_back(tr("Threshold")); list.push_back(tr("Gain")); @@ -158,7 +158,7 @@ { if (name == tr("Gain")) return RangeProperty; if (name == tr("Colour Rotation")) return RangeProperty; - if (name == tr("Normalize")) return ToggleProperty; + if (name == tr("Normalize Columns")) return ToggleProperty; if (name == tr("Threshold")) return RangeProperty; return ValueProperty; } @@ -173,7 +173,7 @@ name == tr("Gain") || name == tr("Threshold") || name == tr("Colour Rotation")) return tr("Colour"); - if (name == tr("Normalize") || + if (name == tr("Normalize Columns") || name == tr("Bin Display") || name == tr("Colour Scale")) return tr("Scale"); if (name == tr("Max Frequency") || @@ -304,7 +304,7 @@ *max = 2; deft = (int)m_binDisplay; - } else if (name == tr("Normalize")) { + } else if (name == tr("Normalize Columns")) { deft = (m_normalizeColumns ? 1 : 0); @@ -490,7 +490,7 @@ case 1: setBinDisplay(PeakBins); break; case 2: setBinDisplay(PeakFrequencies); break; } - } else if (name == "Normalize") { + } else if (name == "Normalize Columns") { setNormalizeColumns(value ? true : false); } } Modified: sonic-visualiser/trunk/main/MainWindow.cpp =================================================================== --- sonic-visualiser/trunk/main/MainWindow.cpp 2006-04-27 11:49:34 UTC (rev 165) +++ sonic-visualiser/trunk/main/MainWindow.cpp 2006-04-27 17:29:19 UTC (rev 166) @@ -155,7 +155,7 @@ this, SLOT(outputLevelsChanged(float, float))); setupMenus(); - setupToolbar(); + setupToolbars(); // statusBar()->addWidget(m_descriptionLabel); @@ -174,40 +174,55 @@ void MainWindow::setupMenus() { - QAction *action; - QMenu *menu; + QAction *action = 0; + QMenu *menu = 0; + QToolBar *toolbar = 0; if (!m_mainMenusCreated) { menu = menuBar()->addMenu(tr("&File")); - - action = new QAction(QIcon(":icons/filenew.png"), - tr("&New Session"), this); + toolbar = addToolBar(tr("File Toolbar")); + + QIcon icon(":icons/filenew.png"); + icon.addFile(":icons/filenew-22.png"); + action = new QAction(icon, tr("&New Session"), this); action->setShortcut(tr("Ctrl+N")); action->setStatusTip(tr("Clear the current Sonic Visualiser session and start a new one")); connect(action, SIGNAL(triggered()), this, SLOT(newSession())); menu->addAction(action); + toolbar->addAction(action); - action = new QAction(QIcon(":/icons/fileopen.png"), - tr("&Open Session..."), this); + icon = QIcon(":icons/fileopen.png"); + icon.addFile(":icons/fileopen-22.png"); + + action = new QAction(icon, tr("&Open Session..."), this); action->setShortcut(tr("Ctrl+O")); action->setStatusTip(tr("Open a previously saved Sonic Visualiser session file")); connect(action, SIGNAL(triggered()), this, SLOT(openSession())); menu->addAction(action); - action = new QAction(QIcon(":/icons/filesave.png"), - tr("&Save Session"), this); + action = new QAction(icon, tr("&Open..."), this); + action->setStatusTip(tr("Open a session file, audio file, or layer")); + connect(action, SIGNAL(triggered()), this, SLOT(openSomething())); + toolbar->addAction(action); + + icon = QIcon(":icons/filesave.png"); + icon.addFile(":icons/filesave-22.png"); + action = new QAction(icon, tr("&Save Session"), this); action->setShortcut(tr("Ctrl+S")); action->setStatusTip(tr("Save the current session into a Sonic Visualiser session file")); connect(action, SIGNAL(triggered()), this, SLOT(saveSession())); connect(this, SIGNAL(canSave(bool)), action, SLOT(setEnabled(bool))); menu->addAction(action); + toolbar->addAction(action); - action = new QAction(QIcon(":/icons/filesaveas.png"), - tr("Save Session &As..."), this); + icon = QIcon(":icons/filesaveas.png"); + icon.addFile(":icons/filesaveas-22.png"); + action = new QAction(icon, tr("Save Session &As..."), this); action->setStatusTip(tr("Save the current session into a new Sonic Visualiser session file")); connect(action, SIGNAL(triggered()), this, SLOT(saveSessionAs())); menu->addAction(action); + toolbar->addAction(action); menu->addSeparator(); @@ -772,7 +787,7 @@ } void -MainWindow::setupToolbar() +MainWindow::setupToolbars() { QToolBar *toolbar = addToolBar(tr("Transport Toolbar")); @@ -814,6 +829,8 @@ connect(action, SIGNAL(triggered()), this, SLOT(ffwdEnd())); connect(this, SIGNAL(canPlay(bool)), action, SLOT(setEnabled(bool))); + toolbar = addToolBar(tr("Play Mode Toolbar")); + action = toolbar->addAction(QIcon(":/icons/playselection.png"), tr("Constrain Playback to Selection")); action->setCheckable(true); @@ -1437,41 +1454,71 @@ if (path != "") { - if (path.endsWith(".svl") || path.endsWith(".xml")) { + if (!openLayerFile(path)) { + QMessageBox::critical(this, tr("Failed to open file"), + tr("File %1 could not be opened.").arg(path)); + return; + } + } +} - //!!! This doesn't yet work -- it imports the model, but - //fails to put it in a new layer! +bool +MainWindow::openLayerFile(QString path) +{ + Pane *pane = m_paneStack->getCurrentPane(); + + if (!pane) { + // shouldn't happen, as the menu action should have been disabled + std::cerr << "WARNING: MainWindow::openLayerFile: no current pane" << std::endl; + return false; + } - PaneCallback callback(this); - QFile file(path); + if (!getMainModel()) { + // shouldn't happen, as the menu action should have been disabled + std::cerr << "WARNING: MainWindow::openLayerFile: No main model -- hence no default sample rate available" << std::endl; + return false; + } - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - QMessageBox::critical(this, tr("Failed to read file"), - tr("File %1 could not be opened.").arg(path)); - return; - } + if (path.endsWith(".svl") || path.endsWith(".xml")) { - SVFileReader reader(m_document, callback); - reader.setCurrentPane(pane); - - QXmlInputSource inputSource(&file); - reader.parse(inputSource); - - if (!reader.isOK()) { - QMessageBox::critical(this, tr("Failed to read file"), - tr("SV XML file read error:\n%1").arg(reader.getErrorString())); + PaneCallback callback(this); + QFile file(path); + + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { + std::cerr << "ERROR: MainWindow::openLayerFile(" + << path.toStdString() + << "): Failed to open file for reading" << std::endl; + return false; + } + + SVFileReader reader(m_document, callback); + reader.setCurrentPane(pane); + + QXmlInputSource inputSource(&file); + reader.parse(inputSource); + + if (!reader.isOK()) { + std::cerr << "ERROR: MainWindow::openLayerFile(" + << path.toStdString() + << "): Failed to read XML file: " + << reader.getErrorString().toStdString() << std::endl; + return false; + } + + } else { + + Model *model = DataFileReaderFactory::load(path, getMainModel()->getSampleRate()); + + if (model) { + Layer *newLayer = m_document->createImportedLayer(model); + if (newLayer) { + m_document->addLayerToView(pane, newLayer); + return true; } - - } else { - - Model *model = DataFileReaderFactory::load(path, getMainModel()->getSampleRate()); - - if (model) { - Layer *newLayer = m_document->createImportedLayer(model); - if (newLayer) m_document->addLayerToView(pane, newLayer); - } } } + + return false; } void @@ -1534,8 +1581,6 @@ bool MainWindow::openAudioFile(QString path, AudioFileOpenMode mode) { - //!!! want to be able to import audio files as non-main model as well - if (!(QFileInfo(path).exists() && QFileInfo(path).isFile() && QFileInfo(path).isReadable())) { @@ -1773,7 +1818,7 @@ QString path = QFileDialog::getOpenFileName (this, tr("Select a session file"), orig, - tr("Sonic Visualiser files (*.sv)\nAll files (*.*)")); + tr("Sonic Visualiser session files (*.sv)\nAll files (*.*)")); if (path.isEmpty()) return; @@ -1791,6 +1836,63 @@ } } +void +MainWindow::openSomething() +{ + QString orig = m_audioFile; + if (orig == "") orig = "."; + else orig = QFileInfo(orig).absoluteDir().canonicalPath(); + + bool canImportLayer = (getMainModel() != 0 && + m_paneStack != 0 && + m_paneStack->getCurrentPane() != 0); + + QString importSpec; + + if (canImportLayer) { + importSpec = tr("All supported files (*.sv %1 %2)\nSonic Visualiser session files (*.sv)\nAudio files (%1)\nLayer files (%2)\nAll files (*.*)") + .arg(AudioFileReaderFactory::getKnownExtensions()) + .arg(DataFileReaderFactory::getKnownExtensions()); + } else { + importSpec = tr("All supported files (*.sv %1)\nSonic Visualiser session files (*.sv)\nAudio files (%1)\nAll files (*.*)") + .arg(AudioFileReaderFactory::getKnownExtensions()); + } + + QString path = QFileDialog::getOpenFileName + (this, tr("Select a file to open"), orig, importSpec); + + if (path.isEmpty()) return; + + if (!(QFileInfo(path).exists() && + QFileInfo(path).isFile() && + QFileInfo(path).isReadable())) { + QMessageBox::critical(this, tr("Failed to open file"), + tr("File \"%1\" does not exist or is not a readable file").arg(path)); + return; + } + + if (path.endsWith(".sv")) { + + if (!checkSaveModified()) return; + + if (!openSessionFile(path)) { + QMessageBox::critical(this, tr("Failed to open file"), + tr("Session file \"%1\" could not be opened").arg(path)); + } + + } else { + + if (!openAudioFile(path, AskUser)) { + + if (!canImportLayer || !openLayerFile(path)) { + + QMessageBox::critical(this, tr("Failed to open file"), + tr("File \"%1\" could not be opened").arg(path)); + } + } + } +} + bool MainWindow::openSomeFile(QString path) { @@ -1923,7 +2025,7 @@ path = QFileDialog::getSaveFileName (this, tr("Select a file to save to"), orig, - tr("Sonic Visualiser files (*.sv)\nAll files (*.*)"), 0, + tr("Sonic Visualiser session files (*.sv)\nAll files (*.*)"), 0, QFileDialog::DontConfirmOverwrite); // we'll do that if (path.isEmpty()) return; Modified: sonic-visualiser/trunk/main/MainWindow.h =================================================================== --- sonic-visualiser/trunk/main/MainWindow.h 2006-04-27 11:49:34 UTC (rev 165) +++ sonic-visualiser/trunk/main/MainWindow.h 2006-04-27 17:29:19 UTC (rev 166) @@ -60,6 +60,7 @@ bool openSomeFile(QString path); bool openAudioFile(QString path, AudioFileOpenMode = AskUser); + bool openLayerFile(QString path); bool openSessionFile(QString path); bool saveSessionFile(QString path); @@ -92,6 +93,7 @@ void openSession(); void importAudio(); void importMoreAudio(); + void openSomething(); void exportAudio(); void importLayer(); void exportLayer(); @@ -227,7 +229,7 @@ void setupMenus(); void setupExistingLayersMenu(); - void setupToolbar(); + void setupToolbars(); Pane *addPaneToStack(); class PaneCallback : public SVFileReaderPaneCallback Modified: sonic-visualiser/trunk/main/main.cpp =================================================================== --- sonic-visualiser/trunk/main/main.cpp 2006-04-27 11:49:34 UTC (rev 165) +++ sonic-visualiser/trunk/main/main.cpp 2006-04-27 17:29:19 UTC (rev 166) @@ -72,6 +72,9 @@ #endif +//!!! catch trappable signals, cleanup temporary directory etc +//!!! check for crap left over from previous run + int main(int argc, char **argv) { Modified: sonic-visualiser/trunk/sonic-visualiser.pro =================================================================== --- sonic-visualiser/trunk/sonic-visualiser.pro 2006-04-27 11:49:34 UTC (rev 165) +++ sonic-visualiser/trunk/sonic-visualiser.pro 2006-04-27 17:29:19 UTC (rev 166) @@ -203,6 +203,7 @@ fileio/AudioFileReader.h \ fileio/AudioFileReaderFactory.h \ fileio/BZipFileDevice.h \ + fileio/CodedAudioFileReader.h \ fileio/CSVFileReader.h \ fileio/CSVFileWriter.h \ fileio/DataFileReader.h \ @@ -297,6 +298,7 @@ base/XmlExportable.cpp \ fileio/AudioFileReaderFactory.cpp \ fileio/BZipFileDevice.cpp \ + fileio/CodedAudioFileReader.cpp \ fileio/CSVFileReader.cpp \ fileio/CSVFileWriter.cpp \ fileio/DataFileReaderFactory.cpp \ Modified: sonic-visualiser/trunk/sonic-visualiser.qrc =================================================================== --- sonic-visualiser/trunk/sonic-visualiser.qrc 2006-04-27 11:49:34 UTC (rev 165) +++ sonic-visualiser/trunk/sonic-visualiser.qrc 2006-04-27 17:29:19 UTC (rev 166) @@ -36,10 +36,14 @@ <file>icons/speaker.png</file> <file>icons/annotation.png</file> <file>icons/fileopen.png</file> + <file>icons/fileopen-22.png</file> <file>icons/fileclose.png</file> <file>icons/filenew.png</file> + <file>icons/filenew-22.png</file> <file>icons/filesave.png</file> + <file>icons/filesave-22.png</file> <file>icons/filesaveas.png</file> + <file>icons/filesaveas-22.png</file> <file>icons/editdelete.png</file> <file>icons/editcut.png</file> <file>icons/editcopy.png</file> Modified: sonic-visualiser/trunk/widgets/AudioDial.cpp =================================================================== --- sonic-visualiser/trunk/widgets/AudioDial.cpp 2006-04-27 11:49:34 UTC (rev 165) +++ sonic-visualiser/trunk/widgets/AudioDial.cpp 2006-04-27 17:29:19 UTC (rev 166) @@ -96,7 +96,7 @@ QColor knobColor(m_knobColor); if (knobColor == Qt::black) - knobColor = palette().mid().color(); + knobColor = palette().background().color(); QColor meterColor(m_meterColor); if (!isEnabled()) Modified: sonic-visualiser/trunk/widgets/Fader.cpp =================================================================== --- sonic-visualiser/trunk/widgets/Fader.cpp 2006-04-27 11:49:34 UTC (rev 165) +++ sonic-visualiser/trunk/widgets/Fader.cpp 2006-04-27 17:29:19 UTC (rev 166) @@ -131,6 +131,13 @@ void Fader::mousePressEvent(QMouseEvent *ev) { + if (ev->button() == Qt::MidButton) { + setValue(1.0); + emit valueChanged(1.0); + update(); + return; + } + int x = ev->x() - 6; const int max_x = 116 - 12; Modified: sonic-visualiser/trunk/widgets/Pane.cpp =================================================================== --- sonic-visualiser/trunk/widgets/Pane.cpp 2006-04-27 11:49:34 UTC (rev 165) +++ sonic-visualiser/trunk/widgets/Pane.cpp 2006-04-27 17:29:19 UTC (rev 166) @@ -525,7 +525,7 @@ int snapFrame = mouseFrame; Layer *layer = getSelectedLayer(); - if (layer) { + if (layer && !m_shiftPressed) { layer->snapToFeatureFrame(this, snapFrame, resolution, Layer::SnapLeft); } @@ -740,7 +740,7 @@ int snapFrameRight = mouseFrame; Layer *layer = getSelectedLayer(); - if (layer) { + if (layer && !m_shiftPressed) { layer->snapToFeatureFrame(this, snapFrameLeft, resolution, Layer::SnapLeft); layer->snapToFeatureFrame(this, snapFrameRight, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ca...@us...> - 2006-04-27 11:49:48
|
Revision: 165 Author: cannam Date: 2006-04-27 04:49:34 -0700 (Thu, 27 Apr 2006) ViewCVS: http://svn.sourceforge.net/sv1/?rev=165&view=rev Log Message: ----------- * Ensure consistent ordering of layer text labels * Fix erroneous SR mismatch warning when adding a wave-file model when no other wave-file model is present (only models that don't assert any particular playback samplerate) Modified Paths: -------------- sonic-visualiser/trunk/audioio/AudioCallbackPlaySource.cpp sonic-visualiser/trunk/base/View.cpp sonic-visualiser/trunk/base/XmlExportable.cpp sonic-visualiser/trunk/base/XmlExportable.h sonic-visualiser/trunk/layer/TimeInstantLayer.h sonic-visualiser/trunk/layer/TimeValueLayer.h sonic-visualiser/trunk/main/MainWindow.cpp sonic-visualiser/trunk/main/MainWindow.h sonic-visualiser/trunk/model/SparseModel.h sonic-visualiser/trunk/sonic-visualiser.pro Removed Paths: ------------- sonic-visualiser/trunk/SConstruct Deleted: sonic-visualiser/trunk/SConstruct =================================================================== --- sonic-visualiser/trunk/SConstruct 2006-04-26 16:27:34 UTC (rev 164) +++ sonic-visualiser/trunk/SConstruct 2006-04-27 11:49:34 UTC (rev 165) @@ -1,135 +0,0 @@ - -mocbuild = Builder(action = '/home/studio/qt4/bin/moc -DHAVE_JACK -o $TARGET $SOURCE', - suffix = '.moc.cpp', - src_suffix = '.h') - -qrcbuild = Builder(action = '/home/studio/qt4/bin/rcc -o $TARGET $SOURCE', - suffix = '.qrc.cpp', - src_suffix = '.qrc') - -env = Environment(platform = 'posix') -env.Append(BUILDERS = {'Moc' : mocbuild}) -env.Append(BUILDERS = {'Qrc' : qrcbuild}) - -files = Split(''' - -audioio/AudioCallbackPlaySource.cpp -audioio/AudioCallbackPlayTarget.cpp -audioio/AudioJACKTarget.cpp -audioio/AudioCoreAudioTarget.cpp -audioio/AudioTargetFactory.cpp - -base/AudioLevel.cpp -base/RealTime.cpp -base/Model.cpp -base/Profiler.cpp -base/View.cpp -base/PropertyContainer.cpp -base/ViewManager.cpp -base/ViewWidget.cpp -base/System.cpp -base/Window.cpp - -fileio/AudioFileReaderFactory.cpp -fileio/WavFileReader.cpp -fileio/MP3FileReader.cpp -fileio/OggVorbisFileReader.cpp - -main/MainWindow.cpp -main/main.cpp - -model/PowerOfTwoZoomConstraint.cpp -model/PowerOfSqrtTwoZoomConstraint.cpp -model/DenseTimeValueModel.cpp -model/RangeSummarisableTimeValueModel.cpp -model/SpectrogramModel.cpp -model/DenseThreeDimensionalModel.cpp -model/WaveFileModel.cpp -model/SparseOneDimensionalModel.cpp -model/SparseTimeValueModel.cpp - -view/SpectrogramView.cpp -view/Colour3DPlot.cpp -view/WaveformView.cpp -view/TimeRuler.cpp -view/TimeInstantView.cpp -view/TimeValueView.cpp - -widgets/AudioDial.cpp -widgets/Pane.cpp -widgets/Panner.cpp -widgets/PropertyBox.cpp -widgets/PropertyStack.cpp - -dsp/chromagram/ConstantQ.cpp -dsp/chromagram/ChromaProcess.cpp -dsp/chromagram/Chromagram.cpp - -dsp/onsets/DetectionFunction.cpp -dsp/onsets/PeakPicking.cpp - -dsp/signalconditioning/FiltFilt.cpp -dsp/signalconditioning/Windowing.cpp -dsp/signalconditioning/DFProcess.cpp -dsp/signalconditioning/Filter.cpp -dsp/signalconditioning/Framer.cpp - -dsp/tempotracking/TempoTrack.cpp - -dsp/phasevocoder/PhaseVocoder.cpp - -dsp/rateconversion/Decimator.cpp - -dsp/transforms/FFT.cpp -dsp/transforms/Fourier.cpp - -dsp/maths/Correlation.cpp -dsp/maths/MathUtilities.cpp - -plugin/PluginIdentifier.cpp -plugin/PluginFactory.cpp -plugin/RealTimePluginInstance.cpp -plugin/LADSPAPluginFactory.cpp -plugin/DSSIPluginFactory.cpp -plugin/LADSPAPluginInstance.cpp -plugin/DSSIPluginInstance.cpp -plugin/api/dssi_alsa_compat.c - -viewer.qrc.cpp - -''') - -env.Moc('audioio/AudioJACKTarget') -env.Moc('audioio/AudioCoreAudioTarget') -env.Moc('audioio/AudioCallbackPlaySource') -env.Moc('audioio/AudioCallbackPlayTarget') -env.Moc('base/Model') -env.Moc('base/View') -env.Moc('base/ViewWidget') -env.Moc('base/ViewManager') -env.Moc('main/MainWindow') -env.Moc('model/DenseTimeValueModel') -env.Moc('model/RangeSummarisableTimeValueModel') -env.Moc('model/SpectrogramModel') -env.Moc('model/DenseThreeDimensionalModel') -env.Moc('model/WaveFileModel') -env.Moc('model/SparseOneDimensionalModel') -env.Moc('model/SparseTimeValueModel') -env.Moc('view/SpectrogramView') -env.Moc('view/Colour3DPlot') -env.Moc('view/WaveformView') -env.Moc('view/TimeRuler') -env.Moc('view/TimeInstantView') -env.Moc('view/TimeValueView') -env.Moc('widgets/AudioDial') -env.Moc('widgets/Pane') -env.Moc('widgets/Panner') -env.Moc('widgets/PropertyBox') -env.Moc('widgets/PropertyStack') - -env.Qrc('viewer') - -env.Program('viewer', files, - LIBPATH = '/home/studio/qt4/lib', - CCFLAGS = '-O3 -DHAVE_JACK -DINCLUDE_MOCFILES -Wall -I. -I/home/studio/qt4/include -I/home/studio/qt4/include/QtGui -I/home/studio/qt4/include/QtCore', - LIBS = Split('QtGui QtCore sndfile samplerate jack fftw3 mad fishsound oggz')) Modified: sonic-visualiser/trunk/audioio/AudioCallbackPlaySource.cpp =================================================================== --- sonic-visualiser/trunk/audioio/AudioCallbackPlaySource.cpp 2006-04-26 16:27:34 UTC (rev 164) +++ sonic-visualiser/trunk/audioio/AudioCallbackPlaySource.cpp 2006-04-27 11:49:34 UTC (rev 165) @@ -107,33 +107,56 @@ bool buffersChanged = false, srChanged = false; + size_t modelChannels = 1; + DenseTimeValueModel *dtvm = dynamic_cast<DenseTimeValueModel *>(model); + if (dtvm) modelChannels = dtvm->getChannelCount(); + if (modelChannels > m_sourceChannelCount) { + m_sourceChannelCount = modelChannels; + } + + std::cerr << "Adding model with " << modelChannels << " channels " << std::endl; + if (m_sourceSampleRate == 0) { m_sourceSampleRate = model->getSampleRate(); srChanged = true; } else if (model->getSampleRate() != m_sourceSampleRate) { - std::cerr << "AudioCallbackPlaySource::addModel: ERROR: " - << "New model sample rate does not match" << std::endl - << "existing model(s) (new " << model->getSampleRate() - << " vs " << m_sourceSampleRate - << "), playback will be wrong" - << std::endl; - if (dynamic_cast<DenseTimeValueModel *>(model)) { - emit sampleRateMismatch(model->getSampleRate(), m_sourceSampleRate, - false); + + // If this is a dense time-value model and we have no other, we + // can just switch to this model's sample rate + + if (dtvm) { + + bool conflicting = false; + + for (std::set<Model *>::const_iterator i = m_models.begin(); + i != m_models.end(); ++i) { + if (*i != dtvm && dynamic_cast<DenseTimeValueModel *>(*i)) { + std::cerr << "AudioCallbackPlaySource::addModel: Conflicting dense time-value model " << *i << " found" << std::endl; + conflicting = true; + break; + } + } + + if (conflicting) { + + std::cerr << "AudioCallbackPlaySource::addModel: ERROR: " + << "New model sample rate does not match" << std::endl + << "existing model(s) (new " << model->getSampleRate() + << " vs " << m_sourceSampleRate + << "), playback will be wrong" + << std::endl; + + emit sampleRateMismatch(model->getSampleRate(), m_sourceSampleRate, + false); + } else { + m_sourceSampleRate = model->getSampleRate(); + srChanged = true; + } } } - size_t modelChannels = 1; - DenseTimeValueModel *dtvm = dynamic_cast<DenseTimeValueModel *>(model); - if (dtvm) modelChannels = dtvm->getChannelCount(); - if (modelChannels > m_sourceChannelCount) { - m_sourceChannelCount = modelChannels; - } - - std::cerr << "Adding model with " << modelChannels << " channels " << std::endl; - if (!m_writeBuffers || (m_writeBuffers->size() < getTargetChannelCount())) { clearRingBuffers(true, getTargetChannelCount()); buffersChanged = true; Modified: sonic-visualiser/trunk/base/View.cpp =================================================================== --- sonic-visualiser/trunk/base/View.cpp 2006-04-26 16:27:34 UTC (rev 164) +++ sonic-visualiser/trunk/base/View.cpp 2006-04-27 11:49:34 UTC (rev 165) @@ -178,18 +178,23 @@ int View::getTextLabelHeight(const Layer *layer, QPainter &paint) const { - int y = 15 + paint.fontMetrics().ascent(); + std::map<int, Layer *> sortedLayers; for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i) { - - if (*i == layer) return y; - if ((*i)->needsTextLabelHeight()) { - y += paint.fontMetrics().height(); + sortedLayers[getObjectExportId(*i)] = *i; } } + int y = 15 + paint.fontMetrics().ascent(); + + for (std::map<int, Layer *>::const_iterator i = sortedLayers.begin(); + i != sortedLayers.end(); ++i) { + if (i->second == layer) return y; + y += paint.fontMetrics().height(); + } + return y; } Modified: sonic-visualiser/trunk/base/XmlExportable.cpp =================================================================== --- sonic-visualiser/trunk/base/XmlExportable.cpp 2006-04-26 16:27:34 UTC (rev 164) +++ sonic-visualiser/trunk/base/XmlExportable.cpp 2006-04-27 11:49:34 UTC (rev 165) @@ -15,6 +15,8 @@ #include "XmlExportable.h" #include <map> +#include <QMutex> +#include <QMutexLocker> QString XmlExportable::encodeEntities(QString s) @@ -49,6 +51,9 @@ int XmlExportable::getObjectExportId(const void * object) { + static QMutex mutex; + QMutexLocker locker(&mutex); + static std::map<const void *, int> idMap; static int maxId = 0; Modified: sonic-visualiser/trunk/base/XmlExportable.h =================================================================== --- sonic-visualiser/trunk/base/XmlExportable.h 2006-04-26 16:27:34 UTC (rev 164) +++ sonic-visualiser/trunk/base/XmlExportable.h 2006-04-27 11:49:34 UTC (rev 165) @@ -31,7 +31,7 @@ static QString encodeColour(QColor); - static int getObjectExportId(const void *); // not thread-safe + static int getObjectExportId(const void *); // thread-safe }; #endif Modified: sonic-visualiser/trunk/layer/TimeInstantLayer.h =================================================================== --- sonic-visualiser/trunk/layer/TimeInstantLayer.h 2006-04-26 16:27:34 UTC (rev 164) +++ sonic-visualiser/trunk/layer/TimeInstantLayer.h 2006-04-27 11:49:34 UTC (rev 165) @@ -85,7 +85,7 @@ virtual int getCompletion() const { return m_model->getCompletion(); } - virtual bool needsTextLabelHeight() const { return true; } + virtual bool needsTextLabelHeight() const { return m_model->hasTextLabels(); } virtual bool getValueExtents(float &min, float &max, QString &unit) const { return false; Modified: sonic-visualiser/trunk/layer/TimeValueLayer.h =================================================================== --- sonic-visualiser/trunk/layer/TimeValueLayer.h 2006-04-26 16:27:34 UTC (rev 164) +++ sonic-visualiser/trunk/layer/TimeValueLayer.h 2006-04-27 11:49:34 UTC (rev 165) @@ -103,7 +103,7 @@ virtual int getCompletion() const { return m_model->getCompletion(); } virtual bool needsTextLabelHeight() const { - return m_plotStyle == PlotSegmentation; + return m_plotStyle == PlotSegmentation && m_model->hasTextLabels(); } virtual bool getValueExtents(float &min, float &max, QString &unit) const; Modified: sonic-visualiser/trunk/main/MainWindow.cpp =================================================================== --- sonic-visualiser/trunk/main/MainWindow.cpp 2006-04-26 16:27:34 UTC (rev 164) +++ sonic-visualiser/trunk/main/MainWindow.cpp 2006-04-27 11:49:34 UTC (rev 165) @@ -675,7 +675,7 @@ menu->addSeparator(); - m_existingLayersMenu = menu->addMenu(tr("Re-Add &Existing Layer")); + m_existingLayersMenu = menu->addMenu(tr("Add &Existing Layer")); setupExistingLayersMenu(); menu->addSeparator(); @@ -698,6 +698,11 @@ menu = menuBar()->addMenu(tr("&Help")); + action = new QAction(tr("&Help Reference"), this); + action->setStatusTip(tr("Open the Sonic Visualiser reference manual")); + connect(action, SIGNAL(triggered()), this, SLOT(help())); + menu->addAction(action); + action = new QAction(tr("&About Sonic Visualiser"), this); action->setStatusTip(tr("Show information about Sonic Visualiser")); connect(action, SIGNAL(triggered()), this, SLOT(about())); @@ -2624,6 +2629,12 @@ } void +MainWindow::help() +{ + //!!! +} + +void MainWindow::about() { bool debug = false; Modified: sonic-visualiser/trunk/main/MainWindow.h =================================================================== --- sonic-visualiser/trunk/main/MainWindow.h 2006-04-26 16:27:34 UTC (rev 164) +++ sonic-visualiser/trunk/main/MainWindow.h 2006-04-27 11:49:34 UTC (rev 165) @@ -171,6 +171,7 @@ void showLayerTree(); + void help(); void about(); protected: Modified: sonic-visualiser/trunk/model/SparseModel.h =================================================================== --- sonic-visualiser/trunk/model/SparseModel.h 2006-04-26 16:27:34 UTC (rev 164) +++ sonic-visualiser/trunk/model/SparseModel.h 2006-04-27 11:49:34 UTC (rev 165) @@ -106,6 +106,8 @@ virtual void setCompletion(int completion); virtual int getCompletion() const { return m_completion; } + virtual bool hasTextLabels() const { return m_hasTextLabels; } + virtual QString toXmlString(QString indent = "", QString extraAttributes = "") const; @@ -231,6 +233,7 @@ bool m_notifyOnAdd; long m_sinceLastNotifyMin; long m_sinceLastNotifyMax; + bool m_hasTextLabels; PointList m_points; mutable QMutex m_mutex; @@ -240,13 +243,14 @@ template <typename PointType> SparseModel<PointType>::SparseModel(size_t sampleRate, - size_t resolution, - bool notifyOnAdd) : + size_t resolution, + bool notifyOnAdd) : m_sampleRate(sampleRate), m_resolution(resolution), m_notifyOnAdd(notifyOnAdd), m_sinceLastNotifyMin(-1), m_sinceLastNotifyMax(-1), + m_hasTextLabels(false), m_completion(100) { } @@ -413,6 +417,7 @@ { QMutexLocker locker(&m_mutex); m_points.insert(point); + if (point.label != "") m_hasTextLabels = true; } // Even though this model is nominally sparse, there may still be Modified: sonic-visualiser/trunk/sonic-visualiser.pro =================================================================== --- sonic-visualiser/trunk/sonic-visualiser.pro 2006-04-26 16:27:34 UTC (rev 164) +++ sonic-visualiser/trunk/sonic-visualiser.pro 2006-04-27 11:49:34 UTC (rev 165) @@ -2,8 +2,9 @@ QT += xml DEFINES += 'SV_VERSION="0.1"' -CONFIG += qt thread debug warn_on stl rtti exceptions +CONFIG += qt thread release warn_on stl rtti exceptions + ### ### BEGIN CONFIGURABLE STUFF ### @@ -28,8 +29,8 @@ # If you don't have it, get it. # DEFINES += HAVE_VAMP -INCLUDEPATH += ../vamp-plugin-sdk -LIBPATH += ../vamp-plugin-sdk/vamp-sdk +INCLUDEPATH += $(HOME)/vamp-plugin-sdk +LIBPATH += $(HOME)/vamp-plugin-sdk/vamp-sdk LIBS += -lvamp-sdk # No pkg-config test for the bzip2 library. This library is required. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ca...@us...> - 2006-04-26 16:27:50
|
Revision: 164 Author: cannam Date: 2006-04-26 09:27:34 -0700 (Wed, 26 Apr 2006) ViewCVS: http://svn.sourceforge.net/sv1/?rev=164&view=rev Log Message: ----------- * Compile fix in DSSIPluginInstance, add origin notes to icons and samples Modified Paths: -------------- sonic-visualiser/trunk/plugin/DSSIPluginInstance.cpp Added Paths: ----------- sonic-visualiser/trunk/icons/README sonic-visualiser/trunk/samples/README Added: sonic-visualiser/trunk/icons/README =================================================================== --- sonic-visualiser/trunk/icons/README (rev 0) +++ sonic-visualiser/trunk/icons/README 2006-04-26 16:27:34 UTC (rev 164) @@ -0,0 +1,3 @@ +Icons are from various GPL'd sources, including the GIMP image editor, +KDE crystalsvg icon set, Rosegarden audio and MIDI sequencer, and Hydrogen +drum machine. Some modifications and new drawings by Chris Cannam. Modified: sonic-visualiser/trunk/plugin/DSSIPluginInstance.cpp =================================================================== --- sonic-visualiser/trunk/plugin/DSSIPluginInstance.cpp 2006-04-26 16:00:13 UTC (rev 163) +++ sonic-visualiser/trunk/plugin/DSSIPluginInstance.cpp 2006-04-26 16:27:34 UTC (rev 164) @@ -847,7 +847,7 @@ qm = qm + message; free(message); - std::cerr << "DSSIPluginInstance::configure: warning: configure returned message: \"" << qm.toStdString() << "\"" << std::endl; + std::cerr << "DSSIPluginInstance::configure: warning: configure returned message: \"" << qm << "\"" << std::endl; } return qm; Added: sonic-visualiser/trunk/samples/README =================================================================== --- sonic-visualiser/trunk/samples/README (rev 0) +++ sonic-visualiser/trunk/samples/README 2006-04-26 16:27:34 UTC (rev 164) @@ -0,0 +1,2 @@ +Samples from standard Hydrogen drum machine kits, except for piano.wav +(ancestry unknown) and click.wav (random noise). This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |