Mercurial > hg > easaier-soundaccess
changeset 225:3200ed3fc957
allow to save/restore filter settings in a session
author | lbajardsilogic |
---|---|
date | Wed, 13 Feb 2008 13:44:28 +0000 |
parents | d2dff2170c7a |
children | 4a157a863e87 |
files | base/PropertyContainer.h sv/document/ESFileReader.cpp sv/filter/EqualizerFilter.cpp sv/filter/EqualizerFilter.h sv/filter/Filter.cpp sv/filter/Filter.h sv/filter/TimeStretchFilter.cpp sv/filter/TimeStretchFilter.h widgets/ItemAudioFilterList.cpp widgets/ItemAudioFilterList.h |
diffstat | 10 files changed, 88 insertions(+), 48 deletions(-) [+] |
line wrap: on
line diff
--- a/base/PropertyContainer.h Tue Feb 12 15:06:02 2008 +0000 +++ b/base/PropertyContainer.h Wed Feb 13 13:44:28 2008 +0000 @@ -102,10 +102,11 @@ virtual PlayParameters *getPlayParameters() { return 0; } - bool isEnabled() const {return m_enabled;} + virtual void emitPropertiesChanged() { emit propertiesChanged(this); } signals: void propertyChanged(PropertyContainer::PropertyName); + void propertiesChanged(PropertyContainer*); public slots: /** @@ -165,7 +166,6 @@ virtual bool convertPropertyStrings(QString nameString, QString valueString, PropertyName &name, int &value); - bool m_enabled; }; #endif
--- a/sv/document/ESFileReader.cpp Tue Feb 12 15:06:02 2008 +0000 +++ b/sv/document/ESFileReader.cpp Wed Feb 13 13:44:28 2008 +0000 @@ -357,7 +357,7 @@ bool ESFileReader::readFilter(const QXmlAttributes &attributes) { - QString name = attributes.value("name"); + QString name = attributes.value("groupname"); FilterStack *filterStack = m_document->getRealTimeFilterStack();
--- a/sv/filter/EqualizerFilter.cpp Tue Feb 12 15:06:02 2008 +0000 +++ b/sv/filter/EqualizerFilter.cpp Wed Feb 13 13:44:28 2008 +0000 @@ -30,6 +30,8 @@ EqualizerFilter::EqualizerFilter() : PropertyContainer() { setObjectName("Equalizer"); + + setFilterEnabled(false); } EqualizerFilter::~EqualizerFilter() @@ -39,7 +41,8 @@ { PropertyList list; list.push_back("Equalizer"); - return list; + list.push_back("Enable"); + return list; } QString EqualizerFilter::getPropertyLabel(const PropertyName &name) const @@ -51,7 +54,8 @@ EqualizerFilter::PropertyType EqualizerFilter::getPropertyType(const PropertyName &name) const { if (name == "Equalizer") return PlotProperty; - return InvalidProperty; + if (name == "Enable") return InvalidProperty; + return InvalidProperty; } int EqualizerFilter::getPropertyRangeAndValue(const PropertyName &name, @@ -64,6 +68,12 @@ /*if (deflt) *deflt = 0; val = (m_peakcheck ? 1 : 0);*/ } + + if (name == "Enable") { + if (deflt) *deflt = 0; + val = (m_enabled ? 1 : 0); + } + #ifdef DEBUG_FILTERS std::cerr << "EqualizerFilter::getPropertyRangeAndValue = " << val << std::endl; #endif @@ -80,6 +90,15 @@ { if (name == "Equalizer"){ + } else if (name == "Enable"){ + if (value > 0) + { + m_enabled = true; + } else + { + m_enabled = false; + } + emit propertyChanged("Enable"); } #ifdef DEBUG_FILTERS std::cerr << "EqualizerFilter::hopfactor = " << hopfactor << std::endl;
--- a/sv/filter/EqualizerFilter.h Tue Feb 12 15:06:02 2008 +0000 +++ b/sv/filter/EqualizerFilter.h Wed Feb 13 13:44:28 2008 +0000 @@ -43,6 +43,8 @@ virtual void setProperty(const PropertyName &, int value); + inline bool isEnabled() {return m_enabled;} + signals: void filterEnabled(bool); @@ -52,6 +54,8 @@ protected: + bool m_enabled; + }; #endif \ No newline at end of file
--- a/sv/filter/Filter.cpp Tue Feb 12 15:06:02 2008 +0000 +++ b/sv/filter/Filter.cpp Wed Feb 13 13:44:28 2008 +0000 @@ -52,35 +52,46 @@ { QString s; - int enable = isFilterEnabled(); - s += indent + QString("<filter name=\"%1\" enable=\"%2\" ").arg(objectName()).arg(enable); + std::vector<PropertyContainer*>::const_iterator iter; + for (iter=m_filterCollection.begin(); iter!=m_filterCollection.end(); iter++) + { + PropertyContainer* filterElt = *(iter); -/* PropertyContainer::PropertyList propertyList = getProperties(); - for(int i=0; i< ((int) propertyList.size());i++) - { - int min, max, deflt; - int value = getPropertyRangeAndValue(propertyList[i], &min, &max, &deflt); - s += propertyList[i] + QString("=\"%1\" ").arg(value); + s += indent + QString("<filter groupname=\"%1\" name=\"%2\" ").arg(objectName()).arg(filterElt->objectName()); + + PropertyContainer::PropertyList propertyList = filterElt->getProperties(); + for(int i=0; i< ((int) propertyList.size());i++) + { + int min, max, deflt; + int value = filterElt->getPropertyRangeAndValue(propertyList[i], &min, &max, &deflt); + s += propertyList[i] + QString("=\"%1\" ").arg(value); + } + + s += QString(" %1 />\n").arg(extraAttributes); } -*/ - s += QString(" %1 />\n").arg(extraAttributes); return s; } void Filter::setProperties(const QXmlAttributes &attributes) { - int enable = attributes.value("enable").toInt(); - setFilterEnabled(enable); - emit filterEnableChange(enable); + QString name = attributes.value("name"); + + std::vector<PropertyContainer*>::const_iterator iter; + for (iter=m_filterCollection.begin(); iter!=m_filterCollection.end(); iter++) + { + PropertyContainer* filterElt = *(iter); -/* PropertyContainer::PropertyList propertyList = getProperties(); - int value; - for(int i=0; i< ((int) propertyList.size());i++) - { - value = attributes.value(propertyList[i]).toInt(); - setProperty(propertyList[i], value); + if (filterElt->objectName() == name) + { + PropertyContainer::PropertyList propertyList = filterElt->getProperties(); + int value; + for(int i=0; i< ((int) propertyList.size());i++) + { + value = attributes.value(propertyList[i]).toInt(); + filterElt->setProperty(propertyList[i], value); + } + filterElt->emitPropertiesChanged(); + } } - - emit propertiesChanged(this);*/ } \ No newline at end of file
--- a/sv/filter/Filter.h Tue Feb 12 15:06:02 2008 +0000 +++ b/sv/filter/Filter.h Wed Feb 13 13:44:28 2008 +0000 @@ -62,7 +62,7 @@ void filterEnableChange(bool); void propertyContainerRemoved(QString); - //void propertiesChanged(PropertyContainer *); + void propertiesChanged(PropertyContainer *); protected:
--- a/sv/filter/TimeStretchFilter.cpp Tue Feb 12 15:06:02 2008 +0000 +++ b/sv/filter/TimeStretchFilter.cpp Wed Feb 13 13:44:28 2008 +0000 @@ -39,6 +39,8 @@ { setObjectName("Pitch-Time Stretching"); + setFilterEnabled(false); + connect(this, SIGNAL(playSpeedChanged(float)), MainWindow::instance(), SLOT(playSpeedChanged(float))); @@ -57,10 +59,9 @@ PropertyList list; list.push_back("Time"); list.push_back("Pitch"); - //list.push_back("Bypass"); + list.push_back("Enable"); list.push_back("Transdetect"); list.push_back("Peaklock"); - list.push_back("Equalizer"); return list; } @@ -71,7 +72,6 @@ //if (name == "Bypass") return tr("Bypass Processing"); if (name == "Transdetect") return tr("Transient Detection"); if (name == "Peaklock") return tr("Peak Locking"); - if (name == "Equalizer") return tr("Equalizer"); return ""; } @@ -79,10 +79,9 @@ { if (name == "Time") return RangeProperty; if (name == "Pitch") return RangeProperty; - //if (name == "Bypass") return ToggleProperty; + if (name == "Enable") return InvalidProperty; if (name == "Transdetect") return ToggleProperty; if (name == "Peaklock") return ToggleProperty; - if (name == "Equalizer") return PlotProperty; return InvalidProperty; } @@ -116,10 +115,10 @@ val = 0; } - /*if (name == "Bypass") { + if (name == "Enable") { if (deflt) *deflt = 0; - val = (m_enabled ? 0 : 1); - }*/ + val = (m_enabled ? 1 : 0); + } if (name == "Transdetect") { if (deflt) *deflt = 0; @@ -173,17 +172,17 @@ if(value == 0){ m_interpfactor=1; } - } /*else if (name == "Bypass"){ + } else if (name == "Enable"){ if (value > 0) { - m_enabled = false; + m_enabled = true; } else { - m_enabled = true; - if (isEnabled()) - emit playSpeedChanged(hopfactor); - } - } */else if (name == "Transdetect"){ + m_enabled = false; + emit playSpeedChanged(hopfactor); + } + emit propertyChanged("Enable"); + } else if (name == "Transdetect"){ m_transcheck = (value > 0) ? true : false; } else if (name == "Peaklock"){ m_peakcheck = (value > 0) ? true : false; @@ -194,7 +193,6 @@ std::cerr << "TimeStretchFilter::m_hop = " << m_hop << std::endl; std::cerr << "TimeStretchFilter::skip = " << getRequiredSkipSamples() << std::endl; #endif - } void TimeStretchFilter::setFilterEnabled(bool b){
--- a/sv/filter/TimeStretchFilter.h Tue Feb 12 15:06:02 2008 +0000 +++ b/sv/filter/TimeStretchFilter.h Wed Feb 13 13:44:28 2008 +0000 @@ -50,6 +50,8 @@ inline bool transcheck() {return m_transcheck;} inline bool peakcheck() {return m_peakcheck;} + inline bool isEnabled() {return m_enabled;} + signals: void playSpeedChanged(float); void filterEnabled(bool); @@ -60,6 +62,8 @@ protected: + bool m_enabled; + bool m_transcheck; bool m_peakcheck;
--- a/widgets/ItemAudioFilterList.cpp Tue Feb 12 15:06:02 2008 +0000 +++ b/widgets/ItemAudioFilterList.cpp Wed Feb 13 13:44:28 2008 +0000 @@ -90,10 +90,10 @@ m_propertyBox = box; if(m_propertyBox!=0){ m_container = m_propertyBox->container(); - updateCheckboxs(); + updateCheckboxs("Enable"); connect(m_propertyBox, SIGNAL(showLayer(bool)), this, SLOT(showLayer(bool))); connect(m_checkBoxPlay, SIGNAL(stateChanged(int)),m_container, SLOT(setFilterEnabled(int))); - connect(m_container, SIGNAL(filterEnableChange(bool)),this, SLOT(updateCheckboxs())); + connect(m_container, SIGNAL(propertyChanged(PropertyContainer::PropertyName)),this, SLOT(updateCheckboxs(PropertyContainer::PropertyName))); } } @@ -109,9 +109,13 @@ ItemAudioFilterList::configAction(); } -void ItemAudioFilterList::updateCheckboxs(){ +void ItemAudioFilterList::updateCheckboxs(PropertyContainer::PropertyName name){ - //m_checkBoxPlay->setChecked(m_container->isFilterEnabled()); + if (name == "Enable") + { + int enable = m_container->getPropertyRangeAndValue(name,0,0,0); + m_checkBoxPlay->setChecked(enable); + } }