Revision: 1521b9f68ca2
Author: Devin Anderson <
surface...@gmail.com>
Date: Mon Feb 18 21:45:49 2013
Log: Add auto-detection of sample rate, and make plugins aware of that
capability. Fix issues with regards to reinstantiating LV2 plugins when
sample rate is changed. Make sure signals are emitted when sample rate or
sample channel count is changed.
http://code.google.com/p/synthclone/source/detail?r=1521b9f68ca2
Modified:
/src/include/synthclone/types.h
/src/plugins/jack/participant.cpp
/src/plugins/jack/sampleratechangeview.ui
/src/plugins/lv2/effect.cpp
/src/plugins/lv2/effectview.cpp
/src/plugins/lv2/effectview.h
/src/plugins/lv2/participant.cpp
/src/plugins/lv2/participant.h
/src/plugins/lv2/types.h
/src/plugins/portmedia/participant.cpp
/src/plugins/portmedia/participant.h
/src/plugins/portmedia/sampler.cpp
/src/synthclone/session.cpp
/src/synthclone/sessionloadview.cpp
/src/synthclone/sessionloadview.h
/src/synthclone/sessionloadview.ui
/src/synthclone/sessionsampledata.cpp
/src/synthclone/zone.cpp
/src/synthclone/zone.h
=======================================
--- /src/include/synthclone/types.h Tue Sep 27 17:29:06 2011
+++ /src/include/synthclone/types.h Mon Feb 18 21:45:49 2013
@@ -1,6 +1,6 @@
/*
* libsynthclone - a plugin API for `synthclone`
- * Copyright (C) 2011 Devin Anderson
+ * Copyright (C) 2011-2013 Devin Anderson
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
by the
@@ -95,6 +95,14 @@
typedef quint32 SampleRate;
+ /**
+ * A value indicating the sample rate is not set. This is generally
only
+ * valid for a session that doesn't have any samples, and doesn't have
a
+ * sampler component.
+ */
+
+ const SampleRate SAMPLE_RATE_NOT_SET = 0;
+
/**
* The minimum valid sample rate. I don't see 1 as being a practical
* sample rate, but I don't see a reason why I shouldn't let it happen
if
=======================================
--- /src/plugins/jack/participant.cpp Sun Aug 26 22:59:01 2012
+++ /src/plugins/jack/participant.cpp Mon Feb 18 21:45:49 2013
@@ -1,7 +1,7 @@
/*
* libsynthclone_jack - JACK Audio Connection Kit sampler plugin for
* `synthclone`
- * Copyright (C) 2011 Devin Anderson
+ * Copyright (C) 2011-2013 Devin Anderson
*
* 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
@@ -88,14 +88,11 @@
QScopedPointer<Sampler> samplerPtr(sampler);
synthclone::SampleRate serverSampleRate = sampler->getSampleRate();
synthclone::SampleRate sessionSampleRate =
context->getSampleRate();
- if (serverSampleRate != sessionSampleRate) {
- if (convertSampleRate) {
- context->setSampleRate(serverSampleRate);
- goto activateSampler;
- }
+ if (! ((serverSampleRate == sessionSampleRate) ||
+ (sessionSampleRate == synthclone::SAMPLE_RATE_NOT_SET) ||
+ convertSampleRate)) {
sampleRateChangeView.setVisible(true);
} else {
- activateSampler:
connect(sampler, SIGNAL(fatalError(QString)),
SLOT(handleFatalError(QString)));
connect(sampler, SIGNAL(sampleRateChanged()),
@@ -106,6 +103,7 @@
SLOT(handleSessionEvent(jack_client_t *,
jack_session_event_t *)));
sampler->activate(context->getSampleChannelCount());
+ context->setSampleRate(serverSampleRate);
const synthclone::Registration ®istration =
context->addSampler(sampler);
connect(®istration, SIGNAL(unregistered(QObject *)),
=======================================
--- /src/plugins/jack/sampleratechangeview.ui Sat Oct 8 14:25:18 2011
+++ /src/plugins/jack/sampleratechangeview.ui Mon Feb 18 21:45:49 2013
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>450</width>
- <height>160</height>
+ <width>502</width>
+ <height>167</height>
</rect>
</property>
<property name="windowTitle">
=======================================
--- /src/plugins/lv2/effect.cpp Wed Nov 21 11:33:19 2012
+++ /src/plugins/lv2/effect.cpp Mon Feb 18 21:45:49 2013
@@ -1,6 +1,6 @@
/*
* libsynthclone_lv2 - LV2 effect plugin for `synthclone`
- * Copyright (C) 2012 Devin Anderson
+ * Copyright (C) 2012-2013 Devin Anderson
*
* 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
@@ -24,6 +24,7 @@
#include <QtCore/QDebug>
#include "effect.h"
+#include "types.h"
// Static functions
@@ -101,7 +102,12 @@
void
Effect::addInstance()
{
- LV2Instance *instance =
plugin.instantiate(static_cast<double>(sampleRate));
+ synthclone::SampleRate instanceSampleRate = sampleRate;
+ if (instanceSampleRate == synthclone::SAMPLE_RATE_NOT_SET) {
+ instanceSampleRate = FALLBACK_SAMPLE_RATE;
+ }
+ LV2Instance *instance =
+ plugin.instantiate(static_cast<double>(instanceSampleRate));
int instanceCount = instances.count();
if (instanceCount) {
LV2State *state = instances[0]->getState();
@@ -607,19 +613,99 @@
void
Effect::setSampleRate(synthclone::SampleRate sampleRate)
{
- assert(sampleRate);
+
+ qDebug() << "Effect::setSampleRate";
+
+ assert((sampleRate == synthclone::SAMPLE_RATE_NOT_SET) ||
+ ((sampleRate >= synthclone::SAMPLE_RATE_MINIMUM) &&
+ (sampleRate <= synthclone::SAMPLE_RATE_MAXIMUM)));
if (sampleRate != this->sampleRate) {
+ synthclone::SampleRate instanceSampleRate = sampleRate;
+ if (instanceSampleRate == synthclone::SAMPLE_RATE_NOT_SET) {
+
+ qDebug() << "fallback sample rate";
+
+ instanceSampleRate = FALLBACK_SAMPLE_RATE;
+ }
+ int audioInputPortCount = plugin.getAudioInputPortCount();
+ int audioOutputPortCount = plugin.getAudioOutputPortCount();
LV2State *state = instances[0]->getState();
QScopedPointer<LV2State> statePtr(state);
for (int i = instances.count() - 1; i >= 0; i--) {
- delete instances[i];
- LV2Instance *instance =
- plugin.instantiate(static_cast<double>(sampleRate));
+
+ qDebug() << "Disconnecting ports for " << i << "...";
+
+ // Disconnect ports from old instance
+ LV2Instance *instance = instances[i];
+
+ instance->activate();
+ instance->deactivate();
+
+ int j;
+ int portIndex;
+ for (j = audioInputPortCount - 1; j >= 0; j--) {
+ portIndex = (i * audioInputPortCount) + j;
+
instance->connectPort(plugin.getAudioInputPort(j).getIndex(),
+ 0);
+ }
+ for (j = audioOutputPortCount - 1; j >= 0; j--) {
+ portIndex = (i * audioOutputPortCount) + j;
+
instance->connectPort(plugin.getAudioOutputPort(j).getIndex(),
+ 0);
+ }
+ for (j = plugin.getControlInputPortCount() - 1; j >= 0; j--) {
+
instance->connectPort(plugin.getControlInputPort(j).getIndex(),
+ 0);
+ }
+ for (j = plugin.getControlOutputPortCount() - 1; j >= 0; j--) {
+
instance->connectPort(plugin.getControlOutputPort(j).getIndex(),
+ 0);
+ }
+
+ qDebug() << "Deleting old instance ...";
+
+ // Delete the old instance
+ delete instance;
+
+ qDebug() << "Creating new instance ...";
+
+ // Create the new instance
+ instance =
+
plugin.instantiate(static_cast<double>(instanceSampleRate));
instance->setState(state);
+
+ qDebug() << "Connecting ports ...";
+
+ // Connect ports to new instance
+ for (j = audioInputPortCount - 1; j >= 0; j--) {
+ portIndex = (i * audioInputPortCount) + j;
+
instance->connectPort(plugin.getAudioInputPort(j).getIndex(),
+ audioInputPortBuffers[portIndex]);
+ }
+ for (j = audioOutputPortCount - 1; j >= 0; j--) {
+ portIndex = (i * audioOutputPortCount) + j;
+
instance->connectPort(plugin.getAudioOutputPort(j).getIndex(),
+ audioOutputPortBuffers[portIndex]);
+ }
+ for (j = plugin.getControlInputPortCount() - 1; j >= 0; j--) {
+
instance->connectPort(plugin.getControlInputPort(j).getIndex(),
+ controlInputPortValues + j);
+ }
+ for (j = plugin.getControlOutputPortCount() - 1; j >= 0; j--) {
+
instance->connectPort(plugin.getControlOutputPort(j).getIndex(),
+ controlOutputPortValues + j);
+ }
+
+ qDebug() << "Assigning instance to " << i << "...";
+
instances[i] = instance;
}
+ this->sampleRate = sampleRate;
emit sampleRateChanged(sampleRate);
}
+
+ qDebug() << "/Effect::setSampleRate";
+
}
void
=======================================
--- /src/plugins/lv2/effectview.cpp Thu Nov 22 14:02:38 2012
+++ /src/plugins/lv2/effectview.cpp Mon Feb 18 21:45:49 2013
@@ -1,6 +1,6 @@
/*
* libsynthclone_lv2 - LV2 effect plugin for `synthclone`
- * Copyright (C) 2012 Devin Anderson
+ * Copyright (C) 2012-2013 Devin Anderson
*
* 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
@@ -34,7 +34,6 @@
#include <synthclone/util.h>
#include "effectview.h"
-#include "types.h"
// Static functions
=======================================
--- /src/plugins/lv2/effectview.h Thu Nov 22 14:02:38 2012
+++ /src/plugins/lv2/effectview.h Mon Feb 18 21:45:49 2013
@@ -1,6 +1,6 @@
/*
* libsynthclone_lv2 - LV2 effect plugin for `synthclone`
- * Copyright (C) 2012 Devin Anderson
+ * Copyright (C) 2012-2013 Devin Anderson
*
* 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
@@ -35,7 +35,6 @@
#include <suil/suil.h>
#include <synthclone/designerview.h>
-#include <synthclone/types.h>
#include "channelmapdelegate.h"
#include "effectviewdata.h"
=======================================
--- /src/plugins/lv2/participant.cpp Thu Dec 20 21:07:04 2012
+++ /src/plugins/lv2/participant.cpp Mon Feb 18 21:45:49 2013
@@ -1,6 +1,6 @@
/*
* libsynthclone_lv2 - LV2 effect plugin for `synthclone`
- * Copyright (C) 2012 Devin Anderson
+ * Copyright (C) 2012-2013 Devin Anderson
*
* 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
@@ -302,6 +302,9 @@
//
http://drobilla.net/software/jalv/
if (port.isSampleRatePort()) {
synthclone::SampleRate sampleRate = context->getSampleRate();
+ if (sampleRate == synthclone::SAMPLE_RATE_NOT_SET) {
+ sampleRate = FALLBACK_SAMPLE_RATE;
+ }
maximumValue *= sampleRate;
minimumValue *= sampleRate;
}
=======================================
--- /src/plugins/lv2/participant.h Mon Nov 19 09:20:33 2012
+++ /src/plugins/lv2/participant.h Mon Feb 18 21:45:49 2013
@@ -1,6 +1,6 @@
/*
* libsynthclone_lv2 - LV2 effect plugin for `synthclone`
- * Copyright (C) 2012 Devin Anderson
+ * Copyright (C) 2012-2013 Devin Anderson
*
* 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
=======================================
--- /src/plugins/lv2/types.h Mon Nov 19 08:43:38 2012
+++ /src/plugins/lv2/types.h Mon Feb 18 21:45:49 2013
@@ -1,6 +1,6 @@
/*
* libsynthclone_lv2 - LV2 effect plugin for `synthclone`
- * Copyright (C) 2012 Devin Anderson
+ * Copyright (C) 2012-2013 Devin Anderson
*
* 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
@@ -20,6 +20,13 @@
#ifndef __TYPES_H__
#define __TYPES_H__
+#include <synthclone/types.h>
+
+// There are times when the sample rate will not be set for synthclone,
but we
+// will need a sample rate to instantiate and configure LV2 effects. As a
hack,
+// we use this value.
+const synthclone::SampleRate FALLBACK_SAMPLE_RATE = 48000;
+
enum ChannelMapTableColumn {
CHANNELMAPTABLECOLUMN_INPUT_CHANNEL = 0,
CHANNELMAPTABLECOLUMN_OUTPUT_CHANNEL = 1,
=======================================
--- /src/plugins/portmedia/participant.cpp Sun Oct 7 22:12:09 2012
+++ /src/plugins/portmedia/participant.cpp Mon Feb 18 21:45:49 2013
@@ -1,6 +1,6 @@
/*
* libsynthclone_portmedia - PortAudio/PortMIDI sampler plugin for
`synthclone`
- * Copyright (C) 2012 Devin Anderson
+ * Copyright (C) 2012-2013 Devin Anderson
*
* 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
@@ -169,12 +169,14 @@
connect(sampler, SIGNAL(midiError(const QString &)),
SLOT(handleMIDIError(const QString &)));
+ connect(sampler, SIGNAL(sampleRateChanged(synthclone::SampleRate)),
+ &context, SLOT(setSampleRate(synthclone::SampleRate)));
connect(&context,
SIGNAL(sampleChannelCountChanged(synthclone::SampleChannelCount)),
SLOT(handleChannelCountChange(synthclone::SampleChannelCount)));
connect(&context, SIGNAL(sampleRateChanged(synthclone::SampleRate)),
- SLOT(handleSampleRateChange(synthclone::SampleRate)));
+ SLOT(handleSessionSampleRateChange(synthclone::SampleRate)));
this->context = &context;
}
@@ -205,7 +207,8 @@
this,
SLOT(handleChannelCountChange(synthclone::SampleChannelCount)));
disconnect(&context, SIGNAL(sampleRateChanged(synthclone::SampleRate)),
- this, SLOT(handleSampleRateChange(synthclone::SampleRate)));
+ this,
+
SLOT(handleSessionSampleRateChange(synthclone::SampleRate)));
context.removeMenuAction(&addSamplerAction);
@@ -294,18 +297,6 @@
context->reportError(tr("The PortMedia sampler was removed due to a
MIDI "
"error: %1").arg(message));
}
-
-void
-Participant::handleSampleRateChange(synthclone::SampleRate sampleRate)
-{
- if (sampler->isActive()) {
- context->removeSampler();
- context->reportError(tr("The PortMedia sampler was removed
because "
- "the session's sample rate has been "
- "changed."));
- }
- sampler->setSampleRate(sampleRate);
-}
void
Participant::handleSamplerUnregistration(QObject *obj)
@@ -319,6 +310,18 @@
{
samplerView.setVisible(false);
}
+
+void
+Participant::handleSessionSampleRateChange(synthclone::SampleRate
sampleRate)
+{
+ if (sampler->isActive()) {
+ context->removeSampler();
+ context->reportError(tr("The PortMedia sampler was removed
because "
+ "the session's sample rate has been "
+ "changed."));
+ }
+ sampler->setSampleRate(sampleRate);
+}
void
Participant::restoreSampler(const QVariant &state)
=======================================
--- /src/plugins/portmedia/participant.h Sun Mar 11 22:19:01 2012
+++ /src/plugins/portmedia/participant.h Mon Feb 18 21:45:49 2013
@@ -1,6 +1,6 @@
/*
* libsynthclone_portmedia - PortAudio/PortMIDI sampler plugin for
`synthclone`
- * Copyright (C) 2012 Devin Anderson
+ * Copyright (C) 2012-2013 Devin Anderson
*
* 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
@@ -65,15 +65,15 @@
void
handleMIDIError(const QString &message);
- void
- handleSampleRateChange(synthclone::SampleRate sampleRate);
-
void
handleSamplerUnregistration(QObject *obj);
void
handleSamplerViewCloseRequest();
+ void
+ handleSessionSampleRateChange(synthclone::SampleRate sampleRate);
+
private:
bool
=======================================
--- /src/plugins/portmedia/sampler.cpp Thu Dec 20 22:23:46 2012
+++ /src/plugins/portmedia/sampler.cpp Mon Feb 18 21:45:49 2013
@@ -1,6 +1,6 @@
/*
* libsynthclone_portmedia - PortAudio/PortMIDI sampler plugin for
`synthclone`
- * Copyright (C) 2012 Devin Anderson
+ * Copyright (C) 2012-2013 Devin Anderson
*
* 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
@@ -58,8 +58,9 @@
midiThread(this)
{
assert(channels >= synthclone::SAMPLE_CHANNEL_COUNT_MINIMUM);
- assert((sampleRate >= synthclone::SAMPLE_RATE_MINIMUM) &&
- (sampleRate <= synthclone::SAMPLE_RATE_MAXIMUM));
+ assert((sampleRate == synthclone::SAMPLE_RATE_NOT_SET) ||
+ ((sampleRate >= synthclone::SAMPLE_RATE_MINIMUM) &&
+ (sampleRate <= synthclone::SAMPLE_RATE_MAXIMUM)));
PaError paError = Pa_Initialize();
if (paError != paNoError) {
throw synthclone::Error(Pa_GetErrorText(paError));
@@ -272,6 +273,14 @@
inputParameters.hostApiSpecificStreamInfo = 0;
inputParameters.sampleFormat = paFloat32;
inputParameters.suggestedLatency = info->defaultHighInputLatency;
+
+ // If the sample rate isn't set, then take the sample rate from the
+ // given default sample rate for the input device.
+ synthclone::SampleRate streamSampleRate = sampleRate;
+ if (sampleRate == synthclone::SAMPLE_RATE_NOT_SET) {
+ streamSampleRate = static_cast<synthclone::SampleRate>
+ (info->defaultSampleRate);
+ }
PaStreamParameters outputParameters;
const AudioDeviceData &outputData = getAudioOutputDeviceData();
@@ -284,7 +293,7 @@
outputParameters.suggestedLatency = info->defaultHighOutputLatency;
PaError paError = Pa_OpenStream(&audioStream, &inputParameters,
- &outputParameters, sampleRate,
+ &outputParameters,
streamSampleRate,
paFramesPerBufferUnspecified,
paNoFlag,
handleProcessEvent, this);
if (paError != paNoError) {
@@ -299,6 +308,11 @@
throw synthclone::Error(tr("failed to start audio
stream: %1").
arg(Pa_GetErrorText(paError)));
}
+
+ if (streamSampleRate != sampleRate) {
+ sampleRate = streamSampleRate;
+ emit sampleRateChanged(sampleRate);
+ }
eventThread.start();
midiThread.start();
=======================================
--- /src/synthclone/session.cpp Thu Dec 20 22:19:11 2012
+++ /src/synthclone/session.cpp Mon Feb 18 21:45:49 2013
@@ -1,6 +1,6 @@
/*
* synthclone - Synthesizer-cloning software
- * Copyright (C) 2011-2012 Devin Anderson
+ * Copyright (C) 2011-2013 Devin Anderson
*
* 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
@@ -42,7 +42,10 @@
synthclone::SampleChannelCount count)
{
CONFIRM(count > 0, tr("'%1': invalid sample channel
count").arg(count));
- CONFIRM(sampleRate > 0, tr("'%1': invalid sample
rate").arg(sampleRate));
+ CONFIRM((sampleRate == synthclone::SAMPLE_RATE_NOT_SET) ||
+ ((sampleRate >= synthclone::SAMPLE_RATE_MINIMUM) &&
+ (sampleRate <= synthclone::SAMPLE_RATE_MAXIMUM)),
+ tr("'%1': invalid sample rate").arg(sampleRate));
initializeDirectory(directory);
QFile file;
@@ -176,6 +179,13 @@
const QByteArray &)),
SLOT(setModified()));
+ connect(&sessionSampleData,
+
SIGNAL(sampleChannelCountChanged(synthclone::SampleChannelCount)),
+
SIGNAL(sampleChannelCountChanged(synthclone::SampleChannelCount)));
+ connect(&sessionSampleData,
+ SIGNAL(sampleRateChanged(synthclone::SampleRate)),
+ SIGNAL(sampleRateChanged(synthclone::SampleRate)));
+
for (int i = 0; i < 0x80; i++) {
controlPropertiesVisible[i] = false;
}
@@ -989,9 +999,12 @@
static_cast<synthclone::SampleChannelCount>(uValue) : 2;
sessionSampleData.setSampleChannelCount(sampleChannelCount);
+ // This code assumes knowledge of the value of the constant
+ // 'SAMPLE_RATE_NOT_SET'.
synthclone::SampleRate sampleRate =
- verifyWholeNumberAttribute(documentElement, "sample-rate", uValue,
1) ?
- static_cast<synthclone::SampleRate>(uValue) : 44100;
+ verifyWholeNumberAttribute(documentElement, "sample-rate", uValue,
0) ?
+ static_cast<synthclone::SampleRate>(uValue) :
+ synthclone::SAMPLE_RATE_NOT_SET;
sessionSampleData.setSampleRate(sampleRate);
// Property visibility flags
=======================================
--- /src/synthclone/sessionloadview.cpp Mon Oct 10 10:36:28 2011
+++ /src/synthclone/sessionloadview.cpp Mon Feb 18 21:45:49 2013
@@ -1,6 +1,6 @@
/*
* synthclone - Synthesizer-cloning software
- * Copyright (C) 2011 Devin Anderson
+ * Copyright (C) 2011-2013 Devin Anderson
*
* 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
@@ -48,6 +48,7 @@
sampleRateValidator->setRange
(1.0, static_cast<double>(synthclone::SAMPLE_RATE_MAXIMUM), 0);
sampleRate->setValidator(sampleRateValidator);
+ autoDetectSampleRateText = sampleRate->itemText(0);
sessionCreationDirectory =
synthclone::getChild<QLineEdit>(dialog, "sessionCreationDirectory");
@@ -139,11 +140,16 @@
bool success;
switch (tabWidget->currentIndex()) {
case 0:
- sampleRate = static_cast<synthclone::SampleRate>
- (this->sampleRate->currentText().toULong(&success));
- if (! (success && sampleRate)) {
- emit error(tr("The supplied sample rate is not valid."));
- return;
+ if ((! this->sampleRate->currentIndex()) &&
+ (this->sampleRate->currentText() == autoDetectSampleRateText))
{
+ sampleRate = synthclone::SAMPLE_RATE_NOT_SET;
+ } else {
+ sampleRate = static_cast<synthclone::SampleRate>
+ (this->sampleRate->currentText().toULong(&success));
+ if (! (success && sampleRate)) {
+ emit error(tr("The supplied sample rate is not valid."));
+ return;
+ }
}
sampleChannelCount = static_cast<synthclone::SampleChannelCount>
(this->sampleChannelCount->value());
=======================================
--- /src/synthclone/sessionloadview.h Mon Oct 10 10:36:28 2011
+++ /src/synthclone/sessionloadview.h Mon Feb 18 21:45:49 2013
@@ -1,6 +1,6 @@
/*
* synthclone - Synthesizer-cloning software
- * Copyright (C) 2011 Devin Anderson
+ * Copyright (C) 2011-2013 Devin Anderson
*
* 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
@@ -142,6 +142,7 @@
QString
getResource(Status status);
+ QString autoDetectSampleRateText;
QPushButton *openButton;
QPushButton *quitButton;
QListWidget *recentSessions;
=======================================
--- /src/synthclone/sessionloadview.ui Sat Oct 8 14:25:18 2011
+++ /src/synthclone/sessionloadview.ui Mon Feb 18 21:45:49 2013
@@ -90,9 +90,14 @@
<bool>true</bool>
</property>
<property name="currentIndex">
- <number>5</number>
+ <number>0</number>
</property>
<item>
+ <property name="text">
+ <string>auto-detect</string>
+ </property>
+ </item>
+ <item>
<property name="text">
<string>8000</string>
</property>
=======================================
--- /src/synthclone/sessionsampledata.cpp Sat Aug 25 21:58:34 2012
+++ /src/synthclone/sessionsampledata.cpp Mon Feb 18 21:45:49 2013
@@ -1,6 +1,6 @@
/*
* synthclone - Synthesizer-cloning software
- * Copyright (C) 2011-2012 Devin Anderson
+ * Copyright (C) 2011-2013 Devin Anderson
*
* 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
@@ -30,7 +30,7 @@
{
sampleChannelCount = 2;
sampleDirectory = 0;
- sampleRate = 44100;
+ sampleRate = synthclone::SAMPLE_RATE_NOT_SET;
}
SessionSampleData::~SessionSampleData()
@@ -89,6 +89,11 @@
void
SessionSampleData::setSampleRate(synthclone::SampleRate sampleRate)
{
+ CONFIRM((sampleRate == synthclone::SAMPLE_RATE_NOT_SET) ||
+ ((sampleRate >= synthclone::SAMPLE_RATE_MINIMUM) &&
+ (sampleRate <= synthclone::SAMPLE_RATE_MAXIMUM)),
+ tr("'%1': invalid sample rate").arg(sampleRate));
+
if (this->sampleRate != sampleRate) {
this->sampleRate = sampleRate;
emit sampleRateChanged(sampleRate);
=======================================
--- /src/synthclone/zone.cpp Sun Oct 9 12:02:52 2011
+++ /src/synthclone/zone.cpp Mon Feb 18 21:45:49 2013
@@ -1,6 +1,6 @@
/*
* synthclone - Synthesizer-cloning software
- * Copyright (C) 2011 Devin Anderson
+ * Copyright (C) 2011-2013 Devin Anderson
*
* 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
@@ -254,6 +254,7 @@
}
this->drySample = sample;
if (sample) {
+ updateSampleRate(*sample);
sample->setTemporary(false);
}
emit drySampleChanged(sample);
@@ -352,6 +353,7 @@
}
this->wetSample = sample;
if (sample) {
+ updateSampleRate(*sample);
sample->setTemporary(false);
}
emit wetSampleChanged(sample);
@@ -383,3 +385,12 @@
emit wetSampleStaleChanged(stale);
}
}
+
+void
+Zone::updateSampleRate(const synthclone::Sample &sample)
+{
+ if (sessionSampleData.getSampleRate() ==
synthclone::SAMPLE_RATE_NOT_SET) {
+ synthclone::SampleInputStream inputStream(sample);
+ sessionSampleData.setSampleRate(inputStream.getSampleRate());
+ }
+}
=======================================
--- /src/synthclone/zone.h Thu Sep 22 09:40:08 2011
+++ /src/synthclone/zone.h Mon Feb 18 21:45:49 2013
@@ -1,6 +1,6 @@
/*
* synthclone - Synthesizer-cloning software
- * Copyright (C) 2011 Devin Anderson
+ * Copyright (C) 2011-2013 Devin Anderson
*
* 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
@@ -133,6 +133,9 @@
private:
+ void
+ updateSampleRate(const synthclone::Sample &sample);
+
synthclone::MIDIData aftertouch;
synthclone::MIDIData channel;
synthclone::MIDIData channelPressure;