1 /* Copyright (c) 1997-1999 Miller Puckette.
2 * For information on usage and redistribution, and for a DISCLAIMER OF ALL
3 * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
5 /* Audio and MIDI I/O, and other scheduling and system stuff. */
7 /* NOTE: this file describes Pd implementation details which may change
8 in future releases. The public (stable) API is in m_pd.h. */
11 typedef struct _namelist
13 struct _namelist
*nl_next
;
17 t_namelist
*namelist_append(t_namelist
*listwas
, const char *s
);
18 void namelist_free(t_namelist
*listwas
);
21 extern int sys_debuglevel
;
22 extern int sys_verbose
;
23 extern int sys_noloadbang
;
25 extern char *sys_guicmd
;
27 EXTERN
int sys_nearestfontsize(int fontsize
);
28 EXTERN
int sys_hostfontsize(int fontsize
);
30 extern int sys_defaultfont
;
31 extern t_symbol
*sys_libdir
; /* library directory for auxilliary files */
34 int sys_load_lib(char *dirname
, char *filename
);
38 #define SENDDACS_NO 0 /* return values for sys_send_dacs() */
39 #define SENDDACS_YES 1
40 #define SENDDACS_SLEPT 2
42 #define DEFDACBLKSIZE 64
43 extern int sys_schedblocksize
; /* audio block size for scheduler */
44 extern int sys_hipriority
; /* real-time flag, true if priority boosted */
45 extern t_sample
*sys_soundout
;
46 extern t_sample
*sys_soundin
;
47 extern int sys_inchannels
;
48 extern int sys_outchannels
;
49 extern int sys_advance_samples
; /* scheduler advance in samples */
50 extern int sys_blocksize
; /* audio I/O block size in sample frames */
51 extern float sys_dacsr
;
52 extern int sys_schedadvance
;
53 extern int sys_sleepgrain
;
54 void sys_open_audio(int naudioindev
, int *audioindev
,
55 int nchindev
, int *chindev
,
56 int naudiooutdev
, int *audiooutdev
, int nchoutdev
, int *choutdev
,
57 int srate
, int advance
, int enable
);
58 void sys_close_audio(void);
61 void sys_open_midi(int nmidiin
, int *midiinvec
, int nmidiout
, int *midioutvec
);
63 /* implemented in the system dependent MIDI code (s_midi_pm.c, etc. ) */
64 void sys_do_open_midi(int nmidiin
, int *midiinvec
,
65 int nmidiout
, int *midioutvec
);
66 void sys_close_midi(void);
67 void midi_getdevs(char *indevlist
, int *nindevs
,
68 char *outdevlist
, int *noutdevs
, int maxndev
, int devdescsize
);
70 int sys_send_dacs(void);
71 void sys_reportidle(void);
72 void sys_set_priority(int higher
);
73 void sys_audiobuf(int nbufs
);
74 void sys_getmeters(float *inmax
, float *outmax
);
75 void sys_listdevs(void);
76 void sys_setblocksize(int n
);
79 #define MAXMIDIINDEV 16 /* max. number of input ports */
80 #define MAXMIDIOUTDEV 16 /* max. number of output ports */
81 extern int sys_nmidiin
;
82 extern int sys_nmidiout
;
83 extern int sys_midiindevlist
[];
84 extern int sys_midioutdevlist
[];
86 EXTERN
void sys_putmidimess(int portno
, int a
, int b
, int c
);
87 EXTERN
void sys_putmidibyte(int portno
, int a
);
88 EXTERN
void sys_poll_midi(void);
89 EXTERN
void sys_setmiditimediff(double inbuftime
, double outbuftime
);
90 EXTERN
void sys_midibytein(int portno
, int byte
);
93 EXTERN
void sys_log_error(int type
);
95 #define ERR_ADCSLEPT 1
96 #define ERR_DACSLEPT 2
98 #define ERR_DATALATE 4
99 void sched_set_using_dacs(int flag
);
103 EXTERN
void sys_microsleep(int microsec
);
105 EXTERN
void sys_bail(int exitcode
);
106 EXTERN
int sys_pollgui(void);
108 EXTERN_STRUCT _socketreceiver
;
109 #define t_socketreceiver struct _socketreceiver
111 typedef void (*t_socketnotifier
)(void *x
);
112 typedef void (*t_socketreceivefn
)(void *x
, t_binbuf
*b
);
114 EXTERN t_socketreceiver
*socketreceiver_new(void *owner
,
115 t_socketnotifier notifier
, t_socketreceivefn socketreceivefn
, int udp
);
116 EXTERN
void socketreceiver_read(t_socketreceiver
*x
, int fd
);
117 EXTERN
void sys_sockerror(char *s
);
118 EXTERN
void sys_closesocket(int fd
);
120 typedef void (*t_fdpollfn
)(void *ptr
, int fd
);
121 EXTERN
void sys_addpollfn(int fd
, t_fdpollfn fn
, void *ptr
);
122 EXTERN
void sys_rmpollfn(int fd
);
124 void sys_setalarm(int microsec
);
125 void sys_setvirtualalarm( void);
131 #define API_PORTAUDIO 4
133 #define API_ROCKBOX 6
135 #if defined(__linux__) && !defined(ROCKBOX)
136 #define API_DEFAULT API_OSS
137 #define API_DEFSTRING "OSS"
140 #define API_DEFAULT API_MMIO
141 #define API_DEFSTRING "MMIO"
144 #define API_DEFAULT API_PORTAUDIO
145 #define API_DEFSTRING "portaudio"
148 #define API_DEFAULT API_ROCKBOX
149 #define API_DEFSTRING "Rockbox"
151 #define DEFAULTAUDIODEV 0
153 #define MAXAUDIOINDEV 4
154 #define MAXAUDIOOUTDEV 4
158 #define DEFAULTSRATE 44100
160 #define DEFAULTADVANCE 70
162 #define DEFAULTADVANCE 50
165 int pa_open_audio(int inchans
, int outchans
, int rate
, t_sample
*soundin
,
166 t_sample
*soundout
, int framesperbuf
, int nbuffers
,
167 int indeviceno
, int outdeviceno
);
168 void pa_close_audio(void);
169 int pa_send_dacs(void);
170 void sys_reportidle(void);
171 void pa_listdevs(void);
172 void pa_getdevs(char *indevlist
, int *nindevs
,
173 char *outdevlist
, int *noutdevs
, int *canmulti
,
174 int maxndev
, int devdescsize
);
176 int oss_open_audio(int naudioindev
, int *audioindev
, int nchindev
,
177 int *chindev
, int naudiooutdev
, int *audiooutdev
, int nchoutdev
,
178 int *choutdev
, int rate
); /* IOhannes */
179 void oss_close_audio(void);
180 int oss_send_dacs(void);
181 void oss_reportidle(void);
182 void oss_getdevs(char *indevlist
, int *nindevs
,
183 char *outdevlist
, int *noutdevs
, int *canmulti
,
184 int maxndev
, int devdescsize
);
186 int alsa_open_audio(int naudioindev
, int *audioindev
, int nchindev
,
187 int *chindev
, int naudiooutdev
, int *audiooutdev
, int nchoutdev
,
188 int *choutdev
, int rate
);
189 void alsa_close_audio(void);
190 int alsa_send_dacs(void);
191 void alsa_reportidle(void);
192 void alsa_getdevs(char *indevlist
, int *nindevs
,
193 char *outdevlist
, int *noutdevs
, int *canmulti
,
194 int maxndev
, int devdescsize
);
196 int jack_open_audio(int wantinchans
, int wantoutchans
, int srate
);
197 void jack_close_audio(void);
198 int jack_send_dacs(void);
199 void jack_reportidle(void);
200 void jack_listdevs(void);
202 void mmio_open_audio(int naudioindev
, int *audioindev
,
203 int nchindev
, int *chindev
, int naudiooutdev
, int *audiooutdev
,
204 int nchoutdev
, int *choutdev
, int rate
);
205 void mmio_close_audio( void);
206 void mmio_reportidle(void);
207 int mmio_send_dacs(void);
208 void mmio_getdevs(char *indevlist
, int *nindevs
,
209 char *outdevlist
, int *noutdevs
, int *canmulti
,
210 int maxndev
, int devdescsize
);
212 void rockbox_open_audio(int rate
);
213 void rockbox_close_audio(void);
214 int rockbox_send_dacs(void);
215 void rockbox_getdevs(void);
217 void sys_listmididevs(void);
218 void sys_set_audio_api(int whichapi
);
219 void sys_get_audio_apis(char *buf
);
220 extern int sys_audioapi
;
221 void sys_set_audio_state(int onoff
);
223 /* API dependent audio flags and settings */
224 void oss_set32bit( void);
225 void linux_alsa_devname(char *devname
);