annotate base/PlayParameters.cpp @ 1111:457a1a619c5f simple-fft-model

Merge from default branch
author Chris Cannam
date Wed, 07 Jan 2015 17:42:21 +0000
parents 3a3541b357fe
children
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@866 46 if (m_playClipId != pp->getPlayClipId()) {
Chris@866 47 m_playClipId = pp->getPlayClipId();
Chris@866 48 emit playClipIdChanged(m_playClipId);
Chris@391 49 changed = true;
Chris@391 50 }
Chris@391 51
Chris@391 52 if (changed) emit playParametersChanged();
Chris@284 53 }
Chris@284 54
Chris@314 55 void
Chris@314 56 PlayParameters::toXml(QTextStream &stream,
Chris@314 57 QString indent,
Chris@314 58 QString extraAttributes) const
Chris@81 59 {
Chris@314 60 stream << indent;
Chris@866 61 stream << QString("<playparameters mute=\"%1\" pan=\"%2\" gain=\"%3\" clipId=\"%4\" %6")
Chris@81 62 .arg(m_playMuted ? "true" : "false")
Chris@81 63 .arg(m_playPan)
Chris@81 64 .arg(m_playGain)
Chris@866 65 .arg(m_playClipId)
Chris@81 66 .arg(extraAttributes);
Chris@865 67
Chris@865 68 stream << ">\n";
Chris@865 69
Chris@866 70 if (m_playClipId != "") {
Chris@865 71 // for backward compatibility
Chris@865 72 stream << indent << " ";
Chris@865 73 stream << QString("<plugin identifier=\"%1\" program=\"%2\"/>\n")
Chris@865 74 .arg("sample_player")
Chris@866 75 .arg(m_playClipId);
Chris@865 76 }
Chris@865 77
Chris@865 78 stream << indent << "</playparameters>\n";
Chris@81 79 }
Chris@81 80
Chris@0 81 void
Chris@0 82 PlayParameters::setPlayMuted(bool muted)
Chris@0 83 {
Chris@843 84 // cerr << "PlayParameters: setPlayMuted(" << muted << ")" << 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@843 96 // cerr << "PlayParameters(" << this << "): setPlayAudible(" << audible << ")" << 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@866 121 PlayParameters::setPlayClipId(QString id)
Chris@57 122 {
Chris@866 123 if (m_playClipId != id) {
Chris@866 124 m_playClipId = id;
Chris@866 125 emit playClipIdChanged(id);
Chris@57 126 emit playParametersChanged();
Chris@57 127 }
Chris@57 128 }