43 |
#include "../engines/EngineChannelFactory.h" |
#include "../engines/EngineChannelFactory.h" |
44 |
#include "../drivers/audio/AudioOutputDeviceFactory.h" |
#include "../drivers/audio/AudioOutputDeviceFactory.h" |
45 |
#include "../drivers/midi/MidiInputDeviceFactory.h" |
#include "../drivers/midi/MidiInputDeviceFactory.h" |
46 |
|
#include "../effects/EffectFactory.h" |
47 |
|
|
48 |
namespace LinuxSampler { |
namespace LinuxSampler { |
49 |
|
|
2447 |
} catch (Exception e) { |
} catch (Exception e) { |
2448 |
result.Error(e); |
result.Error(e); |
2449 |
} |
} |
2450 |
|
return result.Produce(); |
2451 |
|
} |
2452 |
|
|
2453 |
|
String LSCPServer::GetAvailableEffects() { |
2454 |
|
dmsg(2,("LSCPServer: GetAvailableEffects()\n")); |
2455 |
|
LSCPResultSet result; |
2456 |
|
try { |
2457 |
|
int n = EffectFactory::AvailableEffectsCount(); |
2458 |
|
result.Add(n); |
2459 |
|
} |
2460 |
|
catch (Exception e) { |
2461 |
|
result.Error(e); |
2462 |
|
} |
2463 |
|
return result.Produce(); |
2464 |
|
} |
2465 |
|
|
2466 |
|
String LSCPServer::ListAvailableEffects() { |
2467 |
|
dmsg(2,("LSCPServer: ListAvailableEffects()\n")); |
2468 |
|
LSCPResultSet result; |
2469 |
|
String list; |
2470 |
|
try { |
2471 |
|
//FIXME: for now we simply enumerate from 0 .. EffectFactory::AvailableEffectsCount() here, in future we should use unique IDs for effects during the whole sampler session. This issue comes into game when the user forces a reload of available effect plugins |
2472 |
|
int n = EffectFactory::AvailableEffectsCount(); |
2473 |
|
for (int i = 0; i < n; i++) { |
2474 |
|
if (i) list += ","; |
2475 |
|
list += ToString(i); |
2476 |
|
} |
2477 |
|
} |
2478 |
|
catch (Exception e) { |
2479 |
|
result.Error(e); |
2480 |
|
} |
2481 |
|
result.Add(list); |
2482 |
|
return result.Produce(); |
2483 |
|
} |
2484 |
|
|
2485 |
|
String LSCPServer::GetEffectInfo(int iEffectIndex) { |
2486 |
|
dmsg(2,("LSCPServer: GetEffectInfo(%d)\n", iEffectIndex)); |
2487 |
|
LSCPResultSet result; |
2488 |
|
try { |
2489 |
|
EffectInfo* pEffectInfo = EffectFactory::GetEffectInfo(iEffectIndex); |
2490 |
|
if (!pEffectInfo) |
2491 |
|
throw Exception("There is no effect with index " + ToString(iEffectIndex)); |
2492 |
|
|
2493 |
|
// convert the filename into the correct encoding as defined for LSCP |
2494 |
|
// (especially in terms of special characters -> escape sequences) |
2495 |
|
#if WIN32 |
2496 |
|
const String dllFileName = Path::fromWindows(pEffectInfo->Module()).toLscp(); |
2497 |
|
#else |
2498 |
|
// assuming POSIX |
2499 |
|
const String dllFileName = Path::fromPosix(pEffectInfo->Module()).toLscp(); |
2500 |
|
#endif |
2501 |
|
|
2502 |
|
result.Add("SYSTEM", pEffectInfo->EffectSystem()); |
2503 |
|
result.Add("MODULE", dllFileName); |
2504 |
|
result.Add("NAME", _escapeLscpResponse(pEffectInfo->Name())); |
2505 |
|
result.Add("DESCRIPTION", _escapeLscpResponse(pEffectInfo->Description())); |
2506 |
|
} |
2507 |
|
catch (Exception e) { |
2508 |
|
result.Error(e); |
2509 |
|
} |
2510 |
|
return result.Produce(); |
2511 |
|
} |
2512 |
|
|
2513 |
|
String LSCPServer::GetEffectInstanceInfo(int iEffectInstanceIndex) { |
2514 |
|
dmsg(2,("LSCPServer: GetEffectInstanceInfo(%d)\n", iEffectInstanceIndex)); |
2515 |
|
LSCPResultSet result; |
2516 |
|
try { |
2517 |
|
Effect* pEffect = EffectFactory::GetEffectInstanceByID(iEffectInstanceIndex); |
2518 |
|
if (!pEffect) |
2519 |
|
throw Exception("There is no effect instance with index " + ToString(iEffectInstanceIndex)); |
2520 |
|
|
2521 |
|
EffectInfo* pEffectInfo = pEffect->GetEffectInfo(); |
2522 |
|
|
2523 |
|
// convert the filename into the correct encoding as defined for LSCP |
2524 |
|
// (especially in terms of special characters -> escape sequences) |
2525 |
|
#if WIN32 |
2526 |
|
const String dllFileName = Path::fromWindows(pEffectInfo->Module()).toLscp(); |
2527 |
|
#else |
2528 |
|
// assuming POSIX |
2529 |
|
const String dllFileName = Path::fromPosix(pEffectInfo->Module()).toLscp(); |
2530 |
|
#endif |
2531 |
|
|
2532 |
|
result.Add("SYSTEM", pEffectInfo->EffectSystem()); |
2533 |
|
result.Add("MODULE", dllFileName); |
2534 |
|
result.Add("NAME", _escapeLscpResponse(pEffectInfo->Name())); |
2535 |
|
result.Add("DESCRIPTION", _escapeLscpResponse(pEffectInfo->Description())); |
2536 |
|
result.Add("INPUT_CONTROLS", ToString(pEffect->InputControlCount())); |
2537 |
|
} |
2538 |
|
catch (Exception e) { |
2539 |
|
result.Error(e); |
2540 |
|
} |
2541 |
|
return result.Produce(); |
2542 |
|
} |
2543 |
|
|
2544 |
|
String LSCPServer::GetEffectInstanceInputControlInfo(int iEffectInstanceIndex, int iInputControlIndex) { |
2545 |
|
dmsg(2,("LSCPServer: GetEffectInstanceInputControlInfo(%d,%d)\n", iEffectInstanceIndex, iInputControlIndex)); |
2546 |
|
LSCPResultSet result; |
2547 |
|
try { |
2548 |
|
Effect* pEffect = EffectFactory::GetEffectInstanceByID(iEffectInstanceIndex); |
2549 |
|
if (!pEffect) |
2550 |
|
throw Exception("There is no effect instance with index " + ToString(iEffectInstanceIndex)); |
2551 |
|
|
2552 |
|
EffectControl* pEffectControl = pEffect->InputControl(iInputControlIndex); |
2553 |
|
if (!pEffectControl) |
2554 |
|
throw Exception( |
2555 |
|
"Effect instance " + ToString(iEffectInstanceIndex) + |
2556 |
|
" does not have an input control with index " + |
2557 |
|
ToString(iInputControlIndex) |
2558 |
|
); |
2559 |
|
|
2560 |
|
result.Add("DESCRIPTION", _escapeLscpResponse(pEffectControl->Description())); |
2561 |
|
result.Add("VALUE", pEffectControl->Value()); |
2562 |
|
if (pEffectControl->MinValue()) |
2563 |
|
result.Add("RANGE_MIN", *pEffectControl->MinValue()); |
2564 |
|
if (pEffectControl->MaxValue()) |
2565 |
|
result.Add("RANGE_MAX", *pEffectControl->MaxValue()); |
2566 |
|
if (!pEffectControl->Possibilities().empty()) |
2567 |
|
result.Add("POSSIBILITIES", pEffectControl->Possibilities()); |
2568 |
|
if (pEffectControl->DefaultValue()) |
2569 |
|
result.Add("DEFAULT", *pEffectControl->DefaultValue()); |
2570 |
|
} catch (Exception e) { |
2571 |
|
result.Error(e); |
2572 |
|
} |
2573 |
|
return result.Produce(); |
2574 |
|
} |
2575 |
|
|
2576 |
|
String LSCPServer::SetEffectInstanceInputControl(int iEffectInstanceIndex, int iInputControlIndex, double dValue) { |
2577 |
|
dmsg(2,("LSCPServer: SetEffectInstanceInputControl(%d,%d,%f)\n", iEffectInstanceIndex, iInputControlIndex, dValue)); |
2578 |
|
LSCPResultSet result; |
2579 |
|
try { |
2580 |
|
Effect* pEffect = EffectFactory::GetEffectInstanceByID(iEffectInstanceIndex); |
2581 |
|
if (!pEffect) |
2582 |
|
throw Exception("There is no effect instance with index " + ToString(iEffectInstanceIndex)); |
2583 |
|
|
2584 |
|
EffectControl* pEffectControl = pEffect->InputControl(iInputControlIndex); |
2585 |
|
if (!pEffectControl) |
2586 |
|
throw Exception( |
2587 |
|
"Effect instance " + ToString(iEffectInstanceIndex) + |
2588 |
|
" does not have an input control with index " + |
2589 |
|
ToString(iInputControlIndex) |
2590 |
|
); |
2591 |
|
|
2592 |
|
pEffectControl->SetValue(dValue); |
2593 |
|
} catch (Exception e) { |
2594 |
|
result.Error(e); |
2595 |
|
} |
2596 |
|
return result.Produce(); |
2597 |
|
} |
2598 |
|
|
2599 |
|
String LSCPServer::CreateEffectInstance(int index) { |
2600 |
|
dmsg(2,("LSCPServer: CreateEffectInstance()\n")); |
2601 |
|
LSCPResultSet result; |
2602 |
|
try { |
2603 |
|
EffectInfo* pEffectInfo = EffectFactory::GetEffectInfo(index); |
2604 |
|
if (!pEffectInfo) |
2605 |
|
throw Exception("There is no effect with index " + ToString(index)); |
2606 |
|
Effect* pEffect = EffectFactory::Create(pEffectInfo); |
2607 |
|
result.Add(pEffect->ID()); |
2608 |
|
} catch (Exception e) { |
2609 |
|
result.Error(e); |
2610 |
|
} |
2611 |
|
return result.Produce(); |
2612 |
|
} |
2613 |
|
|
2614 |
|
String LSCPServer::CreateEffectInstance(String effectSystem, String module, String effectName) { |
2615 |
|
dmsg(2,("LSCPServer: CreateEffectInstance()\n")); |
2616 |
|
LSCPResultSet result; |
2617 |
|
try { |
2618 |
|
// to allow loading the same LSCP session file on different systems |
2619 |
|
// successfully, probably with different effect plugin DLL paths or even |
2620 |
|
// running completely different operating systems, we do the following |
2621 |
|
// for finding the right effect: |
2622 |
|
// |
2623 |
|
// first try to search for an exact match of the effect plugin DLL |
2624 |
|
// (a.k.a 'module'), to avoid picking the wrong DLL with the same |
2625 |
|
// effect name ... |
2626 |
|
EffectInfo* pEffectInfo = EffectFactory::GetEffectInfo(effectSystem, module, effectName, EffectFactory::MODULE_MATCH_EXACTLY); |
2627 |
|
// ... if no effect with exactly matchin DLL filename was found, then |
2628 |
|
// try to lower the restrictions of matching the effect plugin DLL |
2629 |
|
// filename and try again and again ... |
2630 |
|
if (!pEffectInfo) { |
2631 |
|
dmsg(2,("no exact module match, trying MODULE_IGNORE_PATH\n")); |
2632 |
|
pEffectInfo = EffectFactory::GetEffectInfo(effectSystem, module, effectName, EffectFactory::MODULE_IGNORE_PATH); |
2633 |
|
} |
2634 |
|
if (!pEffectInfo) { |
2635 |
|
dmsg(2,("no module match, trying MODULE_IGNORE_PATH | MODULE_IGNORE_CASE\n")); |
2636 |
|
pEffectInfo = EffectFactory::GetEffectInfo(effectSystem, module, effectName, EffectFactory::MODULE_IGNORE_PATH | EffectFactory::MODULE_IGNORE_CASE); |
2637 |
|
} |
2638 |
|
if (!pEffectInfo) { |
2639 |
|
dmsg(2,("no module match, trying MODULE_IGNORE_PATH | MODULE_IGNORE_CASE | MODULE_IGNORE_EXTENSION\n")); |
2640 |
|
pEffectInfo = EffectFactory::GetEffectInfo(effectSystem, module, effectName, EffectFactory::MODULE_IGNORE_PATH | EffectFactory::MODULE_IGNORE_CASE | EffectFactory::MODULE_IGNORE_EXTENSION); |
2641 |
|
} |
2642 |
|
// ... if there was still no effect found, then completely ignore the |
2643 |
|
// DLL plugin filename argument and just search for the matching effect |
2644 |
|
// system type and effect name |
2645 |
|
if (!pEffectInfo) { |
2646 |
|
dmsg(2,("no module match, trying MODULE_IGNORE_ALL\n")); |
2647 |
|
pEffectInfo = EffectFactory::GetEffectInfo(effectSystem, module, effectName, EffectFactory::MODULE_IGNORE_ALL); |
2648 |
|
} |
2649 |
|
if (!pEffectInfo) |
2650 |
|
throw Exception("There is no such effect '" + effectSystem + "' '" + module + "' '" + effectName + "'"); |
2651 |
|
|
2652 |
|
Effect* pEffect = EffectFactory::Create(pEffectInfo); |
2653 |
|
result = LSCPResultSet(pEffect->ID()); |
2654 |
|
} catch (Exception e) { |
2655 |
|
result.Error(e); |
2656 |
|
} |
2657 |
|
return result.Produce(); |
2658 |
|
} |
2659 |
|
|
2660 |
|
String LSCPServer::DestroyEffectInstance(int iEffectID) { |
2661 |
|
dmsg(2,("LSCPServer: DestroyEffectInstance(%d)\n", iEffectID)); |
2662 |
|
LSCPResultSet result; |
2663 |
|
try { |
2664 |
|
Effect* pEffect = EffectFactory::GetEffectInstanceByID(iEffectID); |
2665 |
|
if (!pEffect) |
2666 |
|
throw Exception("There is no effect instance with ID " + ToString(iEffectID)); |
2667 |
|
EffectFactory::Destroy(pEffect); |
2668 |
|
} catch (Exception e) { |
2669 |
|
result.Error(e); |
2670 |
|
} |
2671 |
|
return result.Produce(); |
2672 |
|
} |
2673 |
|
|
2674 |
|
String LSCPServer::GetEffectInstances() { |
2675 |
|
dmsg(2,("LSCPServer: GetEffectInstances()\n")); |
2676 |
|
LSCPResultSet result; |
2677 |
|
try { |
2678 |
|
int n = EffectFactory::EffectInstancesCount(); |
2679 |
|
result.Add(n); |
2680 |
|
} catch (Exception e) { |
2681 |
|
result.Error(e); |
2682 |
|
} |
2683 |
|
return result.Produce(); |
2684 |
|
} |
2685 |
|
|
2686 |
|
String LSCPServer::ListEffectInstances() { |
2687 |
|
dmsg(2,("LSCPServer: ListEffectInstances()\n")); |
2688 |
|
LSCPResultSet result; |
2689 |
|
String list; |
2690 |
|
try { |
2691 |
|
int n = EffectFactory::EffectInstancesCount(); |
2692 |
|
for (int i = 0; i < n; i++) { |
2693 |
|
Effect* pEffect = EffectFactory::GetEffectInstance(i); |
2694 |
|
if (i) list += ","; |
2695 |
|
list += ToString(pEffect->ID()); |
2696 |
|
} |
2697 |
|
} catch (Exception e) { |
2698 |
|
result.Error(e); |
2699 |
|
} |
2700 |
|
result.Add(list); |
2701 |
|
return result.Produce(); |
2702 |
|
} |
2703 |
|
|
2704 |
|
String LSCPServer::GetMasterEffectChains(int iAudioOutputDevice) { |
2705 |
|
dmsg(2,("LSCPServer: GetMasterEffectChains(%d)\n", iAudioOutputDevice)); |
2706 |
|
LSCPResultSet result; |
2707 |
|
try { |
2708 |
|
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
2709 |
|
if (!devices.count(iAudioOutputDevice)) |
2710 |
|
throw Exception("There is no audio output device with index " + ToString(iAudioOutputDevice) + "."); |
2711 |
|
AudioOutputDevice* pDevice = devices[iAudioOutputDevice]; |
2712 |
|
int n = pDevice->MasterEffectChainCount(); |
2713 |
|
result.Add(n); |
2714 |
|
} catch (Exception e) { |
2715 |
|
result.Error(e); |
2716 |
|
} |
2717 |
|
return result.Produce(); |
2718 |
|
} |
2719 |
|
|
2720 |
|
String LSCPServer::ListMasterEffectChains(int iAudioOutputDevice) { |
2721 |
|
dmsg(2,("LSCPServer: ListMasterEffectChains(%d)\n", iAudioOutputDevice)); |
2722 |
|
LSCPResultSet result; |
2723 |
|
String list; |
2724 |
|
try { |
2725 |
|
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
2726 |
|
if (!devices.count(iAudioOutputDevice)) |
2727 |
|
throw Exception("There is no audio output device with index " + ToString(iAudioOutputDevice) + "."); |
2728 |
|
AudioOutputDevice* pDevice = devices[iAudioOutputDevice]; |
2729 |
|
int n = pDevice->MasterEffectChainCount(); |
2730 |
|
for (int i = 0; i < n; i++) { |
2731 |
|
EffectChain* pEffectChain = pDevice->MasterEffectChain(i); |
2732 |
|
if (i) list += ","; |
2733 |
|
list += ToString(pEffectChain->ID()); |
2734 |
|
} |
2735 |
|
} catch (Exception e) { |
2736 |
|
result.Error(e); |
2737 |
|
} |
2738 |
|
result.Add(list); |
2739 |
|
return result.Produce(); |
2740 |
|
} |
2741 |
|
|
2742 |
|
String LSCPServer::AddMasterEffectChain(int iAudioOutputDevice) { |
2743 |
|
dmsg(2,("LSCPServer: AddMasterEffectChain(%d)\n", iAudioOutputDevice)); |
2744 |
|
LSCPResultSet result; |
2745 |
|
try { |
2746 |
|
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
2747 |
|
if (!devices.count(iAudioOutputDevice)) |
2748 |
|
throw Exception("There is no audio output device with index " + ToString(iAudioOutputDevice) + "."); |
2749 |
|
AudioOutputDevice* pDevice = devices[iAudioOutputDevice]; |
2750 |
|
EffectChain* pEffectChain = pDevice->AddMasterEffectChain(); |
2751 |
|
result.Add(pEffectChain->ID()); |
2752 |
|
} catch (Exception e) { |
2753 |
|
result.Error(e); |
2754 |
|
} |
2755 |
|
return result.Produce(); |
2756 |
|
} |
2757 |
|
|
2758 |
|
String LSCPServer::RemoveMasterEffectChain(int iAudioOutputDevice, int iMasterEffectChain) { |
2759 |
|
dmsg(2,("LSCPServer: RemoveMasterEffectChain(%d,%d)\n", iAudioOutputDevice, iMasterEffectChain)); |
2760 |
|
LSCPResultSet result; |
2761 |
|
try { |
2762 |
|
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
2763 |
|
if (!devices.count(iAudioOutputDevice)) |
2764 |
|
throw Exception("There is no audio output device with index " + ToString(iAudioOutputDevice) + "."); |
2765 |
|
AudioOutputDevice* pDevice = devices[iAudioOutputDevice]; |
2766 |
|
for (int i = 0; i < pDevice->MasterEffectChainCount(); i++) { |
2767 |
|
EffectChain* pEffectChain = pDevice->MasterEffectChain(i); |
2768 |
|
if (pEffectChain->ID() == iMasterEffectChain) { |
2769 |
|
pDevice->RemoveMasterEffectChain(i); |
2770 |
|
return result.Produce(); |
2771 |
|
} |
2772 |
|
} |
2773 |
|
throw Exception( |
2774 |
|
"There is no master effect chain with ID " + |
2775 |
|
ToString(iMasterEffectChain) + " for audio output device " + |
2776 |
|
ToString(iAudioOutputDevice) + "." |
2777 |
|
); |
2778 |
|
} catch (Exception e) { |
2779 |
|
result.Error(e); |
2780 |
|
} |
2781 |
|
return result.Produce(); |
2782 |
|
} |
2783 |
|
|
2784 |
|
static EffectChain* _getMasterEffectChain(Sampler* pSampler, int iAudioOutputDevice, int iMasterEffectChain) throw (Exception) { |
2785 |
|
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
2786 |
|
if (!devices.count(iAudioOutputDevice)) |
2787 |
|
throw Exception( |
2788 |
|
"There is no audio output device with index " + |
2789 |
|
ToString(iAudioOutputDevice) + "." |
2790 |
|
); |
2791 |
|
AudioOutputDevice* pDevice = devices[iAudioOutputDevice]; |
2792 |
|
for (int i = 0; i < pDevice->MasterEffectChainCount(); i++) { |
2793 |
|
EffectChain* pEffectChain = pDevice->MasterEffectChain(i); |
2794 |
|
if (pEffectChain->ID() == iMasterEffectChain) { |
2795 |
|
return pEffectChain; |
2796 |
|
} |
2797 |
|
} |
2798 |
|
throw Exception( |
2799 |
|
"There is no master effect chain with ID " + |
2800 |
|
ToString(iMasterEffectChain) + " for audio output device " + |
2801 |
|
ToString(iAudioOutputDevice) + "." |
2802 |
|
); |
2803 |
|
} |
2804 |
|
|
2805 |
|
String LSCPServer::GetMasterEffectChainInfo(int iAudioOutputDevice, int iMasterEffectChain) { |
2806 |
|
dmsg(2,("LSCPServer: GetMasterEffectChainInfo(%d,%d)\n", iAudioOutputDevice, iMasterEffectChain)); |
2807 |
|
LSCPResultSet result; |
2808 |
|
try { |
2809 |
|
EffectChain* pEffectChain = |
2810 |
|
_getMasterEffectChain(pSampler, iAudioOutputDevice, iMasterEffectChain); |
2811 |
|
String sEffectSequence; |
2812 |
|
for (int i = 0; i < pEffectChain->EffectCount(); i++) { |
2813 |
|
if (i) sEffectSequence += ","; |
2814 |
|
sEffectSequence += ToString(pEffectChain->GetEffect(i)->ID()); |
2815 |
|
} |
2816 |
|
result.Add("EFFECT_COUNT", pEffectChain->EffectCount()); |
2817 |
|
result.Add("EFFECT_SEQUENCE", sEffectSequence); |
2818 |
|
} catch (Exception e) { |
2819 |
|
result.Error(e); |
2820 |
|
} |
2821 |
|
return result.Produce(); |
2822 |
|
} |
2823 |
|
|
2824 |
|
String LSCPServer::AppendMasterEffectChainEffect(int iAudioOutputDevice, int iMasterEffectChain, int iEffectInstance) { |
2825 |
|
dmsg(2,("LSCPServer: AppendMasterEffectChainEffect(%d,%d,%d)\n", iAudioOutputDevice, iMasterEffectChain, iEffectInstance)); |
2826 |
|
LSCPResultSet result; |
2827 |
|
try { |
2828 |
|
EffectChain* pEffectChain = |
2829 |
|
_getMasterEffectChain(pSampler, iAudioOutputDevice, iMasterEffectChain); |
2830 |
|
Effect* pEffect = EffectFactory::GetEffectInstanceByID(iEffectInstance); |
2831 |
|
if (!pEffect) |
2832 |
|
throw Exception("There is no effect instance with index " + ToString(iEffectInstance)); |
2833 |
|
pEffectChain->AppendEffect(pEffect); |
2834 |
|
} catch (Exception e) { |
2835 |
|
result.Error(e); |
2836 |
|
} |
2837 |
|
return result.Produce(); |
2838 |
|
} |
2839 |
|
|
2840 |
|
String LSCPServer::InsertMasterEffectChainEffect(int iAudioOutputDevice, int iMasterEffectChain, int iEffectInstance, int iEffectChainPosition) { |
2841 |
|
dmsg(2,("LSCPServer: InsertMasterEffectChainEffect(%d,%d,%d,%d)\n", iAudioOutputDevice, iMasterEffectChain, iEffectInstance, iEffectChainPosition)); |
2842 |
|
LSCPResultSet result; |
2843 |
|
try { |
2844 |
|
EffectChain* pEffectChain = |
2845 |
|
_getMasterEffectChain(pSampler, iAudioOutputDevice, iMasterEffectChain); |
2846 |
|
Effect* pEffect = EffectFactory::GetEffectInstanceByID(iEffectInstance); |
2847 |
|
if (!pEffect) |
2848 |
|
throw Exception("There is no effect instance with index " + ToString(iEffectInstance)); |
2849 |
|
pEffectChain->InsertEffect(pEffect, iEffectChainPosition); |
2850 |
|
} catch (Exception e) { |
2851 |
|
result.Error(e); |
2852 |
|
} |
2853 |
|
return result.Produce(); |
2854 |
|
} |
2855 |
|
|
2856 |
|
String LSCPServer::RemoveMasterEffectChainEffect(int iAudioOutputDevice, int iMasterEffectChain, int iEffectInstance) { |
2857 |
|
dmsg(2,("LSCPServer: RemoveMasterEffectChainEffect(%d,%d,%d)\n", iAudioOutputDevice, iMasterEffectChain, iEffectInstance)); |
2858 |
|
LSCPResultSet result; |
2859 |
|
try { |
2860 |
|
EffectChain* pEffectChain = |
2861 |
|
_getMasterEffectChain(pSampler, iAudioOutputDevice, iMasterEffectChain); |
2862 |
|
for (int i = 0; i < pEffectChain->EffectCount(); i++) { |
2863 |
|
Effect* pEffect = pEffectChain->GetEffect(i); |
2864 |
|
if (pEffect->ID() == iEffectInstance) { |
2865 |
|
pEffectChain->RemoveEffect(i); |
2866 |
|
return result.Produce(); |
2867 |
|
} |
2868 |
|
} |
2869 |
|
throw Exception( |
2870 |
|
"There is no effect instance with index " + |
2871 |
|
ToString(iEffectInstance) |
2872 |
|
); |
2873 |
|
} catch (Exception e) { |
2874 |
|
result.Error(e); |
2875 |
|
} |
2876 |
return result.Produce(); |
return result.Produce(); |
2877 |
} |
} |
2878 |
|
|