sv1-commits Mailing List for Sonic Visualiser (Page 57)
Brought to you by:
cannam
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(25) |
Oct
(57) |
Nov
(25) |
Dec
(11) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(36) |
Feb
(34) |
Mar
(55) |
Apr
(41) |
May
(25) |
Jun
(27) |
Jul
(22) |
Aug
(16) |
Sep
(33) |
Oct
(52) |
Nov
(79) |
Dec
(28) |
2008 |
Jan
(27) |
Feb
(56) |
Mar
(38) |
Apr
(32) |
May
(22) |
Jun
(55) |
Jul
(48) |
Aug
(10) |
Sep
(23) |
Oct
(32) |
Nov
(56) |
Dec
(71) |
2009 |
Jan
(35) |
Feb
(61) |
Mar
(52) |
Apr
(3) |
May
(18) |
Jun
(24) |
Jul
(13) |
Aug
(20) |
Sep
(27) |
Oct
(29) |
Nov
|
Dec
(1) |
2010 |
Jan
(3) |
Feb
(5) |
Mar
(8) |
Apr
(1) |
May
(20) |
Jun
(15) |
Jul
(8) |
Aug
(4) |
Sep
(3) |
Oct
|
Nov
(1) |
Dec
|
2011 |
Jan
(3) |
Feb
(1) |
Mar
|
Apr
(9) |
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
(3) |
Nov
(2) |
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <ca...@us...> - 2006-09-21 09:43:48
|
Revision: 353 http://svn.sourceforge.net/sv1/?rev=353&view=rev Author: cannam Date: 2006-09-21 02:43:41 -0700 (Thu, 21 Sep 2006) Log Message: ----------- * Buffer size fixes in the time stretcher, to avoid running out of input data for large or small ratios Modified Paths: -------------- sonic-visualiser/trunk/sv/audioio/AudioCallbackPlaySource.cpp sonic-visualiser/trunk/sv/audioio/PhaseVocoderTimeStretcher.cpp sonic-visualiser/trunk/sv/audioio/PhaseVocoderTimeStretcher.h Modified: sonic-visualiser/trunk/sv/audioio/AudioCallbackPlaySource.cpp =================================================================== --- sonic-visualiser/trunk/sv/audioio/AudioCallbackPlaySource.cpp 2006-09-20 16:03:08 UTC (rev 352) +++ sonic-visualiser/trunk/sv/audioio/AudioCallbackPlaySource.cpp 2006-09-21 09:43:41 UTC (rev 353) @@ -619,7 +619,7 @@ channels, factor, sharpen, - lrintf(getTargetBlockSize() / factor)); + getTargetBlockSize()); m_timeStretcher = newStretcher; @@ -688,6 +688,21 @@ size_t available; + int warned = 0; + + + + //!!! + // We want output blocks of e.g. 1024 (probably fixed, certainly + // bounded). We can provide input blocks of any size (unbounded) + // at the timestretcher's request. The input block for a given + // output is approx output / ratio, but we can't predict it + // exactly, for an adaptive timestretcher. The stretcher will + // need some additional buffer space. + + + + while ((available = ts->getAvailableOutputSamples()) < count) { size_t reqd = lrintf((count - available) / ratio); @@ -735,8 +750,8 @@ if (got == 0) break; if (ts->getAvailableOutputSamples() == available) { - std::cerr << "WARNING: AudioCallbackPlaySource::getSamples: Added " << got << " samples to time stretcher, created no new available output samples" << std::endl; - break; + std::cerr << "WARNING: AudioCallbackPlaySource::getSamples: Added " << got << " samples to time stretcher, created no new available output samples (warned = " << warned << ")" << std::endl; + if (++warned == 5) break; } } Modified: sonic-visualiser/trunk/sv/audioio/PhaseVocoderTimeStretcher.cpp =================================================================== --- sonic-visualiser/trunk/sv/audioio/PhaseVocoderTimeStretcher.cpp 2006-09-20 16:03:08 UTC (rev 352) +++ sonic-visualiser/trunk/sv/audioio/PhaseVocoderTimeStretcher.cpp 2006-09-21 09:43:41 UTC (rev 353) @@ -26,10 +26,10 @@ size_t channels, float ratio, bool sharpen, - size_t maxProcessInputBlockSize) : + size_t maxOutputBlockSize) : m_sampleRate(sampleRate), m_channels(channels), - m_maxProcessInputBlockSize(maxProcessInputBlockSize), + m_maxOutputBlockSize(maxOutputBlockSize), m_ratio(ratio), m_sharpen(sharpen), m_totalCount(0), @@ -92,27 +92,31 @@ m_plan[c] = fftwf_plan_dft_r2c_1d(m_wlen, m_time[c], m_freq[c], FFTW_ESTIMATE); m_iplan[c] = fftwf_plan_dft_c2r_1d(m_wlen, m_freq[c], m_time[c], FFTW_ESTIMATE); - m_inbuf[c] = new RingBuffer<float>(m_wlen); m_outbuf[c] = new RingBuffer<float> - (lrintf((m_maxProcessInputBlockSize + m_wlen) * m_ratio)); - + ((m_maxOutputBlockSize + m_wlen) * 2); + m_inbuf[c] = new RingBuffer<float> + (lrintf(m_outbuf[c]->getSize() / m_ratio) + m_wlen); + + std::cerr << "making inbuf size " << m_inbuf[c]->getSize() << " (outbuf size is " << m_outbuf[c]->getSize() << ", ratio " << m_ratio << ")" << std::endl; + + m_mashbuf[c] = (float *)fftwf_malloc(sizeof(float) * m_wlen); - for (int i = 0; i < m_wlen; ++i) { + for (size_t i = 0; i < m_wlen; ++i) { m_mashbuf[c][i] = 0.0; } - for (int i = 0; i <= m_wlen/2; ++i) { + for (size_t i = 0; i <= m_wlen/2; ++i) { m_prevPhase[c][i] = 0.0; m_prevAdjustedPhase[c][i] = 0.0; } } - for (int i = 0; i < m_wlen; ++i) { + for (size_t i = 0; i < m_wlen; ++i) { m_modulationbuf[i] = 0.0; } - for (int i = 0; i <= m_wlen/2; ++i) { + for (size_t i = 0; i <= m_wlen/2; ++i) { m_prevTransientMag[i] = 0.0; } } @@ -143,7 +147,7 @@ if (m_sharpen) { m_wlen = 2048; } - m_n2 = m_n1 * m_ratio; + m_n2 = lrintf(m_n1 * m_ratio); } else { if (m_ratio > 2) { m_n2 = 512; @@ -157,10 +161,10 @@ if (m_sharpen) { if (m_wlen < 2048) m_wlen = 2048; } - m_n1 = m_n2 / m_ratio; + m_n1 = lrintf(m_n2 / m_ratio); } - m_transientThreshold = m_wlen / 4.5; + m_transientThreshold = lrintf(m_wlen / 4.5); m_totalCount = 0; m_transientCount = 0; @@ -170,7 +174,7 @@ std::cerr << "PhaseVocoderTimeStretcher: channels = " << m_channels << ", ratio = " << m_ratio << ", n1 = " << m_n1 << ", n2 = " << m_n2 << ", wlen = " - << m_wlen << ", max = " << m_maxProcessInputBlockSize << std::endl; + << m_wlen << ", max = " << m_maxOutputBlockSize << std::endl; // << ", outbuflen = " << m_outbuf[0]->getSize() << std::endl; } @@ -218,9 +222,7 @@ { QMutexLocker locker(m_mutex); - float formerRatio = m_ratio; size_t formerWlen = m_wlen; - m_ratio = ratio; calculateParameters(); @@ -229,36 +231,43 @@ // This is the only container whose size depends on m_ratio - RingBuffer<float> **newout = new RingBuffer<float> *[m_channels]; + RingBuffer<float> **newin = new RingBuffer<float> *[m_channels]; - size_t formerSize = m_outbuf[0]->getSize(); - size_t newSize = lrintf((m_maxProcessInputBlockSize + m_wlen) * m_ratio); - size_t ready = m_outbuf[0]->getReadSpace(); + size_t formerSize = m_inbuf[0]->getSize(); + size_t newSize = lrintf(m_outbuf[0]->getSize() / m_ratio) + m_wlen; - for (size_t c = 0; c < m_channels; ++c) { - newout[c] = new RingBuffer<float>(newSize); - } + std::cerr << "resizing inbuf from " << formerSize << " to " + << newSize << " (outbuf size is " << m_outbuf[0]->getSize() << ", ratio " << m_ratio << ")" << std::endl; - if (ready > 0) { + if (formerSize != newSize) { - size_t copy = std::min(ready, newSize); - float *tmp = new float[ready]; + size_t ready = m_inbuf[0]->getReadSpace(); for (size_t c = 0; c < m_channels; ++c) { - m_outbuf[c]->read(tmp, ready); - newout[c]->write(tmp + ready - copy, copy); + newin[c] = new RingBuffer<float>(newSize); } - delete[] tmp; - } + if (ready > 0) { - for (size_t c = 0; c < m_channels; ++c) { - delete m_outbuf[c]; + size_t copy = std::min(ready, newSize); + float *tmp = new float[ready]; + + for (size_t c = 0; c < m_channels; ++c) { + m_inbuf[c]->read(tmp, ready); + newin[c]->write(tmp + ready - copy, copy); + } + + delete[] tmp; + } + + for (size_t c = 0; c < m_channels; ++c) { + delete m_inbuf[c]; + } + + delete[] m_inbuf; + m_inbuf = newin; } - delete[] m_outbuf; - m_outbuf = newout; - } else { std::cerr << "wlen changed" << std::endl; @@ -273,13 +282,6 @@ return getWindowSize() - getInputIncrement(); } -void -PhaseVocoderTimeStretcher::process(float **input, float **output, size_t samples) -{ - putInput(input, samples); - getOutput(output, lrintf(samples * m_ratio)); -} - size_t PhaseVocoderTimeStretcher::getRequiredInputSamples() const { @@ -317,18 +319,23 @@ if (writable == 0) { //!!! then what? I don't think this should happen, but - std::cerr << "WARNING: PhaseVocoderTimeStretcher::putInput: writable == 0" << std::endl; - break; - } + std::cerr << "WARNING: PhaseVocoderTimeStretcher::putInput: writable == 0 (inbuf has " << m_inbuf[0]->getReadSpace() << " samples available for reading, space for " << m_inbuf[0]->getWriteSpace() << " more)" << std::endl; + if (m_inbuf[0]->getReadSpace() < m_wlen || + m_outbuf[0]->getWriteSpace() < m_n2) { + std::cerr << "Outbuf has space for " << m_outbuf[0]->getWriteSpace() << " (n2 = " << m_n2 << "), won't be able to process" << std::endl; + break; + } + } else { #ifdef DEBUG_PHASE_VOCODER_TIME_STRETCHER - std::cerr << "writing " << writable << " from index " << consumed << " to inbuf, consumed will be " << consumed + writable << std::endl; + std::cerr << "writing " << writable << " from index " << consumed << " to inbuf, consumed will be " << consumed + writable << std::endl; #endif - for (size_t c = 0; c < m_channels; ++c) { - m_inbuf[c]->write(input[c] + consumed, writable); + for (size_t c = 0; c < m_channels; ++c) { + m_inbuf[c]->write(input[c] + consumed, writable); + } + consumed += writable; } - consumed += writable; while (m_inbuf[0]->getReadSpace() >= m_wlen && m_outbuf[0]->getWriteSpace() >= m_n2) { @@ -501,7 +508,7 @@ { int count = 0; - for (int i = 0; i <= m_wlen/2; ++i) { + for (size_t i = 0; i <= m_wlen/2; ++i) { float real = 0.f, imag = 0.f; @@ -546,11 +553,9 @@ float *modulation, size_t lastStep) { - int i; - bool unchanged = (lastStep == m_n1); - for (i = 0; i <= m_wlen/2; ++i) { + for (size_t i = 0; i <= m_wlen/2; ++i) { float phase = princargf(atan2f(m_freq[c][i][1], m_freq[c][i][0])); float adjustedPhase = phase; @@ -583,19 +588,19 @@ fftwf_execute(m_iplan[c]); // m_freq -> m_time, inverse fft - for (i = 0; i < m_wlen/2; ++i) { + for (size_t i = 0; i < m_wlen/2; ++i) { float temp = m_time[c][i]; m_time[c][i] = m_time[c][i + m_wlen/2]; m_time[c][i + m_wlen/2] = temp; } - for (i = 0; i < m_wlen; ++i) { + for (size_t i = 0; i < m_wlen; ++i) { m_time[c][i] = m_time[c][i] / m_wlen; } m_synthesisWindow->cut(m_time[c]); - for (i = 0; i < m_wlen; ++i) { + for (size_t i = 0; i < m_wlen; ++i) { out[i] += m_time[c][i]; } @@ -603,7 +608,7 @@ float area = m_analysisWindow->getArea(); - for (i = 0; i < m_wlen; ++i) { + for (size_t i = 0; i < m_wlen; ++i) { float val = m_synthesisWindow->getValue(i); modulation[i] += val * area; } Modified: sonic-visualiser/trunk/sv/audioio/PhaseVocoderTimeStretcher.h =================================================================== --- sonic-visualiser/trunk/sv/audioio/PhaseVocoderTimeStretcher.h 2006-09-20 16:03:08 UTC (rev 352) +++ sonic-visualiser/trunk/sv/audioio/PhaseVocoderTimeStretcher.h 2006-09-21 09:43:41 UTC (rev 353) @@ -43,36 +43,22 @@ size_t channels, float ratio, bool sharpen, - size_t maxProcessInputBlockSize); + size_t maxOutputBlockSize); virtual ~PhaseVocoderTimeStretcher(); /** - * Process a block. The input array contains the given number of - * samples (on each channel); the output must have space for - * lrintf(samples * m_ratio). - * - * This function isn't really recommended, and I may yet remove it. - * It should work correctly for some ratios, e.g. small powers of - * two, if transient sharpening is off. For other ratios it may - * drop samples -- use putInput in a loop followed by getOutput - * (when getAvailableOutputSamples reports enough) instead. - * - * Do not mix process calls with putInput/getOutput calls. - */ - void process(float **input, float **output, size_t samples); - - /** * Return the number of samples that would need to be added via * putInput in order to provoke the time stretcher into doing some * time stretching and making more output samples available. - * This will be an estimate, if transient sharpening is on. + * This will be an estimate, if transient sharpening is on; the + * caller may need to do the put/get/test cycle more than once. */ size_t getRequiredInputSamples() const; /** * Put (and possibly process) a given number of input samples. - * Number must not exceed the maxProcessInputBlockSize passed to - * constructor. + * Number should usually equal the value returned from + * getRequiredInputSamples(). */ void putInput(float **input, size_t samples); @@ -159,7 +145,7 @@ size_t m_sampleRate; size_t m_channels; - size_t m_maxProcessInputBlockSize; + size_t m_maxOutputBlockSize; float m_ratio; bool m_sharpen; size_t m_n1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ca...@us...> - 2006-09-20 16:03:13
|
Revision: 352 http://svn.sourceforge.net/sv1/?rev=352&view=rev Author: cannam Date: 2006-09-20 09:03:08 -0700 (Wed, 20 Sep 2006) Log Message: ----------- ... Modified Paths: -------------- vamp-plugin-sdk/trunk/README Modified: vamp-plugin-sdk/trunk/README =================================================================== --- vamp-plugin-sdk/trunk/README 2006-09-20 16:02:42 UTC (rev 351) +++ vamp-plugin-sdk/trunk/README 2006-09-20 16:03:08 UTC (rev 352) @@ -42,6 +42,8 @@ number of values per output or the preferred processing block size may depend on the input parameters. + * Vamp plugins do not have to be able to run in real time. + Vamp reuses some ideas from several existing systems, notably DSSI (http://dssi.sourceforge.net) and FEAPI (http://feapi.sourceforge.net). This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ca...@us...> - 2006-09-20 16:02:48
|
Revision: 351 http://svn.sourceforge.net/sv1/?rev=351&view=rev Author: cannam Date: 2006-09-20 09:02:42 -0700 (Wed, 20 Sep 2006) Log Message: ----------- * save and restore step/blocksize etc Modified Paths: -------------- sonic-visualiser/trunk/sv/document/Document.cpp sonic-visualiser/trunk/sv/document/SVFileReader.cpp sonic-visualiser/trunk/sv/document/SVFileReader.h Modified: sonic-visualiser/trunk/sv/document/Document.cpp =================================================================== --- sonic-visualiser/trunk/sv/document/Document.cpp 2006-09-20 15:47:16 UTC (rev 350) +++ sonic-visualiser/trunk/sv/document/Document.cpp 2006-09-20 16:02:42 UTC (rev 351) @@ -698,10 +698,14 @@ //!!! stream the rest of the execution context in both directions (i.e. not just channel) out << indent; - out << QString(" <derivation source=\"%1\" model=\"%2\" channel=\"%3\" transform=\"%4\"") + out << QString(" <derivation source=\"%1\" model=\"%2\" channel=\"%3\" domain=\"%4\" stepSize=\"%5\" blockSize=\"%6\" windowType=\"%7\" transform=\"%8\"") .arg(XmlExportable::getObjectExportId(rec.source)) .arg(XmlExportable::getObjectExportId(i->first)) .arg(rec.context.channel) + .arg(rec.context.domain) + .arg(rec.context.stepSize) + .arg(rec.context.blockSize) + .arg(int(rec.context.windowType)) .arg(XmlExportable::encodeEntities(rec.transform)); if (rec.configurationXml != "") { Modified: sonic-visualiser/trunk/sv/document/SVFileReader.cpp =================================================================== --- sonic-visualiser/trunk/sv/document/SVFileReader.cpp 2006-09-20 15:47:16 UTC (rev 350) +++ sonic-visualiser/trunk/sv/document/SVFileReader.cpp 2006-09-20 16:02:42 UTC (rev 351) @@ -262,7 +262,7 @@ if (m_currentDerivedModel) { m_document->addDerivedModel(m_currentTransform, m_document->getMainModel(), //!!! - m_currentTransformChannel, + m_currentTransformContext, m_currentDerivedModel, m_currentTransformConfiguration); m_addedModels.insert(m_currentDerivedModel); @@ -897,11 +897,24 @@ m_currentTransform = transform; m_currentTransformConfiguration = ""; + m_currentTransformContext = PluginTransform::ExecutionContext(); + bool ok = false; int channel = attributes.value("channel").trimmed().toInt(&ok); - if (ok) m_currentTransformChannel = channel; - else m_currentTransformChannel = -1; + if (ok) m_currentTransformContext.channel = channel; + int domain = attributes.value("domain").trimmed().toInt(&ok); + if (ok) m_currentTransformContext.domain = Vamp::Plugin::InputDomain(domain); + + int stepSize = attributes.value("stepSize").trimmed().toInt(&ok); + if (ok) m_currentTransformContext.stepSize = stepSize; + + int blockSize = attributes.value("blockSize").trimmed().toInt(&ok); + if (ok) m_currentTransformContext.blockSize = blockSize; + + int windowType = attributes.value("windowType").trimmed().toInt(&ok); + if (ok) m_currentTransformContext.windowType = WindowType(windowType); + } else { std::cerr << "WARNING: SV-XML: Unknown derived model " << modelId << " for transform \"" << transform.toLocal8Bit().data() << "\"" Modified: sonic-visualiser/trunk/sv/document/SVFileReader.h =================================================================== --- sonic-visualiser/trunk/sv/document/SVFileReader.h 2006-09-20 15:47:16 UTC (rev 350) +++ sonic-visualiser/trunk/sv/document/SVFileReader.h 2006-09-20 16:02:42 UTC (rev 351) @@ -18,6 +18,7 @@ #include "layer/LayerFactory.h" #include "transform/Transform.h" +#include "transform/PluginTransform.h" #include <QXmlDefaultHandler> @@ -93,7 +94,7 @@ Model *m_currentDerivedModel; PlayParameters *m_currentPlayParameters; QString m_currentTransform; - int m_currentTransformChannel; + PluginTransform::ExecutionContext m_currentTransformContext; QString m_currentTransformConfiguration; QString m_datasetSeparator; bool m_inRow; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ca...@us...> - 2006-09-20 15:47:22
|
Revision: 350 http://svn.sourceforge.net/sv1/?rev=350&view=rev Author: cannam Date: 2006-09-20 08:47:16 -0700 (Wed, 20 Sep 2006) Log Message: ----------- * Handle plugins with weird block size requirements properly Modified Paths: -------------- sonic-visualiser/trunk/sv/transform/FeatureExtractionPluginTransform.cpp sonic-visualiser/trunk/widgets/PluginParameterDialog.cpp Modified: sonic-visualiser/trunk/sv/transform/FeatureExtractionPluginTransform.cpp =================================================================== --- sonic-visualiser/trunk/sv/transform/FeatureExtractionPluginTransform.cpp 2006-09-20 14:57:52 UTC (rev 349) +++ sonic-visualiser/trunk/sv/transform/FeatureExtractionPluginTransform.cpp 2006-09-20 15:47:16 UTC (rev 350) @@ -269,8 +269,8 @@ if (blockFrame >= endFrame) break; } -// std::cerr << "FeatureExtractionPluginTransform::run: blockFrame " -// << blockFrame << std::endl; + std::cerr << "FeatureExtractionPluginTransform::run: blockFrame " + << blockFrame << std::endl; long completion = (((blockFrame - startFrame) / m_context.stepSize) * 99) / Modified: sonic-visualiser/trunk/widgets/PluginParameterDialog.cpp =================================================================== --- sonic-visualiser/trunk/widgets/PluginParameterDialog.cpp 2006-09-20 14:57:52 UTC (rev 349) +++ sonic-visualiser/trunk/widgets/PluginParameterDialog.cpp 2006-09-20 15:47:16 UTC (rev 350) @@ -275,29 +275,29 @@ this, SLOT(blockSizeComboChanged(QString))); windowLayout->addWidget(blockSizeCombo, 0, 1); - if (showFrequencyDomainOptions) { - - windowLayout->addWidget(new QLabel(tr("Window increment:")), 1, 0); + windowLayout->addWidget(new QLabel(tr("Window increment:")), 1, 0); - QComboBox *incrementCombo = new QComboBox; - incrementCombo->setEditable(true); - found = false; - for (int i = 0; i < 14; ++i) { - int val = pow(2, i + 3); - incrementCombo->addItem(QString("%1").arg(val)); - if (val == increment) { - incrementCombo->setCurrentIndex(i); - found = true; - } + QComboBox *incrementCombo = new QComboBox; + incrementCombo->setEditable(true); + found = false; + for (int i = 0; i < 14; ++i) { + int val = pow(2, i + 3); + incrementCombo->addItem(QString("%1").arg(val)); + if (val == increment) { + incrementCombo->setCurrentIndex(i); + found = true; } - if (!found) { - incrementCombo->addItem(QString("%1").arg(increment)); - incrementCombo->setCurrentIndex(incrementCombo->count() - 1); - } - incrementCombo->setValidator(new QIntValidator(1, pow(2, 18), this)); - connect(incrementCombo, SIGNAL(textChanged(QString)), - this, SLOT(incrementComboChanged(QString))); - windowLayout->addWidget(incrementCombo, 1, 1); + } + if (!found) { + incrementCombo->addItem(QString("%1").arg(increment)); + incrementCombo->setCurrentIndex(incrementCombo->count() - 1); + } + incrementCombo->setValidator(new QIntValidator(1, pow(2, 18), this)); + connect(incrementCombo, SIGNAL(textChanged(QString)), + this, SLOT(incrementComboChanged(QString))); + windowLayout->addWidget(incrementCombo, 1, 1); + + if (showFrequencyDomainOptions) { windowLayout->addWidget(new QLabel(tr("Window shape:")), 2, 0); WindowTypeSelector *windowTypeSelector = new WindowTypeSelector; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ca...@us...> - 2006-09-20 14:57:58
|
Revision: 349 http://svn.sourceforge.net/sv1/?rev=349&view=rev Author: cannam Date: 2006-09-20 07:57:52 -0700 (Wed, 20 Sep 2006) Log Message: ----------- * fix typo Modified Paths: -------------- vamp-plugin-sdk/trunk/examples/PercussionOnsetDetector.cpp vamp-plugin-sdk/trunk/vamp-sdk/PluginHostAdapter.h Modified: vamp-plugin-sdk/trunk/examples/PercussionOnsetDetector.cpp =================================================================== --- vamp-plugin-sdk/trunk/examples/PercussionOnsetDetector.cpp 2006-09-20 14:50:40 UTC (rev 348) +++ vamp-plugin-sdk/trunk/examples/PercussionOnsetDetector.cpp 2006-09-20 14:57:52 UTC (rev 349) @@ -250,7 +250,7 @@ if (m_dfMinus2 < m_dfMinus1 && m_dfMinus1 >= count && - m_dfMinus1 > (m_sensitivity * m_blockSize) / 200) { + m_dfMinus1 > ((100 - m_sensitivity) * m_blockSize) / 200) { Feature onset; onset.hasTimestamp = true; Modified: vamp-plugin-sdk/trunk/vamp-sdk/PluginHostAdapter.h =================================================================== This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ca...@us...> - 2006-09-20 14:50:47
|
Revision: 348 http://svn.sourceforge.net/sv1/?rev=348&view=rev Author: cannam Date: 2006-09-20 07:50:40 -0700 (Wed, 20 Sep 2006) Log Message: ----------- * stepsize/blocksize from plugin dialog actually working, though with some puzzlement Modified Paths: -------------- sonic-visualiser/trunk/sv/transform/PluginTransform.cpp sonic-visualiser/trunk/sv/transform/TransformFactory.cpp sonic-visualiser/trunk/widgets/PluginParameterDialog.cpp Modified: sonic-visualiser/trunk/sv/transform/PluginTransform.cpp =================================================================== --- sonic-visualiser/trunk/sv/transform/PluginTransform.cpp 2006-09-20 14:00:09 UTC (rev 347) +++ sonic-visualiser/trunk/sv/transform/PluginTransform.cpp 2006-09-20 14:50:40 UTC (rev 348) @@ -15,6 +15,8 @@ #include "PluginTransform.h" +#include "vamp-sdk/PluginHostAdapter.h" + PluginTransform::PluginTransform(Model *inputModel, const ExecutionContext &context) : Transform(inputModel), @@ -66,6 +68,9 @@ PluginTransform::ExecutionContext::makeConsistentWithPlugin(const Vamp::PluginBase *_plugin) { const Vamp::Plugin *vp = dynamic_cast<const Vamp::Plugin *>(_plugin); + if (!vp) { + vp = dynamic_cast<const Vamp::PluginHostAdapter *>(_plugin); //!!! why? + } if (!vp) { domain = Vamp::Plugin::TimeDomain; Modified: sonic-visualiser/trunk/sv/transform/TransformFactory.cpp =================================================================== --- sonic-visualiser/trunk/sv/transform/TransformFactory.cpp 2006-09-20 14:00:09 UTC (rev 347) +++ sonic-visualiser/trunk/sv/transform/TransformFactory.cpp 2006-09-20 14:50:40 UTC (rev 348) @@ -26,6 +26,8 @@ #include "data/model/DenseTimeValueModel.h" +#include "vamp-sdk/PluginHostAdapter.h" + #include <iostream> #include <set> @@ -338,7 +340,8 @@ int &minChannels, int &maxChannels) { Vamp::Plugin *vp = 0; - if ((vp = dynamic_cast<Vamp::Plugin *>(plugin))) { + if ((vp = dynamic_cast<Vamp::Plugin *>(plugin)) || + (vp = dynamic_cast<Vamp::PluginHostAdapter *>(plugin))) { minChannels = vp->getMinChannelCount(); maxChannels = vp->getMaxChannelCount(); return true; Modified: sonic-visualiser/trunk/widgets/PluginParameterDialog.cpp =================================================================== --- sonic-visualiser/trunk/widgets/PluginParameterDialog.cpp 2006-09-20 14:00:09 UTC (rev 347) +++ sonic-visualiser/trunk/widgets/PluginParameterDialog.cpp 2006-09-20 14:50:40 UTC (rev 348) @@ -19,6 +19,7 @@ #include "WindowTypeSelector.h" #include "vamp-sdk/Plugin.h" +#include "vamp-sdk/PluginHostAdapter.h" #include <QGridLayout> #include <QLabel> @@ -75,7 +76,7 @@ if (output != "") { - Vamp::Plugin *fePlugin = dynamic_cast<Vamp::Plugin *>(plugin); + Vamp::PluginHostAdapter *fePlugin = dynamic_cast<Vamp::PluginHostAdapter *>(m_plugin); if (fePlugin) { @@ -92,8 +93,6 @@ } } } - } else { - std::cerr << "Plugin " << plugin << " is not a feature extraction plugin" << std::endl;//!!! } } @@ -108,26 +107,38 @@ typeLabel->setWordWrap(true); typeLabel->setFont(font); - subgrid->addWidget(new QLabel(tr("Name:")), 0, 0); + QLabel *label = new QLabel(tr("Name:")); + label->setAlignment(Qt::AlignTop | Qt::AlignLeft); + subgrid->addWidget(label, 0, 0); subgrid->addWidget(nameLabel, 0, 1); - subgrid->addWidget(new QLabel(tr("Type:")), 1, 0); + label = new QLabel(tr("Type:")); + label->setAlignment(Qt::AlignTop | Qt::AlignLeft); + subgrid->addWidget(label, 1, 0); subgrid->addWidget(typeLabel, 1, 1); int outputOffset = 0; if (outputLabel) { - subgrid->addWidget(new QLabel(tr("Output:")), 2, 0); + label = new QLabel(tr("Output:")); + label->setAlignment(Qt::AlignTop | Qt::AlignLeft); + subgrid->addWidget(label, 2, 0); subgrid->addWidget(outputLabel, 2, 1); outputOffset = 1; } - subgrid->addWidget(new QLabel(tr("Maker:")), 2 + outputOffset, 0); + label = new QLabel(tr("Maker:")); + label->setAlignment(Qt::AlignTop | Qt::AlignLeft); + subgrid->addWidget(label, 2 + outputOffset, 0); subgrid->addWidget(makerLabel, 2 + outputOffset, 1); - subgrid->addWidget(new QLabel(tr("Copyright: ")), 3 + outputOffset, 0); + label = new QLabel(tr("Copyright: ")); + label->setAlignment(Qt::AlignTop | Qt::AlignLeft); + subgrid->addWidget(label, 3 + outputOffset, 0); subgrid->addWidget(copyrightLabel, 3 + outputOffset, 1); - subgrid->addWidget(new QLabel(tr("Version:")), 4 + outputOffset, 0); + label = new QLabel(tr("Version:")); + label->setAlignment(Qt::AlignTop | Qt::AlignLeft); + subgrid->addWidget(label, 4 + outputOffset, 0); subgrid->addWidget(versionLabel, 4 + outputOffset, 1); subgrid->setColumnStretch(1, 2); @@ -206,7 +217,7 @@ if (showWindowSize) { - Vamp::Plugin *fePlugin = dynamic_cast<Vamp::Plugin *>(plugin); + Vamp::PluginHostAdapter *fePlugin = dynamic_cast<Vamp::PluginHostAdapter *>(m_plugin); int size = 1024; int increment = 1024; if (fePlugin) { @@ -222,7 +233,7 @@ } } } else { - std::cerr << "Plugin " << plugin << " is not a feature extraction plugin" << std::endl;//!!! + std::cerr << "Plugin " << plugin << " is not a feature extraction plugin (it's a " << typeid(*plugin).name() << ")" << std::endl;//!!! } QGroupBox *windowBox = new QGroupBox; @@ -246,11 +257,19 @@ QComboBox *blockSizeCombo = new QComboBox; blockSizeCombo->setEditable(true); + bool found = false; for (int i = 0; i < 14; ++i) { int val = pow(2, i + 3); blockSizeCombo->addItem(QString("%1").arg(val)); - if (val == size) blockSizeCombo->setCurrentIndex(i); + if (val == size) { + blockSizeCombo->setCurrentIndex(i); + found = true; + } } + if (!found) { + blockSizeCombo->addItem(QString("%1").arg(size)); + blockSizeCombo->setCurrentIndex(blockSizeCombo->count() - 1); + } blockSizeCombo->setValidator(new QIntValidator(1, pow(2, 18), this)); connect(blockSizeCombo, SIGNAL(textChanged(QString)), this, SLOT(blockSizeComboChanged(QString))); @@ -262,11 +281,19 @@ QComboBox *incrementCombo = new QComboBox; incrementCombo->setEditable(true); + found = false; for (int i = 0; i < 14; ++i) { int val = pow(2, i + 3); incrementCombo->addItem(QString("%1").arg(val)); - if (val == increment) incrementCombo->setCurrentIndex(i); + if (val == increment) { + incrementCombo->setCurrentIndex(i); + found = true; + } } + if (!found) { + incrementCombo->addItem(QString("%1").arg(increment)); + incrementCombo->setCurrentIndex(incrementCombo->count() - 1); + } incrementCombo->setValidator(new QIntValidator(1, pow(2, 18), this)); connect(incrementCombo, SIGNAL(textChanged(QString)), this, SLOT(incrementComboChanged(QString))); @@ -349,7 +376,7 @@ { m_stepSize = text.toInt(); //!!! rename increment to step size throughout - std::cerr << "Increment changed to " << m_blockSize << std::endl; + std::cerr << "Increment changed to " << m_stepSize << std::endl; } void This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ca...@us...> - 2006-09-20 14:00:17
|
Revision: 347 http://svn.sourceforge.net/sv1/?rev=347&view=rev Author: cannam Date: 2006-09-20 07:00:09 -0700 (Wed, 20 Sep 2006) Log Message: ----------- * avoid compiler warning Modified Paths: -------------- vamp-plugin-sdk/trunk/examples/PercussionOnsetDetector.cpp Modified: vamp-plugin-sdk/trunk/examples/PercussionOnsetDetector.cpp =================================================================== --- vamp-plugin-sdk/trunk/examples/PercussionOnsetDetector.cpp 2006-09-20 13:51:22 UTC (rev 346) +++ vamp-plugin-sdk/trunk/examples/PercussionOnsetDetector.cpp 2006-09-20 14:00:09 UTC (rev 347) @@ -255,7 +255,7 @@ Feature onset; onset.hasTimestamp = true; onset.timestamp = ts - Vamp::RealTime::frame2RealTime - (m_stepSize, m_inputSampleRate); + (m_stepSize, lrintf(m_inputSampleRate)); returnFeatures[0].push_back(onset); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ca...@us...> - 2006-09-20 13:51:34
|
Revision: 346 http://svn.sourceforge.net/sv1/?rev=346&view=rev Author: cannam Date: 2006-09-20 06:51:22 -0700 (Wed, 20 Sep 2006) Log Message: ----------- * Add an implementation of Dan Barry's percussion onset detector Modified Paths: -------------- vamp-plugin-sdk/trunk/Makefile vamp-plugin-sdk/trunk/README vamp-plugin-sdk/trunk/examples/plugins.cpp vamp-plugin-sdk/trunk/vamp-sdk/Plugin.h vamp-plugin-sdk/trunk/vamp-sdk/PluginHostAdapter.cpp vamp-plugin-sdk/trunk/vamp-sdk/libvamp-sdk.la.in Added Paths: ----------- vamp-plugin-sdk/trunk/examples/PercussionOnsetDetector.cpp vamp-plugin-sdk/trunk/examples/PercussionOnsetDetector.h Modified: vamp-plugin-sdk/trunk/Makefile =================================================================== --- vamp-plugin-sdk/trunk/Makefile 2006-09-19 14:37:06 UTC (rev 345) +++ vamp-plugin-sdk/trunk/Makefile 2006-09-20 13:51:22 UTC (rev 346) @@ -82,10 +82,12 @@ PLUGIN_HEADERS = \ $(EXAMPLEDIR)/SpectralCentroid.h \ + $(EXAMPLEDIR)/PercussionOnsetDetector.h \ $(EXAMPLEDIR)/ZeroCrossing.h PLUGIN_OBJECTS = \ $(EXAMPLEDIR)/SpectralCentroid.o \ + $(EXAMPLEDIR)/PercussionOnsetDetector.o \ $(EXAMPLEDIR)/ZeroCrossing.o \ $(EXAMPLEDIR)/plugins.o @@ -136,7 +138,7 @@ rm -f $(INSTALL_SDK_LIBS)/$(INSTALL_SDK_LINK_ABI) ln -s $(INSTALL_SDK_LIBNAME) $(INSTALL_SDK_LIBS)/$(INSTALL_SDK_LINK_ABI) rm -f $(INSTALL_SDK_LIBS)/$(INSTALL_SDK_LINK_DEV) - ln -s $(INSTALL_SDK_LINK_ABI) $(INSTALL_SDK_LIBS)/$(INSTALL_SDK_LINK_DEV) + ln -s $(INSTALL_SDK_LIBNAME) $(INSTALL_SDK_LIBS)/$(INSTALL_SDK_LINK_DEV) sed "s,%PREFIX%,$(INSTALL_PREFIX)," $(APIDIR)/vamp.pc.in \ > $(INSTALL_PKGCONFIG)/vamp.pc sed "s,%PREFIX%,$(INSTALL_PREFIX)," $(SDKDIR)/vamp-sdk.pc.in \ Modified: vamp-plugin-sdk/trunk/README =================================================================== --- vamp-plugin-sdk/trunk/README 2006-09-19 14:37:06 UTC (rev 345) +++ vamp-plugin-sdk/trunk/README 2006-09-20 13:51:22 UTC (rev 346) @@ -1,6 +1,7 @@ Vamp ==== +http://www.sonicvisualiser.org/vamp.html An API for audio analysis and feature extraction plugins. @@ -78,8 +79,12 @@ Example plugins implemented using the C++ classes. ZeroCrossing calculates the positions and density of zero-crossing points in an -audio waveform; SpectralCentroid calculates the centre of gravity of +audio waveform. SpectralCentroid calculates the centre of gravity of the frequency domain representation of each block of audio. +PercussionOnsetDetector estimates the locations of percussive onsets +using a simple method described in "Drum Source Separation using +Percussive Feature Detection and Spectral Modulation" by Dan Barry, +Derry Fitzgerald, Eugene Coyle and Bob Lawlor, ISSC 2005. * host @@ -118,6 +123,7 @@ Sonic Visualiser, an interactive open-source graphical audio inspection, analysis and visualisation tool supporting Vamp plugins. +http://www.sonicvisualiser.org/ Chris Cannam Added: vamp-plugin-sdk/trunk/examples/PercussionOnsetDetector.cpp =================================================================== --- vamp-plugin-sdk/trunk/examples/PercussionOnsetDetector.cpp (rev 0) +++ vamp-plugin-sdk/trunk/examples/PercussionOnsetDetector.cpp 2006-09-20 13:51:22 UTC (rev 346) @@ -0,0 +1,273 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Vamp + + An API for audio analysis and feature extraction plugins. + + Centre for Digital Music, Queen Mary, University of London. + Copyright 2006 Chris Cannam. + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without + restriction, including without limitation the rights to use, copy, + modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR + ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + Except as contained in this notice, the names of the Centre for + Digital Music; Queen Mary, University of London; and Chris Cannam + shall not be used in advertising or otherwise to promote the sale, + use or other dealings in this Software without prior written + authorization. +*/ + +#include "PercussionOnsetDetector.h" + +using std::string; +using std::vector; +using std::cerr; +using std::endl; + +#include <cmath> + + +PercussionOnsetDetector::PercussionOnsetDetector(float inputSampleRate) : + Plugin(inputSampleRate), + m_stepSize(0), + m_blockSize(0), + m_threshold(3), + m_sensitivity(40), + m_priorMagnitudes(0), + m_dfMinus1(0), + m_dfMinus2(0) +{ +} + +PercussionOnsetDetector::~PercussionOnsetDetector() +{ + delete[] m_priorMagnitudes; +} + +string +PercussionOnsetDetector::getName() const +{ + return "percussiononsets"; +} + +string +PercussionOnsetDetector::getDescription() const +{ + return "Simple Percussion Onset Detector"; +} + +string +PercussionOnsetDetector::getMaker() const +{ + return "Queen Mary, University of London"; +} + +int +PercussionOnsetDetector::getPluginVersion() const +{ + return 2; +} + +string +PercussionOnsetDetector::getCopyright() const +{ + return "Code copyright 2006 Queen Mary, University of London, after Dan Barry et al 2005. Freely redistributable (BSD license)"; +} + +size_t +PercussionOnsetDetector::getPreferredStepSize() const +{ + return 0; +} + +size_t +PercussionOnsetDetector::getPreferredBlockSize() const +{ + return 1024; +} + +bool +PercussionOnsetDetector::initialise(size_t channels, size_t stepSize, size_t blockSize) +{ + if (channels < getMinChannelCount() || + channels > getMaxChannelCount()) return false; + + m_stepSize = stepSize; + m_blockSize = blockSize; + + m_priorMagnitudes = new float[m_blockSize/2]; + + for (size_t i = 0; i < m_blockSize/2; ++i) { + m_priorMagnitudes[i] = 0.f; + } + + m_dfMinus1 = 0.f; + m_dfMinus2 = 0.f; + + return true; +} + +void +PercussionOnsetDetector::reset() +{ + for (size_t i = 0; i < m_blockSize/2; ++i) { + m_priorMagnitudes[i] = 0.f; + } + + m_dfMinus1 = 0.f; + m_dfMinus2 = 0.f; +} + +PercussionOnsetDetector::ParameterList +PercussionOnsetDetector::getParameterDescriptors() const +{ + ParameterList list; + + ParameterDescriptor d; + d.name = "threshold"; + d.description = "Broadband energy rise threshold"; + d.unit = "dB"; + d.minValue = 0; + d.maxValue = 20; + d.defaultValue = 3; + d.isQuantized = false; + list.push_back(d); + + d.name = "sensitivity"; + d.description = "Peak detection sensitivity"; + d.unit = "%"; + d.minValue = 0; + d.maxValue = 100; + d.defaultValue = 40; + d.isQuantized = false; + list.push_back(d); + + return list; +} + +float +PercussionOnsetDetector::getParameter(std::string name) const +{ + if (name == "threshold") return m_threshold; + if (name == "sensitivity") return m_sensitivity; + return 0.f; +} + +void +PercussionOnsetDetector::setParameter(std::string name, float value) +{ + if (name == "threshold") { + if (value < 0) value = 0; + if (value > 20) value = 20; + m_threshold = value; + } else if (name == "sensitivity") { + if (value < 0) value = 0; + if (value > 100) value = 100; + m_sensitivity = value; + } +} + +PercussionOnsetDetector::OutputList +PercussionOnsetDetector::getOutputDescriptors() const +{ + OutputList list; + + OutputDescriptor d; + d.name = "onsets"; + d.unit = ""; + d.description = "Onsets"; + d.hasFixedBinCount = true; + d.binCount = 0; + d.hasKnownExtents = false; + d.isQuantized = false; + d.sampleType = OutputDescriptor::VariableSampleRate; + d.sampleRate = m_inputSampleRate; + list.push_back(d); + + d.name = "detectionfunction"; + d.description = "Onset Detection Function"; + d.binCount = 1; + d.isQuantized = true; + d.quantizeStep = 1.0; + d.sampleType = OutputDescriptor::OneSamplePerStep; + list.push_back(d); + + return list; +} + +PercussionOnsetDetector::FeatureSet +PercussionOnsetDetector::process(float **inputBuffers, Vamp::RealTime ts) +{ + if (m_stepSize == 0) { + cerr << "ERROR: PercussionOnsetDetector::process: " + << "PercussionOnsetDetector has not been initialised" + << endl; + return FeatureSet(); + } + + int count = 0; + + for (size_t i = 1; i < m_blockSize/2; ++i) { + + float real = inputBuffers[0][i*2]; + float imag = inputBuffers[0][i*2 + 1]; + float sqrmag = real * real + imag * imag; + + if (m_priorMagnitudes[i] > 0.f) { + float diff = 10.f * log10f(sqrmag / m_priorMagnitudes[i]); + +// std::cout << "i=" << i << ", mag=" << mag << ", prior=" << m_priorMagnitudes[i] << ", diff=" << diff << ", threshold=" << m_threshold << std::endl; + + if (diff >= m_threshold) ++count; + } + + m_priorMagnitudes[i] = sqrmag; + } + + FeatureSet returnFeatures; + + Feature detectionFunction; + detectionFunction.hasTimestamp = false; + detectionFunction.values.push_back(count); + returnFeatures[1].push_back(detectionFunction); + + if (m_dfMinus2 < m_dfMinus1 && + m_dfMinus1 >= count && + m_dfMinus1 > (m_sensitivity * m_blockSize) / 200) { + + Feature onset; + onset.hasTimestamp = true; + onset.timestamp = ts - Vamp::RealTime::frame2RealTime + (m_stepSize, m_inputSampleRate); + returnFeatures[0].push_back(onset); + } + + m_dfMinus2 = m_dfMinus1; + m_dfMinus1 = count; + + return returnFeatures; +} + +PercussionOnsetDetector::FeatureSet +PercussionOnsetDetector::getRemainingFeatures() +{ + return FeatureSet(); +} + Added: vamp-plugin-sdk/trunk/examples/PercussionOnsetDetector.h =================================================================== --- vamp-plugin-sdk/trunk/examples/PercussionOnsetDetector.h (rev 0) +++ vamp-plugin-sdk/trunk/examples/PercussionOnsetDetector.h 2006-09-20 13:51:22 UTC (rev 346) @@ -0,0 +1,84 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Vamp + + An API for audio analysis and feature extraction plugins. + + Centre for Digital Music, Queen Mary, University of London. + Copyright 2006 Chris Cannam. + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without + restriction, including without limitation the rights to use, copy, + modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR + ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + Except as contained in this notice, the names of the Centre for + Digital Music; Queen Mary, University of London; and Chris Cannam + shall not be used in advertising or otherwise to promote the sale, + use or other dealings in this Software without prior written + authorization. +*/ + +#ifndef _PERCUSSION_ONSET_DETECTOR_PLUGIN_H_ +#define _PERCUSSION_ONSET_DETECTOR_PLUGIN_H_ + +#include "Plugin.h" + +class PercussionOnsetDetector : public Vamp::Plugin +{ +public: + PercussionOnsetDetector(float inputSampleRate); + virtual ~PercussionOnsetDetector(); + + bool initialise(size_t channels, size_t stepSize, size_t blockSize); + void reset(); + + InputDomain getInputDomain() const { return FrequencyDomain; } + + std::string getName() const; + std::string getDescription() const; + std::string getMaker() const; + int getPluginVersion() const; + std::string getCopyright() const; + + size_t getPreferredStepSize() const; + size_t getPreferredBlockSize() const; + + ParameterList getParameterDescriptors() const; + float getParameter(std::string name) const; + void setParameter(std::string name, float value); + + OutputList getOutputDescriptors() const; + + FeatureSet process(float **inputBuffers, Vamp::RealTime timestamp); + + FeatureSet getRemainingFeatures(); + +protected: + size_t m_stepSize; + size_t m_blockSize; + + float m_threshold; + float m_sensitivity; + float *m_priorMagnitudes; + float m_dfMinus1; + float m_dfMinus2; +}; + + +#endif Modified: vamp-plugin-sdk/trunk/examples/plugins.cpp =================================================================== --- vamp-plugin-sdk/trunk/examples/plugins.cpp 2006-09-19 14:37:06 UTC (rev 345) +++ vamp-plugin-sdk/trunk/examples/plugins.cpp 2006-09-20 13:51:22 UTC (rev 346) @@ -39,15 +39,18 @@ #include "PluginAdapter.h" #include "ZeroCrossing.h" #include "SpectralCentroid.h" +#include "PercussionOnsetDetector.h" static Vamp::PluginAdapter<ZeroCrossing> zeroCrossingAdapter; static Vamp::PluginAdapter<SpectralCentroid> spectralCentroidAdapter; +static Vamp::PluginAdapter<PercussionOnsetDetector> percussionOnsetAdapter; const VampPluginDescriptor *vampGetPluginDescriptor(unsigned int index) { switch (index) { case 0: return zeroCrossingAdapter.getDescriptor(); case 1: return spectralCentroidAdapter.getDescriptor(); + case 2: return percussionOnsetAdapter.getDescriptor(); default: return 0; } } Modified: vamp-plugin-sdk/trunk/vamp-sdk/Plugin.h =================================================================== --- vamp-plugin-sdk/trunk/vamp-sdk/Plugin.h 2006-09-19 14:37:06 UTC (rev 345) +++ vamp-plugin-sdk/trunk/vamp-sdk/Plugin.h 2006-09-20 13:51:22 UTC (rev 346) @@ -89,7 +89,8 @@ * all of the parameter and program settings. If the values passed in * to initialise do not match the plugin's advertised preferred values * from step 4, the plugin may refuse to initialise and return false - * (although if possible it should accept the new values). + * (although if possible it should accept the new values). Any + * computationally expensive setup code should take place here. * * 6. Host finally checks the number of values per output (which may * vary depending on the number of channels, step size and block size @@ -110,7 +111,8 @@ * * A plugin does not need to handle the case where setParameter or * selectProgram is called after initialise has been called. It's the - * host's responsibility not to do that. + * host's responsibility not to do that. Similarly, the plugin may + * safely assume that initialise is called no more than once. */ class Plugin : public PluginBase Modified: vamp-plugin-sdk/trunk/vamp-sdk/PluginHostAdapter.cpp =================================================================== --- vamp-plugin-sdk/trunk/vamp-sdk/PluginHostAdapter.cpp 2006-09-19 14:37:06 UTC (rev 345) +++ vamp-plugin-sdk/trunk/vamp-sdk/PluginHostAdapter.cpp 2006-09-20 13:51:22 UTC (rev 346) @@ -72,9 +72,9 @@ #else #define PATH_SEPARATOR ':' #ifdef __APPLE__ -#define DEFAULT_VAMP_PATH "/Library/Audio/Plug-Ins/Vamp/:$HOME/Library/Audio/Plug-Ins/Vamp" +#define DEFAULT_VAMP_PATH "$HOME/Library/Audio/Plug-Ins/Vamp:/Library/Audio/Plug-Ins/Vamp" #else -#define DEFAULT_VAMP_PATH "/usr/local/lib/vamp:/usr/lib/vamp:$HOME/vamp:$HOME/.vamp" +#define DEFAULT_VAMP_PATH "$HOME/vamp:$HOME/.vamp:/usr/local/lib/vamp:/usr/lib/vamp" #endif #endif Modified: vamp-plugin-sdk/trunk/vamp-sdk/libvamp-sdk.la.in =================================================================== --- vamp-plugin-sdk/trunk/vamp-sdk/libvamp-sdk.la.in 2006-09-19 14:37:06 UTC (rev 345) +++ vamp-plugin-sdk/trunk/vamp-sdk/libvamp-sdk.la.in 2006-09-20 13:51:22 UTC (rev 346) @@ -5,4 +5,5 @@ current=0 age=0 revision=5 +installed=yes libdir='%LIBS%' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ca...@us...> - 2006-09-19 14:37:27
|
Revision: 345 http://svn.sourceforge.net/sv1/?rev=345&view=rev Author: cannam Date: 2006-09-19 07:37:06 -0700 (Tue, 19 Sep 2006) Log Message: ----------- * More to do with passing around step/blocksize etc from plugin dialog to plugins. Still some puzzling unresolved details. Modified Paths: -------------- sonic-visualiser/trunk/sv/document/Document.cpp sonic-visualiser/trunk/sv/document/Document.h sonic-visualiser/trunk/sv/main/MainWindow.cpp sonic-visualiser/trunk/sv/sv.pro sonic-visualiser/trunk/sv/transform/FeatureExtractionPluginTransform.cpp sonic-visualiser/trunk/sv/transform/FeatureExtractionPluginTransform.h sonic-visualiser/trunk/sv/transform/RealTimePluginTransform.cpp sonic-visualiser/trunk/sv/transform/RealTimePluginTransform.h sonic-visualiser/trunk/sv/transform/TransformFactory.cpp sonic-visualiser/trunk/sv/transform/TransformFactory.h sonic-visualiser/trunk/widgets/PluginParameterDialog.cpp sonic-visualiser/trunk/widgets/PluginParameterDialog.h Added Paths: ----------- sonic-visualiser/trunk/sv/transform/PluginTransform.cpp sonic-visualiser/trunk/sv/transform/PluginTransform.h Modified: sonic-visualiser/trunk/sv/document/Document.cpp =================================================================== --- sonic-visualiser/trunk/sv/document/Document.cpp 2006-09-18 16:43:17 UTC (rev 344) +++ sonic-visualiser/trunk/sv/document/Document.cpp 2006-09-19 14:37:06 UTC (rev 345) @@ -161,11 +161,11 @@ Layer * Document::createDerivedLayer(TransformName transform, Model *inputModel, - int channel, + const PluginTransform::ExecutionContext &context, QString configurationXml) { Model *newModel = createModelForTransform(transform, inputModel, - channel, configurationXml); + context, configurationXml); if (!newModel) { // error already printed to stderr by createModelForTransform emit modelGenerationFailed(transform); @@ -252,12 +252,12 @@ // model: regenerate it. TransformName transform = m_models[model].transform; - int channel = m_models[model].channel; + PluginTransform::ExecutionContext context = m_models[model].context; Model *replacementModel = createModelForTransform(transform, m_mainModel, - channel, + context, m_models[model].configurationXml); if (!replacementModel) { @@ -288,7 +288,7 @@ void Document::addDerivedModel(TransformName transform, Model *inputModel, - int channel, + const PluginTransform::ExecutionContext &context, Model *outputModelToAdd, QString configurationXml) { @@ -301,7 +301,7 @@ ModelRecord rec; rec.source = inputModel; rec.transform = transform; - rec.channel = channel; + rec.context = context; rec.configurationXml = configurationXml; rec.refcount = 0; @@ -323,7 +323,6 @@ ModelRecord rec; rec.source = 0; rec.transform = ""; - rec.channel = -1; rec.refcount = 0; m_models[model] = rec; @@ -334,7 +333,7 @@ Model * Document::createModelForTransform(TransformName transform, Model *inputModel, - int channel, + const PluginTransform::ExecutionContext &context, QString configurationXml) { Model *model = 0; @@ -342,19 +341,19 @@ for (ModelMap::iterator i = m_models.begin(); i != m_models.end(); ++i) { if (i->second.transform == transform && i->second.source == inputModel && - i->second.channel == channel && + i->second.context == context && i->second.configurationXml == configurationXml) { return i->first; } } model = TransformFactory::getInstance()->transform - (transform, inputModel, channel, configurationXml); + (transform, inputModel, context, configurationXml); if (!model) { std::cerr << "WARNING: Document::createModelForTransform: no output model for transform " << transform.toStdString() << std::endl; } else { - addDerivedModel(transform, inputModel, channel, model, configurationXml); + addDerivedModel(transform, inputModel, context, model, configurationXml); } return model; @@ -696,11 +695,13 @@ if (rec.source && rec.transform != "") { + //!!! stream the rest of the execution context in both directions (i.e. not just channel) + out << indent; out << QString(" <derivation source=\"%1\" model=\"%2\" channel=\"%3\" transform=\"%4\"") .arg(XmlExportable::getObjectExportId(rec.source)) .arg(XmlExportable::getObjectExportId(i->first)) - .arg(rec.channel) + .arg(rec.context.channel) .arg(XmlExportable::encodeEntities(rec.transform)); if (rec.configurationXml != "") { Modified: sonic-visualiser/trunk/sv/document/Document.h =================================================================== --- sonic-visualiser/trunk/sv/document/Document.h 2006-09-18 16:43:17 UTC (rev 344) +++ sonic-visualiser/trunk/sv/document/Document.h 2006-09-19 14:37:06 UTC (rev 345) @@ -18,6 +18,7 @@ #include "layer/LayerFactory.h" #include "transform/Transform.h" +#include "transform/PluginTransform.h" #include "base/Command.h" #include <map> @@ -113,7 +114,7 @@ */ Layer *createDerivedLayer(TransformName, Model *inputModel, - int inputChannel, // -1 -> all + const PluginTransform::ExecutionContext &context, QString configurationXml); /** @@ -136,7 +137,7 @@ */ void addDerivedModel(TransformName, Model *inputModel, - int inputChannel, // -1 -> all + const PluginTransform::ExecutionContext &context, Model *outputModelToAdd, QString configurationXml); @@ -194,7 +195,7 @@ protected: Model *createModelForTransform(TransformName transform, Model *inputModel, - int channel, + const PluginTransform::ExecutionContext &context, QString configurationXml); void releaseModel(Model *model); @@ -230,7 +231,7 @@ // since being generated from it. const Model *source; TransformName transform; - int channel; + PluginTransform::ExecutionContext context; QString configurationXml; // Count of the number of layers using this model. Modified: sonic-visualiser/trunk/sv/main/MainWindow.cpp =================================================================== --- sonic-visualiser/trunk/sv/main/MainWindow.cpp 2006-09-18 16:43:17 UTC (rev 344) +++ sonic-visualiser/trunk/sv/main/MainWindow.cpp 2006-09-19 14:37:06 UTC (rev 345) @@ -2790,6 +2790,9 @@ bool needConfiguration = false; + //!!! actually we should probably always ask for configuration + //because we need the execution context + if (factory->isTransformConfigurable(transform)) { needConfiguration = true; } else { @@ -2803,21 +2806,23 @@ } } + PluginTransform::ExecutionContext context(channel); + if (needConfiguration) { bool ok = factory->getConfigurationForTransform - (transform, m_document->getMainModel(), channel, configurationXml); + (transform, m_document->getMainModel(), context, configurationXml); if (!ok) return; } Layer *newLayer = m_document->createDerivedLayer(transform, m_document->getMainModel(), - channel, + context, configurationXml); if (newLayer) { m_document->addLayerToView(pane, newLayer); - m_document->setChannel(newLayer, channel); + m_document->setChannel(newLayer, context.channel); } updateMenuStates(); Modified: sonic-visualiser/trunk/sv/sv.pro =================================================================== --- sonic-visualiser/trunk/sv/sv.pro 2006-09-18 16:43:17 UTC (rev 344) +++ sonic-visualiser/trunk/sv/sv.pro 2006-09-19 14:37:06 UTC (rev 345) @@ -42,6 +42,7 @@ main/MainWindow.h \ main/PreferencesDialog.h \ transform/FeatureExtractionPluginTransform.h \ + transform/PluginTransform.h \ transform/RealTimePluginTransform.h \ transform/Transform.h \ transform/TransformFactory.h @@ -59,6 +60,7 @@ main/MainWindow.cpp \ main/PreferencesDialog.cpp \ transform/FeatureExtractionPluginTransform.cpp \ + transform/PluginTransform.cpp \ transform/RealTimePluginTransform.cpp \ transform/Transform.cpp \ transform/TransformFactory.cpp Modified: sonic-visualiser/trunk/sv/transform/FeatureExtractionPluginTransform.cpp =================================================================== --- sonic-visualiser/trunk/sv/transform/FeatureExtractionPluginTransform.cpp 2006-09-18 16:43:17 UTC (rev 344) +++ sonic-visualiser/trunk/sv/transform/FeatureExtractionPluginTransform.cpp 2006-09-19 14:37:06 UTC (rev 345) @@ -34,18 +34,11 @@ FeatureExtractionPluginTransform::FeatureExtractionPluginTransform(Model *inputModel, QString pluginId, - int channel, + const ExecutionContext &context, QString configurationXml, - QString outputName, - size_t stepSize, - size_t blockSize, - WindowType windowType) : - Transform(inputModel), + QString outputName) : + PluginTransform(inputModel, context), m_plugin(0), - m_channel(channel), - m_stepSize(0), - m_blockSize(0), - m_windowType(windowType), m_descriptor(0), m_outputFeatureNo(0) { @@ -72,18 +65,6 @@ PluginXml(m_plugin).setParametersFromXml(configurationXml); } - if (m_blockSize == 0) m_blockSize = m_plugin->getPreferredBlockSize(); - if (m_stepSize == 0) m_stepSize = m_plugin->getPreferredStepSize(); - - if (m_blockSize == 0) m_blockSize = 1024; - if (m_stepSize == 0) { - if (m_plugin->getInputDomain() == Vamp::Plugin::FrequencyDomain) { - m_stepSize = m_blockSize / 2; - } else { - m_stepSize = m_blockSize; - } - } - DenseTimeValueModel *input = getInput(); if (!input) return; @@ -100,7 +81,13 @@ return; } - if (!m_plugin->initialise(channelCount, m_stepSize, m_blockSize)) { + std::cerr << "Initialising feature extraction plugin with channels = " + << channelCount << ", step = " << m_context.stepSize + << ", block = " << m_context.blockSize << std::endl; + + if (!m_plugin->initialise(channelCount, + m_context.stepSize, + m_context.blockSize)) { std::cerr << "FeatureExtractionPluginTransform: Plugin " << m_plugin->getName() << " failed to initialise!" << std::endl; return; @@ -160,7 +147,7 @@ break; case Vamp::Plugin::OutputDescriptor::OneSamplePerStep: - modelResolution = m_stepSize; + modelResolution = m_context.stepSize; break; case Vamp::Plugin::OutputDescriptor::FixedSampleRate: @@ -248,7 +235,7 @@ float **buffers = new float*[channelCount]; for (size_t ch = 0; ch < channelCount; ++ch) { - buffers[ch] = new float[m_blockSize]; + buffers[ch] = new float[m_context.blockSize]; } bool frequencyDomain = (m_plugin->getInputDomain() == @@ -259,11 +246,11 @@ for (size_t ch = 0; ch < channelCount; ++ch) { fftModels.push_back(new FFTModel (getInput(), - channelCount == 1 ? m_channel : ch, - m_windowType, - m_blockSize, - m_stepSize, - m_blockSize, + channelCount == 1 ? m_context.channel : ch, + m_context.windowType, + m_context.blockSize, + m_context.stepSize, + m_context.blockSize, false)); } } @@ -277,7 +264,7 @@ while (1) { if (frequencyDomain) { - if (blockFrame - int(m_blockSize)/2 > endFrame) break; + if (blockFrame - int(m_context.blockSize)/2 > endFrame) break; } else { if (blockFrame >= endFrame) break; } @@ -286,21 +273,21 @@ // << blockFrame << std::endl; long completion = - (((blockFrame - startFrame) / m_stepSize) * 99) / - ( (endFrame - startFrame) / m_stepSize); + (((blockFrame - startFrame) / m_context.stepSize) * 99) / + ( (endFrame - startFrame) / m_context.stepSize); // channelCount is either m_input->channelCount or 1 for (size_t ch = 0; ch < channelCount; ++ch) { if (frequencyDomain) { - int column = (blockFrame - startFrame) / m_stepSize; - for (size_t i = 0; i < m_blockSize/2; ++i) { + int column = (blockFrame - startFrame) / m_context.stepSize; + for (size_t i = 0; i < m_context.blockSize/2; ++i) { fftModels[ch]->getValuesAt (column, i, buffers[ch][i*2], buffers[ch][i*2+1]); } /*!!! float sum = 0.0; - for (size_t i = 0; i < m_blockSize/2; ++i) { + for (size_t i = 0; i < m_context.blockSize/2; ++i) { sum += buffers[ch][i*2]; } if (fabs(sum) < 0.0001) { @@ -309,7 +296,7 @@ */ } else { getFrames(ch, channelCount, - blockFrame, m_blockSize, buffers[ch]); + blockFrame, m_context.blockSize, buffers[ch]); } } @@ -327,7 +314,7 @@ prevCompletion = completion; } - blockFrame += m_stepSize; + blockFrame += m_context.stepSize; } Vamp::Plugin::FeatureSet features = m_plugin->getRemainingFeatures(); @@ -365,7 +352,7 @@ } long got = getInput()->getValues - ((channelCount == 1 ? m_channel : channel), + ((channelCount == 1 ? m_context.channel : channel), startFrame, startFrame + size, buffer + offset); while (got < size) { @@ -373,7 +360,7 @@ ++got; } - if (m_channel == -1 && channelCount == 1 && + if (m_context.channel == -1 && channelCount == 1 && getInput()->getChannelCount() > 1) { // use mean instead of sum, as plugin input int cc = getInput()->getChannelCount(); Modified: sonic-visualiser/trunk/sv/transform/FeatureExtractionPluginTransform.h =================================================================== --- sonic-visualiser/trunk/sv/transform/FeatureExtractionPluginTransform.h 2006-09-18 16:43:17 UTC (rev 344) +++ sonic-visualiser/trunk/sv/transform/FeatureExtractionPluginTransform.h 2006-09-19 14:37:06 UTC (rev 345) @@ -16,35 +16,24 @@ #ifndef _FEATURE_EXTRACTION_PLUGIN_TRANSFORM_H_ #define _FEATURE_EXTRACTION_PLUGIN_TRANSFORM_H_ -#include "Transform.h" +#include "PluginTransform.h" -#include "base/Window.h" - -#include "vamp-sdk/Plugin.h" - class DenseTimeValueModel; -class FeatureExtractionPluginTransform : public Transform +class FeatureExtractionPluginTransform : public PluginTransform { public: FeatureExtractionPluginTransform(Model *inputModel, QString plugin, - int channel, + const ExecutionContext &context, QString configurationXml = "", - QString outputName = "", - size_t stepSize = 0, - size_t blockSize = 0, - WindowType windowType = HanningWindow); + QString outputName = ""); virtual ~FeatureExtractionPluginTransform(); protected: virtual void run(); Vamp::Plugin *m_plugin; - int m_channel; - size_t m_stepSize; - size_t m_blockSize; - WindowType m_windowType; Vamp::Plugin::OutputDescriptor *m_descriptor; int m_outputFeatureNo; Added: sonic-visualiser/trunk/sv/transform/PluginTransform.cpp =================================================================== --- sonic-visualiser/trunk/sv/transform/PluginTransform.cpp (rev 0) +++ sonic-visualiser/trunk/sv/transform/PluginTransform.cpp 2006-09-19 14:37:06 UTC (rev 345) @@ -0,0 +1,93 @@ +/* -*- 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 "PluginTransform.h" + +PluginTransform::PluginTransform(Model *inputModel, + const ExecutionContext &context) : + Transform(inputModel), + m_context(context) +{ +} + +PluginTransform::ExecutionContext::ExecutionContext(int _c, size_t _bs) : + channel(_c), + domain(Vamp::Plugin::TimeDomain), + stepSize(_bs ? _bs : 1024), + blockSize(_bs ? _bs : 1024), + windowType(HanningWindow) +{ +} + +PluginTransform::ExecutionContext::ExecutionContext(int _c, size_t _ss, + size_t _bs, WindowType _wt) : + channel(_c), + domain(Vamp::Plugin::FrequencyDomain), + stepSize(_ss ? _ss : (_bs ? _bs / 2 : 512)), + blockSize(_bs ? _bs : 1024), + windowType(_wt) +{ +} + +PluginTransform::ExecutionContext::ExecutionContext(int _c, + const Vamp::PluginBase *_plugin) : + channel(_c), + domain(Vamp::Plugin::TimeDomain), + stepSize(0), + blockSize(0), + windowType(HanningWindow) +{ + makeConsistentWithPlugin(_plugin); +} + +bool +PluginTransform::ExecutionContext::operator==(const ExecutionContext &c) +{ + return (c.channel == channel && + c.domain == domain && + c.stepSize == stepSize && + c.blockSize == blockSize && + c.windowType == windowType); +} + +void +PluginTransform::ExecutionContext::makeConsistentWithPlugin(const Vamp::PluginBase *_plugin) +{ + const Vamp::Plugin *vp = dynamic_cast<const Vamp::Plugin *>(_plugin); + + if (!vp) { + domain = Vamp::Plugin::TimeDomain; + if (!stepSize) { + if (!blockSize) blockSize = 1024; + stepSize = blockSize; + } else { + if (!blockSize) blockSize = stepSize; + } + } else { + domain = vp->getInputDomain(); + if (!stepSize) stepSize = vp->getPreferredStepSize(); + if (!blockSize) blockSize = vp->getPreferredBlockSize(); + if (!blockSize) blockSize = 1024; + if (!stepSize) { + if (domain == Vamp::Plugin::FrequencyDomain) { + stepSize = blockSize/2; + } else { + stepSize = blockSize; + } + } + } +} + + Added: sonic-visualiser/trunk/sv/transform/PluginTransform.h =================================================================== --- sonic-visualiser/trunk/sv/transform/PluginTransform.h (rev 0) +++ sonic-visualiser/trunk/sv/transform/PluginTransform.h 2006-09-19 14:37:06 UTC (rev 345) @@ -0,0 +1,60 @@ +/* -*- 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 _PLUGIN_TRANSFORM_H_ +#define _PLUGIN_TRANSFORM_H_ + +#include "Transform.h" + +#include "base/Window.h" + +#include "vamp-sdk/Plugin.h" + +//!!! should this just move back up to Transform? It is after all used +//directly in all sorts of generic places, like Document + +class PluginTransform : public Transform +{ +public: + class ExecutionContext { + public: + // Time domain: + ExecutionContext(int _c = -1, size_t _bs = 0); + + // Frequency domain: + ExecutionContext(int _c, size_t _ss, size_t _bs, WindowType _wt); + + // From plugin defaults: + ExecutionContext(int _c, const Vamp::PluginBase *_plugin); + + bool operator==(const ExecutionContext &); + + void makeConsistentWithPlugin(const Vamp::PluginBase *_plugin); + + int channel; + Vamp::Plugin::InputDomain domain; + size_t stepSize; + size_t blockSize; + WindowType windowType; + }; + +protected: + PluginTransform(Model *inputModel, + const ExecutionContext &context); + + ExecutionContext m_context; +}; + +#endif Modified: sonic-visualiser/trunk/sv/transform/RealTimePluginTransform.cpp =================================================================== --- sonic-visualiser/trunk/sv/transform/RealTimePluginTransform.cpp 2006-09-18 16:43:17 UTC (rev 344) +++ sonic-visualiser/trunk/sv/transform/RealTimePluginTransform.cpp 2006-09-19 14:37:06 UTC (rev 345) @@ -28,18 +28,15 @@ RealTimePluginTransform::RealTimePluginTransform(Model *inputModel, QString pluginId, - int channel, + const ExecutionContext &context, QString configurationXml, QString units, - int output, - size_t blockSize) : - Transform(inputModel), + int output) : + PluginTransform(inputModel, context), m_plugin(0), - m_channel(channel), - m_outputNo(output), - m_blockSize(blockSize) + m_outputNo(output) { - if (!m_blockSize) m_blockSize = 1024; + if (!m_context.blockSize) m_context.blockSize = 1024; std::cerr << "RealTimePluginTransform::RealTimePluginTransform: plugin " << pluginId.toStdString() << ", output " << output << std::endl; @@ -56,7 +53,7 @@ if (!input) return; m_plugin = factory->instantiatePlugin(pluginId, 0, 0, m_input->getSampleRate(), - m_blockSize, + m_context.blockSize, input->getChannelCount()); if (!m_plugin) { @@ -75,7 +72,7 @@ } SparseTimeValueModel *model = new SparseTimeValueModel - (input->getSampleRate(), m_blockSize, 0.0, 0.0, false); + (input->getSampleRate(), m_context.blockSize, 0.0, 0.0, false); if (units != "") model->setScaleUnits(units); @@ -111,7 +108,7 @@ size_t sampleRate = input->getSampleRate(); int channelCount = input->getChannelCount(); - if (m_channel != -1) channelCount = 1; + if (m_context.channel != -1) channelCount = 1; size_t blockSize = m_plugin->getBufferSize(); @@ -135,11 +132,11 @@ if (channelCount == 1) { got = input->getValues - (m_channel, blockFrame, blockFrame + blockSize, buffers[0]); + (m_context.channel, blockFrame, blockFrame + blockSize, buffers[0]); while (got < blockSize) { buffers[0][got++] = 0.0; } - if (m_channel == -1 && channelCount > 1) { + if (m_context.channel == -1 && channelCount > 1) { // use mean instead of sum, as plugin input for (size_t i = 0; i < got; ++i) { buffers[0][i] /= channelCount; Modified: sonic-visualiser/trunk/sv/transform/RealTimePluginTransform.h =================================================================== --- sonic-visualiser/trunk/sv/transform/RealTimePluginTransform.h 2006-09-18 16:43:17 UTC (rev 344) +++ sonic-visualiser/trunk/sv/transform/RealTimePluginTransform.h 2006-09-19 14:37:06 UTC (rev 345) @@ -16,30 +16,27 @@ #ifndef _REAL_TIME_PLUGIN_TRANSFORM_H_ #define _REAL_TIME_PLUGIN_TRANSFORM_H_ -#include "Transform.h" +#include "PluginTransform.h" #include "plugin/RealTimePluginInstance.h" class DenseTimeValueModel; -class RealTimePluginTransform : public Transform +class RealTimePluginTransform : public PluginTransform { public: RealTimePluginTransform(Model *inputModel, QString plugin, - int channel, + const ExecutionContext &context, QString configurationXml = "", QString units = "", - int output = 0, - size_t blockSize = 0); + int output = 0); virtual ~RealTimePluginTransform(); protected: virtual void run(); RealTimePluginInstance *m_plugin; - int m_channel; int m_outputNo; - size_t m_blockSize; // just casts DenseTimeValueModel *getInput(); Modified: sonic-visualiser/trunk/sv/transform/TransformFactory.cpp =================================================================== --- sonic-visualiser/trunk/sv/transform/TransformFactory.cpp 2006-09-18 16:43:17 UTC (rev 344) +++ sonic-visualiser/trunk/sv/transform/TransformFactory.cpp 2006-09-19 14:37:06 UTC (rev 345) @@ -350,7 +350,7 @@ bool TransformFactory::getConfigurationForTransform(TransformName name, Model *inputModel, - int &channel, + PluginTransform::ExecutionContext &context, QString &configurationXml) { QString id = name.section(':', 0, 2); @@ -382,6 +382,9 @@ } if (plugin) { + + context = PluginTransform::ExecutionContext(context.channel, plugin); + if (configurationXml != "") { PluginXml(plugin).setParametersFromXml(configurationXml); } @@ -399,7 +402,7 @@ if (sourceChannels < minChannels) targetChannels = minChannels; if (sourceChannels > maxChannels) targetChannels = maxChannels; - int defaultChannel = channel; + int defaultChannel = context.channel; PluginParameterDialog *dialog = new PluginParameterDialog(plugin, sourceChannels, @@ -412,11 +415,14 @@ ok = true; } configurationXml = PluginXml(plugin).toXmlString(); - channel = dialog->getChannel(); + context.channel = dialog->getChannel(); - //!!! where now for step size, block size, etc? -// dialog->getProcessingParameters(stepSize, blockSize, windowType); + dialog->getProcessingParameters(context.stepSize, + context.blockSize, + context.windowType); + context.makeConsistentWithPlugin(plugin); + delete dialog; delete plugin; } @@ -428,25 +434,24 @@ Transform * TransformFactory::createTransform(TransformName name, Model *inputModel, - int channel, QString configurationXml, bool start) + const PluginTransform::ExecutionContext &context, + QString configurationXml, bool start) { Transform *transform = 0; - //!!! use channel - QString id = name.section(':', 0, 2); QString output = name.section(':', 3); if (FeatureExtractionPluginFactory::instanceFor(id)) { transform = new FeatureExtractionPluginTransform(inputModel, id, - channel, + context, configurationXml, output); } else if (RealTimePluginFactory::instanceFor(id)) { transform = new RealTimePluginTransform(inputModel, id, - channel, + context, configurationXml, getTransformUnits(name), output.toInt()); @@ -463,9 +468,10 @@ Model * TransformFactory::transform(TransformName name, Model *inputModel, - int channel, QString configurationXml) + const PluginTransform::ExecutionContext &context, + QString configurationXml) { - Transform *t = createTransform(name, inputModel, channel, + Transform *t = createTransform(name, inputModel, context, configurationXml, false); if (!t) return 0; Modified: sonic-visualiser/trunk/sv/transform/TransformFactory.h =================================================================== --- sonic-visualiser/trunk/sv/transform/TransformFactory.h 2006-09-18 16:43:17 UTC (rev 344) +++ sonic-visualiser/trunk/sv/transform/TransformFactory.h 2006-09-19 14:37:06 UTC (rev 345) @@ -17,6 +17,7 @@ #define _TRANSFORM_FACTORY_H_ #include "Transform.h" +#include "PluginTransform.h" #include <map> @@ -68,7 +69,7 @@ */ bool getConfigurationForTransform(TransformName name, Model *inputModel, - int &channel, + PluginTransform::ExecutionContext &context, QString &configurationXml); /** @@ -85,7 +86,8 @@ * when no longer needed. */ Model *transform(TransformName name, Model *inputModel, - int channel, QString configurationXml = ""); + const PluginTransform::ExecutionContext &context, + QString configurationXml = ""); /** * Full description of a transform, suitable for putting on a menu. @@ -128,7 +130,8 @@ protected: Transform *createTransform(TransformName name, Model *inputModel, - int channel, QString configurationXml, bool start); + const PluginTransform::ExecutionContext &context, + QString configurationXml, bool start); struct TransformIdent { Modified: sonic-visualiser/trunk/widgets/PluginParameterDialog.cpp =================================================================== --- sonic-visualiser/trunk/widgets/PluginParameterDialog.cpp 2006-09-18 16:43:17 UTC (rev 344) +++ sonic-visualiser/trunk/widgets/PluginParameterDialog.cpp 2006-09-19 14:37:06 UTC (rev 345) @@ -65,9 +65,11 @@ font.setBold(true); QLabel *nameLabel = new QLabel(plugin->getDescription().c_str()); + nameLabel->setWordWrap(true); nameLabel->setFont(font); QLabel *makerLabel = new QLabel(plugin->getMaker().c_str()); + makerLabel->setWordWrap(true); QLabel *outputLabel = 0; @@ -85,19 +87,25 @@ for (size_t i = 0; i < od.size(); ++i) { if (od[i].name == output.toStdString()) { outputLabel = new QLabel(od[i].description.c_str()); + outputLabel->setWordWrap(true); break; } } } + } else { + std::cerr << "Plugin " << plugin << " is not a feature extraction plugin" << std::endl;//!!! } } QLabel *versionLabel = new QLabel(QString("%1") .arg(plugin->getPluginVersion())); + versionLabel->setWordWrap(true); QLabel *copyrightLabel = new QLabel(plugin->getCopyright().c_str()); + copyrightLabel->setWordWrap(true); QLabel *typeLabel = new QLabel(plugin->getType().c_str()); + typeLabel->setWordWrap(true); typeLabel->setFont(font); subgrid->addWidget(new QLabel(tr("Name:")), 0, 0); @@ -203,9 +211,18 @@ int increment = 1024; if (fePlugin) { size = fePlugin->getPreferredBlockSize(); + std::cerr << "Feature extraction plugin \"" << fePlugin->getDescription() << "\" reports preferred block size as " << size << std::endl; if (size == 0) size = 1024; increment = fePlugin->getPreferredStepSize(); - if (increment == 0) increment = size; + if (increment == 0) { + if (fePlugin->getInputDomain() == Vamp::Plugin::TimeDomain) { + increment = size; + } else { + increment = size/2; + } + } + } else { + std::cerr << "Plugin " << plugin << " is not a feature extraction plugin" << std::endl;//!!! } QGroupBox *windowBox = new QGroupBox; @@ -235,7 +252,7 @@ if (val == size) blockSizeCombo->setCurrentIndex(i); } blockSizeCombo->setValidator(new QIntValidator(1, pow(2, 18), this)); - connect(blockSizeCombo, SIGNAL(valueChanged(QString)), + connect(blockSizeCombo, SIGNAL(textChanged(QString)), this, SLOT(blockSizeComboChanged(QString))); windowLayout->addWidget(blockSizeCombo, 0, 1); @@ -251,7 +268,7 @@ if (val == increment) incrementCombo->setCurrentIndex(i); } incrementCombo->setValidator(new QIntValidator(1, pow(2, 18), this)); - connect(incrementCombo, SIGNAL(valueChanged(QString)), + connect(incrementCombo, SIGNAL(textChanged(QString)), this, SLOT(incrementComboChanged(QString))); windowLayout->addWidget(incrementCombo, 1, 1); @@ -317,18 +334,22 @@ stepSize = m_stepSize; blockSize = m_blockSize; windowType = m_windowType; + return; } void PluginParameterDialog::blockSizeComboChanged(QString text) { m_blockSize = text.toInt(); + std::cerr << "Block size changed to " << m_blockSize << std::endl; } void PluginParameterDialog::incrementComboChanged(QString text) { m_stepSize = text.toInt(); + //!!! rename increment to step size throughout + std::cerr << "Increment changed to " << m_blockSize << std::endl; } void Modified: sonic-visualiser/trunk/widgets/PluginParameterDialog.h =================================================================== --- sonic-visualiser/trunk/widgets/PluginParameterDialog.h 2006-09-18 16:43:17 UTC (rev 344) +++ sonic-visualiser/trunk/widgets/PluginParameterDialog.h 2006-09-19 14:37:06 UTC (rev 345) @@ -52,6 +52,8 @@ int getChannel() const { return m_channel; } + //!!! merge with PluginTransform::ExecutionContext + void getProcessingParameters(size_t &blockSize) const; void getProcessingParameters(size_t &stepSize, size_t &blockSize, WindowType &windowType) const; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ca...@us...> - 2006-09-18 16:45:43
|
Revision: 344 http://svn.sourceforge.net/sv1/?rev=344&view=rev Author: cannam Date: 2006-09-18 09:43:17 -0700 (Mon, 18 Sep 2006) Log Message: ----------- * Add mono timestretch toggle button; some more work on getting blocksize etc parameters through to plugins Modified Paths: -------------- sonic-visualiser/trunk/data/model/WaveFileModel.cpp sonic-visualiser/trunk/data/model/WaveFileModel.h sonic-visualiser/trunk/plugin/PluginXml.cpp sonic-visualiser/trunk/sv/audioio/AudioCallbackPlaySource.cpp sonic-visualiser/trunk/sv/audioio/AudioCallbackPlaySource.h sonic-visualiser/trunk/sv/audioio/PhaseVocoderTimeStretcher.cpp sonic-visualiser/trunk/sv/audioio/PhaseVocoderTimeStretcher.h sonic-visualiser/trunk/sv/main/MainWindow.cpp sonic-visualiser/trunk/sv/main/MainWindow.h sonic-visualiser/trunk/sv/sonic-visualiser.qrc sonic-visualiser/trunk/sv/transform/FeatureExtractionPluginTransform.cpp sonic-visualiser/trunk/sv/transform/FeatureExtractionPluginTransform.h sonic-visualiser/trunk/sv/transform/RealTimePluginTransform.cpp sonic-visualiser/trunk/sv/transform/RealTimePluginTransform.h sonic-visualiser/trunk/sv/transform/TransformFactory.cpp sonic-visualiser/trunk/sv/transform/TransformFactory.h sonic-visualiser/trunk/sv.prf sonic-visualiser/trunk/view/Pane.cpp sonic-visualiser/trunk/widgets/PluginParameterDialog.cpp sonic-visualiser/trunk/widgets/PluginParameterDialog.h Added Paths: ----------- sonic-visualiser/trunk/sv/icons/mono.png sonic-visualiser/trunk/sv/icons/sharpen.png sonic-visualiser/trunk/sv/icons/stereo.png Modified: sonic-visualiser/trunk/data/model/WaveFileModel.cpp =================================================================== --- sonic-visualiser/trunk/data/model/WaveFileModel.cpp 2006-09-15 16:36:04 UTC (rev 343) +++ sonic-visualiser/trunk/data/model/WaveFileModel.cpp 2006-09-18 16:43:17 UTC (rev 344) @@ -479,6 +479,16 @@ // } } +void +WaveFileModel::toXml(QTextStream &out, + QString indent, + QString extraAttributes) const +{ + Model::toXml(out, indent, + QString("type=\"wavefile\" file=\"%1\" %2") + .arg(m_path).arg(extraAttributes)); +} + QString WaveFileModel::toXmlString(QString indent, QString extraAttributes) const Modified: sonic-visualiser/trunk/data/model/WaveFileModel.h =================================================================== --- sonic-visualiser/trunk/data/model/WaveFileModel.h 2006-09-15 16:36:04 UTC (rev 343) +++ sonic-visualiser/trunk/data/model/WaveFileModel.h 2006-09-18 16:43:17 UTC (rev 344) @@ -62,6 +62,10 @@ virtual Range getRange(size_t channel, size_t start, size_t end) const; + virtual void toXml(QTextStream &out, + QString indent = "", + QString extraAttributes = "") const; + virtual QString toXmlString(QString indent = "", QString extraAttributes = "") const; Modified: sonic-visualiser/trunk/plugin/PluginXml.cpp =================================================================== --- sonic-visualiser/trunk/plugin/PluginXml.cpp 2006-09-15 16:36:04 UTC (rev 343) +++ sonic-visualiser/trunk/plugin/PluginXml.cpp 2006-09-18 16:43:17 UTC (rev 344) @@ -211,7 +211,7 @@ setParameters(attrs); } - + QString PluginXml::stripInvalidParameterNameCharacters(QString s) const { Modified: sonic-visualiser/trunk/sv/audioio/AudioCallbackPlaySource.cpp =================================================================== --- sonic-visualiser/trunk/sv/audioio/AudioCallbackPlaySource.cpp 2006-09-15 16:36:04 UTC (rev 343) +++ sonic-visualiser/trunk/sv/audioio/AudioCallbackPlaySource.cpp 2006-09-18 16:43:17 UTC (rev 344) @@ -588,34 +588,41 @@ } void -AudioCallbackPlaySource::setSlowdownFactor(float factor, bool sharpen) +AudioCallbackPlaySource::setTimeStretch(float factor, bool sharpen, bool mono) { // Avoid locks -- create, assign, mark old one for scavenging // later (as a call to getSourceSamples may still be using it) PhaseVocoderTimeStretcher *existingStretcher = m_timeStretcher; + size_t channels = getTargetChannelCount(); + if (mono) channels = 1; + if (existingStretcher && existingStretcher->getRatio() == factor && - existingStretcher->getSharpening() == sharpen) { + existingStretcher->getSharpening() == sharpen && + existingStretcher->getChannelCount() == channels) { return; } if (factor != 1) { if (existingStretcher && - existingStretcher->getSharpening() == sharpen) { + existingStretcher->getSharpening() == sharpen && + existingStretcher->getChannelCount() == channels) { existingStretcher->setRatio(factor); return; } PhaseVocoderTimeStretcher *newStretcher = new PhaseVocoderTimeStretcher (getTargetSampleRate(), - getTargetChannelCount(), + channels, factor, sharpen, lrintf(getTargetBlockSize() / factor)); + m_timeStretcher = newStretcher; + } else { m_timeStretcher = 0; } @@ -624,7 +631,7 @@ m_timeStretcherScavenger.claim(existingStretcher); } } - + size_t AudioCallbackPlaySource::getSourceSamples(size_t count, float **buffer) { @@ -676,6 +683,9 @@ // std::cout << "ratio = " << ratio << std::endl; + size_t channels = getTargetChannelCount(); + bool mix = (channels > 1 && ts->getChannelCount() == 1); + size_t available; while ((available = ts->getAvailableOutputSamples()) < count) { @@ -684,19 +694,31 @@ reqd = std::max(reqd, ts->getRequiredInputSamples()); if (reqd == 0) reqd = 1; - size_t channels = getTargetChannelCount(); - float *ib[channels]; size_t got = reqd; - for (size_t c = 0; c < channels; ++c) { - ib[c] = new float[reqd]; //!!! fix -- this is a rt function - RingBuffer<float> *rb = getReadRingBuffer(c); - if (rb) { - size_t gotHere = rb->read(ib[c], got); - if (gotHere < got) got = gotHere; + if (mix) { + for (size_t c = 0; c < channels; ++c) { + if (c == 0) ib[c] = new float[reqd]; //!!! fix -- this is a rt function + else ib[c] = 0; + RingBuffer<float> *rb = getReadRingBuffer(c); + if (rb) { + size_t gotHere; + if (c > 0) gotHere = rb->readAdding(ib[0], got); + else gotHere = rb->read(ib[0], got); + if (gotHere < got) got = gotHere; + } } + } else { + for (size_t c = 0; c < channels; ++c) { + ib[c] = new float[reqd]; //!!! fix -- this is a rt function + RingBuffer<float> *rb = getReadRingBuffer(c); + if (rb) { + size_t gotHere = rb->read(ib[c], got); + if (gotHere < got) got = gotHere; + } + } } if (got < reqd) { @@ -720,6 +742,17 @@ ts->getOutput(buffer, count); + if (mix) { + for (size_t c = 1; c < channels; ++c) { + for (size_t i = 0; i < count; ++i) { + buffer[c][i] = buffer[0][i] / channels; + } + } + for (size_t i = 0; i < count; ++i) { + buffer[0][i] /= channels; + } + } + m_condition.wakeAll(); return count; Modified: sonic-visualiser/trunk/sv/audioio/AudioCallbackPlaySource.h =================================================================== --- sonic-visualiser/trunk/sv/audioio/AudioCallbackPlaySource.h 2006-09-15 16:36:04 UTC (rev 343) +++ sonic-visualiser/trunk/sv/audioio/AudioCallbackPlaySource.h 2006-09-18 16:43:17 UTC (rev 344) @@ -177,7 +177,7 @@ */ size_t getSourceSamples(size_t count, float **buffer); - void setSlowdownFactor(float factor, bool sharpen); + void setTimeStretch(float factor, bool sharpen, bool mono); signals: void modelReplaced(); Modified: sonic-visualiser/trunk/sv/audioio/PhaseVocoderTimeStretcher.cpp =================================================================== --- sonic-visualiser/trunk/sv/audioio/PhaseVocoderTimeStretcher.cpp 2006-09-15 16:36:04 UTC (rev 343) +++ sonic-visualiser/trunk/sv/audioio/PhaseVocoderTimeStretcher.cpp 2006-09-18 16:43:17 UTC (rev 344) @@ -39,11 +39,6 @@ { initialise(); - std::cerr << "PhaseVocoderTimeStretcher: channels = " << m_channels - << ", ratio = " << m_ratio - << ", n1 = " << m_n1 << ", n2 = " << m_n2 << ", wlen = " - << m_wlen << ", max = " << maxProcessInputBlockSize - << ", outbuflen = " << m_outbuf[0]->getSize() << std::endl; } PhaseVocoderTimeStretcher::~PhaseVocoderTimeStretcher() @@ -166,6 +161,17 @@ } m_transientThreshold = m_wlen / 4.5; + + m_totalCount = 0; + m_transientCount = 0; + m_n2sum = 0; + + + std::cerr << "PhaseVocoderTimeStretcher: channels = " << m_channels + << ", ratio = " << m_ratio + << ", n1 = " << m_n1 << ", n2 = " << m_n2 << ", wlen = " + << m_wlen << ", max = " << m_maxProcessInputBlockSize << std::endl; +// << ", outbuflen = " << m_outbuf[0]->getSize() << std::endl; } void @@ -516,10 +522,17 @@ bool isTransient = false; - if (count > m_transientThreshold && - count > m_prevTransientScore * 1.2) { +// if (count > m_transientThreshold && +// count > m_prevTransientScore * 1.2) { + if (count > m_prevTransientScore && + count > m_transientThreshold && + count - m_prevTransientScore > m_wlen / 20) { isTransient = true; - std::cerr << "isTransient (count = " << count << ", prev = " << m_prevTransientScore << ")" << std::endl; + + + std::cerr << "isTransient (count = " << count << ", prev = " << m_prevTransientScore << ", diff = " << count - m_prevTransientScore << ", ratio = " << (m_totalCount > 0 ? (float (m_n2sum) / float(m_totalCount * m_n1)) : 1.f) << ", ideal = " << m_ratio << ")" << std::endl; +// } else { +// std::cerr << " !transient (count = " << count << ", prev = " << m_prevTransientScore << ", diff = " << count - m_prevTransientScore << ")" << std::endl; } m_prevTransientScore = count; Modified: sonic-visualiser/trunk/sv/audioio/PhaseVocoderTimeStretcher.h =================================================================== --- sonic-visualiser/trunk/sv/audioio/PhaseVocoderTimeStretcher.h 2006-09-15 16:36:04 UTC (rev 343) +++ sonic-visualiser/trunk/sv/audioio/PhaseVocoderTimeStretcher.h 2006-09-18 16:43:17 UTC (rev 344) @@ -119,6 +119,11 @@ bool getSharpening() const { return m_sharpen; } /** + * Return the number of channels for this time stretcher. + */ + size_t getChannelCount() const { return m_channels; } + + /** * Get the latency added by the time stretcher, in sample frames. * This will be exact if transient sharpening is off, or approximate * if it is on. Added: sonic-visualiser/trunk/sv/icons/mono.png =================================================================== (Binary files differ) Property changes on: sonic-visualiser/trunk/sv/icons/mono.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: sonic-visualiser/trunk/sv/icons/sharpen.png =================================================================== (Binary files differ) Property changes on: sonic-visualiser/trunk/sv/icons/sharpen.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: sonic-visualiser/trunk/sv/icons/stereo.png =================================================================== (Binary files differ) Property changes on: sonic-visualiser/trunk/sv/icons/stereo.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: sonic-visualiser/trunk/sv/main/MainWindow.cpp =================================================================== --- sonic-visualiser/trunk/sv/main/MainWindow.cpp 2006-09-15 16:36:04 UTC (rev 343) +++ sonic-visualiser/trunk/sv/main/MainWindow.cpp 2006-09-18 16:43:17 UTC (rev 344) @@ -166,23 +166,38 @@ connect(m_playSpeed, SIGNAL(valueChanged(int)), this, SLOT(playSpeedChanged(int))); - m_playSharpen = new QCheckBox(frame); + m_playSharpen = new QPushButton(frame); m_playSharpen->setToolTip(tr("Sharpen percussive transients")); + m_playSharpen->setFixedSize(20, 20); +// m_playSharpen->setFlat(true); m_playSharpen->setEnabled(false); + m_playSharpen->setCheckable(true); + m_playSharpen->setChecked(false); + m_playSharpen->setIcon(QIcon(":icons/sharpen.png")); + connect(m_playSharpen, SIGNAL(clicked()), this, SLOT(playSharpenToggled())); + m_playMono = new QPushButton(frame); + m_playMono->setToolTip(tr("Run time stretcher in mono only")); + m_playMono->setFixedSize(20, 20); +// m_playMono->setFlat(true); + m_playMono->setEnabled(false); + m_playMono->setCheckable(true); + m_playMono->setChecked(false); + m_playMono->setIcon(QIcon(":icons/mono.png")); + connect(m_playMono, SIGNAL(clicked()), this, SLOT(playMonoToggled())); + QSettings settings; settings.beginGroup("MainWindow"); m_playSharpen->setChecked(settings.value("playsharpen", true).toBool()); + m_playMono->setChecked(settings.value("playmono", false).toBool()); settings.endGroup(); - connect(m_playSharpen, SIGNAL(clicked()), - this, SLOT(playSharpenToggled())); - - layout->addWidget(m_paneStack, 0, 0, 1, 4); + layout->addWidget(m_paneStack, 0, 0, 1, 5); layout->addWidget(m_panner, 1, 0); layout->addWidget(m_fader, 1, 1); layout->addWidget(m_playSpeed, 1, 2); layout->addWidget(m_playSharpen, 1, 3); + layout->addWidget(m_playMono, 1, 4); layout->setColumnStretch(0, 10); @@ -2870,11 +2885,6 @@ void MainWindow::playSpeedChanged(int speed) { -// static float factors[] = { -// 1.0, 1.1, 1.2, 1.3, 1.5, 1.7, 2.0, 3.0, 4.0, 6.0, 10.0 -// }; -// float factor = factors[speed >= 10 ? speed - 10 : 10 - speed]; - bool slow = false; bool something = false; float factor; @@ -2907,8 +2917,10 @@ .arg(pc)); m_playSharpen->setEnabled(something); + m_playMono->setEnabled(something); bool sharpen = (something && m_playSharpen->isChecked()); - m_playSource->setSlowdownFactor(factor, sharpen); + bool mono = (something && m_playMono->isChecked()); + m_playSource->setTimeStretch(factor, sharpen, mono); } void @@ -2923,6 +2935,17 @@ } void +MainWindow::playMonoToggled() +{ + QSettings settings; + settings.beginGroup("MainWindow"); + settings.setValue("playmono", m_playMono->isChecked()); + settings.endGroup(); + + playSpeedChanged(m_playSpeed->value()); +} + +void MainWindow::outputLevelsChanged(float left, float right) { m_fader->setPeakLeft(left); Modified: sonic-visualiser/trunk/sv/main/MainWindow.h =================================================================== --- sonic-visualiser/trunk/sv/main/MainWindow.h 2006-09-15 16:36:04 UTC (rev 343) +++ sonic-visualiser/trunk/sv/main/MainWindow.h 2006-09-18 16:43:17 UTC (rev 344) @@ -46,6 +46,7 @@ class QLabel; class QCheckBox; class PreferencesDialog; +class QPushButton; class MainWindow : public QMainWindow @@ -141,6 +142,7 @@ void playSelectionToggled(); void playSpeedChanged(int); void playSharpenToggled(); + void playMonoToggled(); void sampleRateMismatch(size_t, size_t, bool); void outputLevelsChanged(float, float); @@ -205,7 +207,8 @@ Panner *m_panner; Fader *m_fader; AudioDial *m_playSpeed; - QCheckBox *m_playSharpen; + QPushButton *m_playSharpen; + QPushButton *m_playMono; WaveformLayer *m_panLayer; Layer *m_timeRulerLayer; Modified: sonic-visualiser/trunk/sv/sonic-visualiser.qrc =================================================================== --- sonic-visualiser/trunk/sv/sonic-visualiser.qrc 2006-09-15 16:36:04 UTC (rev 343) +++ sonic-visualiser/trunk/sv/sonic-visualiser.qrc 2006-09-18 16:43:17 UTC (rev 344) @@ -48,6 +48,9 @@ <file>icons/editcut.png</file> <file>icons/editcopy.png</file> <file>icons/editpaste.png</file> + <file>icons/mono.png</file> + <file>icons/stereo.png</file> + <file>icons/sharpen.png</file> <file>samples/bass.wav</file> <file>samples/beep.wav</file> <file>samples/bounce.wav</file> Modified: sonic-visualiser/trunk/sv/transform/FeatureExtractionPluginTransform.cpp =================================================================== --- sonic-visualiser/trunk/sv/transform/FeatureExtractionPluginTransform.cpp 2006-09-15 16:36:04 UTC (rev 343) +++ sonic-visualiser/trunk/sv/transform/FeatureExtractionPluginTransform.cpp 2006-09-18 16:43:17 UTC (rev 344) @@ -36,12 +36,16 @@ QString pluginId, int channel, QString configurationXml, - QString outputName) : + QString outputName, + size_t stepSize, + size_t blockSize, + WindowType windowType) : Transform(inputModel), m_plugin(0), m_channel(channel), m_stepSize(0), m_blockSize(0), + m_windowType(windowType), m_descriptor(0), m_outputFeatureNo(0) { @@ -68,11 +72,17 @@ PluginXml(m_plugin).setParametersFromXml(configurationXml); } - m_blockSize = m_plugin->getPreferredBlockSize(); - m_stepSize = m_plugin->getPreferredStepSize(); + if (m_blockSize == 0) m_blockSize = m_plugin->getPreferredBlockSize(); + if (m_stepSize == 0) m_stepSize = m_plugin->getPreferredStepSize(); - if (m_blockSize == 0) m_blockSize = 1024; //!!! todo: ask user - if (m_stepSize == 0) m_stepSize = m_blockSize; //!!! likewise + if (m_blockSize == 0) m_blockSize = 1024; + if (m_stepSize == 0) { + if (m_plugin->getInputDomain() == Vamp::Plugin::FrequencyDomain) { + m_stepSize = m_blockSize / 2; + } else { + m_stepSize = m_blockSize; + } + } DenseTimeValueModel *input = getInput(); if (!input) return; @@ -250,7 +260,7 @@ fftModels.push_back(new FFTModel (getInput(), channelCount == 1 ? m_channel : ch, - HanningWindow, + m_windowType, m_blockSize, m_stepSize, m_blockSize, Modified: sonic-visualiser/trunk/sv/transform/FeatureExtractionPluginTransform.h =================================================================== --- sonic-visualiser/trunk/sv/transform/FeatureExtractionPluginTransform.h 2006-09-15 16:36:04 UTC (rev 343) +++ sonic-visualiser/trunk/sv/transform/FeatureExtractionPluginTransform.h 2006-09-18 16:43:17 UTC (rev 344) @@ -18,6 +18,8 @@ #include "Transform.h" +#include "base/Window.h" + #include "vamp-sdk/Plugin.h" class DenseTimeValueModel; @@ -29,7 +31,10 @@ QString plugin, int channel, QString configurationXml = "", - QString outputName = ""); + QString outputName = "", + size_t stepSize = 0, + size_t blockSize = 0, + WindowType windowType = HanningWindow); virtual ~FeatureExtractionPluginTransform(); protected: @@ -39,6 +44,7 @@ int m_channel; size_t m_stepSize; size_t m_blockSize; + WindowType m_windowType; Vamp::Plugin::OutputDescriptor *m_descriptor; int m_outputFeatureNo; Modified: sonic-visualiser/trunk/sv/transform/RealTimePluginTransform.cpp =================================================================== --- sonic-visualiser/trunk/sv/transform/RealTimePluginTransform.cpp 2006-09-15 16:36:04 UTC (rev 343) +++ sonic-visualiser/trunk/sv/transform/RealTimePluginTransform.cpp 2006-09-18 16:43:17 UTC (rev 344) @@ -31,12 +31,16 @@ int channel, QString configurationXml, QString units, - int output) : + int output, + size_t blockSize) : Transform(inputModel), m_plugin(0), m_channel(channel), - m_outputNo(output) + m_outputNo(output), + m_blockSize(blockSize) { + if (!m_blockSize) m_blockSize = 1024; + std::cerr << "RealTimePluginTransform::RealTimePluginTransform: plugin " << pluginId.toStdString() << ", output " << output << std::endl; RealTimePluginFactory *factory = @@ -52,7 +56,7 @@ if (!input) return; m_plugin = factory->instantiatePlugin(pluginId, 0, 0, m_input->getSampleRate(), - 1024, //!!! wants to be configurable + m_blockSize, input->getChannelCount()); if (!m_plugin) { @@ -71,8 +75,7 @@ } SparseTimeValueModel *model = new SparseTimeValueModel - (input->getSampleRate(), 1024, //!!! - 0.0, 0.0, false); + (input->getSampleRate(), m_blockSize, 0.0, 0.0, false); if (units != "") model->setScaleUnits(units); Modified: sonic-visualiser/trunk/sv/transform/RealTimePluginTransform.h =================================================================== --- sonic-visualiser/trunk/sv/transform/RealTimePluginTransform.h 2006-09-15 16:36:04 UTC (rev 343) +++ sonic-visualiser/trunk/sv/transform/RealTimePluginTransform.h 2006-09-18 16:43:17 UTC (rev 344) @@ -29,7 +29,8 @@ int channel, QString configurationXml = "", QString units = "", - int output = 0); + int output = 0, + size_t blockSize = 0); virtual ~RealTimePluginTransform(); protected: @@ -38,6 +39,7 @@ RealTimePluginInstance *m_plugin; int m_channel; int m_outputNo; + size_t m_blockSize; // just casts DenseTimeValueModel *getInput(); Modified: sonic-visualiser/trunk/sv/transform/TransformFactory.cpp =================================================================== --- sonic-visualiser/trunk/sv/transform/TransformFactory.cpp 2006-09-15 16:36:04 UTC (rev 343) +++ sonic-visualiser/trunk/sv/transform/TransformFactory.cpp 2006-09-18 16:43:17 UTC (rev 344) @@ -413,6 +413,10 @@ } configurationXml = PluginXml(plugin).toXmlString(); channel = dialog->getChannel(); + + //!!! where now for step size, block size, etc? +// dialog->getProcessingParameters(stepSize, blockSize, windowType); + delete dialog; delete plugin; } Modified: sonic-visualiser/trunk/sv/transform/TransformFactory.h =================================================================== --- sonic-visualiser/trunk/sv/transform/TransformFactory.h 2006-09-15 16:36:04 UTC (rev 343) +++ sonic-visualiser/trunk/sv/transform/TransformFactory.h 2006-09-18 16:43:17 UTC (rev 344) @@ -66,7 +66,8 @@ * asking the user, most likely). Returns true if the transform * is acceptable, false if the operation should be cancelled. */ - bool getConfigurationForTransform(TransformName name, Model *inputModel, + bool getConfigurationForTransform(TransformName name, + Model *inputModel, int &channel, QString &configurationXml); Modified: sonic-visualiser/trunk/sv.prf =================================================================== --- sonic-visualiser/trunk/sv.prf 2006-09-15 16:36:04 UTC (rev 343) +++ sonic-visualiser/trunk/sv.prf 2006-09-18 16:43:17 UTC (rev 344) @@ -3,7 +3,7 @@ ### BEGIN CONFIGURABLE STUFF ### -CONFIG += releas +CONFIG += release # Whizzy optimization flags here # Modified: sonic-visualiser/trunk/view/Pane.cpp =================================================================== --- sonic-visualiser/trunk/view/Pane.cpp 2006-09-15 16:36:04 UTC (rev 343) +++ sonic-visualiser/trunk/view/Pane.cpp 2006-09-18 16:43:17 UTC (rev 344) @@ -980,6 +980,23 @@ //!!! this should have its own function + //!!! want to do some cleverness to avoid dragging left/right + // at the same time as up/down when the user moves the mouse + // diagonally. + // e.g. have horizontal and vertical thresholds and a series + // of states: unknown, constrained, free + // + // -> when the mouse first moves we're in unknown state: + // what then? the thing we really want to avoid is moving + // a tiny amount in the wrong direction, because usually + // the problem is that to move at all is expensive -- so what + // do we do? + // + // -> when it's moved more than say 10px in h or v + // direction we lock into h or v constrained mode. If it + // moves more than say 20px in the other direction + // subsequently, then we switch into free mode. + Layer *layer = 0; if (getLayerCount() > 0) layer = getLayer(getLayerCount() - 1); Modified: sonic-visualiser/trunk/widgets/PluginParameterDialog.cpp =================================================================== --- sonic-visualiser/trunk/widgets/PluginParameterDialog.cpp 2006-09-15 16:36:04 UTC (rev 343) +++ sonic-visualiser/trunk/widgets/PluginParameterDialog.cpp 2006-09-18 16:43:17 UTC (rev 344) @@ -41,6 +41,9 @@ QDialog(parent), m_plugin(plugin), m_channel(defaultChannel), + m_stepSize(0), + m_blockSize(0), + m_windowType(HanningWindow), m_parameterBox(0) { setWindowTitle(tr("Plugin Parameters")); @@ -221,6 +224,9 @@ std::cerr << "size: " << size << ", increment: " << increment << std::endl; + //!!! deal with block and step sizes (coming from the plugin's + // preferences) that don't fit into the default list + QComboBox *blockSizeCombo = new QComboBox; blockSizeCombo->setEditable(true); for (int i = 0; i < 14; ++i) { @@ -229,6 +235,8 @@ if (val == size) blockSizeCombo->setCurrentIndex(i); } blockSizeCombo->setValidator(new QIntValidator(1, pow(2, 18), this)); + connect(blockSizeCombo, SIGNAL(valueChanged(QString)), + this, SLOT(blockSizeComboChanged(QString))); windowLayout->addWidget(blockSizeCombo, 0, 1); if (showFrequencyDomainOptions) { @@ -243,17 +251,18 @@ if (val == increment) incrementCombo->setCurrentIndex(i); } incrementCombo->setValidator(new QIntValidator(1, pow(2, 18), this)); + connect(incrementCombo, SIGNAL(valueChanged(QString)), + this, SLOT(incrementComboChanged(QString))); windowLayout->addWidget(incrementCombo, 1, 1); windowLayout->addWidget(new QLabel(tr("Window shape:")), 2, 0); WindowTypeSelector *windowTypeSelector = new WindowTypeSelector; + connect(windowTypeSelector, SIGNAL(windowTypeChanged(WindowType type)), + this, SLOT(windowTypeChanged(type))); windowLayout->addWidget(windowTypeSelector, 2, 1); } } - //!!! We lack a comfortable way of passing around the channel and - //blocksize data - QHBoxLayout *hbox = new QHBoxLayout; grid->addLayout(hbox, 4, 0); @@ -294,6 +303,41 @@ } void +PluginParameterDialog::getProcessingParameters(size_t &blockSize) const +{ + blockSize = m_blockSize; + return; +} + +void +PluginParameterDialog::getProcessingParameters(size_t &stepSize, + size_t &blockSize, + WindowType &windowType) const +{ + stepSize = m_stepSize; + blockSize = m_blockSize; + windowType = m_windowType; +} + +void +PluginParameterDialog::blockSizeComboChanged(QString text) +{ + m_blockSize = text.toInt(); +} + +void +PluginParameterDialog::incrementComboChanged(QString text) +{ + m_stepSize = text.toInt(); +} + +void +PluginParameterDialog::windowTypeChanged(WindowType type) +{ + m_windowType = type; +} + +void PluginParameterDialog::advancedToggled() { bool visible = !m_advanced->isVisible(); Modified: sonic-visualiser/trunk/widgets/PluginParameterDialog.h =================================================================== --- sonic-visualiser/trunk/widgets/PluginParameterDialog.h 2006-09-15 16:36:04 UTC (rev 343) +++ sonic-visualiser/trunk/widgets/PluginParameterDialog.h 2006-09-18 16:43:17 UTC (rev 344) @@ -18,6 +18,8 @@ #include <QDialog> +#include "base/Window.h" + namespace Vamp { class PluginBase; } class PluginParameterBox; class QWidget; @@ -50,16 +52,26 @@ int getChannel() const { return m_channel; } + void getProcessingParameters(size_t &blockSize) const; + void getProcessingParameters(size_t &stepSize, size_t &blockSize, + WindowType &windowType) const; + signals: void pluginConfigurationChanged(QString); protected slots: void channelComboChanged(int); + void blockSizeComboChanged(QString); + void incrementComboChanged(QString); + void windowTypeChanged(WindowType type); void advancedToggled(); protected: Vamp::PluginBase *m_plugin; int m_channel; + size_t m_stepSize; + size_t m_blockSize; + WindowType m_windowType; PluginParameterBox *m_parameterBox; QPushButton *m_advancedButton; QWidget *m_advanced; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |