annotate base/PlayParameterRepository.h @ 1886:f803d3c33f76 tip

Switch off copious debug in soft synth driving
author Chris Cannam
date Fri, 14 Aug 2020 10:44:44 +0100
parents 77543124651b
children
rev   line source
Chris@49 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@28 2
Chris@28 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@28 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@28 14 */
Chris@28 15
Chris@1580 16 #ifndef SV_PLAY_PARAMETER_REPOSITORY_H
Chris@1580 17 #define SV_PLAY_PARAMETER_REPOSITORY_H
Chris@28 18
Chris@391 19 #include "PlayParameters.h"
Chris@391 20 #include "Command.h"
Chris@391 21
Chris@391 22 class Playable;
Chris@28 23
Chris@28 24 #include <map>
Chris@1751 25 #include <memory>
Chris@28 26
Chris@29 27 #include <QObject>
Chris@391 28 #include <QString>
Chris@29 29
Chris@29 30 class PlayParameterRepository : public QObject
Chris@28 31 {
Chris@29 32 Q_OBJECT
Chris@29 33
Chris@28 34 public:
Chris@145 35 static PlayParameterRepository *getInstance();
Chris@28 36
Chris@28 37 virtual ~PlayParameterRepository();
Chris@28 38
Chris@1742 39 /**
Chris@1751 40 * Register a playable. The id can be anything you like, so long
Chris@1751 41 * as it is unique among playables.
Chris@1742 42 */
Chris@1751 43 void addPlayable(int id, const Playable *);
Chris@30 44
Chris@1742 45 /**
Chris@1751 46 * Unregister a playable. This must happen before a playable is
Chris@1751 47 * deleted.
Chris@1742 48 */
Chris@1751 49 void removePlayable(int id);
Chris@1742 50
Chris@1742 51 /**
Chris@1742 52 * Copy the play parameters from one playable to another.
Chris@1742 53 */
Chris@1742 54 void copyParameters(int fromId, int toId);
Chris@1742 55
Chris@1742 56 /**
Chris@1742 57 * Retrieve the play parameters for a playable.
Chris@1742 58 */
Chris@1751 59 std::shared_ptr<PlayParameters> getPlayParameters(int id);
Chris@28 60
Chris@28 61 void clear();
Chris@28 62
Chris@391 63 class EditCommand : public Command
Chris@391 64 {
Chris@391 65 public:
Chris@1751 66 EditCommand(std::shared_ptr<PlayParameters> params);
Chris@391 67 void setPlayMuted(bool);
Chris@391 68 void setPlayAudible(bool);
Chris@391 69 void setPlayPan(float);
Chris@391 70 void setPlayGain(float);
Chris@866 71 void setPlayClipId(QString);
Chris@1580 72 void execute() override;
Chris@1580 73 void unexecute() override;
Chris@1580 74 QString getName() const override;
Chris@391 75
Chris@391 76 protected:
Chris@1751 77 std::shared_ptr<PlayParameters> m_params;
Chris@391 78 PlayParameters m_from;
Chris@391 79 PlayParameters m_to;
Chris@391 80 };
Chris@391 81
Chris@29 82 signals:
Chris@1751 83 void playParametersChanged(int playableId);
Chris@1742 84 void playClipIdChanged(int playableId, QString);
Chris@29 85
Chris@29 86 protected slots:
Chris@29 87 void playParametersChanged();
Chris@866 88 void playClipIdChanged(QString);
Chris@29 89
Chris@28 90 protected:
Chris@1751 91 typedef std::map<int, std::shared_ptr<PlayParameters>> PlayableParameterMap;
Chris@391 92 PlayableParameterMap m_playParameters;
Chris@28 93
Chris@28 94 static PlayParameterRepository *m_instance;
Chris@28 95 };
Chris@28 96
Chris@28 97 #endif