3 |
* LinuxSampler - modular, streaming capable sampler * |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
* Copyright (C) 2005 - 2009 Christian Schoenebeck * |
* Copyright (C) 2005 - 2010 Christian Schoenebeck * |
7 |
* * |
* * |
8 |
* This library is free software; you can redistribute it and/or modify * |
* This library is free software; you can redistribute it and/or modify * |
9 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
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 |
|
|
2383 |
AudioRouting += ToString(pFxSend->DestinationChannel(chan)); |
AudioRouting += ToString(pFxSend->DestinationChannel(chan)); |
2384 |
} |
} |
2385 |
|
|
2386 |
|
const String sEffectRouting = |
2387 |
|
(pFxSend->DestinationEffectChain() >= 0 && pFxSend->DestinationEffectChainPosition() >= 0) |
2388 |
|
? ToString(pFxSend->DestinationEffectChain()) + "," + ToString(pFxSend->DestinationEffectChainPosition()) |
2389 |
|
: "NONE"; |
2390 |
|
|
2391 |
// success |
// success |
2392 |
result.Add("NAME", _escapeLscpResponse(pFxSend->Name())); |
result.Add("NAME", _escapeLscpResponse(pFxSend->Name())); |
2393 |
result.Add("MIDI_CONTROLLER", pFxSend->MidiController()); |
result.Add("MIDI_CONTROLLER", pFxSend->MidiController()); |
2394 |
result.Add("LEVEL", ToString(pFxSend->Level())); |
result.Add("LEVEL", ToString(pFxSend->Level())); |
2395 |
result.Add("AUDIO_OUTPUT_ROUTING", AudioRouting); |
result.Add("AUDIO_OUTPUT_ROUTING", AudioRouting); |
2396 |
|
result.Add("SEND_EFFECT", sEffectRouting); |
2397 |
} catch (Exception e) { |
} catch (Exception e) { |
2398 |
result.Error(e); |
result.Error(e); |
2399 |
} |
} |
2456 |
return result.Produce(); |
return result.Produce(); |
2457 |
} |
} |
2458 |
|
|
2459 |
|
String LSCPServer::SetFxSendEffect(uint uiSamplerChannel, uint FxSendID, int iSendEffectChain, int iEffectChainPosition) { |
2460 |
|
dmsg(2,("LSCPServer: SetFxSendEffect(%d,%d)\n", iSendEffectChain, iEffectChainPosition)); |
2461 |
|
LSCPResultSet result; |
2462 |
|
try { |
2463 |
|
FxSend* pFxSend = GetFxSend(uiSamplerChannel, FxSendID); |
2464 |
|
|
2465 |
|
pFxSend->SetDestinationEffect(iSendEffectChain, iEffectChainPosition); |
2466 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_info, uiSamplerChannel, FxSendID)); |
2467 |
|
} catch (Exception e) { |
2468 |
|
result.Error(e); |
2469 |
|
} |
2470 |
|
return result.Produce(); |
2471 |
|
} |
2472 |
|
|
2473 |
|
String LSCPServer::GetAvailableEffects() { |
2474 |
|
dmsg(2,("LSCPServer: GetAvailableEffects()\n")); |
2475 |
|
LSCPResultSet result; |
2476 |
|
try { |
2477 |
|
int n = EffectFactory::AvailableEffectsCount(); |
2478 |
|
result.Add(n); |
2479 |
|
} |
2480 |
|
catch (Exception e) { |
2481 |
|
result.Error(e); |
2482 |
|
} |
2483 |
|
return result.Produce(); |
2484 |
|
} |
2485 |
|
|
2486 |
|
String LSCPServer::ListAvailableEffects() { |
2487 |
|
dmsg(2,("LSCPServer: ListAvailableEffects()\n")); |
2488 |
|
LSCPResultSet result; |
2489 |
|
String list; |
2490 |
|
try { |
2491 |
|
//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 |
2492 |
|
int n = EffectFactory::AvailableEffectsCount(); |
2493 |
|
for (int i = 0; i < n; i++) { |
2494 |
|
if (i) list += ","; |
2495 |
|
list += ToString(i); |
2496 |
|
} |
2497 |
|
} |
2498 |
|
catch (Exception e) { |
2499 |
|
result.Error(e); |
2500 |
|
} |
2501 |
|
result.Add(list); |
2502 |
|
return result.Produce(); |
2503 |
|
} |
2504 |
|
|
2505 |
|
String LSCPServer::GetEffectInfo(int iEffectIndex) { |
2506 |
|
dmsg(2,("LSCPServer: GetEffectInfo(%d)\n", iEffectIndex)); |
2507 |
|
LSCPResultSet result; |
2508 |
|
try { |
2509 |
|
EffectInfo* pEffectInfo = EffectFactory::GetEffectInfo(iEffectIndex); |
2510 |
|
if (!pEffectInfo) |
2511 |
|
throw Exception("There is no effect with index " + ToString(iEffectIndex)); |
2512 |
|
|
2513 |
|
// convert the filename into the correct encoding as defined for LSCP |
2514 |
|
// (especially in terms of special characters -> escape sequences) |
2515 |
|
#if WIN32 |
2516 |
|
const String dllFileName = Path::fromWindows(pEffectInfo->Module()).toLscp(); |
2517 |
|
#else |
2518 |
|
// assuming POSIX |
2519 |
|
const String dllFileName = Path::fromPosix(pEffectInfo->Module()).toLscp(); |
2520 |
|
#endif |
2521 |
|
|
2522 |
|
result.Add("SYSTEM", pEffectInfo->EffectSystem()); |
2523 |
|
result.Add("MODULE", dllFileName); |
2524 |
|
result.Add("NAME", _escapeLscpResponse(pEffectInfo->Name())); |
2525 |
|
result.Add("DESCRIPTION", _escapeLscpResponse(pEffectInfo->Description())); |
2526 |
|
} |
2527 |
|
catch (Exception e) { |
2528 |
|
result.Error(e); |
2529 |
|
} |
2530 |
|
return result.Produce(); |
2531 |
|
} |
2532 |
|
|
2533 |
|
String LSCPServer::GetEffectInstanceInfo(int iEffectInstance) { |
2534 |
|
dmsg(2,("LSCPServer: GetEffectInstanceInfo(%d)\n", iEffectInstance)); |
2535 |
|
LSCPResultSet result; |
2536 |
|
try { |
2537 |
|
Effect* pEffect = EffectFactory::GetEffectInstanceByID(iEffectInstance); |
2538 |
|
if (!pEffect) |
2539 |
|
throw Exception("There is no effect instance with ID " + ToString(iEffectInstance)); |
2540 |
|
|
2541 |
|
EffectInfo* pEffectInfo = pEffect->GetEffectInfo(); |
2542 |
|
|
2543 |
|
// convert the filename into the correct encoding as defined for LSCP |
2544 |
|
// (especially in terms of special characters -> escape sequences) |
2545 |
|
#if WIN32 |
2546 |
|
const String dllFileName = Path::fromWindows(pEffectInfo->Module()).toLscp(); |
2547 |
|
#else |
2548 |
|
// assuming POSIX |
2549 |
|
const String dllFileName = Path::fromPosix(pEffectInfo->Module()).toLscp(); |
2550 |
|
#endif |
2551 |
|
|
2552 |
|
result.Add("SYSTEM", pEffectInfo->EffectSystem()); |
2553 |
|
result.Add("MODULE", dllFileName); |
2554 |
|
result.Add("NAME", _escapeLscpResponse(pEffectInfo->Name())); |
2555 |
|
result.Add("DESCRIPTION", _escapeLscpResponse(pEffectInfo->Description())); |
2556 |
|
result.Add("INPUT_CONTROLS", ToString(pEffect->InputControlCount())); |
2557 |
|
} |
2558 |
|
catch (Exception e) { |
2559 |
|
result.Error(e); |
2560 |
|
} |
2561 |
|
return result.Produce(); |
2562 |
|
} |
2563 |
|
|
2564 |
|
String LSCPServer::GetEffectInstanceInputControlInfo(int iEffectInstance, int iInputControlIndex) { |
2565 |
|
dmsg(2,("LSCPServer: GetEffectInstanceInputControlInfo(%d,%d)\n", iEffectInstance, iInputControlIndex)); |
2566 |
|
LSCPResultSet result; |
2567 |
|
try { |
2568 |
|
Effect* pEffect = EffectFactory::GetEffectInstanceByID(iEffectInstance); |
2569 |
|
if (!pEffect) |
2570 |
|
throw Exception("There is no effect instance with ID " + ToString(iEffectInstance)); |
2571 |
|
|
2572 |
|
EffectControl* pEffectControl = pEffect->InputControl(iInputControlIndex); |
2573 |
|
if (!pEffectControl) |
2574 |
|
throw Exception( |
2575 |
|
"Effect instance " + ToString(iEffectInstance) + |
2576 |
|
" does not have an input control with index " + |
2577 |
|
ToString(iInputControlIndex) |
2578 |
|
); |
2579 |
|
|
2580 |
|
result.Add("DESCRIPTION", _escapeLscpResponse(pEffectControl->Description())); |
2581 |
|
result.Add("VALUE", pEffectControl->Value()); |
2582 |
|
if (pEffectControl->MinValue()) |
2583 |
|
result.Add("RANGE_MIN", *pEffectControl->MinValue()); |
2584 |
|
if (pEffectControl->MaxValue()) |
2585 |
|
result.Add("RANGE_MAX", *pEffectControl->MaxValue()); |
2586 |
|
if (!pEffectControl->Possibilities().empty()) |
2587 |
|
result.Add("POSSIBILITIES", pEffectControl->Possibilities()); |
2588 |
|
if (pEffectControl->DefaultValue()) |
2589 |
|
result.Add("DEFAULT", *pEffectControl->DefaultValue()); |
2590 |
|
} catch (Exception e) { |
2591 |
|
result.Error(e); |
2592 |
|
} |
2593 |
|
return result.Produce(); |
2594 |
|
} |
2595 |
|
|
2596 |
|
String LSCPServer::SetEffectInstanceInputControlValue(int iEffectInstance, int iInputControlIndex, double dValue) { |
2597 |
|
dmsg(2,("LSCPServer: SetEffectInstanceInputControlValue(%d,%d,%f)\n", iEffectInstance, iInputControlIndex, dValue)); |
2598 |
|
LSCPResultSet result; |
2599 |
|
try { |
2600 |
|
Effect* pEffect = EffectFactory::GetEffectInstanceByID(iEffectInstance); |
2601 |
|
if (!pEffect) |
2602 |
|
throw Exception("There is no effect instance with ID " + ToString(iEffectInstance)); |
2603 |
|
|
2604 |
|
EffectControl* pEffectControl = pEffect->InputControl(iInputControlIndex); |
2605 |
|
if (!pEffectControl) |
2606 |
|
throw Exception( |
2607 |
|
"Effect instance " + ToString(iEffectInstance) + |
2608 |
|
" does not have an input control with index " + |
2609 |
|
ToString(iInputControlIndex) |
2610 |
|
); |
2611 |
|
|
2612 |
|
pEffectControl->SetValue(dValue); |
2613 |
|
} catch (Exception e) { |
2614 |
|
result.Error(e); |
2615 |
|
} |
2616 |
|
return result.Produce(); |
2617 |
|
} |
2618 |
|
|
2619 |
|
String LSCPServer::CreateEffectInstance(int iEffectIndex) { |
2620 |
|
dmsg(2,("LSCPServer: CreateEffectInstance(%d)\n", iEffectIndex)); |
2621 |
|
LSCPResultSet result; |
2622 |
|
try { |
2623 |
|
EffectInfo* pEffectInfo = EffectFactory::GetEffectInfo(iEffectIndex); |
2624 |
|
if (!pEffectInfo) |
2625 |
|
throw Exception("There is no effect with index " + ToString(iEffectIndex)); |
2626 |
|
Effect* pEffect = EffectFactory::Create(pEffectInfo); |
2627 |
|
result = pEffect->ID(); // success |
2628 |
|
} catch (Exception e) { |
2629 |
|
result.Error(e); |
2630 |
|
} |
2631 |
|
return result.Produce(); |
2632 |
|
} |
2633 |
|
|
2634 |
|
String LSCPServer::CreateEffectInstance(String effectSystem, String module, String effectName) { |
2635 |
|
dmsg(2,("LSCPServer: CreateEffectInstance('%s','%s','%s')\n", effectSystem.c_str(), module.c_str(), effectName.c_str())); |
2636 |
|
LSCPResultSet result; |
2637 |
|
try { |
2638 |
|
// to allow loading the same LSCP session file on different systems |
2639 |
|
// successfully, probably with different effect plugin DLL paths or even |
2640 |
|
// running completely different operating systems, we do the following |
2641 |
|
// for finding the right effect: |
2642 |
|
// |
2643 |
|
// first try to search for an exact match of the effect plugin DLL |
2644 |
|
// (a.k.a 'module'), to avoid picking the wrong DLL with the same |
2645 |
|
// effect name ... |
2646 |
|
EffectInfo* pEffectInfo = EffectFactory::GetEffectInfo(effectSystem, module, effectName, EffectFactory::MODULE_MATCH_EXACTLY); |
2647 |
|
// ... if no effect with exactly matchin DLL filename was found, then |
2648 |
|
// try to lower the restrictions of matching the effect plugin DLL |
2649 |
|
// filename and try again and again ... |
2650 |
|
if (!pEffectInfo) { |
2651 |
|
dmsg(2,("no exact module match, trying MODULE_IGNORE_PATH\n")); |
2652 |
|
pEffectInfo = EffectFactory::GetEffectInfo(effectSystem, module, effectName, EffectFactory::MODULE_IGNORE_PATH); |
2653 |
|
} |
2654 |
|
if (!pEffectInfo) { |
2655 |
|
dmsg(2,("no module match, trying MODULE_IGNORE_PATH | MODULE_IGNORE_CASE\n")); |
2656 |
|
pEffectInfo = EffectFactory::GetEffectInfo(effectSystem, module, effectName, EffectFactory::MODULE_IGNORE_PATH | EffectFactory::MODULE_IGNORE_CASE); |
2657 |
|
} |
2658 |
|
if (!pEffectInfo) { |
2659 |
|
dmsg(2,("no module match, trying MODULE_IGNORE_PATH | MODULE_IGNORE_CASE | MODULE_IGNORE_EXTENSION\n")); |
2660 |
|
pEffectInfo = EffectFactory::GetEffectInfo(effectSystem, module, effectName, EffectFactory::MODULE_IGNORE_PATH | EffectFactory::MODULE_IGNORE_CASE | EffectFactory::MODULE_IGNORE_EXTENSION); |
2661 |
|
} |
2662 |
|
// ... if there was still no effect found, then completely ignore the |
2663 |
|
// DLL plugin filename argument and just search for the matching effect |
2664 |
|
// system type and effect name |
2665 |
|
if (!pEffectInfo) { |
2666 |
|
dmsg(2,("no module match, trying MODULE_IGNORE_ALL\n")); |
2667 |
|
pEffectInfo = EffectFactory::GetEffectInfo(effectSystem, module, effectName, EffectFactory::MODULE_IGNORE_ALL); |
2668 |
|
} |
2669 |
|
if (!pEffectInfo) |
2670 |
|
throw Exception("There is no such effect '" + effectSystem + "' '" + module + "' '" + effectName + "'"); |
2671 |
|
|
2672 |
|
Effect* pEffect = EffectFactory::Create(pEffectInfo); |
2673 |
|
result = LSCPResultSet(pEffect->ID()); |
2674 |
|
} catch (Exception e) { |
2675 |
|
result.Error(e); |
2676 |
|
} |
2677 |
|
return result.Produce(); |
2678 |
|
} |
2679 |
|
|
2680 |
|
String LSCPServer::DestroyEffectInstance(int iEffectInstance) { |
2681 |
|
dmsg(2,("LSCPServer: DestroyEffectInstance(%d)\n", iEffectInstance)); |
2682 |
|
LSCPResultSet result; |
2683 |
|
try { |
2684 |
|
Effect* pEffect = EffectFactory::GetEffectInstanceByID(iEffectInstance); |
2685 |
|
if (!pEffect) |
2686 |
|
throw Exception("There is no effect instance with ID " + ToString(iEffectInstance)); |
2687 |
|
EffectFactory::Destroy(pEffect); |
2688 |
|
} catch (Exception e) { |
2689 |
|
result.Error(e); |
2690 |
|
} |
2691 |
|
return result.Produce(); |
2692 |
|
} |
2693 |
|
|
2694 |
|
String LSCPServer::GetEffectInstances() { |
2695 |
|
dmsg(2,("LSCPServer: GetEffectInstances()\n")); |
2696 |
|
LSCPResultSet result; |
2697 |
|
try { |
2698 |
|
int n = EffectFactory::EffectInstancesCount(); |
2699 |
|
result.Add(n); |
2700 |
|
} catch (Exception e) { |
2701 |
|
result.Error(e); |
2702 |
|
} |
2703 |
|
return result.Produce(); |
2704 |
|
} |
2705 |
|
|
2706 |
|
String LSCPServer::ListEffectInstances() { |
2707 |
|
dmsg(2,("LSCPServer: ListEffectInstances()\n")); |
2708 |
|
LSCPResultSet result; |
2709 |
|
String list; |
2710 |
|
try { |
2711 |
|
int n = EffectFactory::EffectInstancesCount(); |
2712 |
|
for (int i = 0; i < n; i++) { |
2713 |
|
Effect* pEffect = EffectFactory::GetEffectInstance(i); |
2714 |
|
if (i) list += ","; |
2715 |
|
list += ToString(pEffect->ID()); |
2716 |
|
} |
2717 |
|
} catch (Exception e) { |
2718 |
|
result.Error(e); |
2719 |
|
} |
2720 |
|
result.Add(list); |
2721 |
|
return result.Produce(); |
2722 |
|
} |
2723 |
|
|
2724 |
|
String LSCPServer::GetSendEffectChains(int iAudioOutputDevice) { |
2725 |
|
dmsg(2,("LSCPServer: GetSendEffectChains(%d)\n", iAudioOutputDevice)); |
2726 |
|
LSCPResultSet result; |
2727 |
|
try { |
2728 |
|
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
2729 |
|
if (!devices.count(iAudioOutputDevice)) |
2730 |
|
throw Exception("There is no audio output device with index " + ToString(iAudioOutputDevice) + "."); |
2731 |
|
AudioOutputDevice* pDevice = devices[iAudioOutputDevice]; |
2732 |
|
int n = pDevice->SendEffectChainCount(); |
2733 |
|
result.Add(n); |
2734 |
|
} catch (Exception e) { |
2735 |
|
result.Error(e); |
2736 |
|
} |
2737 |
|
return result.Produce(); |
2738 |
|
} |
2739 |
|
|
2740 |
|
String LSCPServer::ListSendEffectChains(int iAudioOutputDevice) { |
2741 |
|
dmsg(2,("LSCPServer: ListSendEffectChains(%d)\n", iAudioOutputDevice)); |
2742 |
|
LSCPResultSet result; |
2743 |
|
String list; |
2744 |
|
try { |
2745 |
|
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
2746 |
|
if (!devices.count(iAudioOutputDevice)) |
2747 |
|
throw Exception("There is no audio output device with index " + ToString(iAudioOutputDevice) + "."); |
2748 |
|
AudioOutputDevice* pDevice = devices[iAudioOutputDevice]; |
2749 |
|
int n = pDevice->SendEffectChainCount(); |
2750 |
|
for (int i = 0; i < n; i++) { |
2751 |
|
EffectChain* pEffectChain = pDevice->SendEffectChain(i); |
2752 |
|
if (i) list += ","; |
2753 |
|
list += ToString(pEffectChain->ID()); |
2754 |
|
} |
2755 |
|
} catch (Exception e) { |
2756 |
|
result.Error(e); |
2757 |
|
} |
2758 |
|
result.Add(list); |
2759 |
|
return result.Produce(); |
2760 |
|
} |
2761 |
|
|
2762 |
|
String LSCPServer::AddSendEffectChain(int iAudioOutputDevice) { |
2763 |
|
dmsg(2,("LSCPServer: AddSendEffectChain(%d)\n", iAudioOutputDevice)); |
2764 |
|
LSCPResultSet result; |
2765 |
|
try { |
2766 |
|
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
2767 |
|
if (!devices.count(iAudioOutputDevice)) |
2768 |
|
throw Exception("There is no audio output device with index " + ToString(iAudioOutputDevice) + "."); |
2769 |
|
AudioOutputDevice* pDevice = devices[iAudioOutputDevice]; |
2770 |
|
EffectChain* pEffectChain = pDevice->AddSendEffectChain(); |
2771 |
|
result = pEffectChain->ID(); |
2772 |
|
} catch (Exception e) { |
2773 |
|
result.Error(e); |
2774 |
|
} |
2775 |
|
return result.Produce(); |
2776 |
|
} |
2777 |
|
|
2778 |
|
String LSCPServer::RemoveSendEffectChain(int iAudioOutputDevice, int iSendEffectChain) { |
2779 |
|
dmsg(2,("LSCPServer: RemoveSendEffectChain(%d,%d)\n", iAudioOutputDevice, iSendEffectChain)); |
2780 |
|
LSCPResultSet result; |
2781 |
|
try { |
2782 |
|
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
2783 |
|
if (!devices.count(iAudioOutputDevice)) |
2784 |
|
throw Exception("There is no audio output device with index " + ToString(iAudioOutputDevice) + "."); |
2785 |
|
AudioOutputDevice* pDevice = devices[iAudioOutputDevice]; |
2786 |
|
for (int i = 0; i < pDevice->SendEffectChainCount(); i++) { |
2787 |
|
EffectChain* pEffectChain = pDevice->SendEffectChain(i); |
2788 |
|
if (pEffectChain->ID() == iSendEffectChain) { |
2789 |
|
pDevice->RemoveSendEffectChain(i); |
2790 |
|
return result.Produce(); |
2791 |
|
} |
2792 |
|
} |
2793 |
|
throw Exception( |
2794 |
|
"There is no send effect chain with ID " + |
2795 |
|
ToString(iSendEffectChain) + " for audio output device " + |
2796 |
|
ToString(iAudioOutputDevice) + "." |
2797 |
|
); |
2798 |
|
} catch (Exception e) { |
2799 |
|
result.Error(e); |
2800 |
|
} |
2801 |
|
return result.Produce(); |
2802 |
|
} |
2803 |
|
|
2804 |
|
static EffectChain* _getSendEffectChain(Sampler* pSampler, int iAudioOutputDevice, int iSendEffectChain) throw (Exception) { |
2805 |
|
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
2806 |
|
if (!devices.count(iAudioOutputDevice)) |
2807 |
|
throw Exception( |
2808 |
|
"There is no audio output device with index " + |
2809 |
|
ToString(iAudioOutputDevice) + "." |
2810 |
|
); |
2811 |
|
AudioOutputDevice* pDevice = devices[iAudioOutputDevice]; |
2812 |
|
for (int i = 0; i < pDevice->SendEffectChainCount(); i++) { |
2813 |
|
EffectChain* pEffectChain = pDevice->SendEffectChain(i); |
2814 |
|
if (pEffectChain->ID() == iSendEffectChain) { |
2815 |
|
return pEffectChain; |
2816 |
|
} |
2817 |
|
} |
2818 |
|
throw Exception( |
2819 |
|
"There is no send effect chain with ID " + |
2820 |
|
ToString(iSendEffectChain) + " for audio output device " + |
2821 |
|
ToString(iAudioOutputDevice) + "." |
2822 |
|
); |
2823 |
|
} |
2824 |
|
|
2825 |
|
String LSCPServer::GetSendEffectChainInfo(int iAudioOutputDevice, int iSendEffectChain) { |
2826 |
|
dmsg(2,("LSCPServer: GetSendEffectChainInfo(%d,%d)\n", iAudioOutputDevice, iSendEffectChain)); |
2827 |
|
LSCPResultSet result; |
2828 |
|
try { |
2829 |
|
EffectChain* pEffectChain = |
2830 |
|
_getSendEffectChain(pSampler, iAudioOutputDevice, iSendEffectChain); |
2831 |
|
String sEffectSequence; |
2832 |
|
for (int i = 0; i < pEffectChain->EffectCount(); i++) { |
2833 |
|
if (i) sEffectSequence += ","; |
2834 |
|
sEffectSequence += ToString(pEffectChain->GetEffect(i)->ID()); |
2835 |
|
} |
2836 |
|
result.Add("EFFECT_COUNT", pEffectChain->EffectCount()); |
2837 |
|
result.Add("EFFECT_SEQUENCE", sEffectSequence); |
2838 |
|
} catch (Exception e) { |
2839 |
|
result.Error(e); |
2840 |
|
} |
2841 |
|
return result.Produce(); |
2842 |
|
} |
2843 |
|
|
2844 |
|
String LSCPServer::AppendSendEffectChainEffect(int iAudioOutputDevice, int iSendEffectChain, int iEffectInstance) { |
2845 |
|
dmsg(2,("LSCPServer: AppendSendEffectChainEffect(%d,%d,%d)\n", iAudioOutputDevice, iSendEffectChain, iEffectInstance)); |
2846 |
|
LSCPResultSet result; |
2847 |
|
try { |
2848 |
|
EffectChain* pEffectChain = |
2849 |
|
_getSendEffectChain(pSampler, iAudioOutputDevice, iSendEffectChain); |
2850 |
|
Effect* pEffect = EffectFactory::GetEffectInstanceByID(iEffectInstance); |
2851 |
|
if (!pEffect) |
2852 |
|
throw Exception("There is no effect instance with ID " + ToString(iEffectInstance)); |
2853 |
|
pEffectChain->AppendEffect(pEffect); |
2854 |
|
} catch (Exception e) { |
2855 |
|
result.Error(e); |
2856 |
|
} |
2857 |
|
return result.Produce(); |
2858 |
|
} |
2859 |
|
|
2860 |
|
String LSCPServer::InsertSendEffectChainEffect(int iAudioOutputDevice, int iSendEffectChain, int iEffectChainPosition, int iEffectInstance) { |
2861 |
|
dmsg(2,("LSCPServer: InsertSendEffectChainEffect(%d,%d,%d,%d)\n", iAudioOutputDevice, iSendEffectChain, iEffectChainPosition, iEffectInstance)); |
2862 |
|
LSCPResultSet result; |
2863 |
|
try { |
2864 |
|
EffectChain* pEffectChain = |
2865 |
|
_getSendEffectChain(pSampler, iAudioOutputDevice, iSendEffectChain); |
2866 |
|
Effect* pEffect = EffectFactory::GetEffectInstanceByID(iEffectInstance); |
2867 |
|
if (!pEffect) |
2868 |
|
throw Exception("There is no effect instance with index " + ToString(iEffectInstance)); |
2869 |
|
pEffectChain->InsertEffect(pEffect, iEffectChainPosition); |
2870 |
|
} catch (Exception e) { |
2871 |
|
result.Error(e); |
2872 |
|
} |
2873 |
|
return result.Produce(); |
2874 |
|
} |
2875 |
|
|
2876 |
|
String LSCPServer::RemoveSendEffectChainEffect(int iAudioOutputDevice, int iSendEffectChain, int iEffectChainPosition) { |
2877 |
|
dmsg(2,("LSCPServer: RemoveSendEffectChainEffect(%d,%d,%d)\n", iAudioOutputDevice, iSendEffectChain, iEffectChainPosition)); |
2878 |
|
LSCPResultSet result; |
2879 |
|
try { |
2880 |
|
EffectChain* pEffectChain = |
2881 |
|
_getSendEffectChain(pSampler, iAudioOutputDevice, iSendEffectChain); |
2882 |
|
pEffectChain->RemoveEffect(iEffectChainPosition); |
2883 |
|
} catch (Exception e) { |
2884 |
|
result.Error(e); |
2885 |
|
} |
2886 |
|
return result.Produce(); |
2887 |
|
} |
2888 |
|
|
2889 |
String LSCPServer::EditSamplerChannelInstrument(uint uiSamplerChannel) { |
String LSCPServer::EditSamplerChannelInstrument(uint uiSamplerChannel) { |
2890 |
dmsg(2,("LSCPServer: EditSamplerChannelInstrument(SamplerChannel=%d)\n", uiSamplerChannel)); |
dmsg(2,("LSCPServer: EditSamplerChannelInstrument(SamplerChannel=%d)\n", uiSamplerChannel)); |
2891 |
LSCPResultSet result; |
LSCPResultSet result; |
2934 |
pMidiDevice->SendNoteOffToDevice(Arg1, Arg2); |
pMidiDevice->SendNoteOffToDevice(Arg1, Arg2); |
2935 |
bool b = pMidiDevice->SendNoteOffToSampler(Arg1, Arg2); |
bool b = pMidiDevice->SendNoteOffToSampler(Arg1, Arg2); |
2936 |
if (!b) throw Exception("MIDI event failed: " + MidiMsg + " " + ToString(Arg1) + " " + ToString(Arg2)); |
if (!b) throw Exception("MIDI event failed: " + MidiMsg + " " + ToString(Arg1) + " " + ToString(Arg2)); |
2937 |
|
} else if (MidiMsg == "CC") { |
2938 |
|
pMidiDevice->SendCCToDevice(Arg1, Arg2); |
2939 |
|
bool b = pMidiDevice->SendCCToSampler(Arg1, Arg2); |
2940 |
|
if (!b) throw Exception("MIDI event failed: " + MidiMsg + " " + ToString(Arg1) + " " + ToString(Arg2)); |
2941 |
} else { |
} else { |
2942 |
throw Exception("Unknown MIDI message type: " + MidiMsg); |
throw Exception("Unknown MIDI message type: " + MidiMsg); |
2943 |
} |
} |