497 |
* sampler channel. |
* sampler channel. |
498 |
*/ |
*/ |
499 |
String LSCPServer::SetEngineType(String EngineName, uint uiSamplerChannel) { |
String LSCPServer::SetEngineType(String EngineName, uint uiSamplerChannel) { |
500 |
dmsg(2,("LSCPServer: LoadEngine(EngineName=%s,SamplerChannel=%d)\n", EngineName.c_str(), uiSamplerChannel)); |
dmsg(2,("LSCPServer: SetEngineType(EngineName=%s,uiSamplerChannel=%d)\n", EngineName.c_str(), uiSamplerChannel)); |
501 |
LSCPResultSet result; |
LSCPResultSet result; |
502 |
try { |
try { |
503 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
504 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
505 |
LockRTNotify(); |
LockRTNotify(); |
506 |
pSamplerChannel->SetEngineType(EngineName); |
pSamplerChannel->SetEngineType(EngineName); |
507 |
|
if(HasSoloChannel()) pSamplerChannel->GetEngineChannel()->SetMute(-1); |
508 |
UnlockRTNotify(); |
UnlockRTNotify(); |
509 |
} |
} |
510 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
620 |
int InstrumentStatus = -1; |
int InstrumentStatus = -1; |
621 |
int AudioOutputChannels = 0; |
int AudioOutputChannels = 0; |
622 |
String AudioRouting; |
String AudioRouting; |
623 |
|
int Mute = 0; |
624 |
|
bool Solo = false; |
625 |
|
|
626 |
if (pEngineChannel) { |
if (pEngineChannel) { |
627 |
EngineName = pEngineChannel->EngineName(); |
EngineName = pEngineChannel->EngineName(); |
637 |
if (AudioRouting != "") AudioRouting += ","; |
if (AudioRouting != "") AudioRouting += ","; |
638 |
AudioRouting += ToString(pEngineChannel->OutputChannel(chan)); |
AudioRouting += ToString(pEngineChannel->OutputChannel(chan)); |
639 |
} |
} |
640 |
|
Mute = pEngineChannel->GetMute(); |
641 |
|
Solo = pEngineChannel->GetSolo(); |
642 |
} |
} |
643 |
|
|
644 |
result.Add("ENGINE_NAME", EngineName); |
result.Add("ENGINE_NAME", EngineName); |
658 |
result.Add("INSTRUMENT_NR", InstrumentIndex); |
result.Add("INSTRUMENT_NR", InstrumentIndex); |
659 |
result.Add("INSTRUMENT_NAME", InstrumentName); |
result.Add("INSTRUMENT_NAME", InstrumentName); |
660 |
result.Add("INSTRUMENT_STATUS", InstrumentStatus); |
result.Add("INSTRUMENT_STATUS", InstrumentStatus); |
661 |
|
result.Add("MUTE", Mute == -1 ? "MUTED_BY_SOLO" : (Mute ? "true" : "false")); |
662 |
|
result.Add("SOLO", Solo); |
663 |
} |
} |
664 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
665 |
result.Error(e); |
result.Error(e); |
1403 |
} |
} |
1404 |
|
|
1405 |
/** |
/** |
1406 |
|
* Will be called by the parser to mute/unmute particular sampler channel. |
1407 |
|
*/ |
1408 |
|
String LSCPServer::SetChannelMute(bool bMute, uint uiSamplerChannel) { |
1409 |
|
dmsg(2,("LSCPServer: SetChannelMute(bMute=%d,uiSamplerChannel=%d)\n",bMute,uiSamplerChannel)); |
1410 |
|
LSCPResultSet result; |
1411 |
|
try { |
1412 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1413 |
|
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1414 |
|
|
1415 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1416 |
|
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel"); |
1417 |
|
|
1418 |
|
if(!bMute) pEngineChannel->SetMute((HasSoloChannel() && !pEngineChannel->GetSolo()) ? -1 : 0); |
1419 |
|
else pEngineChannel->SetMute(1); |
1420 |
|
} catch (LinuxSamplerException e) { |
1421 |
|
result.Error(e); |
1422 |
|
} |
1423 |
|
return result.Produce(); |
1424 |
|
} |
1425 |
|
|
1426 |
|
/** |
1427 |
|
* Will be called by the parser to solo particular sampler channel. |
1428 |
|
*/ |
1429 |
|
String LSCPServer::SetChannelSolo(bool bSolo, uint uiSamplerChannel) { |
1430 |
|
dmsg(2,("LSCPServer: SetChannelSolo(bSolo=%d,uiSamplerChannel=%d)\n",bSolo,uiSamplerChannel)); |
1431 |
|
LSCPResultSet result; |
1432 |
|
try { |
1433 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1434 |
|
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1435 |
|
|
1436 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1437 |
|
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel"); |
1438 |
|
|
1439 |
|
bool oldSolo = pEngineChannel->GetSolo(); |
1440 |
|
bool hadSoloChannel = HasSoloChannel(); |
1441 |
|
|
1442 |
|
pEngineChannel->SetSolo(bSolo); |
1443 |
|
|
1444 |
|
if(!oldSolo && bSolo) { |
1445 |
|
if(pEngineChannel->GetMute() == -1) pEngineChannel->SetMute(0); |
1446 |
|
if(!hadSoloChannel) MuteNonSoloChannels(); |
1447 |
|
} |
1448 |
|
|
1449 |
|
if(oldSolo && !bSolo) { |
1450 |
|
if(!HasSoloChannel()) UnmuteChannels(); |
1451 |
|
else if(!pEngineChannel->GetMute()) pEngineChannel->SetMute(-1); |
1452 |
|
} |
1453 |
|
} catch (LinuxSamplerException e) { |
1454 |
|
result.Error(e); |
1455 |
|
} |
1456 |
|
return result.Produce(); |
1457 |
|
} |
1458 |
|
|
1459 |
|
/** |
1460 |
|
* Determines whether there is at least one solo channel in the channel list. |
1461 |
|
* |
1462 |
|
* @returns true if there is at least one solo channel in the channel list, |
1463 |
|
* false otherwise. |
1464 |
|
*/ |
1465 |
|
bool LSCPServer::HasSoloChannel() { |
1466 |
|
std::map<uint,SamplerChannel*> channels = pSampler->GetSamplerChannels(); |
1467 |
|
std::map<uint,SamplerChannel*>::iterator iter = channels.begin(); |
1468 |
|
for (; iter != channels.end(); iter++) { |
1469 |
|
EngineChannel* c = iter->second->GetEngineChannel(); |
1470 |
|
if(c && c->GetSolo()) return true; |
1471 |
|
} |
1472 |
|
|
1473 |
|
return false; |
1474 |
|
} |
1475 |
|
|
1476 |
|
/** |
1477 |
|
* Mutes all unmuted non-solo channels. Notice that the channels are muted |
1478 |
|
* with -1 which indicates that they are muted because of the presence |
1479 |
|
* of a solo channel(s). Channels muted with -1 will be automatically unmuted |
1480 |
|
* when there are no solo channels left. |
1481 |
|
*/ |
1482 |
|
void LSCPServer::MuteNonSoloChannels() { |
1483 |
|
dmsg(2,("LSCPServer: MuteNonSoloChannels()\n")); |
1484 |
|
std::map<uint,SamplerChannel*> channels = pSampler->GetSamplerChannels(); |
1485 |
|
std::map<uint,SamplerChannel*>::iterator iter = channels.begin(); |
1486 |
|
for (; iter != channels.end(); iter++) { |
1487 |
|
EngineChannel* c = iter->second->GetEngineChannel(); |
1488 |
|
if(c && !c->GetSolo() && !c->GetMute()) c->SetMute(-1); |
1489 |
|
} |
1490 |
|
} |
1491 |
|
|
1492 |
|
/** |
1493 |
|
* Unmutes all channels that are muted because of the presence |
1494 |
|
* of a solo channel(s). |
1495 |
|
*/ |
1496 |
|
void LSCPServer::UnmuteChannels() { |
1497 |
|
dmsg(2,("LSCPServer: UnmuteChannels()\n")); |
1498 |
|
std::map<uint,SamplerChannel*> channels = pSampler->GetSamplerChannels(); |
1499 |
|
std::map<uint,SamplerChannel*>::iterator iter = channels.begin(); |
1500 |
|
for (; iter != channels.end(); iter++) { |
1501 |
|
EngineChannel* c = iter->second->GetEngineChannel(); |
1502 |
|
if(c && c->GetMute() == -1) c->SetMute(0); |
1503 |
|
} |
1504 |
|
} |
1505 |
|
|
1506 |
|
/** |
1507 |
* Will be called by the parser to reset a particular sampler channel. |
* Will be called by the parser to reset a particular sampler channel. |
1508 |
*/ |
*/ |
1509 |
String LSCPServer::ResetChannel(uint uiSamplerChannel) { |
String LSCPServer::ResetChannel(uint uiSamplerChannel) { |