/[svn]/linuxsampler/trunk/src/network/lscpserver.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/network/lscpserver.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 981 by iliev, Sun Dec 17 22:35:01 2006 UTC revision 1026 by schoenebeck, Sun Jan 14 17:10:59 2007 UTC
# Line 3  Line 3 
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, 2006 Christian Schoenebeck                        *   *   Copyright (C) 2005 - 2007 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  *
# Line 24  Line 24 
24  #include "lscpserver.h"  #include "lscpserver.h"
25  #include "lscpresultset.h"  #include "lscpresultset.h"
26  #include "lscpevent.h"  #include "lscpevent.h"
27  //#include "../common/global.h"  #include "../common/global.h"
28    
29  #include <fcntl.h>  #include <fcntl.h>
30    
# Line 1502  String LSCPServer::SetChannelSolo(bool b Line 1502  String LSCPServer::SetChannelSolo(bool b
1502    
1503          bool oldSolo = pEngineChannel->GetSolo();          bool oldSolo = pEngineChannel->GetSolo();
1504          bool hadSoloChannel = HasSoloChannel();          bool hadSoloChannel = HasSoloChannel();
1505            
1506          pEngineChannel->SetSolo(bSolo);          pEngineChannel->SetSolo(bSolo);
1507            
1508          if(!oldSolo && bSolo) {          if(!oldSolo && bSolo) {
1509              if(pEngineChannel->GetMute() == -1) pEngineChannel->SetMute(0);              if(pEngineChannel->GetMute() == -1) pEngineChannel->SetMute(0);
1510              if(!hadSoloChannel) MuteNonSoloChannels();              if(!hadSoloChannel) MuteNonSoloChannels();
1511          }          }
1512            
1513          if(oldSolo && !bSolo) {          if(oldSolo && !bSolo) {
1514              if(!HasSoloChannel()) UnmuteChannels();              if(!HasSoloChannel()) UnmuteChannels();
1515              else if(!pEngineChannel->GetMute()) pEngineChannel->SetMute(-1);              else if(!pEngineChannel->GetMute()) pEngineChannel->SetMute(-1);
# Line 1698  String LSCPServer::ListMidiInstrumentMap Line 1698  String LSCPServer::ListMidiInstrumentMap
1698          for (; iter != mappings.end(); iter++) {          for (; iter != mappings.end(); iter++) {
1699              if (s.size()) s += ",";              if (s.size()) s += ",";
1700              s += "{" + ToString(MidiMapID) + ","              s += "{" + ToString(MidiMapID) + ","
1701                       + ToString((int(iter->first.midi_bank_msb) << 7) & int(iter->first.midi_bank_lsb)) + ","                       + ToString((int(iter->first.midi_bank_msb) << 7) | int(iter->first.midi_bank_lsb)) + ","
1702                       + ToString(int(iter->first.midi_prog)) + "}";                       + ToString(int(iter->first.midi_prog)) + "}";
1703          }          }
1704          result.Add(s);          result.Add(s);
# Line 1720  String LSCPServer::ListAllMidiInstrument Line 1720  String LSCPServer::ListAllMidiInstrument
1720              for (; iter != mappings.end(); iter++) {              for (; iter != mappings.end(); iter++) {
1721                  if (s.size()) s += ",";                  if (s.size()) s += ",";
1722                  s += "{" + ToString(maps[i]) + ","                  s += "{" + ToString(maps[i]) + ","
1723                           + ToString((int(iter->first.midi_bank_msb) << 7) & int(iter->first.midi_bank_lsb)) + ","                           + ToString((int(iter->first.midi_bank_msb) << 7) | int(iter->first.midi_bank_lsb)) + ","
1724                           + ToString(int(iter->first.midi_prog)) + "}";                           + ToString(int(iter->first.midi_prog)) + "}";
1725              }              }
1726          }          }
# Line 1866  String LSCPServer::SetChannelMap(uint ui Line 1866  String LSCPServer::SetChannelMap(uint ui
1866      return result.Produce();      return result.Produce();
1867  }  }
1868    
1869    String LSCPServer::CreateFxSend(uint uiSamplerChannel, uint MidiCtrl, String Name) {
1870        dmsg(2,("LSCPServer: CreateFxSend()\n"));
1871        LSCPResultSet result;
1872        try {
1873            SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
1874            if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
1875    
1876            EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
1877            if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet");
1878    
1879            FxSend* pFxSend = pEngineChannel->AddFxSend(MidiCtrl, Name);
1880            if (!pFxSend) throw Exception("Could not add FxSend, don't ask, I don't know why (probably a bug)");
1881    
1882            result = LSCPResultSet(pFxSend->Id()); // success
1883        } catch (Exception e) {
1884            result.Error(e);
1885        }
1886        return result.Produce();
1887    }
1888    
1889    String LSCPServer::DestroyFxSend(uint uiSamplerChannel, uint FxSendID) {
1890        dmsg(2,("LSCPServer: DestroyFxSend()\n"));
1891        LSCPResultSet result;
1892        try {
1893            SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
1894            if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
1895    
1896            EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
1897            if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet");
1898    
1899            FxSend* pFxSend = NULL;
1900            for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) {
1901                if (pEngineChannel->GetFxSend(i)->Id() == FxSendID) {
1902                    pFxSend = pEngineChannel->GetFxSend(i);
1903                    break;
1904                }
1905            }
1906            if (!pFxSend) throw Exception("There is no FxSend with that ID on the given sampler channel");
1907            pEngineChannel->RemoveFxSend(pFxSend);
1908        } catch (Exception e) {
1909            result.Error(e);
1910        }
1911        return result.Produce();
1912    }
1913    
1914    String LSCPServer::GetFxSends(uint uiSamplerChannel) {
1915        dmsg(2,("LSCPServer: GetFxSends()\n"));
1916        LSCPResultSet result;
1917        try {
1918            SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
1919            if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
1920    
1921            EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
1922            if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet");
1923    
1924            result.Add(pEngineChannel->GetFxSendCount());
1925        } catch (Exception e) {
1926            result.Error(e);
1927        }
1928        return result.Produce();
1929    }
1930    
1931    String LSCPServer::ListFxSends(uint uiSamplerChannel) {
1932        dmsg(2,("LSCPServer: ListFxSends()\n"));
1933        LSCPResultSet result;
1934        String list;
1935        try {
1936            SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
1937            if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
1938    
1939            EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
1940            if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet");
1941    
1942            for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) {
1943                FxSend* pFxSend = pEngineChannel->GetFxSend(i);
1944                if (list != "") list += ",";
1945                list += ToString(pFxSend->Id());
1946            }
1947            result.Add(list);
1948        } catch (Exception e) {
1949            result.Error(e);
1950        }
1951        return result.Produce();
1952    }
1953    
1954    String LSCPServer::GetFxSendInfo(uint uiSamplerChannel, uint FxSendID) {
1955        dmsg(2,("LSCPServer: GetFxSendInfo()\n"));
1956        LSCPResultSet result;
1957        try {
1958            SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
1959            if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
1960    
1961            EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
1962            if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet");
1963    
1964            FxSend* pFxSend = NULL;
1965            for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) {
1966                if (pEngineChannel->GetFxSend(i)->Id() == FxSendID) {
1967                    pFxSend = pEngineChannel->GetFxSend(i);
1968                    break;
1969                }
1970            }
1971            if (!pFxSend) throw Exception("There is no FxSend with that ID on the given sampler channel");
1972    
1973            // gather audio routing informations
1974            String AudioRouting;
1975            for (int chan = 0; chan < pEngineChannel->Channels(); chan++) {
1976                if (AudioRouting != "") AudioRouting += ",";
1977                AudioRouting += ToString(pFxSend->DestinationChannel(chan));
1978            }
1979    
1980            // success
1981            result.Add("NAME", pFxSend->Name());
1982            result.Add("MIDI_CONTROLLER", pFxSend->MidiController());
1983            result.Add("LEVEL", ToString(pFxSend->Level()));
1984            result.Add("AUDIO_OUTPUT_ROUTING", AudioRouting);
1985        } catch (Exception e) {
1986            result.Error(e);
1987        }
1988        return result.Produce();
1989    }
1990    
1991    String LSCPServer::SetFxSendAudioOutputChannel(uint uiSamplerChannel, uint FxSendID, uint FxSendChannel, uint DeviceChannel) {
1992        dmsg(2,("LSCPServer: SetFxSendAudioOutputChannel()\n"));
1993        LSCPResultSet result;
1994        try {
1995            SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
1996            if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
1997    
1998            EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
1999            if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet");
2000    
2001            FxSend* pFxSend = NULL;
2002            for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) {
2003                if (pEngineChannel->GetFxSend(i)->Id() == FxSendID) {
2004                    pFxSend = pEngineChannel->GetFxSend(i);
2005                    break;
2006                }
2007            }
2008            if (!pFxSend) throw Exception("There is no FxSend with that ID on the given sampler channel");
2009    
2010            pFxSend->SetDestinationChannel(FxSendChannel, DeviceChannel);
2011        } catch (Exception e) {
2012            result.Error(e);
2013        }
2014        return result.Produce();
2015    }
2016    
2017    String LSCPServer::SetFxSendMidiController(uint uiSamplerChannel, uint FxSendID, uint MidiController) {
2018        dmsg(2,("LSCPServer: SetFxSendMidiController()\n"));
2019        LSCPResultSet result;
2020        try {
2021            SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
2022            if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
2023    
2024            EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
2025            if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet");
2026    
2027            FxSend* pFxSend = NULL;
2028            for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) {
2029                if (pEngineChannel->GetFxSend(i)->Id() == FxSendID) {
2030                    pFxSend = pEngineChannel->GetFxSend(i);
2031                    break;
2032                }
2033            }
2034            if (!pFxSend) throw Exception("There is no FxSend with that ID on the given sampler channel");
2035    
2036            pFxSend->SetMidiController(MidiController);
2037        } catch (Exception e) {
2038            result.Error(e);
2039        }
2040        return result.Produce();
2041    }
2042    
2043    String LSCPServer::SetFxSendLevel(uint uiSamplerChannel, uint FxSendID, double dLevel) {
2044        dmsg(2,("LSCPServer: SetFxSendLevel()\n"));
2045        LSCPResultSet result;
2046        try {
2047            SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
2048            if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
2049    
2050            EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
2051            if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet");
2052    
2053            FxSend* pFxSend = NULL;
2054            for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) {
2055                if (pEngineChannel->GetFxSend(i)->Id() == FxSendID) {
2056                    pFxSend = pEngineChannel->GetFxSend(i);
2057                    break;
2058                }
2059            }
2060            if (!pFxSend) throw Exception("There is no FxSend with that ID on the given sampler channel");
2061    
2062            pFxSend->SetLevel((float)dLevel);
2063        } catch (Exception e) {
2064            result.Error(e);
2065        }
2066        return result.Produce();
2067    }
2068    
2069  /**  /**
2070   * Will be called by the parser to reset a particular sampler channel.   * Will be called by the parser to reset a particular sampler channel.
2071   */   */
# Line 1928  String LSCPServer::GetTotalVoiceCountMax Line 2128  String LSCPServer::GetTotalVoiceCountMax
2128      return result.Produce();      return result.Produce();
2129  }  }
2130    
2131    String LSCPServer::GetGlobalVolume() {
2132        LSCPResultSet result;
2133        result.Add(ToString(GLOBAL_VOLUME)); // see common/global.cpp
2134        return result.Produce();
2135    }
2136    
2137    String LSCPServer::SetGlobalVolume(double dVolume) {
2138        LSCPResultSet result;
2139        try {
2140            if (dVolume < 0) throw Exception("Volume may not be negative");
2141            GLOBAL_VOLUME = dVolume; // see common/global.cpp
2142        } catch (Exception e) {
2143            result.Error(e);
2144        }
2145        return result.Produce();
2146    }
2147    
2148  /**  /**
2149   * Will be called by the parser to subscribe a client (frontend) on the   * Will be called by the parser to subscribe a client (frontend) on the
2150   * server for receiving event messages.   * server for receiving event messages.

Legend:
Removed from v.981  
changed lines
  Added in v.1026

  ViewVC Help
Powered by ViewVC