76 |
} |
} |
77 |
|
|
78 |
|
|
79 |
|
// Create a new sampler channel, if not already. |
80 |
|
bool qsamplerChannel::addChannel (void) |
81 |
|
{ |
82 |
|
if (client() == NULL) |
83 |
|
return false; |
84 |
|
|
85 |
|
// Are we a new channel? |
86 |
|
if (m_iChannelID < 0) { |
87 |
|
m_iChannelID = ::lscp_add_channel(client()); |
88 |
|
if (m_iChannelID < 0) { |
89 |
|
appendMessagesClient("lscp_add_channel"); |
90 |
|
appendMessagesError(QObject::tr("Could not create the new channel.\n\nSorry.")); |
91 |
|
} // Otherwise it's created... |
92 |
|
else appendMessages(QObject::tr("Channel %1 created.").arg(m_iChannelID)); |
93 |
|
} |
94 |
|
|
95 |
|
// Return whether we're a valid channel... |
96 |
|
return (m_iChannelID >= 0); |
97 |
|
} |
98 |
|
|
99 |
|
|
100 |
|
// Remove sampler channel. |
101 |
|
bool qsamplerChannel::removeChannel (void) |
102 |
|
{ |
103 |
|
if (client() == NULL) |
104 |
|
return false; |
105 |
|
|
106 |
|
// Are we an existing channel? |
107 |
|
if (m_iChannelID >= 0) { |
108 |
|
if (::lscp_remove_channel(client(), m_iChannelID) != LSCP_OK) { |
109 |
|
appendMessagesClient("lscp_remove_channel"); |
110 |
|
appendMessagesError(QObject::tr("Could not remove channel.\n\nSorry.")); |
111 |
|
} else { |
112 |
|
// Otherwise it's removed. |
113 |
|
appendMessages(QObject::tr("Channel %1 removed.").arg(m_iChannelID)); |
114 |
|
m_iChannelID = -1; |
115 |
|
} |
116 |
|
} |
117 |
|
|
118 |
|
// Return whether we've removed the channel... |
119 |
|
return (m_iChannelID < 0); |
120 |
|
} |
121 |
|
|
122 |
|
|
123 |
// Channel-ID (aka Sammpler-Channel) accessors. |
// Channel-ID (aka Sammpler-Channel) accessors. |
124 |
int qsamplerChannel::channelID (void) |
int qsamplerChannel::channelID (void) |
125 |
{ |
{ |
132 |
} |
} |
133 |
|
|
134 |
|
|
135 |
|
// Readable channel name. |
136 |
|
QString qsamplerChannel::channelName (void) |
137 |
|
{ |
138 |
|
return (m_iChannelID < 0 ? QObject::tr("New Channel") : QObject::tr("Channel %1").arg(m_iChannelID)); |
139 |
|
} |
140 |
|
|
141 |
|
|
142 |
// Engine name accessors. |
// Engine name accessors. |
143 |
QString& qsamplerChannel::engineName (void) |
QString& qsamplerChannel::engineName (void) |
144 |
{ |
{ |
147 |
|
|
148 |
bool qsamplerChannel::loadEngine ( const QString& sEngineName ) |
bool qsamplerChannel::loadEngine ( const QString& sEngineName ) |
149 |
{ |
{ |
150 |
if (client() == NULL) |
if (client() == NULL || m_iChannelID < 0) |
151 |
return false; |
return false; |
152 |
|
|
153 |
if (::lscp_load_engine(client(), sEngineName.latin1(), m_iChannelID) != LSCP_OK) { |
if (::lscp_load_engine(client(), sEngineName.latin1(), m_iChannelID) != LSCP_OK) { |
181 |
// Instrument file loader. |
// Instrument file loader. |
182 |
bool qsamplerChannel::loadInstrument ( const QString& sInstrumentFile, int iInstrumentNr ) |
bool qsamplerChannel::loadInstrument ( const QString& sInstrumentFile, int iInstrumentNr ) |
183 |
{ |
{ |
184 |
if (client() == NULL) |
if (client() == NULL || m_iChannelID < 0) |
185 |
return false; |
return false; |
186 |
|
|
187 |
if (::lscp_load_instrument_non_modal(client(), sInstrumentFile.latin1(), iInstrumentNr, m_iChannelID) != LSCP_OK) { |
if (::lscp_load_instrument_non_modal(client(), sInstrumentFile.latin1(), iInstrumentNr, m_iChannelID) != LSCP_OK) { |
205 |
|
|
206 |
bool qsamplerChannel::setMidiDriver ( const QString& sMidiDriver ) |
bool qsamplerChannel::setMidiDriver ( const QString& sMidiDriver ) |
207 |
{ |
{ |
208 |
if (client() == NULL) |
if (client() == NULL || m_iChannelID < 0) |
209 |
return false; |
return false; |
210 |
|
|
211 |
if (::lscp_set_channel_midi_type(client(), m_iChannelID, sMidiDriver.latin1()) != LSCP_OK) { |
if (::lscp_set_channel_midi_type(client(), m_iChannelID, sMidiDriver.latin1()) != LSCP_OK) { |
226 |
|
|
227 |
bool qsamplerChannel::setMidiDevice ( int iMidiDevice ) |
bool qsamplerChannel::setMidiDevice ( int iMidiDevice ) |
228 |
{ |
{ |
229 |
if (client() == NULL) |
if (client() == NULL || m_iChannelID < 0) |
230 |
return false; |
return false; |
231 |
|
|
232 |
if (::lscp_set_channel_midi_device(client(), m_iChannelID, iMidiDevice) != LSCP_OK) { |
if (::lscp_set_channel_midi_device(client(), m_iChannelID, iMidiDevice) != LSCP_OK) { |
247 |
|
|
248 |
bool qsamplerChannel::setMidiPort ( int iMidiPort ) |
bool qsamplerChannel::setMidiPort ( int iMidiPort ) |
249 |
{ |
{ |
250 |
if (client() == NULL) |
if (client() == NULL || m_iChannelID < 0) |
251 |
return false; |
return false; |
252 |
|
|
253 |
if (::lscp_set_channel_midi_port(client(), m_iChannelID, iMidiPort) != LSCP_OK) { |
if (::lscp_set_channel_midi_port(client(), m_iChannelID, iMidiPort) != LSCP_OK) { |
268 |
|
|
269 |
bool qsamplerChannel::setMidiChannel ( int iMidiChannel ) |
bool qsamplerChannel::setMidiChannel ( int iMidiChannel ) |
270 |
{ |
{ |
271 |
if (client() == NULL) |
if (client() == NULL || m_iChannelID < 0) |
272 |
return false; |
return false; |
273 |
|
|
274 |
if (::lscp_set_channel_midi_channel(client(), m_iChannelID, iMidiChannel) != LSCP_OK) { |
if (::lscp_set_channel_midi_channel(client(), m_iChannelID, iMidiChannel) != LSCP_OK) { |
289 |
|
|
290 |
bool qsamplerChannel::setAudioDevice ( int iAudioDevice ) |
bool qsamplerChannel::setAudioDevice ( int iAudioDevice ) |
291 |
{ |
{ |
292 |
if (client() == NULL) |
if (client() == NULL || m_iChannelID < 0) |
293 |
return false; |
return false; |
294 |
|
|
295 |
if (::lscp_set_channel_audio_device(client(), m_iChannelID, iAudioDevice) != LSCP_OK) { |
if (::lscp_set_channel_audio_device(client(), m_iChannelID, iAudioDevice) != LSCP_OK) { |
310 |
|
|
311 |
bool qsamplerChannel::setAudioDriver ( const QString& sAudioDriver ) |
bool qsamplerChannel::setAudioDriver ( const QString& sAudioDriver ) |
312 |
{ |
{ |
313 |
if (client() == NULL) |
if (client() == NULL || m_iChannelID < 0) |
314 |
return false; |
return false; |
315 |
|
|
316 |
if (::lscp_set_channel_audio_type(client(), m_iChannelID, sAudioDriver.latin1()) != LSCP_OK) { |
if (::lscp_set_channel_audio_type(client(), m_iChannelID, sAudioDriver.latin1()) != LSCP_OK) { |
331 |
|
|
332 |
bool qsamplerChannel::setVolume ( float fVolume ) |
bool qsamplerChannel::setVolume ( float fVolume ) |
333 |
{ |
{ |
334 |
if (client() == NULL) |
if (client() == NULL || m_iChannelID < 0) |
335 |
return false; |
return false; |
336 |
|
|
337 |
if (::lscp_set_channel_volume(client(), m_iChannelID, fVolume) != LSCP_OK) { |
if (::lscp_set_channel_volume(client(), m_iChannelID, fVolume) != LSCP_OK) { |
345 |
|
|
346 |
|
|
347 |
// Update whole channel info state. |
// Update whole channel info state. |
348 |
void qsamplerChannel::updateChannelInfo (void) |
bool qsamplerChannel::updateChannelInfo (void) |
349 |
{ |
{ |
350 |
// Check if we're up and connected. |
if (client() == NULL || m_iChannelID < 0) |
351 |
if (client() == NULL) |
return false; |
|
return; |
|
352 |
|
|
353 |
// Read channel information. |
// Read channel information. |
354 |
lscp_channel_info_t *pChannelInfo = ::lscp_get_channel_info(client(), m_iChannelID); |
lscp_channel_info_t *pChannelInfo = ::lscp_get_channel_info(client(), m_iChannelID); |
355 |
if (pChannelInfo == NULL) { |
if (pChannelInfo == NULL) { |
356 |
appendMessagesClient("lscp_get_channel_info"); |
appendMessagesClient("lscp_get_channel_info"); |
357 |
appendMessagesError(QObject::tr("Could not get channel information.\n\nSorry.")); |
appendMessagesError(QObject::tr("Could not get channel information.\n\nSorry.")); |
358 |
} else { |
return false; |
|
// Cache in channel information. |
|
|
m_sEngineName = pChannelInfo->engine_name; |
|
|
m_sInstrumentFile = pChannelInfo->instrument_file; |
|
|
m_iInstrumentNr = pChannelInfo->instrument_nr; |
|
|
m_iInstrumentStatus = pChannelInfo->instrument_status; |
|
|
m_iMidiDevice = pChannelInfo->midi_device; |
|
|
m_iMidiPort = pChannelInfo->midi_port; |
|
|
m_iMidiChannel = pChannelInfo->midi_channel; |
|
|
m_iAudioDevice = pChannelInfo->audio_device; |
|
|
m_fVolume = pChannelInfo->volume; |
|
|
// Some sanity checks. |
|
|
if (m_sEngineName == "NONE") |
|
|
m_sEngineName = QString::null; |
|
|
if (m_sInstrumentFile == "NONE") |
|
|
m_sInstrumentFile = QString::null; |
|
359 |
} |
} |
360 |
|
|
361 |
|
// Cache in channel information. |
362 |
|
m_sEngineName = pChannelInfo->engine_name; |
363 |
|
m_sInstrumentFile = pChannelInfo->instrument_file; |
364 |
|
m_iInstrumentNr = pChannelInfo->instrument_nr; |
365 |
|
m_iInstrumentStatus = pChannelInfo->instrument_status; |
366 |
|
m_iMidiDevice = pChannelInfo->midi_device; |
367 |
|
m_iMidiPort = pChannelInfo->midi_port; |
368 |
|
m_iMidiChannel = pChannelInfo->midi_channel; |
369 |
|
m_iAudioDevice = pChannelInfo->audio_device; |
370 |
|
m_fVolume = pChannelInfo->volume; |
371 |
|
// Some sanity checks. |
372 |
|
if (m_sEngineName == "NONE") |
373 |
|
m_sEngineName = QString::null; |
374 |
|
if (m_sInstrumentFile == "NONE") |
375 |
|
m_sInstrumentFile = QString::null; |
376 |
|
|
377 |
|
return true; |
378 |
} |
} |
379 |
|
|
380 |
|
|
381 |
// Reset channel method. |
// Reset channel method. |
382 |
void qsamplerChannel::resetChannel (void) |
bool qsamplerChannel::resetChannel (void) |
383 |
{ |
{ |
384 |
// Check if we're up and connected. |
if (client() == NULL || m_iChannelID < 0) |
385 |
if (client() == NULL) |
return false; |
|
return; |
|
386 |
|
|
387 |
if (::lscp_reset_channel(client(), m_iChannelID) != LSCP_OK) |
if (::lscp_reset_channel(client(), m_iChannelID) != LSCP_OK) { |
388 |
appendMessagesClient("lscp_reset_channel"); |
appendMessagesClient("lscp_reset_channel"); |
389 |
else |
return false; |
390 |
appendMessages(QObject::tr("Channel %1 reset.").arg(m_iChannelID)); |
} |
391 |
|
|
392 |
|
appendMessages(QObject::tr("Channel %1 reset.").arg(m_iChannelID)); |
393 |
|
return true; |
394 |
} |
} |
395 |
|
|
396 |
|
|