1 /*
2     TiMidity++ -- MIDI to WAVE converter and player
3     Copyright (C) 1999-2002 Masanao Izumo <mo@goice.co.jp>
4     Copyright (C) 1995 Tuukka Toivonen <tt@cgs.fi>
5 
6     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10 
11     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15 
16     You should have received a copy of the GNU General Public License
17     along with this program; if not, write to the Free Software
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 
20     controls.h
21 */
22 
23 #ifndef ___CONTROLS_H_
24 #define ___CONTROLS_H_
25 
26 #define RC_IS_SKIP_FILE(rc) ((rc) == RC_QUIT || (rc) == RC_LOAD_FILE || \
27 			     (rc) == RC_NEXT || (rc) == RC_REALLY_PREVIOUS || \
28 			     (rc) == RC_ERROR || (rc) == RC_STOP || \
29 			     (rc) == RC_TUNE_END)
30 
31 /* Return values for ControlMode.read */
32 #define RC_ERROR	-1
33 #ifdef RC_NONE
34 #undef RC_NONE
35 #endif
36 #define RC_NONE		0
37 #define RC_QUIT		1
38 #define RC_NEXT		2
39 #define RC_PREVIOUS	3 /* Restart this song at beginning, or the previous
40 			     song if we're less than a second into this one. */
41 #define RC_FORWARD	4
42 #define RC_BACK		5
43 #define RC_JUMP		6
44 #define RC_TOGGLE_PAUSE 7	/* Pause/continue */
45 #define RC_RESTART	8	/* Restart song at beginning */
46 #define RC_PAUSE	9	/* Really pause playing */
47 #define RC_CONTINUE	10	/* Continue if paused */
48 #define RC_REALLY_PREVIOUS 11	/* Really go to the previous song */
49 #define RC_CHANGE_VOLUME 12
50 #define RC_LOAD_FILE	13	/* Load a new midifile */
51 #define RC_TUNE_END	14	/* The tune is over, play it again sam? */
52 #define RC_KEYUP	15	/* Key up */
53 #define RC_KEYDOWN	16	/* Key down */
54 #define RC_SPEEDUP	17	/* Speed up */
55 #define RC_SPEEDDOWN	18	/* Speed down */
56 #define RC_VOICEINCR	19	/* Increase voices */
57 #define RC_VOICEDECR	20	/* Decrease voices */
58 #define RC_TOGGLE_DRUMCHAN 21	/* Toggle drum channel */
59 #define RC_RELOAD	22	/* Reload & Play */
60 #define RC_TOGGLE_SNDSPEC 23	/* Open/Close Sound Spectrogram Window */
61 #define RC_CHANGE_REV_EFFB 24
62 #define RC_CHANGE_REV_TIME 25
63 #define RC_SYNC_RESTART 26
64 #define RC_TOGGLE_CTL_SPEANA 27
65 #define RC_CHANGE_RATE	28
66 #define RC_OUTPUT_CHANGED      29
67 #define RC_STOP		30	/* Stop to play */
68 #define RC_TOGGLE_MUTE	31
69 #define RC_SOLO_PLAY	32
70 #define RC_MUTE_CLEAR	33
71 
72 #define CMSG_INFO	0
73 #define CMSG_WARNING	1
74 #define CMSG_ERROR	2
75 #define CMSG_FATAL	3
76 #define CMSG_TRACE	4
77 #define CMSG_TIME	5
78 #define CMSG_TOTAL	6
79 #define CMSG_FILE	7
80 #define CMSG_TEXT	8
81 
82 #define VERB_NORMAL	0
83 #define VERB_VERBOSE	1
84 #define VERB_NOISY	2
85 #define VERB_DEBUG	3
86 #define VERB_DEBUG_SILLY 4
87 
88 enum {
89     CTLE_NOW_LOADING,		/* v1:filename */
90     CTLE_LOADING_DONE,		/* v1:0=success -1=error 1=terminated */
91     CTLE_PLAY_START,		/* v1:nsamples */
92     CTLE_PLAY_END,
93     CTLE_CUEPOINT,		/* v1:nsamples */
94     CTLE_CURRENT_TIME,		/* v1:secs, v2:voices */
95     CTLE_NOTE,			/* v1:status, v2:ch, v3:note, v4:velo */
96     CTLE_MASTER_VOLUME,		/* v1:amp(%) */
97     CTLE_METRONOME,		/* v1:measure, v2:beat */
98     CTLE_KEYSIG,		/* v1:key sig */
99     CTLE_KEY_OFFSET,		/* v1:key offset */
100     CTLE_TEMPO,			/* v1:tempo */
101     CTLE_TIME_RATIO,		/* v1:time ratio(%) */
102     CTLE_TEMPER_KEYSIG,		/* v1:tuning key sig */
103     CTLE_TEMPER_TYPE,		/* v1:ch, v2:tuning type */
104     CTLE_MUTE,			/* v1:ch, v2:is_mute */
105     CTLE_PROGRAM,		/* v1:ch, v2:prog, v3:name, v4:bank,lsb.msb */
106     CTLE_VOLUME,		/* v1:ch, v2:value */
107     CTLE_EXPRESSION,		/* v1:ch, v2:value */
108     CTLE_PANNING,		/* v1:ch, v2:value */
109     CTLE_SUSTAIN,		/* v1:ch, v2:value */
110     CTLE_PITCH_BEND,		/* v1:ch, v2:value */
111     CTLE_MOD_WHEEL,		/* v1:ch, v2:value */
112     CTLE_CHORUS_EFFECT,		/* v1:ch, v2:value */
113     CTLE_REVERB_EFFECT,		/* v1:ch, v2:value */
114     CTLE_LYRIC,			/* v1:lyric-ID */
115     CTLE_REFRESH,
116     CTLE_RESET,
117     CTLE_SPEANA,		/* v1:double[] v2:len */
118     CTLE_PAUSE,			/* v1:pause on/off v2:time of pause */
119     CTLE_GSLCD,			/* GS L.C.D. */
120     CTLE_MAXVOICES,		/* v1:voices, Change voices */
121     CTLE_DRUMPART		/* v1:ch, v2:is_drum */
122 };
123 
124 typedef struct _CtlEvent {
125     int type;		/* See above */
126     ptr_size_t v1, v2, v3, v4;/* Event value */
127 } CtlEvent;
128 
129 
130 typedef struct {
131   char *id_name, id_character;
132   char *id_short_name;
133   int verbosity, trace_playing, opened;
134 
135   int32 flags;
136 /* ControlMode flags.
137  * Some interfaces ignore these flags.
138  */
139 #define CTLF_LIST_LOOP		(1u<<0)	/* -i?l */
140 #define CTLF_LIST_RANDOM	(1u<<1)	/* -i?r */
141 #define CTLF_LIST_SORT		(1u<<2)	/* -i?s */
142 #define CTLF_AUTOSTART		(1u<<3)	/* -i?a */
143 #define CTLF_AUTOEXIT		(1u<<4)	/* -i?x */
144 #define CTLF_DRAG_START		(1u<<5)	/* -i?d */
145 #define CTLF_AUTOUNIQ		(1u<<6)	/* -i?u */
146 #define CTLF_AUTOREFINE		(1u<<7)	/* -i?R */
147 #define CTLF_NOT_CONTINUE	(1u<<8)	/* -i?C */
148 #define CTLF_DAEMONIZE		(1u<<9) /* -i?D */
149 
150   int  (*open)(int using_stdin, int using_stdout);
151   void (*close)(void);
152   int (*pass_playing_list)(int number_of_files, char *list_of_files[]);
153   int  (*read)(int32 *valp);
154   int  (*write)(char *buf, int32 size);
155   int  (*cmsg)(int type, int verbosity_level, char *fmt, ...);
156   void (*event)(CtlEvent *ev);	/* Control events */
157 } ControlMode;
158 
159 extern ControlMode *ctl_list[], *ctl;
160 extern int dumb_error_count;
161 
162 extern int std_write(int fd, const void *buffer, int size);
163 
164 #endif /* ___CONTROLS_H_ */
165