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

Annotation of /linuxsampler/trunk/src/network/lscpserver.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 53 - (hide annotations) (download) (as text)
Mon Apr 26 17:15:51 2004 UTC (19 years, 11 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 5086 byte(s)
* completely restructured source tree
* implemented multi channel support
* implemented instrument manager, which controls sharing of instruments
  between multiple sampler engines / sampler channels
* created abstract classes 'AudioOutputDevice' and 'MidiInputDevice' for
  convenient implementation of further audio output driver and MIDI input
  driver for LinuxSampler
* implemented following LSCP commands: 'SET CHANNEL MIDI INPUT TYPE',
  'LOAD ENGINE', 'GET CHANNELS', 'ADD CHANNEL', 'REMOVE CHANNEL',
  'SET CHANNEL AUDIO OUTPUT TYPE'
* temporarily removed all command line options
* LSCP server is now launched by default

1 schoenebeck 35 /***************************************************************************
2     * *
3     * LinuxSampler - modular, streaming capable sampler *
4     * *
5     * Copyright (C) 2003 by Benno Senoner and Christian Schoenebeck *
6     * *
7     * This program is free software; you can redistribute it and/or modify *
8     * it under the terms of the GNU General Public License as published by *
9     * the Free Software Foundation; either version 2 of the License, or *
10     * (at your option) any later version. *
11     * *
12     * This program is distributed in the hope that it will be useful, *
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15     * GNU General Public License for more details. *
16     * *
17     * You should have received a copy of the GNU General Public License *
18     * along with this program; if not, write to the Free Software *
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
20     * MA 02111-1307 USA *
21     ***************************************************************************/
22    
23     #ifndef __LSCPSERVER_H_
24     #define __LSCPSERVER_H_
25    
26     #include <unistd.h>
27     #include <sys/types.h>
28     #include <sys/socket.h>
29     #include <netinet/in.h>
30     #include <netinet/tcp.h>
31     #include <arpa/inet.h>
32     #include <netdb.h>
33    
34 schoenebeck 53 #include "lscp.h"
35 schoenebeck 35 #include "lscpparser.h"
36 schoenebeck 53 #include "../Sampler.h"
37     #include "../common/Thread.h"
38 schoenebeck 35
39     /// TCP Port on which the server should listen for connection requests.
40     #define LSCP_PORT 8888
41    
42 schoenebeck 53 using namespace LinuxSampler;
43    
44 schoenebeck 35 /// Handle for a client connection (FIXME: doesn't work for more than one network connections of course, thus has to be included to the yyparse() parameters instead).
45     extern int hSession;
46    
47     // External references to the main scanner and parser functions
48     extern int yyparse(void* YYPARSE_PARAM);
49     extern int yylex_init(yyscan_t* scanner);
50     extern int yylex_destroy(yyscan_t yyscanner);
51    
52     /**
53     * Network server for the LinuxSampler Control Protocol (LSCP).
54     */
55     class LSCPServer : public Thread {
56     public:
57 schoenebeck 53 LSCPServer(Sampler* pSampler);
58 schoenebeck 35
59     // Methods called by the parser
60 schoenebeck 53 String LoadInstrument(String Filename, uint uiInstrument, uint uiSamplerChannel);
61     String LoadEngine(String EngineName, uint uiSamplerChannel);
62 schoenebeck 35 String GetChannels();
63     String AddChannel();
64 schoenebeck 53 String RemoveChannel(uint uiSamplerChannel);
65 schoenebeck 35 String GetAvailableEngines();
66     String GetEngineInfo(String EngineName);
67 schoenebeck 53 String GetChannelInfo(uint uiSamplerChannel);
68     String GetVoiceCount(uint uiSamplerChannel);
69     String GetStreamCount(uint uiSamplerChannel);
70     String GetBufferFill(fill_response_t ResponseType, uint uiSamplerChannel);
71     String SetAudioOutputType(audio_output_type_t AudioOutputType, uint uiSamplerChannel);
72     String SetAudioOutputChannel(uint AudioOutputChannel, uint uiSamplerChannel);
73     String SetMIDIInputType(midi_input_type_t MidiInputType, uint uiSamplerChannel);
74     String SetMIDIInputPort(String MIDIInputPort, uint uiSamplerchannel);
75     String SetMIDIInputChannel(uint MIDIChannel, uint uiSamplerChannel);
76     String SetVolume(double Volume, uint uiSamplerChannel);
77     String ResetChannel(uint uiSamplerChannel);
78 schoenebeck 35 String SubscribeNotification(uint UDPPort);
79     String UnsubscribeNotification(String SessionID);
80     void AnswerClient(String ReturnMessage);
81     protected:
82 schoenebeck 53 int hSocket;
83     sockaddr_in SocketAddress;
84     Sampler* pSampler;
85 schoenebeck 35
86     int Main(); ///< Implementation of virtual method from class Thread
87     private:
88     /**
89     * Converts a result_t structure into a valid LSCP answer message.
90     */
91     inline String ConvertResult(result_t result) {
92     switch (result.type) {
93     case result_type_success: {
94     return "OK\r\n";
95     }
96     case result_type_warning: {
97     std::stringstream ss;
98     ss << "WRN:" << result.code << ":" << result.message << "\r\n";
99     return ss.str();
100     }
101     case result_type_error: {
102     std::stringstream ss;
103     ss << "ERR:" << result.code << ":" << result.message << "\r\n";
104     return ss.str();
105     }
106     }
107     }
108    
109 schoenebeck 53 template<class T> inline String ToString(T o) {
110 schoenebeck 35 std::stringstream ss;
111 schoenebeck 53 ss << o;
112 schoenebeck 35 return ss.str();
113     }
114     };
115    
116     #endif // __LSCPSERVER_H_

  ViewVC Help
Powered by ViewVC