37 |
|
|
38 |
// Channel status/usage usage limit control. |
// Channel status/usage usage limit control. |
39 |
#define QSAMPLER_ERROR_LIMIT 3 |
#define QSAMPLER_ERROR_LIMIT 3 |
|
#define QSAMPLER_ERROR_CYCLE 33 |
|
40 |
|
|
41 |
|
|
42 |
// Kind of constructor. |
// Kind of constructor. |
190 |
// Channel setup dialog slot. |
// Channel setup dialog slot. |
191 |
bool qsamplerChannelStrip::channelSetup (void) |
bool qsamplerChannelStrip::channelSetup (void) |
192 |
{ |
{ |
193 |
|
if (m_pChannel == NULL) |
194 |
|
return false; |
195 |
|
|
196 |
// Invoke the channel setup dialog. |
// Invoke the channel setup dialog. |
197 |
bool bResult = m_pChannel->channelSetup(this); |
bool bResult = m_pChannel->channelSetup(this); |
198 |
|
// Notify that thie channel has changed. |
199 |
|
if (bResult) |
200 |
|
emit channelChanged(this); |
201 |
|
|
202 |
|
return bResult; |
203 |
|
} |
204 |
|
|
205 |
|
|
206 |
if (bResult) { |
// Channel reset slot. |
207 |
// Reset the error/cycle. |
bool qsamplerChannelStrip::channelReset (void) |
208 |
m_iErrorCount = 0; |
{ |
209 |
// Notify that thie channel has changed. |
if (m_pChannel == NULL) |
210 |
|
return false; |
211 |
|
|
212 |
|
// Invoke the channel reset method. |
213 |
|
bool bResult = m_pChannel->channelReset(); |
214 |
|
// Notify that thie channel has changed. |
215 |
|
if (bResult) |
216 |
emit channelChanged(this); |
emit channelChanged(this); |
|
} |
|
217 |
|
|
218 |
return bResult; |
return bResult; |
219 |
} |
} |
239 |
} |
} |
240 |
|
|
241 |
|
|
242 |
|
// Do the dirty volume change. |
243 |
|
bool qsamplerChannelStrip::updateChannelVolume (void) |
244 |
|
{ |
245 |
|
if (m_pChannel == NULL) |
246 |
|
return false; |
247 |
|
|
248 |
|
// Convert... |
249 |
|
#ifdef CONFIG_ROUND |
250 |
|
int iVolume = (int) ::round(100.0 * m_pChannel->volume()); |
251 |
|
#else |
252 |
|
double fIPart = 0.0; |
253 |
|
double fFPart = ::modf(100.0 * m_pChannel->volume(), &fIPart); |
254 |
|
int iVolume = (int) fIPart; |
255 |
|
if (fFPart >= +0.5) |
256 |
|
iVolume++; |
257 |
|
else |
258 |
|
if (fFPart <= -0.5) |
259 |
|
iVolume--; |
260 |
|
#endif |
261 |
|
|
262 |
|
// And clip... |
263 |
|
if (iVolume < 0) |
264 |
|
iVolume = 0; |
265 |
|
|
266 |
|
// Flag it here, to avoid infinite recursion. |
267 |
|
m_iDirtyChange++; |
268 |
|
VolumeSlider->setValue(iVolume); |
269 |
|
VolumeSpinBox->setValue(iVolume); |
270 |
|
m_iDirtyChange--; |
271 |
|
|
272 |
|
return true; |
273 |
|
} |
274 |
|
|
275 |
|
|
276 |
// Update whole channel info state. |
// Update whole channel info state. |
277 |
bool qsamplerChannelStrip::updateChannelInfo (void) |
bool qsamplerChannelStrip::updateChannelInfo (void) |
278 |
{ |
{ |
279 |
if (m_pChannel == NULL) |
if (m_pChannel == NULL) |
280 |
return false; |
return false; |
281 |
|
|
282 |
|
// Check for error limit/recycle... |
283 |
|
if (m_iErrorCount > QSAMPLER_ERROR_LIMIT) |
284 |
|
return true; |
285 |
|
|
286 |
// Update strip caption. |
// Update strip caption. |
287 |
QString sText = m_pChannel->channelName(); |
QString sText = m_pChannel->channelName(); |
288 |
setCaption(sText); |
setCaption(sText); |
304 |
// Instrument name... |
// Instrument name... |
305 |
updateInstrumentName(false); |
updateInstrumentName(false); |
306 |
|
|
|
// Instrument status... |
|
|
int iInstrumentStatus = m_pChannel->instrumentStatus(); |
|
|
if (iInstrumentStatus < 0) { |
|
|
InstrumentStatusTextLabel->setPaletteForegroundColor(Qt::red); |
|
|
InstrumentStatusTextLabel->setText(tr("ERR%1").arg(iInstrumentStatus)); |
|
|
} else { |
|
|
InstrumentStatusTextLabel->setPaletteForegroundColor(iInstrumentStatus < 100 ? Qt::yellow : Qt::green); |
|
|
InstrumentStatusTextLabel->setText(QString::number(iInstrumentStatus) + "%"); |
|
|
} |
|
|
|
|
307 |
// MIDI Port/Channel... |
// MIDI Port/Channel... |
308 |
if (m_pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL) |
if (m_pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL) |
309 |
MidiPortChannelTextLabel->setText(QString("%1 / *").arg(m_pChannel->midiPort())); |
MidiPortChannelTextLabel->setText(QString("%1 / *").arg(m_pChannel->midiPort())); |
310 |
else |
else |
311 |
MidiPortChannelTextLabel->setText(QString("%1 / %2").arg(m_pChannel->midiPort()).arg(m_pChannel->midiChannel() + 1)); |
MidiPortChannelTextLabel->setText(QString("%1 / %2").arg(m_pChannel->midiPort()).arg(m_pChannel->midiChannel() + 1)); |
312 |
|
|
313 |
// And update the both GUI volume elements. |
// Instrument status... |
314 |
return updateChannelVolume(); |
int iInstrumentStatus = m_pChannel->instrumentStatus(); |
315 |
} |
if (iInstrumentStatus < 0) { |
316 |
|
InstrumentStatusTextLabel->setPaletteForegroundColor(Qt::red); |
317 |
|
InstrumentStatusTextLabel->setText(tr("ERR%1").arg(iInstrumentStatus)); |
318 |
// Do the dirty volume change. |
m_iErrorCount++; |
|
bool qsamplerChannelStrip::updateChannelVolume (void) |
|
|
{ |
|
|
if (m_pChannel == NULL) |
|
319 |
return false; |
return false; |
320 |
|
} |
321 |
// Convert... |
// All seems normal... |
322 |
#ifdef CONFIG_ROUND |
InstrumentStatusTextLabel->setPaletteForegroundColor(iInstrumentStatus < 100 ? Qt::yellow : Qt::green); |
323 |
int iVolume = (int) ::round(100.0 * m_pChannel->volume()); |
InstrumentStatusTextLabel->setText(QString::number(iInstrumentStatus) + '%'); |
324 |
#else |
m_iErrorCount = 0; |
325 |
double fIPart = 0.0; |
|
326 |
double fFPart = ::modf(100.0 * m_pChannel->volume(), &fIPart); |
// And update the both GUI volume elements; |
327 |
int iVolume = (int) fIPart; |
// return success if, and only if, intrument is fully loaded... |
328 |
if (fFPart >= +0.5) |
return updateChannelVolume() && (iInstrumentStatus == 100); |
|
iVolume++; |
|
|
else |
|
|
if (fFPart <= -0.5) |
|
|
iVolume--; |
|
|
#endif |
|
|
|
|
|
// And clip... |
|
|
if (iVolume < 0) |
|
|
iVolume = 0; |
|
|
|
|
|
// Flag it here, to avoid infinite recursion. |
|
|
m_iDirtyChange++; |
|
|
VolumeSlider->setValue(iVolume); |
|
|
VolumeSpinBox->setValue(iVolume); |
|
|
m_iDirtyChange--; |
|
|
|
|
|
return true; |
|
329 |
} |
} |
330 |
|
|
331 |
|
|
337 |
if (m_pChannel->client() == NULL) |
if (m_pChannel->client() == NULL) |
338 |
return false; |
return false; |
339 |
|
|
340 |
// Check for error limit/recycle... |
// This only makes sense on fully loaded channels... |
341 |
if (m_iErrorCount > QSAMPLER_ERROR_LIMIT) |
if (m_pChannel->instrumentStatus() < 100) |
342 |
m_iErrorCount -= QSAMPLER_ERROR_CYCLE; |
return false; |
343 |
if (m_iErrorCount < 0) { |
|
|
m_iErrorCount++; |
|
|
return false; |
|
|
} |
|
|
|
|
|
// Update whole channel status info, |
|
|
// if instrument load is still pending... |
|
|
if (m_pChannel->instrumentStatus() < 100) { |
|
|
// grab the whole sampler channel data... |
|
|
updateChannelInfo(); |
|
|
// Check (updated) status again... |
|
|
int iInstrumentStatus = m_pChannel->instrumentStatus(); |
|
|
if (iInstrumentStatus < 100) { |
|
|
if (iInstrumentStatus < 0) |
|
|
m_iErrorCount++; |
|
|
return false; |
|
|
} |
|
|
// Once we get a complete instrument load, |
|
|
// we'll try an implied channel reset... |
|
|
m_pChannel->resetChannel(); |
|
|
// Reset error count. |
|
|
m_iErrorCount = 0; |
|
|
} |
|
|
|
|
344 |
// Get current channel voice count. |
// Get current channel voice count. |
345 |
int iVoiceCount = ::lscp_get_channel_voice_count(m_pChannel->client(), m_pChannel->channelID()); |
int iVoiceCount = ::lscp_get_channel_voice_count(m_pChannel->client(), m_pChannel->channelID()); |
346 |
// Get current stream count. |
// Get current stream count. |