diff options
author | Robert Jonsson <spamatica@gmail.com> | 2012-10-04 16:08:51 +0000 |
---|---|---|
committer | Robert Jonsson <spamatica@gmail.com> | 2012-10-04 16:08:51 +0000 |
commit | 8f81edb163136e8374db131eeefd261fc58e2dc9 (patch) | |
tree | aa107d525e28c06a3543b2de1d1e48d76ac057a3 /muse2/muse | |
parent | 2783d453532728eee509c1e61d4bdd4a5bfac64f (diff) |
added gain knob to channel strips
Diffstat (limited to 'muse2/muse')
-rw-r--r-- | muse2/muse/audiotrack.cpp | 23 | ||||
-rw-r--r-- | muse2/muse/mixer/astrip.cpp | 108 | ||||
-rw-r--r-- | muse2/muse/mixer/astrip.h | 7 | ||||
-rw-r--r-- | muse2/muse/node.cpp | 8 | ||||
-rw-r--r-- | muse2/muse/track.h | 3 | ||||
-rw-r--r-- | muse2/muse/widgets/knob.h | 6 | ||||
-rw-r--r-- | muse2/muse/widgets/mtrackinfobase.ui | 17 |
7 files changed, 123 insertions, 49 deletions
diff --git a/muse2/muse/audiotrack.cpp b/muse2/muse/audiotrack.cpp index ab750edb..da6f196b 100644 --- a/muse2/muse/audiotrack.cpp +++ b/muse2/muse/audiotrack.cpp @@ -40,6 +40,7 @@ #include "dssihost.h" #include "app.h" #include "controlfifo.h" +#include "fastlog.h" namespace MusECore { @@ -123,6 +124,7 @@ AudioTrack::AudioTrack(TrackType t) bufferPos = INT_MAX; setVolume(1.0); + _gain = 1.0; } AudioTrack::AudioTrack(const AudioTrack& t, int flags) @@ -802,6 +804,24 @@ void AudioTrack::setPan(double val) } //--------------------------------------------------------- +// pan +//--------------------------------------------------------- + +double AudioTrack::gain() const + { + return _gain; + } + +//--------------------------------------------------------- +// setPan +//--------------------------------------------------------- + +void AudioTrack::setGain(double val) + { + _gain = val; + } + +//--------------------------------------------------------- // pluginCtrlVal //--------------------------------------------------------- @@ -1084,6 +1104,7 @@ void AudioTrack::writeProperties(int level, Xml& xml) const xml.intTag(level, "prefader", prefader()); xml.intTag(level, "sendMetronome", sendMetronome()); xml.intTag(level, "automation", int(automationType())); + xml.floatTag(level, "gain", _gain); if (hasAuxSend()) { int naux = MusEGlobal::song->auxs()->size(); for (int idx = 0; idx < naux; ++idx) { @@ -1167,6 +1188,8 @@ bool AudioTrack::readProperties(Xml& xml, const QString& tag) _prefader = xml.parseInt(); else if (tag == "sendMetronome") _sendMetronome = xml.parseInt(); + else if (tag == "gain") + _gain = xml.parseFloat(); else if (tag == "automation") setAutomationType(AutomationType(xml.parseInt())); else if (tag == "controller") { diff --git a/muse2/muse/mixer/astrip.cpp b/muse2/muse/mixer/astrip.cpp index 530ca7e2..243df29c 100644 --- a/muse2/muse/mixer/astrip.cpp +++ b/muse2/muse/mixer/astrip.cpp @@ -179,7 +179,8 @@ void AudioStrip::songChanged(MusECore::SongChangedFlags_t val) updateRouteButtons(); MusECore::AudioTrack* src = (MusECore::AudioTrack*)track; - + gain->setValue(src->gain()); + // Do channels before MusEGlobal::config... if (val & SC_CHANNELS) updateChannels(); @@ -441,6 +442,15 @@ void AudioStrip::auxChanged(double val, int idx) } //--------------------------------------------------------- +// gainChanged +//--------------------------------------------------------- + +void AudioStrip::gainChanged(double val) + { + ((MusECore::AudioTrack*)track)->setGain(val); + } + +//--------------------------------------------------------- // auxLabelChanged //--------------------------------------------------------- @@ -664,74 +674,79 @@ void AudioStrip::updateChannels() // 1 - aux send //--------------------------------------------------------- -MusEGui::Knob* AudioStrip::addKnob(int type, int id, MusEGui::DoubleLabel** dlabel, QLabel *name) +MusEGui::Knob* AudioStrip::addKnob(Knob::KnobType type, int id, MusEGui::DoubleLabel** dlabel, QLabel *name) { - MusEGui::Knob* knob = new MusEGui::Knob(this); + MusEGui::Knob* knob = new Knob(this); knob->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum)); - if (type == 0) + MusEGui::DoubleLabel* knobLabel; + if (type == Knob::panType) + { knob->setRange(-1.0, +1.0); - else - knob->setRange(MusEGlobal::config.minSlider-0.1, 10.0); - knob->setBackgroundRole(QPalette::Mid); - - if (type == 0) knob->setToolTip(tr("panorama")); - else + knobLabel = new MusEGui::DoubleLabel(0, -1.0, +1.0, this); + + } else if (type == Knob::auxType) + { + knob->setRange(MusEGlobal::config.minSlider-0.1, 10.0); knob->setToolTip(tr("aux send level")); + knob->setFaceColor(Qt::blue); + knobLabel = new MusEGui::DoubleLabel(0.0, MusEGlobal::config.minSlider, 10.1, this); - MusEGui::DoubleLabel* pl; - if (type == 0) - pl = new MusEGui::DoubleLabel(0, -1.0, +1.0, this); - else - pl = new MusEGui::DoubleLabel(0.0, MusEGlobal::config.minSlider, 10.1, this); + } else if (type == Knob::gainType) + { + knob->setRange(1.0, 20.0); + knob->setFaceColor(Qt::yellow); + knob->setToolTip(tr("calibration gain")); + knobLabel = new MusEGui::DoubleLabel(1.0, 1.0, 30.0, this); + } + knob->setBackgroundRole(QPalette::Mid); if (dlabel) - *dlabel = pl; - pl->setSlider(knob); + *dlabel = knobLabel; + knobLabel->setSlider(knob); ///pl->setFont(MusEGlobal::config.fonts[1]); - pl->setBackgroundRole(QPalette::Mid); - pl->setFrame(true); - if (type == 0) - pl->setPrecision(2); - else { - pl->setPrecision(0); + knobLabel->setBackgroundRole(QPalette::Mid); + knobLabel->setFrame(true); + if (type == Knob::panType) + knobLabel->setPrecision(2); + else if (type == Knob::auxType){ + knobLabel->setPrecision(0); + } + else if (type == Knob::gainType){ + knobLabel->setPrecision(1); } - pl->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum)); + knobLabel->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum)); - // QString label; - // if (type == 0) - // label = tr("Pan"); - // else - // label = name; - - //QLabel* plb = new QLabel(label, this); name->setParent(this); name->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum)); name->setAlignment(Qt::AlignCenter); grid->addWidget(name, _curGridRow, 0); - grid->addWidget(pl, _curGridRow+1, 0); + grid->addWidget(knobLabel, _curGridRow+1, 0); grid->addWidget(knob, _curGridRow, 1, 2, 1); _curGridRow += 2; - connect(knob, SIGNAL(valueChanged(double,int)), pl, SLOT(setValue(double))); + connect(knob, SIGNAL(valueChanged(double,int)), knobLabel, SLOT(setValue(double))); - if (type == 0) { - connect(pl, SIGNAL(valueChanged(double, int)), SLOT(panLabelChanged(double))); + if (type == Knob::panType) { + connect(knobLabel, SIGNAL(valueChanged(double, int)), SLOT(panLabelChanged(double))); connect(knob, SIGNAL(sliderMoved(double,int,bool)), SLOT(panChanged(double,int,bool))); connect(knob, SIGNAL(sliderPressed(int)), SLOT(panPressed())); connect(knob, SIGNAL(sliderReleased(int)), SLOT(panReleased())); connect(knob, SIGNAL(sliderRightClicked(const QPoint &, int)), SLOT(panRightClicked(const QPoint &))); } - else { + else if (type == Knob::auxType){ + knobLabel->setReadOnly(true); knob->setId(id); - - connect(pl, SIGNAL(valueChanged(double, int)), knob, SLOT(setValue(double))); - // Not used yet. Switch if/when necessary. - //connect(pl, SIGNAL(valueChanged(double, int)), SLOT(auxLabelChanged(double, int))); - + connect(knobLabel, SIGNAL(valueChanged(double, int)), knob, SLOT(setValue(double))); connect(knob, SIGNAL(sliderMoved(double, int)), SLOT(auxChanged(double, int))); } + else if (type == Knob::gainType){ + knobLabel->setReadOnly(true); + knob->setId(id); + connect(knobLabel, SIGNAL(valueChanged(double, int)), knob, SLOT(setValue(double))); + connect(knob, SIGNAL(sliderMoved(double, int)), SLOT(gainChanged(double))); + } return knob; } @@ -813,6 +828,13 @@ AudioStrip::AudioStrip(QWidget* parent, MusECore::AudioTrack* at) grid->addWidget(pre, _curGridRow++, 1); //--------------------------------------------------- + // Gain + //--------------------------------------------------- + + gain = addKnob(MusEGui::Knob::gainType, 0, &gainLabel, new QLabel("Gain", this)); + gain->setValue(t->gain()); + + //--------------------------------------------------- // aux send //--------------------------------------------------- @@ -826,7 +848,7 @@ AudioStrip::AudioStrip(QWidget* parent, MusECore::AudioTrack* at) title = title.mid(0,8) + "."; } QLabel *name = new QLabel(title,this); - MusEGui::Knob* ak = addKnob(1, idx, &al, name); + MusEGui::Knob* ak = addKnob(MusEGui::Knob::auxType, idx, &al, name); auxKnob.push_back(ak); auxLabel.push_back(al); @@ -899,7 +921,7 @@ AudioStrip::AudioStrip(QWidget* parent, MusECore::AudioTrack* at) // pan, balance //--------------------------------------------------- - pan = addKnob(0, 0, &panl, new QLabel("Pan", this)); + pan = addKnob(MusEGui::Knob::panType, 0, &panl, new QLabel("Pan", this)); pan->setValue(t->pan()); //--------------------------------------------------- diff --git a/muse2/muse/mixer/astrip.h b/muse2/muse/mixer/astrip.h index 81edc664..7088301f 100644 --- a/muse2/muse/mixer/astrip.h +++ b/muse2/muse/mixer/astrip.h @@ -29,6 +29,7 @@ #include "type_defs.h" #include "strip.h" +#include "knob.h" //#include "route.h" //class QDialog; @@ -67,6 +68,9 @@ class AudioStrip : public Strip { MusEGui::Knob* pan; MusEGui::DoubleLabel* panl; + MusEGui::Knob* gain; + MusEGui::DoubleLabel* gainLabel; + std::vector<MusEGui::Knob*> auxKnob; std::vector<MusEGui::DoubleLabel*> auxLabel; @@ -81,7 +85,7 @@ class AudioStrip : public Strip { //QToolButton* iR; //QToolButton* oR; - MusEGui::Knob* addKnob(int, int, MusEGui::DoubleLabel**, QLabel *name); + MusEGui::Knob* addKnob(Knob::KnobType, int, MusEGui::DoubleLabel**, QLabel *name); void updateOffState(); void updateVolume(); @@ -96,6 +100,7 @@ class AudioStrip : public Strip { void iRoutePressed(); void oRoutePressed(); void auxChanged(double, int); + void gainChanged(double); void volumeChanged(double,int,bool); void volumePressed(); void volumeReleased(); diff --git a/muse2/muse/node.cpp b/muse2/muse/node.cpp index 02264a37..ffc26ee9 100644 --- a/muse2/muse/node.cpp +++ b/muse2/muse/node.cpp @@ -406,8 +406,8 @@ void AudioTrack::copyData(unsigned pos, int dstChannels, int srcStartChan, int s double _pan = controller()->value(AC_PAN, pos, !MusEGlobal::automation || automationType() == AUTO_OFF || !_panEnCtrl || !_panEn2Ctrl); - vol[0] = _volume * (1.0 - _pan); - vol[1] = _volume * (1.0 + _pan); + vol[0] = _volume * (1.0 - _pan) * _gain; + vol[1] = _volume * (1.0 + _pan) * _gain; float meter[trackChans]; // Have we been here already during this process cycle? @@ -744,8 +744,8 @@ void AudioTrack::addData(unsigned pos, int dstChannels, int srcStartChan, int sr double _pan = controller()->value(AC_PAN, pos, !MusEGlobal::automation || automationType() == AUTO_OFF || !_panEnCtrl || !_panEn2Ctrl); - vol[0] = _volume * (1.0 - _pan); - vol[1] = _volume * (1.0 + _pan); + vol[0] = _volume * (1.0 - _pan) * _gain; + vol[1] = _volume * (1.0 + _pan) * _gain; float meter[trackChans]; // Have we been here already during this process cycle? diff --git a/muse2/muse/track.h b/muse2/muse/track.h index 5390d40c..19c824cd 100644 --- a/muse2/muse/track.h +++ b/muse2/muse/track.h @@ -351,6 +351,7 @@ class AudioTrack : public Track { bool _sendMetronome; AutomationType _automationType; Pipeline* _efxPipe; + double _gain; void internal_assign(const Track&, int flags); protected: @@ -421,6 +422,8 @@ class AudioTrack : public Track { void setVolume(double val); double pan() const; void setPan(double val); + double gain() const; + void setGain(double val); bool prefader() const { return _prefader; } double auxSend(int idx) const; diff --git a/muse2/muse/widgets/knob.h b/muse2/muse/widgets/knob.h index bd8621a1..114284d0 100644 --- a/muse2/muse/widgets/knob.h +++ b/muse2/muse/widgets/knob.h @@ -43,6 +43,12 @@ class Knob : public SliderBase, public ScaleIf public: enum Symbol { Line, Dot }; + enum KnobType { + panType, + auxType, + gainType, + }; + private: bool hasScale; diff --git a/muse2/muse/widgets/mtrackinfobase.ui b/muse2/muse/widgets/mtrackinfobase.ui index 93c2f2c9..f566d207 100644 --- a/muse2/muse/widgets/mtrackinfobase.ui +++ b/muse2/muse/widgets/mtrackinfobase.ui @@ -6,7 +6,7 @@ <rect> <x>0</x> <y>0</y> - <width>93</width> + <width>94</width> <height>417</height> </rect> </property> @@ -284,6 +284,9 @@ <verstretch>0</verstretch> </sizepolicy> </property> + <property name="toolTip"> + <string>Transpose notes up or down</string> + </property> <property name="text"> <string>Transp.</string> </property> @@ -325,6 +328,9 @@ <verstretch>0</verstretch> </sizepolicy> </property> + <property name="toolTip"> + <string>Offset playback of notes before or after actual note</string> + </property> <property name="text"> <string>Delay</string> </property> @@ -369,6 +375,9 @@ <verstretch>0</verstretch> </sizepolicy> </property> + <property name="toolTip"> + <string>Change note length in percent of actual length</string> + </property> <property name="text"> <string>Length</string> </property> @@ -416,6 +425,9 @@ <verstretch>0</verstretch> </sizepolicy> </property> + <property name="toolTip"> + <string><html><head/><body><p>Add or substract velocity to notes on track.</p><p><span style=" font-style:italic;">Since the midi note range is 0-127 this <br/>might mean that the notes do not reach <br/>the combined velocity, note + Velocity.</span></p></body></html></string> + </property> <property name="text"> <string>Velocity</string> </property> @@ -463,6 +475,9 @@ <verstretch>0</verstretch> </sizepolicy> </property> + <property name="toolTip"> + <string>Compress the notes velocity range, in percent of actual velocity</string> + </property> <property name="text"> <string>Compr.</string> </property> |