/[svn]/linuxsampler/trunk/src/engines/InstrumentManager.h
ViewVC logotype

Contents of /linuxsampler/trunk/src/engines/InstrumentManager.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1212 - (show annotations) (download) (as text)
Tue May 29 23:59:36 2007 UTC (16 years, 10 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 5742 byte(s)
* added highly experimental support for on-the-fly instrument editing
  within the sampler's process (by using instrument editor plugins),
  you'll notice the new "Registered instrument editors:" message on
  startup, the plugin path can be overridden at compile time with
  ./configure --enable-plugin-dir=/some/dir
* added a new LSCP command "EDIT INSTRUMENT <sampler-channel>" to spawn
  a matching instrument editor for the instrument on the given sampler
  channel (LSCP command syntax might be subject to change soon)
* config.h is not going to be installed along with liblinuxsampler's
  API header files anymore (not necessary anymore)
* take care of $(DESTDIR) when creating the instruments DB on 'make
  install' rule (needed for packaging and cross compilation)
* bumped version to 0.4.0.5cvs

1 /***************************************************************************
2 * *
3 * LinuxSampler - modular, streaming capable sampler *
4 * *
5 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 * Copyright (C) 2005 - 2007 Christian Schoenebeck *
7 * *
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
21 * MA 02111-1307 USA *
22 ***************************************************************************/
23
24 #ifndef __LS_INSTRUMENTMANAGER_H__
25 #define __LS_INSTRUMENTMANAGER_H__
26
27 #include "../common/global.h"
28 #include "../common/Exception.h"
29
30 #include <vector>
31
32 namespace LinuxSampler {
33
34 // just symbol prototyping
35 class EngineChannel;
36
37 /**
38 * Will be thrown by InstrumentManager implementations on errors.
39 */
40 class InstrumentManagerException : public Exception {
41 public:
42 InstrumentManagerException(String msg) : Exception(msg) {}
43 };
44
45 /** @brief Abstract interface class for InstrumentManagers.
46 *
47 * Sampler engines should provide an InstrumentManager for allowing
48 * detailed information retrieval and setting of its managed instruments
49 * through this general API.
50 */
51 class InstrumentManager {
52 public:
53 /**
54 * Defines life-time of an instrument.
55 */
56 enum mode_t {
57 ON_DEMAND = 0, ///< Instrument will be loaded when needed, freed once not needed anymore.
58 ON_DEMAND_HOLD = 1, ///< Instrument will be loaded when needed and kept even if not needed anymore.
59 PERSISTENT = 2 ///< Instrument will immediately be loaded and kept all the time.
60 };
61
62 /**
63 * Reflects unique ID of an instrument.
64 */
65 struct instrument_id_t {
66 String FileName; ///< File name of the instrument.
67 uint Index; ///< Index of the instrument within the file.
68
69 // TODO: we should extend operator<() so it will be able to detect that file x and file y are actually the same files, e.g. because one of them is a symlink / share the same inode
70 bool operator<(const instrument_id_t& o) const {
71 return (Index < o.Index || (Index == o.Index && FileName < o.FileName));
72 }
73 };
74
75 /**
76 * Returns all managed instruments.
77 *
78 * This method has to be implemented by the descendant.
79 */
80 virtual std::vector<instrument_id_t> Instruments() = 0;
81
82 /**
83 * Returns the current life-time strategy for the given
84 * instrument.
85 *
86 * This method has to be implemented by the descendant.
87 */
88 virtual mode_t GetMode(const instrument_id_t& ID) = 0;
89
90 /**
91 * Change the current life-time strategy for the given
92 * instrument.
93 *
94 * This method has to be implemented by the descendant.
95 */
96 virtual void SetMode(const instrument_id_t& ID, mode_t Mode) = 0;
97
98 /**
99 * Same as SetMode(), but with the difference that this method
100 * won't block.
101 */
102 void SetModeInBackground(const instrument_id_t& ID, mode_t Mode);
103
104 /**
105 * Same as loading the given instrument directly on the given
106 * EngineChannel, but this method will not block, instead it
107 * will load the instrument in a separate thread.
108 *
109 * @param ID - the instrument to be loaded
110 * @param pEngineChannel - on which engine channel the instrument
111 * should be loaded
112 */
113 static void LoadInstrumentInBackground(instrument_id_t ID, EngineChannel* pEngineChannel);
114
115 /**
116 * Returns the name of the given instrument as reflected by its
117 * file.
118 *
119 * This method has to be implemented by the descendant.
120 */
121 virtual String GetInstrumentName(instrument_id_t ID) = 0;
122
123 virtual String GetInstrumentTypeName(instrument_id_t ID) = 0;
124
125 virtual String GetInstrumentTypeVersion(instrument_id_t ID) = 0;
126
127 virtual void LaunchInstrumentEditor(instrument_id_t ID) throw (InstrumentManagerException) = 0;
128 };
129
130 }
131
132 #endif // __LS_INSTRUMENTMANAGER_H__

  ViewVC Help
Powered by ViewVC