linuxsampler 1.0.0
|
00001 /*************************************************************************** 00002 * * 00003 * LinuxSampler - modular, streaming capable sampler * 00004 * * 00005 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * 00006 * Copyright (C) 2005 - 2009 Christian Schoenebeck * 00007 * * 00008 * This library is free software; you can redistribute it and/or modify * 00009 * it under the terms of the GNU General Public License as published by * 00010 * the Free Software Foundation; either version 2 of the License, or * 00011 * (at your option) any later version. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00016 * GNU General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU General Public License * 00019 * along with this library; if not, write to the Free Software * 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * 00021 * MA 02111-1307 USA * 00022 ***************************************************************************/ 00023 00024 #ifndef __LS_INSTRUMENTMANAGER_H__ 00025 #define __LS_INSTRUMENTMANAGER_H__ 00026 00027 #include "../common/global.h" 00028 #include "../common/Exception.h" 00029 00030 #include <vector> 00031 00032 namespace LinuxSampler { 00033 00034 // just symbol prototyping 00035 class EngineChannel; 00036 class InstrumentEditor; 00037 00041 class InstrumentManagerException : public Exception { 00042 public: 00043 InstrumentManagerException(String msg) : Exception(msg) {} 00044 }; 00045 00052 class InstrumentManager { 00053 public: 00057 enum mode_t { 00058 ON_DEMAND = 0, 00059 ON_DEMAND_HOLD = 1, 00060 PERSISTENT = 2 00061 }; 00062 00066 struct instrument_id_t { 00067 String FileName; 00068 uint Index; 00069 00070 // 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 00071 bool operator<(const instrument_id_t& o) const { 00072 return (Index < o.Index || (Index == o.Index && FileName < o.FileName)); 00073 } 00074 00075 bool operator==(const instrument_id_t& o) const { 00076 return (Index == o.Index && FileName == o.FileName); 00077 } 00078 }; 00079 00083 struct instrument_info_t { 00084 String InstrumentName; 00085 String FormatVersion; 00086 String Product; 00087 String Artists; 00088 uint8_t KeyBindings[128]; 00089 uint8_t KeySwitchBindings[128]; 00090 }; 00091 00097 virtual std::vector<instrument_id_t> Instruments() = 0; 00098 00105 virtual mode_t GetMode(const instrument_id_t& ID) = 0; 00106 00113 virtual void SetMode(const instrument_id_t& ID, mode_t Mode) = 0; 00114 00119 void SetModeInBackground(const instrument_id_t& ID, mode_t Mode); 00120 00130 static void LoadInstrumentInBackground(instrument_id_t ID, EngineChannel* pEngineChannel); 00131 00136 static void StopBackgroundThread(); 00137 00144 virtual String GetInstrumentName(instrument_id_t ID) = 0; 00145 00153 virtual String GetInstrumentDataStructureName(instrument_id_t ID) = 0; 00154 00162 virtual String GetInstrumentDataStructureVersion(instrument_id_t ID) = 0; 00163 00188 virtual InstrumentEditor* LaunchInstrumentEditor(instrument_id_t ID, void* pUserData = NULL) throw (InstrumentManagerException) = 0; 00189 00197 virtual std::vector<instrument_id_t> GetInstrumentFileContent(String File) throw (InstrumentManagerException) = 0; 00198 00205 virtual instrument_info_t GetInstrumentInfo(instrument_id_t ID) throw (InstrumentManagerException) = 0; 00206 }; 00207 00208 } 00209 00210 #endif // __LS_INSTRUMENTMANAGER_H__