annotate base/PlayParameterRepository.cpp @ 37:838652cc31e6

MacOS fixes, TonalChangeDetector added
author Martin Gasser
date Fri, 03 Mar 2006 16:32:45 +0000
parents a6ef94ecbe74
children 39ae3dee27b9
rev   line source
Chris@28 1 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */
Chris@28 2
Chris@28 3 /*
Chris@28 4 A waveform viewer and audio annotation editor.
Chris@28 5 Chris Cannam, Queen Mary University of London, 2005-2006
Chris@28 6
Chris@28 7 This is experimental software. Not for distribution.
Chris@28 8 */
Chris@28 9
Chris@28 10 #include "PlayParameterRepository.h"
Chris@28 11 #include "PlayParameters.h"
Chris@28 12
Chris@30 13 //!!! shouldn't be including this here -- restructure needed
Chris@30 14 #include "audioio/AudioGenerator.h"
Chris@30 15
Chris@29 16 #include <iostream>
Chris@29 17
Chris@28 18 PlayParameterRepository *
Chris@28 19 PlayParameterRepository::m_instance = new PlayParameterRepository;
Chris@28 20
Chris@28 21 PlayParameterRepository *
Chris@28 22 PlayParameterRepository::instance()
Chris@28 23 {
Chris@28 24 return m_instance;
Chris@28 25 }
Chris@28 26
Chris@28 27 PlayParameterRepository::~PlayParameterRepository()
Chris@28 28 {
Chris@28 29 }
Chris@28 30
Chris@30 31 void
Chris@30 32 PlayParameterRepository::addModel(const Model *model)
Chris@30 33 {
Chris@30 34 if (!getPlayParameters(model)) {
Chris@30 35
Chris@30 36 // Give all models the same type of play parameters for the
Chris@30 37 // moment, provided they can be played at all
Chris@30 38
Chris@30 39 if (AudioGenerator::canPlay(model)) {
Chris@30 40
Chris@30 41 std::cerr << "PlayParameterRepository: Adding play parameters for " << model << std::endl;
Chris@30 42
Chris@30 43 m_playParameters[model] = new PlayParameters;
Chris@30 44
Chris@30 45 connect(m_playParameters[model], SIGNAL(playParametersChanged()),
Chris@30 46 this, SLOT(playParametersChanged()));
Chris@30 47
Chris@30 48 } else {
Chris@30 49
Chris@30 50 std::cerr << "PlayParameterRepository: Model " << model << " not playable" << std::endl;
Chris@30 51 }
Chris@30 52 }
Chris@30 53 }
Chris@30 54
Chris@30 55 void
Chris@30 56 PlayParameterRepository::removeModel(const Model *model)
Chris@30 57 {
Chris@30 58 delete m_playParameters[model];
Chris@30 59 m_playParameters.erase(model);
Chris@30 60 }
Chris@30 61
Chris@28 62 PlayParameters *
Chris@30 63 PlayParameterRepository::getPlayParameters(const Model *model) const
Chris@28 64 {
Chris@30 65 if (m_playParameters.find(model) == m_playParameters.end()) return 0;
Chris@30 66 return m_playParameters.find(model)->second;
Chris@28 67 }
Chris@28 68
Chris@28 69 void
Chris@29 70 PlayParameterRepository::playParametersChanged()
Chris@29 71 {
Chris@29 72 emit playParametersChanged(dynamic_cast<PlayParameters *>(sender()));
Chris@29 73 }
Chris@29 74
Chris@29 75 void
Chris@28 76 PlayParameterRepository::clear()
Chris@28 77 {
Chris@30 78 std::cerr << "PlayParameterRepository: PlayParameterRepository::clear" << std::endl;
Chris@28 79 while (!m_playParameters.empty()) {
Chris@28 80 delete m_playParameters.begin()->second;
Chris@28 81 m_playParameters.erase(m_playParameters.begin());
Chris@28 82 }
Chris@28 83 }
Chris@28 84