Chris@49: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
Chris@0: 
Chris@0: /*
Chris@52:     Sonic Visualiser
Chris@52:     An audio file viewer and annotation editor.
Chris@52:     Centre for Digital Music, Queen Mary, University of London.
Chris@52:     This file copyright 2006 Chris Cannam.
Chris@0:     
Chris@52:     This program is free software; you can redistribute it and/or
Chris@52:     modify it under the terms of the GNU General Public License as
Chris@52:     published by the Free Software Foundation; either version 2 of the
Chris@52:     License, or (at your option) any later version.  See the file
Chris@52:     COPYING included with this distribution for more information.
Chris@0: */
Chris@0: 
Chris@0: #include "PlayParameters.h"
Chris@0: 
Chris@29: #include <iostream>
Chris@29: 
Chris@81: QString
Chris@81: PlayParameters::toXmlString(QString indent,
Chris@81:                             QString extraAttributes) const
Chris@81: {
Chris@81:     QString s;
Chris@81:     s += indent;
Chris@82:     s += QString("<playparameters mute=\"%1\" pan=\"%2\" gain=\"%3\" pluginId=\"%4\" %6")
Chris@81:         .arg(m_playMuted ? "true" : "false")
Chris@81:         .arg(m_playPan)
Chris@81:         .arg(m_playGain)
Chris@81:         .arg(m_playPluginId)
Chris@81:         .arg(extraAttributes);
Chris@81:     if (m_playPluginConfiguration != "") {
Chris@81:         s += ">\n  " + indent + m_playPluginConfiguration
Chris@82:             + "\n" + indent + "</playparameters>\n";
Chris@81:     } else {
Chris@81:         s += "/>\n";
Chris@81:     }
Chris@81:     return s;
Chris@81: }
Chris@81: 
Chris@0: void
Chris@0: PlayParameters::setPlayMuted(bool muted)
Chris@0: {
Chris@117: //    std::cerr << "PlayParameters: setPlayMuted(" << muted << ")" << std::endl;
Chris@0:     m_playMuted = muted;
Chris@29:     emit playMutedChanged(muted);
Chris@30:     emit playAudibleChanged(!muted);
Chris@0:     emit playParametersChanged();
Chris@0: }
Chris@0: 
Chris@29: void
Chris@29: PlayParameters::setPlayAudible(bool audible)
Chris@29: {
Chris@117: //    std::cerr << "PlayParameters(" << this << "): setPlayAudible(" << audible << ")" << std::endl;
Chris@29:     setPlayMuted(!audible);
Chris@29: }
Chris@0: 
Chris@0: void
Chris@0: PlayParameters::setPlayPan(float pan)
Chris@0: {
Chris@57:     if (m_playPan != pan) {
Chris@57:         m_playPan = pan;
Chris@57:         emit playPanChanged(pan);
Chris@57:         emit playParametersChanged();
Chris@57:     }
Chris@0: }
Chris@0: 
Chris@0: void
Chris@0: PlayParameters::setPlayGain(float gain)
Chris@0: {
Chris@57:     if (m_playGain != gain) {
Chris@57:         m_playGain = gain;
Chris@57:         emit playGainChanged(gain);
Chris@57:         emit playParametersChanged();
Chris@57:     }
Chris@0: }
Chris@0: 
Chris@57: void
Chris@57: PlayParameters::setPlayPluginId(QString id)
Chris@57: {
Chris@57:     if (m_playPluginId != id) {
Chris@57:         m_playPluginId = id;
Chris@57:         emit playPluginIdChanged(id);
Chris@57:         emit playParametersChanged();
Chris@57:     }
Chris@57: }
Chris@0: 
Chris@57: void
Chris@57: PlayParameters::setPlayPluginConfiguration(QString configuration)
Chris@57: {
Chris@57:     if (m_playPluginConfiguration != configuration) {
Chris@57:         m_playPluginConfiguration = configuration;
Chris@117: //        std::cerr << "PlayParameters(" << this << "): setPlayPluginConfiguration to \"" << configuration.toStdString() << "\"" << std::endl;
Chris@57:         emit playPluginConfigurationChanged(configuration);
Chris@57:         emit playParametersChanged();
Chris@57:     }
Chris@57: }
Chris@57: 
Chris@57: