/[svn]/liblscp/trunk/src/event.c
ViewVC logotype

Contents of /liblscp/trunk/src/event.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1689 - (show annotations) (download)
Thu Feb 14 17:05:51 2008 UTC (12 years, 1 month ago) by schoenebeck
File MIME type: text/plain
File size: 4855 byte(s)
* added new LSCP event "CHANNEL_MIDI" (CAUTION: behavior change for
  lscp_client_subscribe() and lscp_client_unsubscribe!)
* bumped version to 0.5.5.4

1 // event.c
2 //
3 /****************************************************************************
4 liblscp - LinuxSampler Control Protocol API
5 Copyright (C) 2004-2008, rncbc aka Rui Nuno Capela. All rights reserved.
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 This library 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 GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21 *****************************************************************************/
22
23 #include "lscp/event.h"
24
25 // Case unsensitive comparison substitutes.
26 #if defined(WIN32)
27 #define strcasecmp stricmp
28 #define strncasecmp strnicmp
29 #endif
30
31
32 //-------------------------------------------------------------------------
33 // Simple event helper functions.
34
35
36 /**
37 * Getting the text string representation of a single event.
38 *
39 * @param event Event to convert to text string.
40 *
41 * @returns The text string representation of the event.
42 */
43 const char *lscp_event_to_text ( lscp_event_t event )
44 {
45 const char *pszText = NULL;
46
47 switch (event) {
48 case LSCP_EVENT_CHANNEL_COUNT:
49 pszText = "CHANNEL_COUNT";
50 break;
51 case LSCP_EVENT_VOICE_COUNT:
52 pszText = "VOICE_COUNT";
53 break;
54 case LSCP_EVENT_STREAM_COUNT:
55 pszText = "STREAM_COUNT";
56 break;
57 case LSCP_EVENT_BUFFER_FILL:
58 pszText = "BUFFER_FILL";
59 break;
60 case LSCP_EVENT_CHANNEL_INFO:
61 pszText = "CHANNEL_INFO";
62 break;
63 case LSCP_EVENT_TOTAL_VOICE_COUNT:
64 pszText = "TOTAL_VOICE_COUNT";
65 break;
66 case LSCP_EVENT_AUDIO_OUTPUT_DEVICE_COUNT:
67 pszText = "AUDIO_OUTPUT_DEVICE_COUNT";
68 break;
69 case LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO:
70 pszText = "AUDIO_OUTPUT_DEVICE_INFO";
71 break;
72 case LSCP_EVENT_MIDI_INPUT_DEVICE_COUNT:
73 pszText = "MIDI_INPUT_DEVICE_COUNT";
74 break;
75 case LSCP_EVENT_MIDI_INPUT_DEVICE_INFO:
76 pszText = "MIDI_INPUT_DEVICE_INFO";
77 break;
78 case LSCP_EVENT_MIDI_INSTRUMENT_MAP_COUNT:
79 pszText = "MIDI_INSTRUMENT_MAP_COUNT";
80 break;
81 case LSCP_EVENT_MIDI_INSTRUMENT_MAP_INFO:
82 pszText = "MIDI_INSTRUMENT_MAP_INFO";
83 break;
84 case LSCP_EVENT_MIDI_INSTRUMENT_COUNT:
85 pszText = "MIDI_INSTRUMENT_COUNT";
86 break;
87 case LSCP_EVENT_MIDI_INSTRUMENT_INFO:
88 pszText = "MIDI_INSTRUMENT_INFO";
89 break;
90 case LSCP_EVENT_MISCELLANEOUS:
91 pszText = "MISCELLANEOUS";
92 break;
93 case LSCP_EVENT_CHANNEL_MIDI:
94 pszText = "CHANNEL_MIDI";
95 break;
96 case LSCP_EVENT_NONE:
97 default:
98 break;
99 }
100
101 return pszText;
102 }
103
104
105 /**
106 * Getting an event from a text string.
107 *
108 * @param pszText Text string to convert to event.
109 *
110 * @returns The event correponding to the text string.
111 */
112 lscp_event_t lscp_event_from_text ( const char *pszText )
113 {
114 lscp_event_t event = LSCP_EVENT_NONE;
115
116 if (pszText) {
117 if (strcasecmp(pszText, "CHANNEL_COUNT") == 0)
118 event = LSCP_EVENT_CHANNEL_COUNT;
119 else if (strcasecmp(pszText, "VOICE_COUNT") == 0)
120 event = LSCP_EVENT_VOICE_COUNT;
121 else if (strcasecmp(pszText, "STREAM_COUNT") == 0)
122 event = LSCP_EVENT_STREAM_COUNT;
123 else if (strcasecmp(pszText, "BUFFER_FILL") == 0)
124 event = LSCP_EVENT_BUFFER_FILL;
125 else if (strcasecmp(pszText, "CHANNEL_INFO") == 0)
126 event = LSCP_EVENT_CHANNEL_INFO;
127 else if (strcasecmp(pszText, "TOTAL_VOICE_COUNT") == 0)
128 event = LSCP_EVENT_TOTAL_VOICE_COUNT;
129 else if (strcasecmp(pszText, "AUDIO_OUTPUT_DEVICE_COUNT") == 0)
130 event = LSCP_EVENT_AUDIO_OUTPUT_DEVICE_COUNT;
131 else if (strcasecmp(pszText, "AUDIO_OUTPUT_DEVICE_INFO") == 0)
132 event = LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO;
133 else if (strcasecmp(pszText, "MIDI_INPUT_DEVICE_COUNT") == 0)
134 event = LSCP_EVENT_MIDI_INPUT_DEVICE_COUNT;
135 else if (strcasecmp(pszText, "MIDI_INPUT_DEVICE_INFO") == 0)
136 event = LSCP_EVENT_MIDI_INPUT_DEVICE_INFO;
137 else if (strcasecmp(pszText, "MIDI_INSTRUMENT_MAP_COUNT") == 0)
138 event = LSCP_EVENT_MIDI_INSTRUMENT_MAP_COUNT;
139 else if (strcasecmp(pszText, "MIDI_INSTRUMENT_MAP_INFO") == 0)
140 event = LSCP_EVENT_MIDI_INSTRUMENT_MAP_INFO;
141 else if (strcasecmp(pszText, "MIDI_INSTRUMENT_COUNT") == 0)
142 event = LSCP_EVENT_MIDI_INSTRUMENT_COUNT;
143 else if (strcasecmp(pszText, "MIDI_INSTRUMENT_INFO") == 0)
144 event = LSCP_EVENT_MIDI_INSTRUMENT_INFO;
145 else if (strcasecmp(pszText, "MISCELLANEOUS") == 0)
146 event = LSCP_EVENT_MISCELLANEOUS;
147 else if (strcasecmp(pszText, "CHANNEL_MIDI") == 0)
148 event = LSCP_EVENT_CHANNEL_MIDI;
149 }
150
151 return event;
152 }
153
154
155 // end of event.c

  ViewVC Help
Powered by ViewVC