00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 00002 00003 /* 00004 Sonic Visualiser 00005 An audio file viewer and annotation editor. 00006 Centre for Digital Music, Queen Mary, University of London. 00007 This file copyright 2006 Chris Cannam. 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License as 00011 published by the Free Software Foundation; either version 2 of the 00012 License, or (at your option) any later version. See the file 00013 COPYING included with this distribution for more information. 00014 */ 00015 00016 #include "PlayParameters.h" 00017 00018 #include <iostream> 00019 00020 #include <QTextStream> 00021 00022 void 00023 PlayParameters::copyFrom(const PlayParameters *pp) 00024 { 00025 m_playMuted = pp->isPlayMuted(); 00026 m_playPan = pp->getPlayPan(); 00027 m_playGain = pp->getPlayGain(); 00028 m_playPluginId = pp->getPlayPluginId(); 00029 m_playPluginConfiguration = pp->getPlayPluginConfiguration(); 00030 } 00031 00032 void 00033 PlayParameters::toXml(QTextStream &stream, 00034 QString indent, 00035 QString extraAttributes) const 00036 { 00037 stream << indent; 00038 stream << QString("<playparameters mute=\"%1\" pan=\"%2\" gain=\"%3\" pluginId=\"%4\" %6") 00039 .arg(m_playMuted ? "true" : "false") 00040 .arg(m_playPan) 00041 .arg(m_playGain) 00042 .arg(m_playPluginId) 00043 .arg(extraAttributes); 00044 if (m_playPluginConfiguration != "") { 00045 stream << ">\n " << indent << m_playPluginConfiguration 00046 << "\n" << indent << "</playparameters>\n"; 00047 } else { 00048 stream << "/>\n"; 00049 } 00050 } 00051 00052 void 00053 PlayParameters::setPlayMuted(bool muted) 00054 { 00055 // std::cerr << "PlayParameters: setPlayMuted(" << muted << ")" << std::endl; 00056 m_playMuted = muted; 00057 emit playMutedChanged(muted); 00058 emit playAudibleChanged(!muted); 00059 emit playParametersChanged(); 00060 } 00061 00062 void 00063 PlayParameters::setPlayAudible(bool audible) 00064 { 00065 // std::cerr << "PlayParameters(" << this << "): setPlayAudible(" << audible << ")" << std::endl; 00066 setPlayMuted(!audible); 00067 } 00068 00069 void 00070 PlayParameters::setPlayPan(float pan) 00071 { 00072 if (m_playPan != pan) { 00073 m_playPan = pan; 00074 emit playPanChanged(pan); 00075 emit playParametersChanged(); 00076 } 00077 } 00078 00079 void 00080 PlayParameters::setPlayGain(float gain) 00081 { 00082 if (m_playGain != gain) { 00083 m_playGain = gain; 00084 emit playGainChanged(gain); 00085 emit playParametersChanged(); 00086 } 00087 } 00088 00089 void 00090 PlayParameters::setPlayPluginId(QString id) 00091 { 00092 if (m_playPluginId != id) { 00093 m_playPluginId = id; 00094 emit playPluginIdChanged(id); 00095 emit playParametersChanged(); 00096 } 00097 } 00098 00099 void 00100 PlayParameters::setPlayPluginConfiguration(QString configuration) 00101 { 00102 if (m_playPluginConfiguration != configuration) { 00103 m_playPluginConfiguration = configuration; 00104 // std::cerr << "PlayParameters(" << this << "): setPlayPluginConfiguration to \"" << configuration.toStdString() << "\"" << std::endl; 00105 emit playPluginConfigurationChanged(configuration); 00106 emit playParametersChanged(); 00107 } 00108 } 00109 00110
1.5.1