00001 /*********************************************************************** 00002 * 00003 * Copyright (C) 2009 Nils Doormann <ndmn@users.sourceforge.net> 00004 * 00005 * This program is free software: you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation, either version 3 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 * 00018 ***********************************************************************/ 00019 00020 /*************************************************************** 00021 * defs.h 00022 * 00023 * $Id: defs.h,v 1.4 2009/09/08 21:54:48 ndmn Exp $ 00024 * 00025 * Definitions common to all units 00026 * 00027 ***************************************************************/ 00028 00029 #ifndef __NCHAINS_DEFS_H 00030 #define __NCHAINS_DEFS_H 00031 00032 #include <stdio.h> 00033 #include <stdlib.h> 00034 #include <unistd.h> 00035 #include <sys/time.h> 00036 #include <curses.h> 00037 #include <signal.h> 00038 #include <string.h> 00039 00040 /** 00041 * @desc The ecasound standard server port 00042 */ 00043 #define ECA_SERVER_PORT 2868 /* see man ecasound(1) */ 00044 00045 /** 00046 * @desc Maximum size of server response string 00047 */ 00048 #define MAX_SRESP 1024 00049 00050 /* 00051 * @desc Server response code 00052 */ 00053 #define SRESP_OK 256 00054 #define SRESP_ERR -1 00055 00056 /* 00057 * The maximum length of an input or output name 00058 */ 00059 #define INPUT_MAX 256 00060 #define OUTPUT_MAX 256 00061 00062 /** 00063 * number of chains 00064 */ 00065 #define NUM_CHAINS 8 00066 00067 /* 00068 * View offsets 00069 */ 00070 #define OFFSET_CHAINLIST 2 00071 #define FOOTER_OFFSET (OFFSET_CHAINLIST + app->num_chains ) 00072 #define STATUS_Y (FOOTER_OFFSET + 5) 00073 #define STATUS_OFFSET STATUS_Y /* synonym */ 00074 00075 /* 00076 * X-positions 00077 */ 00078 #define CNAME_X 0 00079 #define INPUT_X 20 00080 #define OUTPUT_X 22 00081 #define MUTED_X 24 00082 #define SOLO_X 26 00083 #define CHCOPY_X 28 00084 #define VOLUME_X 30 00085 #define PANNING_X 35 00086 00087 00088 /* 00089 * Positions 00090 */ 00091 #define CUR_CHAIN_INDEX gchain[y-OFFSET_CHAINLIST].index 00092 #define PCUR_CHAIN_INDEX gchain[y-OFFSET_CHAINLIST]->index 00093 #define CURSOR_OVER_CHAIN (y >= OFFSET_CHAINLIST && y < (app->num_chains+OFFSET_CHAINLIST)) 00094 00095 /* 00096 * Other 00097 */ 00098 #define STR_STATUS " " 00099 00100 /** 00101 * Foreground color pairs 00102 */ 00103 enum __color_pairs { 00104 CP_CYAN = 1, 00105 CP_YELLOW = 2, 00106 CP_GREEN = 3, 00107 CP_RED = 4, 00108 CP_RED_INV = 5, 00109 CP_MAGENTA = 6, 00110 CP_GREEN_INV = 7, 00111 CP_BLUE = 8 00112 }; 00113 00114 /** 00115 * @desc All the muted states 00116 */ 00117 enum __muted_states 00118 { 00119 STATE_MUTED_NONE = 0, 00120 STATE_MUTED_MUTED = 1, 00121 STATE_MUTED_SOLO = 2 00122 }; 00123 00124 /* 00125 * @desc Mute actions 00126 */ 00127 enum __mute_actions 00128 { 00129 MA_MUTE = 0, 00130 MA_SOLO = 1, 00131 MA_SMUTE = 2 00132 }; 00133 00134 /** 00135 * Channel copy modes 00136 */ 00137 enum __chcopy_modes 00138 { 00139 CHCOPY_OFF = 0, 00140 CHCOPY_ON = 1 00141 }; 00142 00143 /* 00144 * @desc End Of Command 00145 */ 00146 #define EOC "\r\n" 00147 00148 /************************************************************************* 00149 * Types 00150 *************************************************************************/ 00151 //struct _aio; 00152 //struct _chain; 00153 00154 struct _aio 00155 { 00156 struct _chain *chains_connected; 00157 int num_chains_connected; 00158 int selected; 00159 char *name; 00160 char *position; 00161 char *length; 00162 }; 00163 00164 typedef struct _aio AIO_INPUT; 00165 typedef struct _aio* AIO_INPUT_ITERATOR; 00166 00167 typedef struct _aio AIO_OUTPUT; 00168 typedef struct _aio* AIO_OUTPUT_ITERATOR; 00169 00170 00171 00172 struct _chain 00173 { 00174 /** 00175 * @desc The row index of the chain from 0..n where 0 is the first and n the last chain in row. 00176 */ 00177 int index; /* == visual row */ 00178 00179 /** 00180 * @desc The chain identifier string. 00181 * According to the active signal selection option <b>-a</b> from ecasound(3), 00182 * this field defines the chain name of the chain. 00183 */ 00184 char a[20]; 00185 00186 /** 00187 * @desc The visual chain name string. 00188 */ 00189 char va[20]; 00190 00191 /** 00192 * @desc The chain input name which corresponds to ecasound(3) option <b>-i</b>. 00193 */ 00194 char i[255]; 00195 00196 /* 00197 * audio input index, 0 if not attached 00198 */ 00199 unsigned int input; 00200 00201 /** 00202 * @desc The chain output which corresponds to ecasound(3) option <b>-o</b>. 00203 */ 00204 char o[255]; 00205 00206 /* 00207 * audio output index, 0 if not attached 00208 */ 00209 unsigned int output; 00210 00211 /** 00212 * @desc The Amplify parameter of the chain. See ecasound(3) <b>-ea</b>. 00213 */ 00214 int ea; 00215 00216 /** 00217 * @desc The Normal pan parameter of the chain. See ecasound(3) <b>-epp</b>. 00218 */ 00219 int epp; 00220 00221 /** 00222 * @desc Channel copy mode switch, can be 0(off) or 1(on). 00223 */ 00224 int chcopy; 00225 00226 /** 00227 * @desc Muting status switch. Values can be STATE_MUTED_NONE, STATE_MUTED_MUTED or STATE_MUTED_SOLO. 00228 */ 00229 short state_muted; 00230 00231 /** 00232 * @desc This file sequencing parameter defines the time position in seconds when the specific chain input should be played. 00233 * Think of "play input.wav at songposition 330.475 seconds". See ecasound(3), section <i>Audio file sequencing</i>. 00234 */ 00235 float ai_playat; 00236 00237 /** 00238 * @desc The sequence offset. Plays the input from its time position <i>offset</i>. See ecasound(3), section <i>Audio file sequencing</i>. 00239 */ 00240 float ai_select; 00241 00242 /** 00243 * @desc The input sequence duration in seconds. 00244 */ 00245 float ai_duration; 00246 00247 /** 00248 * @desc The total length of the chain input. 00249 */ 00250 float ai_length; 00251 00252 /** 00253 * Indicates that the chain is temporarily being removed (for ex. a chain with null input device during bounce) 00254 * can be 0 or 1(removed) 00255 */ 00256 int removed; 00257 00258 }; 00259 00260 00261 typedef struct _chain CHAIN; 00262 typedef struct _chain* CHAIN_ITERATOR; 00263 00264 /* 00265 * Application state 00266 */ 00267 struct _application 00268 { 00269 WINDOW *win; 00270 char debug; 00271 char is_running; 00272 char csname[255]; 00273 00274 /* 00275 * Client socket file descriptors/pointers 00276 */ 00277 int cl_sfd; 00278 FILE *cl_sfp; 00279 00280 /** 00281 * Number of all chains contained in the project 00282 */ 00283 unsigned int num_chains; 00284 00285 /** 00286 * @desc Container for all chains. 00287 * @see num_chains for the number of elements contained in the chain list. 00288 */ 00289 struct _chain *gchain; 00290 00291 /** 00292 * Pointer to the fist chain in chain list 00293 */ 00294 struct _chain *cbegin; 00295 00296 /** 00297 * Pointer to the last chain in chain list 00298 */ 00299 struct _chain *cend; 00300 00301 /* 00302 * The total number of inputs and outputs 00303 * contained in chain setup 00304 */ 00305 unsigned int num_inputs; 00306 unsigned int num_outputs; 00307 00308 /* 00309 * How many chains are soloized 00310 */ 00311 int count_solo; 00312 00313 /* 00314 * real length is the computed length of all relevant chains 00315 */ 00316 float real_length; 00317 00318 /* 00319 * initial setup flags 00320 */ 00321 char start_server; 00322 char server_host[1024]; // hostname 00323 unsigned int server_port; 00324 00325 }; 00326 00327 /************************************************************************ 00328 * Global Solo state counter 00329 ************************************************************************/ 00330 //extern int count_solo; 00331 00332 /************************************************************************ 00333 * global chain container 00334 ***********************************************************************/ 00335 //extern struct _chain gchain[NUM_CHAINS]; 00336 00337 struct _application *gappl; 00338 00339 #endif /* __NCHAINS_DEFS_H */