1 |
// qsamplerInstrument.cpp |
// qsamplerInstrument.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2006, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
|
Copyright (C) 2007, Christian Schoenebeck |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
8 |
modify it under the terms of the GNU General Public License |
modify it under the terms of the GNU General Public License |
22 |
|
|
23 |
#include "qsamplerAbout.h" |
#include "qsamplerAbout.h" |
24 |
#include "qsamplerInstrument.h" |
#include "qsamplerInstrument.h" |
25 |
|
#include "qsamplerUtilities.h" |
26 |
|
|
27 |
|
#include "qsamplerOptions.h" |
28 |
#include "qsamplerMainForm.h" |
#include "qsamplerMainForm.h" |
29 |
|
|
30 |
|
|
31 |
|
namespace QSampler { |
32 |
|
|
33 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
34 |
// qsamplerInstrument - MIDI instrument map structure. |
// QSampler::Instrument - MIDI instrument map structure. |
35 |
// |
// |
36 |
|
|
37 |
// Constructor. |
// Constructor. |
38 |
qsamplerInstrument::qsamplerInstrument ( int iMap, int iBank, int iProg ) |
Instrument::Instrument ( int iMap, int iBank, int iProg ) |
39 |
{ |
{ |
40 |
m_iMap = iMap; |
m_iMap = iMap; |
41 |
m_iBank = iBank; |
m_iBank = iBank; |
42 |
m_iProg = iProg; |
m_iProg = iProg; |
43 |
m_iInstrumentNr = 0;; |
m_iInstrumentNr = 0; |
44 |
m_fVolume = 1.0f; |
m_fVolume = 1.0f; |
45 |
m_iLoadMode = 0; |
m_iLoadMode = 0; |
46 |
} |
} |
47 |
|
|
48 |
// Default destructor. |
// Default destructor. |
49 |
qsamplerInstrument::~qsamplerInstrument (void) |
Instrument::~Instrument (void) |
50 |
{ |
{ |
51 |
} |
} |
52 |
|
|
53 |
|
|
54 |
// Instrument accessors. |
// Instrument accessors. |
55 |
void qsamplerInstrument::setMap ( int iMap ) |
void Instrument::setMap ( int iMap ) |
56 |
{ |
{ |
57 |
m_iMap = iMap; |
m_iMap = iMap; |
58 |
} |
} |
59 |
|
|
60 |
int qsamplerInstrument::map (void) const |
int Instrument::map (void) const |
61 |
{ |
{ |
62 |
return m_iMap; |
return m_iMap; |
63 |
} |
} |
64 |
|
|
65 |
|
|
66 |
void qsamplerInstrument::setBank ( int iBank ) |
void Instrument::setBank ( int iBank ) |
67 |
{ |
{ |
68 |
m_iBank = iBank; |
m_iBank = iBank; |
69 |
} |
} |
70 |
|
|
71 |
int qsamplerInstrument::bank (void) const |
int Instrument::bank (void) const |
72 |
{ |
{ |
73 |
return m_iBank; |
return m_iBank; |
74 |
} |
} |
75 |
|
|
76 |
|
|
77 |
void qsamplerInstrument::setProg ( int iProg ) |
void Instrument::setProg ( int iProg ) |
78 |
{ |
{ |
79 |
m_iProg = iProg; |
m_iProg = iProg; |
80 |
} |
} |
81 |
|
|
82 |
int qsamplerInstrument::prog (void) const |
int Instrument::prog (void) const |
83 |
{ |
{ |
84 |
return m_iProg; |
return m_iProg; |
85 |
} |
} |
86 |
|
|
87 |
|
|
88 |
void qsamplerInstrument::setName ( const QString& sName ) |
void Instrument::setName ( const QString& sName ) |
89 |
{ |
{ |
90 |
m_sName = sName; |
m_sName = sName; |
91 |
} |
} |
92 |
|
|
93 |
const QString& qsamplerInstrument::name (void) const |
const QString& Instrument::name (void) const |
94 |
{ |
{ |
95 |
return m_sName; |
return m_sName; |
96 |
} |
} |
97 |
|
|
98 |
|
|
99 |
void qsamplerInstrument::setEngineName ( const QString& sEngineName ) |
void Instrument::setEngineName ( const QString& sEngineName ) |
100 |
{ |
{ |
101 |
m_sEngineName = sEngineName; |
m_sEngineName = sEngineName; |
102 |
} |
} |
103 |
|
|
104 |
const QString& qsamplerInstrument::engineName (void) const |
const QString& Instrument::engineName (void) const |
105 |
{ |
{ |
106 |
return m_sEngineName; |
return m_sEngineName; |
107 |
} |
} |
108 |
|
|
109 |
|
|
110 |
void qsamplerInstrument::setInstrumentFile ( const QString& sInstrumentFile ) |
void Instrument::setInstrumentFile ( const QString& sInstrumentFile ) |
111 |
{ |
{ |
112 |
m_sInstrumentFile = sInstrumentFile; |
m_sInstrumentFile = sInstrumentFile; |
113 |
} |
} |
114 |
|
|
115 |
const QString& qsamplerInstrument::instrumentFile (void) const |
const QString& Instrument::instrumentFile (void) const |
116 |
{ |
{ |
117 |
return m_sInstrumentFile; |
return m_sInstrumentFile; |
118 |
} |
} |
119 |
|
|
120 |
|
|
121 |
const QString& qsamplerInstrument::instrumentName (void) const |
const QString& Instrument::instrumentName (void) const |
122 |
{ |
{ |
123 |
return m_sInstrumentName; |
return m_sInstrumentName; |
124 |
} |
} |
125 |
|
|
126 |
|
|
127 |
void qsamplerInstrument::setInstrumentNr ( int iInstrumentNr ) |
void Instrument::setInstrumentNr ( int iInstrumentNr ) |
128 |
{ |
{ |
129 |
m_iInstrumentNr = iInstrumentNr; |
m_iInstrumentNr = iInstrumentNr; |
130 |
} |
} |
131 |
|
|
132 |
int qsamplerInstrument::instrumentNr (void) const |
int Instrument::instrumentNr (void) const |
133 |
{ |
{ |
134 |
return m_iInstrumentNr; |
return m_iInstrumentNr; |
135 |
} |
} |
136 |
|
|
137 |
|
|
138 |
void qsamplerInstrument::setVolume ( float fVolume ) |
void Instrument::setVolume ( float fVolume ) |
139 |
{ |
{ |
140 |
m_fVolume = fVolume; |
m_fVolume = fVolume; |
141 |
} |
} |
142 |
|
|
143 |
float qsamplerInstrument::volume (void) const |
float Instrument::volume (void) const |
144 |
{ |
{ |
145 |
return m_fVolume; |
return m_fVolume; |
146 |
} |
} |
147 |
|
|
148 |
|
|
149 |
void qsamplerInstrument::setLoadMode ( int iLoadMode ) |
void Instrument::setLoadMode ( int iLoadMode ) |
150 |
{ |
{ |
151 |
m_iLoadMode = iLoadMode; |
m_iLoadMode = iLoadMode; |
152 |
} |
} |
153 |
|
|
154 |
int qsamplerInstrument::loadMode (void) const |
int Instrument::loadMode (void) const |
155 |
{ |
{ |
156 |
return m_iLoadMode; |
return m_iLoadMode; |
157 |
} |
} |
158 |
|
|
159 |
|
|
160 |
// Sync methods. |
// Sync methods. |
161 |
bool qsamplerInstrument::mapInstrument (void) |
bool Instrument::mapInstrument (void) |
162 |
{ |
{ |
163 |
#ifdef CONFIG_MIDI_INSTRUMENT |
#ifdef CONFIG_MIDI_INSTRUMENT |
164 |
|
|
165 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
166 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
167 |
return false; |
return false; |
168 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
195 |
} |
} |
196 |
|
|
197 |
if (::lscp_map_midi_instrument(pMainForm->client(), &instr, |
if (::lscp_map_midi_instrument(pMainForm->client(), &instr, |
198 |
m_sEngineName.latin1(), |
m_sEngineName.toUtf8().constData(), |
199 |
m_sInstrumentFile.latin1(), |
qsamplerUtilities::lscpEscapePath( |
200 |
m_iInstrumentNr, |
m_sInstrumentFile).toUtf8().constData(), |
201 |
m_fVolume, |
m_iInstrumentNr, m_fVolume, load_mode, |
202 |
load_mode, |
m_sName.toUtf8().constData()) != LSCP_OK) { |
|
m_sName.latin1()) != LSCP_OK) { |
|
203 |
pMainForm->appendMessagesClient("lscp_map_midi_instrument"); |
pMainForm->appendMessagesClient("lscp_map_midi_instrument"); |
204 |
return false; |
return false; |
205 |
} |
} |
214 |
} |
} |
215 |
|
|
216 |
|
|
217 |
bool qsamplerInstrument::unmapInstrument (void) |
bool Instrument::unmapInstrument (void) |
218 |
{ |
{ |
219 |
#ifdef CONFIG_MIDI_INSTRUMENT |
#ifdef CONFIG_MIDI_INSTRUMENT |
220 |
|
|
221 |
if (m_iMap < 0 || m_iBank < 0 || m_iProg < 0) |
if (m_iMap < 0 || m_iBank < 0 || m_iProg < 0) |
222 |
return false; |
return false; |
223 |
|
|
224 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
225 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
226 |
return false; |
return false; |
227 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
248 |
} |
} |
249 |
|
|
250 |
|
|
251 |
bool qsamplerInstrument::getInstrument (void) |
bool Instrument::getInstrument (void) |
252 |
{ |
{ |
253 |
#ifdef CONFIG_MIDI_INSTRUMENT |
#ifdef CONFIG_MIDI_INSTRUMENT |
254 |
|
|
255 |
if (m_iMap < 0 || m_iBank < 0 || m_iProg < 0) |
if (m_iMap < 0 || m_iBank < 0 || m_iProg < 0) |
256 |
return false; |
return false; |
257 |
|
|
258 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
259 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
260 |
return false; |
return false; |
261 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
274 |
return false; |
return false; |
275 |
} |
} |
276 |
|
|
277 |
m_sName = pInstrInfo->name; |
m_sName = qsamplerUtilities::lscpEscapedTextToRaw(pInstrInfo->name); |
278 |
m_sEngineName = pInstrInfo->engine_name; |
m_sEngineName = pInstrInfo->engine_name; |
279 |
m_sInstrumentName = pInstrInfo->instrument_name; |
m_sInstrumentName = qsamplerUtilities::lscpEscapedTextToRaw( |
280 |
m_sInstrumentFile = pInstrInfo->instrument_file; |
pInstrInfo->instrument_name); |
281 |
m_iInstrumentNr = pInstrInfo->instrument_nr; |
m_sInstrumentFile = qsamplerUtilities::lscpEscapedPathToPosix( |
282 |
m_fVolume = pInstrInfo->volume; |
pInstrInfo->instrument_file); |
283 |
|
m_iInstrumentNr = pInstrInfo->instrument_nr; |
284 |
|
m_fVolume = pInstrInfo->volume; |
285 |
|
|
286 |
switch (pInstrInfo->load_mode) { |
switch (pInstrInfo->load_mode) { |
287 |
case LSCP_LOAD_PERSISTENT: |
case LSCP_LOAD_PERSISTENT: |
314 |
|
|
315 |
|
|
316 |
// Instrument map name enumerator. |
// Instrument map name enumerator. |
317 |
QStringList qsamplerInstrument::getMapNames (void) |
QStringList Instrument::getMapNames (void) |
318 |
{ |
{ |
319 |
QStringList maps; |
QStringList maps; |
320 |
|
|
321 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
322 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
323 |
return maps; |
return maps; |
324 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
342 |
} |
} |
343 |
|
|
344 |
// Instrument map name enumerator. |
// Instrument map name enumerator. |
345 |
QString qsamplerInstrument::getMapName ( int iMidiMap ) |
QString Instrument::getMapName ( int iMidiMap ) |
346 |
{ |
{ |
347 |
QString sMapName; |
QString sMapName; |
348 |
|
|
349 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
350 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
351 |
return sMapName; |
return sMapName; |
352 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
360 |
if (::lscp_client_get_errno(pMainForm->client())) |
if (::lscp_client_get_errno(pMainForm->client())) |
361 |
pMainForm->appendMessagesClient("lscp_get_midi_instrument_name"); |
pMainForm->appendMessagesClient("lscp_get_midi_instrument_name"); |
362 |
} |
} |
363 |
sMapName = QString("%1 - %2").arg(iMidiMap).arg(pszMapName); |
sMapName = QString("%1 - %2").arg(iMidiMap) |
364 |
|
.arg(qsamplerUtilities::lscpEscapedTextToRaw(pszMapName)); |
365 |
#endif |
#endif |
366 |
|
|
367 |
return sMapName; |
return sMapName; |
368 |
} |
} |
369 |
|
|
370 |
|
} // namespace QSampler |
371 |
|
|
372 |
// end of qsamplerInstrument.cpp |
// end of qsamplerInstrument.cpp |