30 |
// |
// |
31 |
|
|
32 |
// Constructor. |
// Constructor. |
33 |
qsamplerInstrument::qsamplerInstrument ( int iBank, int iProgram ) |
qsamplerInstrument::qsamplerInstrument ( int iMap, int iBank, int iProg ) |
34 |
{ |
{ |
35 |
|
m_iMap = iMap; |
36 |
m_iBank = iBank; |
m_iBank = iBank; |
37 |
m_iProgram = iProgram; |
m_iProg = iProg; |
38 |
m_iInstrumentNr = 0;; |
m_iInstrumentNr = 0;; |
39 |
m_fVolume = 1.0f; |
m_fVolume = 1.0f; |
40 |
m_iLoadMode = 0; |
m_iLoadMode = 0; |
47 |
|
|
48 |
|
|
49 |
// Instrument accessors. |
// Instrument accessors. |
50 |
|
void qsamplerInstrument::setMap ( int iMap ) |
51 |
|
{ |
52 |
|
m_iMap = iMap; |
53 |
|
} |
54 |
|
|
55 |
|
int qsamplerInstrument::map (void) const |
56 |
|
{ |
57 |
|
return m_iMap; |
58 |
|
} |
59 |
|
|
60 |
|
|
61 |
void qsamplerInstrument::setBank ( int iBank ) |
void qsamplerInstrument::setBank ( int iBank ) |
62 |
{ |
{ |
63 |
m_iBank = iBank; |
m_iBank = iBank; |
69 |
} |
} |
70 |
|
|
71 |
|
|
72 |
void qsamplerInstrument::setProgram ( int iProgram ) |
void qsamplerInstrument::setProg ( int iProg ) |
73 |
{ |
{ |
74 |
m_iProgram = iProgram; |
m_iProg = iProg; |
75 |
} |
} |
76 |
|
|
77 |
int qsamplerInstrument::program (void) const |
int qsamplerInstrument::prog (void) const |
78 |
{ |
{ |
79 |
return m_iProgram; |
return m_iProg; |
80 |
} |
} |
81 |
|
|
82 |
|
|
153 |
|
|
154 |
|
|
155 |
// Sync methods. |
// Sync methods. |
156 |
bool qsamplerInstrument::map (void) |
bool qsamplerInstrument::mapInstrument (void) |
157 |
{ |
{ |
158 |
#ifdef CONFIG_MIDI_INSTRUMENT |
#ifdef CONFIG_MIDI_INSTRUMENT |
159 |
|
|
163 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
164 |
return false; |
return false; |
165 |
|
|
166 |
if (m_iBank < 0 || m_iProgram < 0) |
if (m_iMap < 0 || m_iBank < 0 || m_iProg < 0) |
167 |
return false; |
return false; |
168 |
|
|
169 |
lscp_midi_instrument_t instr; |
lscp_midi_instrument_t instr; |
170 |
|
|
171 |
instr.bank_msb = (m_iBank & 0x3f80) >> 7; |
instr.map = m_iMap; |
172 |
instr.bank_lsb = (m_iBank & 0x7f); |
instr.bank = (m_iBank & 0x0fff); |
173 |
instr.program = (m_iProgram & 0x7f); |
instr.prog = (m_iProg & 0x7f); |
174 |
|
|
175 |
lscp_load_mode_t load_mode; |
lscp_load_mode_t load_mode; |
176 |
switch (m_iLoadMode) { |
switch (m_iLoadMode) { |
210 |
} |
} |
211 |
|
|
212 |
|
|
213 |
bool qsamplerInstrument::unmap (void) |
bool qsamplerInstrument::unmapInstrument (void) |
214 |
{ |
{ |
215 |
#ifdef CONFIG_MIDI_INSTRUMENT |
#ifdef CONFIG_MIDI_INSTRUMENT |
216 |
|
|
217 |
if (m_iBank < 0 || m_iProgram < 0) |
if (m_iMap < 0 || m_iBank < 0 || m_iProg < 0) |
218 |
return false; |
return false; |
219 |
|
|
220 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
225 |
|
|
226 |
lscp_midi_instrument_t instr; |
lscp_midi_instrument_t instr; |
227 |
|
|
228 |
instr.bank_msb = (m_iBank & 0x3f80) >> 7; |
instr.map = m_iMap; |
229 |
instr.bank_lsb = (m_iBank & 0x7f); |
instr.bank = (m_iBank & 0x0fff); |
230 |
instr.program = (m_iProgram & 0x7f); |
instr.prog = (m_iProg & 0x7f); |
231 |
|
|
232 |
if (::lscp_unmap_midi_instrument(pMainForm->client(), &instr) != LSCP_OK) { |
if (::lscp_unmap_midi_instrument(pMainForm->client(), &instr) != LSCP_OK) { |
233 |
pMainForm->appendMessagesClient("lscp_unmap_midi_instrument"); |
pMainForm->appendMessagesClient("lscp_unmap_midi_instrument"); |
244 |
} |
} |
245 |
|
|
246 |
|
|
247 |
bool qsamplerInstrument::get (void) |
bool qsamplerInstrument::getInstrument (void) |
248 |
{ |
{ |
249 |
#ifdef CONFIG_MIDI_INSTRUMENT |
#ifdef CONFIG_MIDI_INSTRUMENT |
250 |
|
|
251 |
if (m_iBank < 0 || m_iProgram < 0) |
if (m_iMap < 0 || m_iBank < 0 || m_iProg < 0) |
252 |
return false; |
return false; |
253 |
|
|
254 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
259 |
|
|
260 |
lscp_midi_instrument_t instr; |
lscp_midi_instrument_t instr; |
261 |
|
|
262 |
instr.bank_msb = (m_iBank & 0x3f80) >> 7; |
instr.map = m_iMap; |
263 |
instr.bank_lsb = (m_iBank & 0x7f); |
instr.bank = (m_iBank & 0x0fff); |
264 |
instr.program = (m_iProgram & 0x7f); |
instr.prog = (m_iProg & 0x7f); |
265 |
|
|
266 |
lscp_midi_instrument_info_t *pInstrInfo |
lscp_midi_instrument_info_t *pInstrInfo |
267 |
= ::lscp_get_midi_instrument_info(pMainForm->client(), &instr); |
= ::lscp_get_midi_instrument_info(pMainForm->client(), &instr); |
307 |
} |
} |
308 |
|
|
309 |
|
|
310 |
|
// Instrument map name enumerator. |
311 |
|
QStringList qsamplerInstrument::getMapNames (void) |
312 |
|
{ |
313 |
|
QStringList maps; |
314 |
|
|
315 |
|
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
316 |
|
if (pMainForm == NULL) |
317 |
|
return maps; |
318 |
|
if (pMainForm->client() == NULL) |
319 |
|
return maps; |
320 |
|
|
321 |
|
#ifdef CONFIG_MIDI_INSTRUMENT |
322 |
|
int *piMaps = ::lscp_list_midi_instrument_maps(pMainForm->client()); |
323 |
|
for (int iMap = 0; piMaps && piMaps[iMap] >= 0; iMap++) { |
324 |
|
const QString& sMapName = getMapName(piMaps[iMap]); |
325 |
|
if (!sMapName.isEmpty()) |
326 |
|
maps.append(sMapName); |
327 |
|
} |
328 |
|
#endif |
329 |
|
|
330 |
|
return maps; |
331 |
|
} |
332 |
|
|
333 |
|
// Instrument map name enumerator. |
334 |
|
QString qsamplerInstrument::getMapName ( int iMidiMap ) |
335 |
|
{ |
336 |
|
QString sMapName; |
337 |
|
|
338 |
|
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
339 |
|
if (pMainForm == NULL) |
340 |
|
return sMapName; |
341 |
|
if (pMainForm->client() == NULL) |
342 |
|
return sMapName; |
343 |
|
|
344 |
|
#ifdef CONFIG_MIDI_INSTRUMENT |
345 |
|
const char *pszMapName |
346 |
|
= ::lscp_get_midi_instrument_map_name(pMainForm->client(), iMidiMap); |
347 |
|
if (pszMapName == NULL) |
348 |
|
pszMapName = " -"; |
349 |
|
sMapName = QString("%1 - %2").arg(iMidiMap).arg(pszMapName); |
350 |
|
#endif |
351 |
|
|
352 |
|
return sMapName; |
353 |
|
} |
354 |
|
|
355 |
|
|
356 |
// end of qsamplerInstrument.cpp |
// end of qsamplerInstrument.cpp |