[synthclone] push by surfacep...@gmail.com - Add new fader plugin to synthclone for adding fade-ins and fade-outs t... on 2013-02-20 06:24 GMT

1 view
Skip to first unread message

synth...@googlecode.com

unread,
Feb 20, 2013, 1:24:56 AM2/20/13
to synthclone-...@googlegroups.com
Revision: 117266a35c41
Author: Devin Anderson <surface...@gmail.com>
Date: Tue Feb 19 22:24:29 2013
Log: Add new fader plugin to synthclone for adding fade-ins and
fade-outs to samples.

http://code.google.com/p/synthclone/source/detail?r=117266a35c41

Added:
/src/plugins/fader/effect.cpp
/src/plugins/fader/effect.h
/src/plugins/fader/effectview.cpp
/src/plugins/fader/effectview.h
/src/plugins/fader/effectview.ui
/src/plugins/fader/fader.pro
/src/plugins/fader/fader.qrc
/src/plugins/fader/participant.cpp
/src/plugins/fader/participant.h
/src/plugins/fader/plugin.cpp
/src/plugins/fader/plugin.h
Modified:
/configure
/src/plugins/plugins.pro

=======================================
--- /dev/null
+++ /src/plugins/fader/effect.cpp Tue Feb 19 22:24:29 2013
@@ -0,0 +1,264 @@
+/*
+ * libsynthclone_fader - Fader effect plugin for `synthclone`
+ * Copyright (C) 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
+ * Software Foundation; either version 2 of the License, or (at your
option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
with
+ * this program; if not, write to the Free Software Foundation, Inc., 675
Mass
+ * Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <cassert>
+#include <cmath>
+
+#include <QtCore/QDebug>
+
+#include <QtCore/QScopedArrayPointer>
+
+#include <synthclone/samplecopier.h>
+
+#include "effect.h"
+
+Effect::Effect(const QString &name, QObject *parent):
+ synthclone::Effect(name, parent)
+{
+ fadeInEnabled = true;
+ fadeInStartVolume = -64.0;
+ fadeInTime = 0.01;
+ fadeOutEnabled = true;
+ fadeOutEndVolume = -64.0;
+ fadeOutTime = 0.01;
+}
+
+Effect::~Effect()
+{
+ // Empty
+}
+
+float
+Effect::getAmplitude(float dBFS) const
+{
+ assert(dBFS <= 0.0);
+ return std::pow(10, dBFS / 20.0);
+}
+
+float
+Effect::getFadeInStartVolume() const
+{
+ return fadeInStartVolume;
+}
+
+float
+Effect::getFadeInTime() const
+{
+ return fadeInTime;
+}
+
+float
+Effect::getFadeOutEndVolume() const
+{
+ return fadeOutEndVolume;
+}
+
+float
+Effect::getFadeOutTime() const
+{
+ return fadeOutTime;
+}
+
+void
+Effect::handleCopyProgress(synthclone::SampleFrameCount current,
+ synthclone::SampleFrameCount /*total*/)
+{
+ emit progressChanged(static_cast<float>(copyStartFrame + current) /
+ static_cast<float>(copyTotalFrames));
+}
+
+
+bool
+Effect::isFadeInEnabled() const
+{
+ return fadeInEnabled;
+}
+
+bool
+Effect::isFadeOutEnabled() const
+{
+ return fadeOutEnabled;
+}
+
+void
+Effect::process(const synthclone::Zone &/*zone*/,
+ synthclone::SampleInputStream &inputStream,
+ synthclone::SampleOutputStream &outputStream)
+{
+ synthclone::SampleFrameCount frames = inputStream.getFrames();
+ float sampleRate = static_cast<float>(inputStream.getSampleRate());
+ synthclone::SampleFrameCount fadeInFrames = fadeInEnabled ?
+ static_cast<synthclone::SampleFrameCount>(fadeInTime *
sampleRate) : 0;
+ synthclone::SampleFrameCount fadeOutFrames = fadeOutEnabled ?
+ static_cast<synthclone::SampleFrameCount>(fadeOutTime *
sampleRate) : 0;
+ synthclone::SampleFrameCount totalFadeFrames = fadeInFrames +
fadeOutFrames;
+
+ qDebug() << "\tfade in frames:" << fadeInFrames;
+ qDebug() << "\t fade out frames:" << fadeOutFrames;
+
+ // If the amount of frames spent fading is greater than the number of
total
+ // frames, then shorten the fades proportionally. If anyone has a
better
+ // suggestion, I'm all ears.
+ if (totalFadeFrames > frames) {
+
+ qDebug() << "adjusting fade frames";
+
+ fadeInFrames = static_cast<synthclone::SampleFrameCount>
+ (static_cast<float>(fadeInFrames) *
+ (static_cast<float>(frames) /
+ static_cast<float>(totalFadeFrames)));
+ fadeOutFrames = frames - fadeInFrames;
+
+ qDebug() << "\tfade in frames:" << fadeInFrames;
+ qDebug() << "\t fade out frames:" << fadeOutFrames;
+
+ }
+
+ synthclone::SampleChannelCount channels = inputStream.getChannels();
+ QScopedArrayPointer<float> audioDataPtr(new float[channels]);
+ float *audioData = audioDataPtr.data();
+ synthclone::SampleFrameCount currentFrame = 0;
+ synthclone::SampleFrameCount framesRead;
+ float volume;
+ if (fadeInFrames) {
+
+ qDebug() << "\tapplying fade in ...";
+
+ emit statusChanged(tr("Creating fade-in of sample ..."));
+ for (; currentFrame < fadeInFrames; currentFrame++) {
+ framesRead = inputStream.read(audioData, 1);
+ assert(framesRead == 1);
+ volume = getAmplitude(fadeInStartVolume *
+ (1.0 - (static_cast<float>(currentFrame
+ 1) /
+
static_cast<float>(fadeInFrames))));
+ for (int i = 0; i < channels; i++) {
+ audioData[i] *= volume;
+ }
+ outputStream.write(audioData, 1);
+ emit progressChanged(static_cast<float>(currentFrame + 1) /
+ static_cast<float>(frames));
+ }
+ }
+ synthclone::SampleFrameCount fadeOutStartFrame = frames -
fadeOutFrames;
+ synthclone::SampleFrameCount copyFrames = fadeOutStartFrame -
currentFrame;
+
+ qDebug() << "\tcopy frames:" << copyFrames;
+ qDebug() << "\tfade out start frame:" << fadeOutStartFrame;
+
+ if (copyFrames) {
+
+ qDebug() << "copying frames ...";
+
+ emit statusChanged(tr("Writing sample ..."));
+ copyStartFrame = currentFrame;
+ copyTotalFrames = frames;
+ synthclone::SampleCopier copier;
+ connect(&copier,
+ SIGNAL(copyProgress(synthclone::SampleFrameCount,
+ synthclone::SampleFrameCount)),
+ SLOT(handleCopyProgress(synthclone::SampleFrameCount,
+ synthclone::SampleFrameCount)),
+ Qt::DirectConnection);
+ copier.copy(inputStream, outputStream, copyFrames);
+ }
+ currentFrame += copyFrames;
+ if (fadeOutFrames) {
+
+ qDebug() << "\tapplying fade out ...";
+
+ emit statusChanged(tr("Creating fade-out of sample ..."));
+ for (; currentFrame < frames; currentFrame++) {
+ framesRead = inputStream.read(audioData, 1);
+ assert(framesRead == 1);
+ volume = getAmplitude(fadeOutEndVolume *
+ (static_cast<float>(currentFrame + 1 -
+ fadeOutStartFrame) /
+ static_cast<float>(fadeOutFrames)));
+ for (int i = 0; i < channels; i++) {
+ audioData[i] *= volume;
+ }
+ outputStream.write(audioData, 1);
+ emit progressChanged(static_cast<float>(currentFrame + 1) /
+ static_cast<float>(frames));
+ }
+ }
+ emit progressChanged(0.0);
+ emit statusChanged("");
+
+ qDebug() << "/Effect::process";
+
+}
+
+void
+Effect::setFadeInEnabled(bool enabled)
+{
+ if (enabled != fadeInEnabled) {
+ fadeInEnabled = enabled;
+ emit fadeInEnabledChanged(enabled);
+ }
+}
+
+void
+Effect::setFadeInStartVolume(float volume)
+{
+ assert(volume <= 0.0);
+ if (volume != fadeInStartVolume) {
+ fadeInStartVolume = volume;
+ emit fadeInStartVolumeChanged(volume);
+ }
+}
+
+void
+Effect::setFadeInTime(float time)
+{
+ assert(time > 0.0);
+ if (time != fadeInTime) {
+ fadeInTime = time;
+ emit fadeInTimeChanged(time);
+ }
+}
+
+void
+Effect::setFadeOutEnabled(bool enabled)
+{
+ if (enabled != fadeOutEnabled) {
+ fadeOutEnabled = enabled;
+ emit fadeOutEnabledChanged(enabled);
+ }
+}
+
+void
+Effect::setFadeOutEndVolume(float volume)
+{
+ assert(volume <= 0.0);
+ if (volume != fadeOutEndVolume) {
+ fadeOutEndVolume = volume;
+ emit fadeOutEndVolumeChanged(volume);
+ }
+}
+
+void
+Effect::setFadeOutTime(float time)
+{
+ assert(time > 0.0);
+ if (time != fadeOutTime) {
+ fadeOutTime = time;
+ emit fadeOutTimeChanged(time);
+ }
+}
=======================================
--- /dev/null
+++ /src/plugins/fader/effect.h Tue Feb 19 22:24:29 2013
@@ -0,0 +1,121 @@
+/*
+ * libsynthclone_fader - Fader effect plugin for `synthclone`
+ * Copyright (C) 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
+ * Software Foundation; either version 2 of the License, or (at your
option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
with
+ * this program; if not, write to the Free Software Foundation, Inc., 675
Mass
+ * Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __EFFECT_H__
+#define __EFFECT_H__
+
+#include <synthclone/effect.h>
+
+class Effect: public synthclone::Effect {
+
+ Q_OBJECT
+
+public:
+
+ explicit
+ Effect(const QString &name, QObject *parent=0);
+
+ ~Effect();
+
+ float
+ getFadeInStartVolume() const;
+
+ float
+ getFadeInTime() const;
+
+ float
+ getFadeOutEndVolume() const;
+
+ float
+ getFadeOutTime() const;
+
+ bool
+ isFadeInEnabled() const;
+
+ bool
+ isFadeOutEnabled() const;
+
+ void
+ process(const synthclone::Zone &zone,
+ synthclone::SampleInputStream &inputStream,
+ synthclone::SampleOutputStream &outputStream);
+
+public slots:
+
+ void
+ setFadeInEnabled(bool enabled);
+
+ void
+ setFadeInStartVolume(float volume);
+
+ void
+ setFadeInTime(float time);
+
+ void
+ setFadeOutEnabled(bool enabled);
+
+ void
+ setFadeOutEndVolume(float volume);
+
+ void
+ setFadeOutTime(float time);
+
+signals:
+
+ void
+ fadeInEnabledChanged(bool enabled);
+
+ void
+ fadeInStartVolumeChanged(float volume);
+
+ void
+ fadeInTimeChanged(float time);
+
+ void
+ fadeOutEnabledChanged(bool enabled);
+
+ void
+ fadeOutEndVolumeChanged(float volume);
+
+ void
+ fadeOutTimeChanged(float time);
+
+private slots:
+
+ void
+ handleCopyProgress(synthclone::SampleFrameCount current,
+ synthclone::SampleFrameCount total);
+
+private:
+
+ float
+ getAmplitude(float dBFS) const;
+
+ synthclone::SampleFrameCount copyStartFrame;
+ synthclone::SampleFrameCount copyTotalFrames;
+ bool fadeInEnabled;
+ float fadeInStartVolume;
+ float fadeInTime;
+ bool fadeOutEnabled;
+ float fadeOutEndVolume;
+ float fadeOutTime;
+
+};
+
+#endif
=======================================
--- /dev/null
+++ /src/plugins/fader/effectview.cpp Tue Feb 19 22:24:29 2013
@@ -0,0 +1,133 @@
+/*
+ * libsynthclone_fader - Fader effect plugin for `synthclone`
+ * Copyright (C) 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
+ * Software Foundation; either version 2 of the License, or (at your
option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
with
+ * this program; if not, write to the Free Software Foundation, Inc., 675
Mass
+ * Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <synthclone/util.h>
+
+#include "effectview.h"
+
+EffectView::EffectView(QObject *parent):
+ synthclone::DesignerView(":/synthclone/plugins/fader/effectview.ui",
parent)
+{
+ QWidget *widget = getRootWidget();
+
+ closeButton = synthclone::getChild<QPushButton>(widget, "closeButton");
+ connect(closeButton, SIGNAL(clicked()), SIGNAL(closeRequest()));
+
+ fadeInGroupBox =
synthclone::getChild<QGroupBox>(widget, "fadeInGroupBox");
+ connect(fadeInGroupBox, SIGNAL(clicked(bool)),
+ SIGNAL(fadeInEnabledChanged(bool)));
+
+ fadeInStartVolume =
+ synthclone::getChild<QDoubleSpinBox>(widget, "fadeInStartVolume");
+ connect(fadeInStartVolume, SIGNAL(valueChanged(double)),
+ SLOT(handleFadeInStartVolumeChangedSignal(double)));
+
+ fadeInTime =
synthclone::getChild<QDoubleSpinBox>(widget, "fadeInTime");
+ connect(fadeInTime, SIGNAL(valueChanged(double)),
+ SLOT(handleFadeInTimeChangedSignal(double)));
+
+ fadeOutEndVolume =
+ synthclone::getChild<QDoubleSpinBox>(widget, "fadeOutEndVolume");
+ connect(fadeOutEndVolume, SIGNAL(valueChanged(double)),
+ SLOT(handleFadeOutEndVolumeChangedSignal(double)));
+
+ fadeOutGroupBox =
+ synthclone::getChild<QGroupBox>(widget, "fadeOutGroupBox");
+ connect(fadeOutGroupBox, SIGNAL(clicked(bool)),
+ SIGNAL(fadeOutEnabledChanged(bool)));
+
+ fadeOutTime =
synthclone::getChild<QDoubleSpinBox>(widget, "fadeOutTime");
+ connect(fadeOutTime, SIGNAL(valueChanged(double)),
+ SLOT(handleFadeOutTimeChangedSignal(double)));
+
+ name = synthclone::getChild<QLineEdit>(widget, "name");
+ connect(name, SIGNAL(textEdited(const QString &)),
+ SIGNAL(nameChanged(const QString &)));
+}
+
+EffectView::~EffectView()
+{
+ // Empty
+}
+
+void
+EffectView::handleFadeInStartVolumeChangedSignal(double volume)
+{
+ emit fadeInStartVolumeChanged(static_cast<float>(volume));
+}
+
+void
+EffectView::handleFadeInTimeChangedSignal(double time)
+{
+ emit fadeInTimeChanged(static_cast<float>(time));
+}
+
+void
+EffectView::handleFadeOutEndVolumeChangedSignal(double volume)
+{
+ emit fadeOutEndVolumeChanged(static_cast<float>(volume));
+}
+
+void
+EffectView::handleFadeOutTimeChangedSignal(double time)
+{
+ emit fadeOutTimeChanged(static_cast<float>(time));
+}
+
+void
+EffectView::setFadeInEnabled(bool enabled)
+{
+ fadeInGroupBox->setChecked(enabled);
+}
+
+void
+EffectView::setFadeInStartVolume(float volume)
+{
+ fadeInStartVolume->setValue(volume);
+}
+
+void
+EffectView::setFadeInTime(float time)
+{
+ fadeInTime->setValue(time);
+}
+
+void
+EffectView::setFadeOutEnabled(bool enabled)
+{
+ fadeOutGroupBox->setChecked(enabled);
+}
+
+void
+EffectView::setFadeOutEndVolume(float volume)
+{
+ fadeOutEndVolume->setValue(volume);
+}
+
+void
+EffectView::setFadeOutTime(float time)
+{
+ fadeOutTime->setValue(time);
+}
+
+void
+EffectView::setName(const QString &name)
+{
+ this->name->setText(name);
+}
=======================================
--- /dev/null
+++ /src/plugins/fader/effectview.h Tue Feb 19 22:24:29 2013
@@ -0,0 +1,114 @@
+/*
+ * libsynthclone_fader - Fader effect plugin for `synthclone`
+ * Copyright (C) 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
+ * Software Foundation; either version 2 of the License, or (at your
option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
with
+ * this program; if not, write to the Free Software Foundation, Inc., 675
Mass
+ * Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __EFFECTVIEW_H__
+#define __EFFECTVIEW_H__
+
+#include <QtGui/QDoubleSpinBox>
+#include <QtGui/QGroupBox>
+#include <QtGui/QLineEdit>
+#include <QtGui/QPushButton>
+
+#include <synthclone/designerview.h>
+
+class EffectView: public synthclone::DesignerView {
+
+ Q_OBJECT
+
+public:
+
+ explicit
+ EffectView(QObject *parent=0);
+
+ ~EffectView();
+
+public slots:
+
+ void
+ setFadeInEnabled(bool enabled);
+
+ void
+ setFadeInStartVolume(float volume);
+
+ void
+ setFadeInTime(float time);
+
+ void
+ setFadeOutEnabled(bool enabled);
+
+ void
+ setFadeOutEndVolume(float volume);
+
+ void
+ setFadeOutTime(float time);
+
+ void
+ setName(const QString &name);
+
+signals:
+
+ void
+ fadeInEnabledChanged(bool enabled);
+
+ void
+ fadeInStartVolumeChanged(float volume);
+
+ void
+ fadeInTimeChanged(float time);
+
+ void
+ fadeOutEnabledChanged(bool enabled);
+
+ void
+ fadeOutEndVolumeChanged(float volume);
+
+ void
+ fadeOutTimeChanged(float time);
+
+ void
+ nameChanged(const QString &name);
+
+private slots:
+
+ void
+ handleFadeInStartVolumeChangedSignal(double volume);
+
+ void
+ handleFadeInTimeChangedSignal(double time);
+
+ void
+ handleFadeOutEndVolumeChangedSignal(double volume);
+
+ void
+ handleFadeOutTimeChangedSignal(double time);
+
+private:
+
+ QPushButton *closeButton;
+ QGroupBox *fadeInGroupBox;
+ QDoubleSpinBox *fadeInStartVolume;
+ QDoubleSpinBox *fadeInTime;
+ QDoubleSpinBox *fadeOutEndVolume;
+ QGroupBox *fadeOutGroupBox;
+ QDoubleSpinBox *fadeOutTime;
+ QLineEdit *name;
+
+};
+
+#endif
=======================================
--- /dev/null
+++ /src/plugins/fader/effectview.ui Tue Feb 19 22:24:29 2013
@@ -0,0 +1,199 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>dialog</class>
+ <widget class="QDialog" name="dialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>258</width>
+ <height>266</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Fader Configuration</string>
+ </property>
+ <layout class="QVBoxLayout" stretch="0,1,0,0">
+ <item>
+ <layout class="QHBoxLayout" stretch="0,1">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Effect Name:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="name"/>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="fadeInGroupBox">
+ <property name="title">
+ <string>Fade In</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <layout class="QFormLayout">
+ <property name="fieldGrowthPolicy">
+ <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Start Volume</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QDoubleSpinBox" name="fadeInStartVolume">
+ <property name="suffix">
+ <string> dBFS</string>
+ </property>
+ <property name="minimum">
+ <double>-128.000000000000000</double>
+ </property>
+ <property name="maximum">
+ <double>0.000000000000000</double>
+ </property>
+ <property name="singleStep">
+ <double>0.100000000000000</double>
+ </property>
+ <property name="value">
+ <double>-64.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Fade Time</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QDoubleSpinBox" name="fadeInTime">
+ <property name="suffix">
+ <string> seconds</string>
+ </property>
+ <property name="decimals">
+ <number>3</number>
+ </property>
+ <property name="minimum">
+ <double>0.001000000000000</double>
+ </property>
+ <property name="maximum">
+ <double>60.000000000000000</double>
+ </property>
+ <property name="value">
+ <double>0.010000000000000</double>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="fadeOutGroupBox">
+ <property name="title">
+ <string>Fade Out</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <layout class="QFormLayout">
+ <property name="fieldGrowthPolicy">
+ <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>End Volume</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QDoubleSpinBox" name="fadeOutEndVolume">
+ <property name="suffix">
+ <string> dBFS</string>
+ </property>
+ <property name="minimum">
+ <double>-128.000000000000000</double>
+ </property>
+ <property name="maximum">
+ <double>0.000000000000000</double>
+ </property>
+ <property name="singleStep">
+ <double>0.100000000000000</double>
+ </property>
+ <property name="value">
+ <double>-64.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Fade Time</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QDoubleSpinBox" name="fadeOutTime">
+ <property name="suffix">
+ <string> seconds</string>
+ </property>
+ <property name="decimals">
+ <number>3</number>
+ </property>
+ <property name="minimum">
+ <double>0.001000000000000</double>
+ </property>
+ <property name="maximum">
+ <double>60.000000000000000</double>
+ </property>
+ <property name="value">
+ <double>0.010000000000000</double>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <spacer>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="closeButton">
+ <property name="text">
+ <string>Close</string>
+ </property>
+ <property name="icon">
+ <iconset resource="../../lib/lib.qrc">
+
<normaloff>:/synthclone/images/16x16/close.png</normaloff>:/synthclone/images/16x16/close.png</iconset>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources>
+ <include location="../../lib/lib.qrc"/>
+ </resources>
+ <connections/>
+</ui>
=======================================
--- /dev/null
+++ /src/plugins/fader/fader.pro Tue Feb 19 22:24:29 2013
@@ -0,0 +1,19 @@
+include(../plugins.pri)
+
+################################################################################
+# Build
+################################################################################
+
+HEADERS += effect.h \
+ effectview.h \
+ participant.h \
+ plugin.h
+MOC_DIR = $${MAKEDIR}/plugins/fader
+OBJECTS_DIR = $${MAKEDIR}/plugins/fader
+RCC_DIR = $${MAKEDIR}/plugins/fader
+RESOURCES += fader.qrc
+SOURCES += effect.cpp \
+ effectview.cpp \
+ participant.cpp \
+ plugin.cpp
+TARGET = $$qtLibraryTarget(synthclone_fader)
=======================================
--- /dev/null
+++ /src/plugins/fader/fader.qrc Tue Feb 19 22:24:29 2013
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/synthclone/plugins/fader">
+ <file>effectview.ui</file>
+ </qresource>
+</RCC>
=======================================
--- /dev/null
+++ /src/plugins/fader/participant.cpp Tue Feb 19 22:24:29 2013
@@ -0,0 +1,227 @@
+/*
+ * libsynthclone_fader - Fader effect plugin for `synthclone`
+ * Copyright (C) 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
+ * Software Foundation; either version 2 of the License, or (at your
option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
with
+ * this program; if not, write to the Free Software Foundation, Inc., 675
Mass
+ * Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <cassert>
+
+#include "participant.h"
+
+Participant::Participant(QObject *parent):
+ synthclone::Participant(tr("Fader"), 0, 0, 1, "Devin Anderson",
+ tr("Adds a fade-in/fade-out effect to
samples"),
+ parent),
+ addEffectAction(tr("Fader"))
+{
+ connect(&addEffectAction, SIGNAL(triggered()),
+ SLOT(handleEffectAddition()));
+ connect(&effectView, SIGNAL(closeRequest()),
+ SLOT(handleEffectViewCloseRequest()));
+ configuredEffect = 0;
+ context = 0;
+}
+
+Participant::~Participant()
+{
+ // Empty
+}
+
+void
+Participant::activate(synthclone::Context &context, const QVariant
&/*state*/)
+{
+ context.addMenuAction(&addEffectAction, synthclone::MENU_ADD_EFFECT);
+ configuredEffect = 0;
+ this->context = &context;
+}
+
+Effect *
+Participant::addEffect()
+{
+ Effect *effect = new Effect(tr("Fader"), this);
+ connect(effect, SIGNAL(fadeInEnabledChanged(bool)),
+ context, SLOT(setSessionModified()));
+ connect(effect, SIGNAL(fadeInStartVolumeChanged(float)),
+ context, SLOT(setSessionModified()));
+ connect(effect, SIGNAL(fadeInTimeChanged(float)),
+ context, SLOT(setSessionModified()));
+ connect(effect, SIGNAL(fadeOutEnabledChanged(bool)),
+ context, SLOT(setSessionModified()));
+ connect(effect, SIGNAL(fadeOutEndVolumeChanged(float)),
+ context, SLOT(setSessionModified()));
+ connect(effect, SIGNAL(fadeOutTimeChanged(float)),
+ context, SLOT(setSessionModified()));
+ connect(effect, SIGNAL(nameChanged(const QString &)),
+ context, SLOT(setSessionModified()));
+
+ synthclone::MenuAction *action =
+ new synthclone::MenuAction(tr("Configure"), effect);
+ connect(action, SIGNAL(triggered()),
SLOT(handleEffectConfiguration()));
+
+ const synthclone::Registration &effectRegistration =
+ context->addEffect(effect);
+ connect(&effectRegistration, SIGNAL(unregistered(QObject *)),
+ SLOT(handleUnregistration(QObject *)));
+
+ const synthclone::Registration &actionRegistration =
+ context->addMenuAction(action, effect);
+ connect(&actionRegistration, SIGNAL(unregistered(QObject *)),
+ SLOT(handleUnregistration(QObject *)));
+
+ return effect;
+}
+
+void
+Participant::configureEffect(Effect *effect)
+{
+ connect(effect, SIGNAL(fadeInEnabledChanged(bool)),
+ &effectView, SLOT(setFadeInEnabled(bool)));
+ connect(effect, SIGNAL(fadeInStartVolumeChanged(float)),
+ &effectView, SLOT(setFadeInStartVolume(float)));
+ connect(effect, SIGNAL(fadeInTimeChanged(float)),
+ &effectView, SLOT(setFadeInTime(float)));
+ connect(effect, SIGNAL(fadeOutEnabledChanged(bool)),
+ &effectView, SLOT(setFadeOutEnabled(bool)));
+ connect(effect, SIGNAL(fadeOutEndVolumeChanged(float)),
+ &effectView, SLOT(setFadeOutEndVolume(float)));
+ connect(effect, SIGNAL(fadeOutTimeChanged(float)),
+ &effectView, SLOT(setFadeOutTime(float)));
+ connect(effect, SIGNAL(nameChanged(const QString &)),
+ &effectView, SLOT(setName(const QString &)));
+
+ connect(&effectView, SIGNAL(fadeInEnabledChanged(bool)),
+ effect, SLOT(setFadeInEnabled(bool)));
+ connect(&effectView, SIGNAL(fadeInStartVolumeChanged(float)),
+ effect, SLOT(setFadeInStartVolume(float)));
+ connect(&effectView, SIGNAL(fadeInTimeChanged(float)),
+ effect, SLOT(setFadeInTime(float)));
+ connect(&effectView, SIGNAL(fadeOutEnabledChanged(bool)),
+ effect, SLOT(setFadeOutEnabled(bool)));
+ connect(&effectView, SIGNAL(fadeOutEndVolumeChanged(float)),
+ effect, SLOT(setFadeOutEndVolume(float)));
+ connect(&effectView, SIGNAL(fadeOutTimeChanged(float)),
+ effect, SLOT(setFadeOutTime(float)));
+ connect(&effectView, SIGNAL(nameChanged(const QString &)),
+ effect, SLOT(setName(const QString &)));
+
+ effectView.setFadeInEnabled(effect->isFadeInEnabled());
+ effectView.setFadeInStartVolume(effect->getFadeInStartVolume());
+ effectView.setFadeInTime(effect->getFadeInTime());
+ effectView.setFadeOutEnabled(effect->isFadeOutEnabled());
+ effectView.setFadeOutEndVolume(effect->getFadeOutEndVolume());
+ effectView.setFadeOutTime(effect->getFadeOutTime());
+ effectView.setName(effect->getName());
+
+ configuredEffect = effect;
+
+ effectView.setVisible(true);
+}
+
+void
+Participant::deactivate(synthclone::Context &context)
+{
+ context.removeMenuAction(&addEffectAction);
+ this->context = 0;
+}
+
+QVariant
+Participant::getState(const synthclone::Effect *effect) const
+{
+ const Effect *fader = qobject_cast<const Effect *>(effect);
+ assert(fader);
+ QVariantMap map;
+ map["fadeInEnabled"] = fader->isFadeInEnabled();
+ map["fadeInStartVolume"] = fader->getFadeInStartVolume();
+ map["fadeInTime"] = fader->getFadeInTime();
+ map["fadeOutEnabled"] = fader->isFadeOutEnabled();
+ map["fadeOutEndVolume"] = fader->getFadeOutEndVolume();
+ map["fadeOutTime"] = fader->getFadeOutTime();
+ map["name"] = fader->getName();
+ return map;
+}
+
+void
+Participant::handleEffectAddition()
+{
+ configureEffect(addEffect());
+}
+
+void
+Participant::handleEffectConfiguration()
+{
+ synthclone::MenuAction *action =
+ qobject_cast<synthclone::MenuAction *>(sender());
+ configureEffect(qobject_cast<Effect *>(action->parent()));
+}
+
+void
+Participant::handleEffectViewCloseRequest()
+{
+ effectView.setVisible(false);
+
+ disconnect(configuredEffect, SIGNAL(fadeInEnabledChanged(bool)),
+ &effectView, SLOT(setFadeInEnabled(bool)));
+ disconnect(configuredEffect, SIGNAL(fadeInStartVolumeChanged(float)),
+ &effectView, SLOT(setFadeInStartVolume(float)));
+ disconnect(configuredEffect, SIGNAL(fadeInTimeChanged(float)),
+ &effectView, SLOT(setFadeInTime(float)));
+ disconnect(configuredEffect, SIGNAL(fadeOutEnabledChanged(bool)),
+ &effectView, SLOT(setFadeOutEnabled(bool)));
+ disconnect(configuredEffect, SIGNAL(fadeOutEndVolumeChanged(float)),
+ &effectView, SLOT(setFadeOutEndVolume(float)));
+ disconnect(configuredEffect, SIGNAL(fadeOutTimeChanged(float)),
+ &effectView, SLOT(setFadeOutTime(float)));
+ disconnect(configuredEffect, SIGNAL(nameChanged(const QString &)),
+ &effectView, SLOT(setName(const QString &)));
+
+ disconnect(&effectView, SIGNAL(fadeInEnabledChanged(bool)),
+ configuredEffect, SLOT(setFadeInEnabled(bool)));
+ disconnect(&effectView, SIGNAL(fadeInStartVolumeChanged(float)),
+ configuredEffect, SLOT(setFadeInStartVolume(float)));
+ disconnect(&effectView, SIGNAL(fadeInTimeChanged(float)),
+ configuredEffect, SLOT(setFadeInTime(float)));
+ disconnect(&effectView, SIGNAL(fadeOutEnabledChanged(bool)),
+ configuredEffect, SLOT(setFadeOutEnabled(bool)));
+ disconnect(&effectView, SIGNAL(fadeOutEndVolumeChanged(float)),
+ configuredEffect, SLOT(setFadeOutEndVolume(float)));
+ disconnect(&effectView, SIGNAL(fadeOutTimeChanged(float)),
+ configuredEffect, SLOT(setFadeOutTime(float)));
+ disconnect(&effectView, SIGNAL(nameChanged(const QString &)),
+ configuredEffect, SLOT(setName(const QString &)));
+
+ configuredEffect = 0;
+}
+
+void
+Participant::handleUnregistration(QObject *obj)
+{
+ delete obj;
+}
+
+void
+Participant::restoreEffect(const QVariant &state)
+{
+ Effect *effect = addEffect();
+ const QVariantMap map = state.toMap();
+ effect->setFadeInEnabled(map.value("fadeInEnabled", true).toBool());
+ effect->setFadeInStartVolume
+ (map.value("fadeInStartVolume", -64).toFloat());
+ effect->setFadeInTime(map.value("fadeInTime", 0.01).toFloat());
+ effect->setFadeOutEnabled(map.value("fadeOutEnabled", true).toBool());
+ effect->setFadeOutEndVolume(map.value("fadeOutEndVolume",
-64).toFloat());
+ effect->setFadeOutTime(map.value("fadeOutTime", 0.01).toFloat());
+ effect->setName(map.value("name", tr("Fader")).toString());
+}
=======================================
--- /dev/null
+++ /src/plugins/fader/participant.h Tue Feb 19 22:24:29 2013
@@ -0,0 +1,80 @@
+/*
+ * libsynthclone_fader - Fader effect plugin for `synthclone`
+ * Copyright (C) 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
+ * Software Foundation; either version 2 of the License, or (at your
option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
with
+ * this program; if not, write to the Free Software Foundation, Inc., 675
Mass
+ * Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __PARTICIPANT_H__
+#define __PARTICIPANT_H__
+
+#include <synthclone/participant.h>
+
+#include "effect.h"
+#include "effectview.h"
+
+class Participant: public synthclone::Participant {
+
+ Q_OBJECT
+
+public:
+
+ explicit
+ Participant(QObject *parent=0);
+
+ ~Participant();
+
+ void
+ activate(synthclone::Context &context, const QVariant
&state=QVariant());
+
+ void
+ deactivate(synthclone::Context &context);
+
+ QVariant
+ getState(const synthclone::Effect *effect) const;
+
+ void
+ restoreEffect(const QVariant &state);
+
+private slots:
+
+ void
+ handleEffectAddition();
+
+ void
+ handleEffectConfiguration();
+
+ void
+ handleEffectViewCloseRequest();
+
+ void
+ handleUnregistration(QObject *obj);
+
+private:
+
+ Effect *
+ addEffect();
+
+ void
+ configureEffect(Effect *effect);
+
+ synthclone::MenuAction addEffectAction;
+ synthclone::Context *context;
+ Effect *configuredEffect;
+ EffectView effectView;
+
+};
+
+#endif
=======================================
--- /dev/null
+++ /src/plugins/fader/plugin.cpp Tue Feb 19 22:24:29 2013
@@ -0,0 +1,45 @@
+/*
+ * libsynthclone_fader - Fader effect plugin for `synthclone`
+ * Copyright (C) 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
+ * Software Foundation; either version 2 of the License, or (at your
option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
with
+ * this program; if not, write to the Free Software Foundation, Inc., 675
Mass
+ * Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "plugin.h"
+
+Plugin::Plugin(QObject *parent):
+ QObject(parent)
+{
+ // Empty
+}
+
+Plugin::~Plugin()
+{
+ // Empty
+}
+
+QByteArray
+Plugin::getId() const
+{
+ return "com.googlecode.synthclone.plugins.fader";
+}
+
+synthclone::Participant *
+Plugin::getParticipant()
+{
+ return &participant;
+}
+
+Q_EXPORT_PLUGIN2(synthclone_fader, Plugin);
=======================================
--- /dev/null
+++ /src/plugins/fader/plugin.h Tue Feb 19 22:24:29 2013
@@ -0,0 +1,51 @@
+/*
+ * libsynthclone_fader - Fader effect plugin for `synthclone`
+ * Copyright (C) 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
+ * Software Foundation; either version 2 of the License, or (at your
option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
with
+ * this program; if not, write to the Free Software Foundation, Inc., 675
Mass
+ * Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __PLUGIN_H__
+#define __PLUGIN_H__
+
+#include <synthclone/iplugin.h>
+
+#include "participant.h"
+
+class Plugin: public QObject, public synthclone::IPlugin {
+
+ Q_OBJECT
+ Q_INTERFACES(synthclone::IPlugin)
+
+public:
+
+ explicit
+ Plugin(QObject *parent=0);
+
+ ~Plugin();
+
+ QByteArray
+ getId() const;
+
+ synthclone::Participant *
+ getParticipant();
+
+private:
+
+ Participant participant;
+
+};
+
+#endif
=======================================
--- /configure Fri Dec 21 21:01:25 2012
+++ /configure Tue Feb 19 22:24:29 2013
@@ -50,6 +50,9 @@
parser.add_option("--skip-api-docs", action="store", default=0,
dest="skipAPIDocs", help="Don't build API
documentation",
type="int")
+ parser.add_option("--skip-fader", action="store", default=0,
+ dest="skipFader", help="Don't build the fader
plugin",
+ type="int")
parser.add_option("--skip-headers", action="store", default=0,
dest="skipHeaders", help="Don't build API headers",
type="int")
@@ -176,6 +179,8 @@
qmakeArgs.append("DEBUG=1")
if options.skipAPIDocs:
qmakeArgs.append("SKIP_API_DOCS=1")
+ if options.skipFader:
+ qmakeArgs.append("SKIP_FADER_PLUGIN=1")
if options.skipHeaders:
qmakeArgs.append("SKIP_HEADERS=1")
if options.skipHydrogen:
=======================================
--- /src/plugins/plugins.pro Sat Nov 10 03:24:03 2012
+++ /src/plugins/plugins.pro Tue Feb 19 22:24:29 2013
@@ -1,3 +1,6 @@
+isEmpty(SKIP_FADER_PLUGIN) {
+ SUBDIRS += fader
+}
isEmpty(SKIP_HYDROGEN_PLUGIN) {
SUBDIRS += hydrogen
}
Reply all
Reply to author
Forward
0 new messages