annotate base/PlayParameters.cpp @ 509:6066bde1c126

* Cut back on the locking and general workload in FFTDataServer::getMagnitudes(). This stuff is far too complicated!
author Chris Cannam
date Mon, 08 Dec 2008 11:15:13 +0000
parents 5858cc462d0a
children b4a8d8221eaf
rev   line source
Chris@49 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@0 2
Chris@0 3 /*
Chris@52 4 Sonic Visualiser
Chris@52 5 An audio file viewer and annotation editor.
Chris@52 6 Centre for Digital Music, Queen Mary, University of London.
Chris@52 7 This file copyright 2006 Chris Cannam.
Chris@0 8
Chris@52 9 This program is free software; you can redistribute it and/or
Chris@52 10 modify it under the terms of the GNU General Public License as
Chris@52 11 published by the Free Software Foundation; either version 2 of the
Chris@52 12 License, or (at your option) any later version. See the file
Chris@52 13 COPYING included with this distribution for more information.
Chris@0 14 */
Chris@0 15
Chris@0 16 #include "PlayParameters.h"
Chris@0 17
Chris@29 18 #include <iostream>
Chris@29 19
Chris@314 20 #include <QTextStream>
Chris@314 21
Chris@284 22 void
Chris@284 23 PlayParameters::copyFrom(const PlayParameters *pp)
Chris@284 24 {
Chris@391 25 bool changed = false;
Chris@391 26
Chris@391 27 if (m_playMuted != pp->isPlayMuted()) {
Chris@391 28 m_playMuted = pp->isPlayMuted();
Chris@391 29 emit playMutedChanged(m_playMuted);
Chris@391 30 emit playAudibleChanged(!m_playMuted);
Chris@391 31 changed = true;
Chris@391 32 }
Chris@391 33
Chris@391 34 if (m_playPan != pp->getPlayPan()) {
Chris@391 35 m_playPan = pp->getPlayPan();
Chris@391 36 emit playPanChanged(m_playPan);
Chris@391 37 changed = true;
Chris@391 38 }
Chris@391 39
Chris@391 40 if (m_playGain != pp->getPlayGain()) {
Chris@391 41 m_playGain = pp->getPlayGain();
Chris@391 42 emit playGainChanged(m_playGain);
Chris@391 43 changed = true;
Chris@391 44 }
Chris@391 45
Chris@391 46 if (m_playPluginId != pp->getPlayPluginId()) {
Chris@391 47 m_playPluginId = pp->getPlayPluginId();
Chris@391 48 emit playPluginIdChanged(m_playPluginId);
Chris@391 49 changed = true;
Chris@391 50 }
Chris@391 51
Chris@391 52 if (m_playPluginConfiguration != pp->getPlayPluginConfiguration()) {
Chris@391 53 m_playPluginConfiguration = pp->getPlayPluginConfiguration();
Chris@391 54 emit playPluginConfigurationChanged(m_playPluginConfiguration);
Chris@391 55 changed = true;
Chris@391 56 }
Chris@391 57
Chris@391 58 if (changed) emit playParametersChanged();
Chris@284 59 }
Chris@284 60
Chris@314 61 void
Chris@314 62 PlayParameters::toXml(QTextStream &stream,
Chris@314 63 QString indent,
Chris@314 64 QString extraAttributes) const
Chris@81 65 {
Chris@314 66 stream << indent;
Chris@314 67 stream << QString("<playparameters mute=\"%1\" pan=\"%2\" gain=\"%3\" pluginId=\"%4\" %6")
Chris@81 68 .arg(m_playMuted ? "true" : "false")
Chris@81 69 .arg(m_playPan)
Chris@81 70 .arg(m_playGain)
Chris@81 71 .arg(m_playPluginId)
Chris@81 72 .arg(extraAttributes);
Chris@81 73 if (m_playPluginConfiguration != "") {
Chris@314 74 stream << ">\n " << indent << m_playPluginConfiguration
Chris@314 75 << "\n" << indent << "</playparameters>\n";
Chris@81 76 } else {
Chris@314 77 stream << "/>\n";
Chris@81 78 }
Chris@81 79 }
Chris@81 80
Chris@0 81 void
Chris@0 82 PlayParameters::setPlayMuted(bool muted)
Chris@0 83 {
Chris@117 84 // std::cerr << "PlayParameters: setPlayMuted(" << muted << ")" << std::endl;
Chris@391 85 if (m_playMuted != muted) {
Chris@391 86 m_playMuted = muted;
Chris@391 87 emit playMutedChanged(muted);
Chris@391 88 emit playAudibleChanged(!muted);
Chris@391 89 emit playParametersChanged();
Chris@391 90 }
Chris@0 91 }
Chris@0 92
Chris@29 93 void
Chris@29 94 PlayParameters::setPlayAudible(bool audible)
Chris@29 95 {
Chris@117 96 // std::cerr << "PlayParameters(" << this << "): setPlayAudible(" << audible << ")" << std::endl;
Chris@29 97 setPlayMuted(!audible);
Chris@29 98 }
Chris@0 99
Chris@0 100 void
Chris@0 101 PlayParameters::setPlayPan(float pan)
Chris@0 102 {
Chris@57 103 if (m_playPan != pan) {
Chris@57 104 m_playPan = pan;
Chris@57 105 emit playPanChanged(pan);
Chris@57 106 emit playParametersChanged();
Chris@57 107 }
Chris@0 108 }
Chris@0 109
Chris@0 110 void
Chris@0 111 PlayParameters::setPlayGain(float gain)
Chris@0 112 {
Chris@57 113 if (m_playGain != gain) {
Chris@57 114 m_playGain = gain;
Chris@57 115 emit playGainChanged(gain);
Chris@57 116 emit playParametersChanged();
Chris@57 117 }
Chris@0 118 }
Chris@0 119
Chris@57 120 void
Chris@57 121 PlayParameters::setPlayPluginId(QString id)
Chris@57 122 {
Chris@57 123 if (m_playPluginId != id) {
Chris@57 124 m_playPluginId = id;
Chris@57 125 emit playPluginIdChanged(id);
Chris@57 126 emit playParametersChanged();
Chris@57 127 }
Chris@57 128 }
Chris@0 129
Chris@57 130 void
Chris@57 131 PlayParameters::setPlayPluginConfiguration(QString configuration)
Chris@57 132 {
Chris@57 133 if (m_playPluginConfiguration != configuration) {
Chris@57 134 m_playPluginConfiguration = configuration;
Chris@117 135 // std::cerr << "PlayParameters(" << this << "): setPlayPluginConfiguration to \"" << configuration.toStdString() << "\"" << std::endl;
Chris@57 136 emit playPluginConfigurationChanged(configuration);
Chris@57 137 emit playParametersChanged();
Chris@57 138 }
Chris@57 139 }
Chris@57 140
Chris@57 141