/[svn]/linuxsampler/trunk/src/plugins/InstrumentEditor.cpp
ViewVC logotype

Annotation of /linuxsampler/trunk/src/plugins/InstrumentEditor.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1659 - (hide annotations) (download)
Sun Feb 3 00:13:27 2008 UTC (16 years, 2 months ago) by schoenebeck
File size: 4889 byte(s)
* added support for triggering notes by instrument editors
  (still some cleanup / refactoring ahead, but it should work)
* bumped version to 0.5.1.1cvs

1 schoenebeck 1374 /***************************************************************************
2     * *
3 schoenebeck 1653 * Copyright (C) 2007, 2008 Christian Schoenebeck *
4 schoenebeck 1374 * *
5     * This program is free software; you can redistribute it and/or modify *
6     * it under the terms of the GNU General Public License as published by *
7     * the Free Software Foundation; either version 2 of the License, or *
8     * (at your option) any later version. *
9     * *
10     * This program is distributed in the hope that it will be useful, *
11     * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13     * GNU General Public License for more details. *
14     * *
15     * You should have received a copy of the GNU General Public License *
16     * along with this program; if not, write to the Free Software *
17     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
18     * MA 02111-1307 USA *
19     ***************************************************************************/
20    
21     #include "InstrumentEditor.h"
22    
23 schoenebeck 1425 #include "../common/global_private.h"
24 schoenebeck 1653 #include "../common/atomic.h"
25 schoenebeck 1425
26 schoenebeck 1374 #include <algorithm>
27     #include <functional>
28    
29     namespace LinuxSampler {
30    
31     InstrumentEditor::InstrumentEditor() : Thread(false, false, -1, 0) {
32     pInstrument = NULL;
33     }
34    
35 schoenebeck 1653 InstrumentEditor::~InstrumentEditor() {
36     }
37    
38 schoenebeck 1374 void InstrumentEditor::Launch(void* pInstrument, String sTypeName, String sTypeVersion) {
39     dmsg(1,("InstrumentEditor::Launch(instr=%x,type=%s,version=%s)\n", pInstrument, sTypeName.c_str(), sTypeVersion.c_str()));
40     // prepare the editor's mandatory parameters
41     this->pInstrument = pInstrument;
42     this->sTypeName = sTypeName;
43     this->sTypeVersion = sTypeVersion;
44     // start the editor in its own thread
45     StartThread();
46     }
47    
48     int InstrumentEditor::Main() {
49     dmsg(1,("InstrumentEditor::Main()\n"));
50     // run the editor's main loop
51     int iResult = Main(pInstrument, sTypeName, sTypeVersion);
52     // reset editor parameters
53     this->pInstrument = NULL;
54     this->sTypeName = "";
55     this->sTypeVersion = "";
56     dmsg(1,("Instrument editor '%s' returned with exit status %d\n", Name().c_str(), iResult));
57     // notify all registered listeners
58     std::for_each(
59     listeners.begin(), listeners.end(),
60     std::bind2nd(std::mem_fun(&InstrumentEditorListener::OnInstrumentEditorQuit), this)
61     );
62     // done
63     return iResult;
64     }
65    
66     void InstrumentEditor::AddListener(InstrumentEditorListener* pListener) {
67     listeners.insert(pListener);
68     }
69    
70     void InstrumentEditor::RemoveListener(InstrumentEditorListener* pListener) {
71     listeners.erase(pListener);
72     }
73    
74     void InstrumentEditor::NotifySamplesToBeRemoved(std::set<void*> Samples) {
75     for ( // notify all registered listeners
76     std::set<InstrumentEditorListener*>::iterator iter = listeners.begin();
77     iter != listeners.end(); iter++
78     ) (*iter)->OnSamplesToBeRemoved(Samples, this);
79     }
80    
81     void InstrumentEditor::NotifySamplesRemoved() {
82     for ( // notify all registered listeners
83     std::set<InstrumentEditorListener*>::iterator iter = listeners.begin();
84     iter != listeners.end(); iter++
85     ) (*iter)->OnSamplesRemoved(this);
86     }
87    
88     void InstrumentEditor::NotifyDataStructureToBeChanged(void* pStruct, String sStructType) {
89     for ( // notify all registered listeners
90     std::set<InstrumentEditorListener*>::iterator iter = listeners.begin();
91     iter != listeners.end(); iter++
92     ) (*iter)->OnDataStructureToBeChanged(pStruct, sStructType, this);
93     }
94    
95     void InstrumentEditor::NotifyDataStructureChanged(void* pStruct, String sStructType) {
96     for ( // notify all registered listeners
97     std::set<InstrumentEditorListener*>::iterator iter = listeners.begin();
98     iter != listeners.end(); iter++
99     ) (*iter)->OnDataStructureChanged(pStruct, sStructType, this);
100     }
101    
102     void InstrumentEditor::NotifySampleReferenceChanged(void* pOldSample, void* pNewSample) {
103     for ( // notify all registered listeners
104     std::set<InstrumentEditorListener*>::iterator iter = listeners.begin();
105     iter != listeners.end(); iter++
106     ) (*iter)->OnSampleReferenceChanged(pOldSample, pNewSample, this);
107     }
108    
109     } // namespace LinuxSampler

  ViewVC Help
Powered by ViewVC