PlayParameters.cpp
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2006 Chris Cannam.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #include "PlayParameters.h"
17 
18 #include <iostream>
19 
20 #include <QTextStream>
21 
22 void
24 {
25  bool changed = false;
26 
27  if (m_playMuted != pp->isPlayMuted()) {
28  m_playMuted = pp->isPlayMuted();
31  changed = true;
32  }
33 
34  if (m_playPan != pp->getPlayPan()) {
35  m_playPan = pp->getPlayPan();
37  changed = true;
38  }
39 
40  if (m_playGain != pp->getPlayGain()) {
41  m_playGain = pp->getPlayGain();
43  changed = true;
44  }
45 
46  if (m_playClipId != pp->getPlayClipId()) {
49  changed = true;
50  }
51 
52  if (changed) emit playParametersChanged();
53 }
54 
55 void
56 PlayParameters::toXml(QTextStream &stream,
57  QString indent,
58  QString extraAttributes) const
59 {
60  stream << indent;
61  stream << QString("<playparameters mute=\"%1\" pan=\"%2\" gain=\"%3\" clipId=\"%4\" %6")
62  .arg(m_playMuted ? "true" : "false")
63  .arg(m_playPan)
64  .arg(m_playGain)
65  .arg(m_playClipId)
66  .arg(extraAttributes);
67 
68  stream << ">\n";
69 
70  if (m_playClipId != "") {
71  // for backward compatibility
72  stream << indent << " ";
73  stream << QString("<plugin identifier=\"%1\" program=\"%2\"/>\n")
74  .arg("sample_player")
75  .arg(m_playClipId);
76  }
77 
78  stream << indent << "</playparameters>\n";
79 }
80 
81 void
83 {
84 // cerr << "PlayParameters: setPlayMuted(" << muted << ")" << endl;
85  if (m_playMuted != muted) {
86  m_playMuted = muted;
87  emit playMutedChanged(muted);
88  emit playAudibleChanged(!muted);
89  emit playParametersChanged();
90  }
91 }
92 
93 void
95 {
96 // cerr << "PlayParameters(" << this << "): setPlayAudible(" << audible << ")" << endl;
97  setPlayMuted(!audible);
98 }
99 
100 void
102 {
103  if (m_playPan != pan) {
104  m_playPan = pan;
105  emit playPanChanged(pan);
106  emit playParametersChanged();
107  }
108 }
109 
110 void
112 {
113  if (m_playGain != gain) {
114  m_playGain = gain;
115  emit playGainChanged(gain);
116  emit playParametersChanged();
117  }
118 }
119 
120 void
122 {
123  if (m_playClipId != id) {
124  m_playClipId = id;
125  emit playClipIdChanged(id);
126  emit playParametersChanged();
127  }
128 }
virtual bool isPlayMuted() const
void playPanChanged(float)
void playAudibleChanged(bool)
void toXml(QTextStream &stream, QString indent="", QString extraAttributes="") const override
Stream this exportable object out to XML on a text stream.
virtual QString getPlayClipId() const
virtual float getPlayPan() const
QString m_playClipId
virtual void setPlayAudible(bool nonMuted)
void playParametersChanged()
void playMutedChanged(bool)
virtual float getPlayGain() const
virtual void setPlayClipId(QString id)
void playGainChanged(float)
void playClipIdChanged(QString)
virtual void copyFrom(const PlayParameters *)
virtual void setPlayGain(float gain)
virtual void setPlayMuted(bool muted)
virtual void setPlayPan(float pan)