annotate examples/08-PureData/basic_libpd/s_stuff.h @ 464:8fcfbfb32aa0 prerelease

Examples reorder with subdirectories. Added header to each project. Moved Doxygen to bottom of render.cpp.
author Robert Jack <robert.h.jack@gmail.com>
date Mon, 20 Jun 2016 16:20:38 +0100
parents
children
rev   line source
robert@464 1 /* Copyright (c) 1997-1999 Miller Puckette.
robert@464 2 * For information on usage and redistribution, and for a DISCLAIMER OF ALL
robert@464 3 * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
robert@464 4
robert@464 5 /* Audio and MIDI I/O, and other scheduling and system stuff. */
robert@464 6
robert@464 7 /* NOTE: this file describes Pd implementation details which may change
robert@464 8 in future releases. The public (stable) API is in m_pd.h. */
robert@464 9
robert@464 10 /* in s_path.c */
robert@464 11
robert@464 12 typedef struct _namelist /* element in a linked list of stored strings */
robert@464 13 {
robert@464 14 struct _namelist *nl_next; /* next in list */
robert@464 15 char *nl_string; /* the string */
robert@464 16 } t_namelist;
robert@464 17
robert@464 18 t_namelist *namelist_append(t_namelist *listwas, const char *s, int allowdup);
robert@464 19 t_namelist *namelist_append_files(t_namelist *listwas, const char *s);
robert@464 20 void namelist_free(t_namelist *listwas);
robert@464 21 char *namelist_get(t_namelist *namelist, int n);
robert@464 22 void sys_setextrapath(const char *p);
robert@464 23 extern int sys_usestdpath;
robert@464 24 extern t_namelist *sys_externlist;
robert@464 25 extern t_namelist *sys_searchpath;
robert@464 26 extern t_namelist *sys_helppath;
robert@464 27 int sys_open_absolute(const char *name, const char* ext,
robert@464 28 char *dirresult, char **nameresult, unsigned int size, int bin, int *fdp);
robert@464 29 int sys_trytoopenone(const char *dir, const char *name, const char* ext,
robert@464 30 char *dirresult, char **nameresult, unsigned int size, int bin);
robert@464 31 t_symbol *sys_decodedialog(t_symbol *s);
robert@464 32
robert@464 33 /* s_file.c */
robert@464 34
robert@464 35 void sys_loadpreferences( void);
robert@464 36 void sys_savepreferences( void);
robert@464 37 extern int sys_defeatrt;
robert@464 38 extern t_symbol *sys_flags;
robert@464 39
robert@464 40 /* s_main.c */
robert@464 41 extern int sys_debuglevel;
robert@464 42 extern int sys_verbose;
robert@464 43 extern int sys_noloadbang;
robert@464 44 extern int sys_nogui;
robert@464 45 extern char *sys_guicmd;
robert@464 46
robert@464 47 EXTERN int sys_nearestfontsize(int fontsize);
robert@464 48 EXTERN int sys_hostfontsize(int fontsize);
robert@464 49
robert@464 50 extern int sys_defaultfont;
robert@464 51 EXTERN t_symbol *sys_libdir; /* library directory for auxilliary files */
robert@464 52 extern t_symbol *sys_guidir; /* directory holding pd_gui, u_pdsend, etc */
robert@464 53
robert@464 54 /* s_loader.c */
robert@464 55
robert@464 56 typedef int (*loader_t)(t_canvas *canvas, char *classname); /* callback type */
robert@464 57 EXTERN int sys_load_lib(t_canvas *canvas, char *filename);
robert@464 58 EXTERN void sys_register_loader(loader_t loader);
robert@464 59
robert@464 60 /* s_audio.c */
robert@464 61
robert@464 62 #define SENDDACS_NO 0 /* return values for sys_send_dacs() */
robert@464 63 #define SENDDACS_YES 1
robert@464 64 #define SENDDACS_SLEPT 2
robert@464 65
robert@464 66 #define DEFDACBLKSIZE 8
robert@464 67 extern int sys_schedblocksize; /* audio block size for scheduler */
robert@464 68 extern int sys_hipriority; /* real-time flag, true if priority boosted */
robert@464 69 EXTERN t_sample *sys_soundout;
robert@464 70 EXTERN t_sample *sys_soundin;
robert@464 71 extern int sys_inchannels;
robert@464 72 extern int sys_outchannels;
robert@464 73 extern int sys_advance_samples; /* scheduler advance in samples */
robert@464 74 extern int sys_blocksize; /* audio I/O block size in sample frames */
robert@464 75 extern t_float sys_dacsr;
robert@464 76 extern int sys_schedadvance;
robert@464 77 extern int sys_sleepgrain;
robert@464 78 EXTERN void sys_set_audio_settings(int naudioindev, int *audioindev,
robert@464 79 int nchindev, int *chindev,
robert@464 80 int naudiooutdev, int *audiooutdev, int nchoutdev, int *choutdev,
robert@464 81 int srate, int advance, int callback, int blocksize);
robert@464 82 /* the same as above, but reopens the audio subsystem if needed */
robert@464 83 EXTERN void sys_set_audio_settings_reopen(int naudioindev, int *audioindev,
robert@464 84 int nchindev, int *chindev,
robert@464 85 int naudiooutdev, int *audiooutdev, int nchoutdev, int *choutdev,
robert@464 86 int srate, int advance, int callback, int blocksize);
robert@464 87 EXTERN void sys_reopen_audio( void);
robert@464 88 EXTERN void sys_close_audio(void);
robert@464 89 /* return true if the interface prefers always being open (ala jack) : */
robert@464 90 EXTERN int audio_shouldkeepopen( void);
robert@464 91 EXTERN int audio_isopen( void); /* true if audio interface is open */
robert@464 92 EXTERN int sys_audiodevnametonumber(int output, const char *name);
robert@464 93 EXTERN void sys_audiodevnumbertoname(int output, int devno, char *name,
robert@464 94 int namesize);
robert@464 95
robert@464 96 int sys_send_dacs(void);
robert@464 97 void sys_reportidle(void);
robert@464 98 void sys_set_priority(int higher);
robert@464 99 void sys_audiobuf(int nbufs);
robert@464 100 void sys_getmeters(t_sample *inmax, t_sample *outmax);
robert@464 101 void sys_listdevs(void);
robert@464 102 void sys_setblocksize(int n);
robert@464 103
robert@464 104 EXTERN void sys_get_audio_devs(char *indevlist, int *nindevs,
robert@464 105 char *outdevlist, int *noutdevs, int *canmulti, int *cancallback,
robert@464 106 int maxndev, int devdescsize);
robert@464 107 EXTERN void sys_get_audio_apis(char *buf);
robert@464 108
robert@464 109 /* s_midi.c */
robert@464 110 #define MAXMIDIINDEV 16 /* max. number of input ports */
robert@464 111 #define MAXMIDIOUTDEV 16 /* max. number of output ports */
robert@464 112 extern int sys_midiapi;
robert@464 113 extern int sys_nmidiin;
robert@464 114 extern int sys_nmidiout;
robert@464 115 extern int sys_midiindevlist[];
robert@464 116 extern int sys_midioutdevlist[];
robert@464 117
robert@464 118 EXTERN void sys_open_midi(int nmidiin, int *midiinvec,
robert@464 119 int nmidiout, int *midioutvec, int enable);
robert@464 120
robert@464 121 EXTERN void sys_get_midi_apis(char *buf);
robert@464 122 EXTERN void sys_get_midi_devs(char *indevlist, int *nindevs,
robert@464 123 char *outdevlist, int *noutdevs,
robert@464 124 int maxndev, int devdescsize);
robert@464 125 EXTERN void sys_get_midi_params(int *pnmidiindev, int *pmidiindev,
robert@464 126 int *pnmidioutdev, int *pmidioutdev);
robert@464 127 EXTERN int sys_mididevnametonumber(int output, const char *name);
robert@464 128 EXTERN void sys_mididevnumbertoname(int output, int devno, char *name,
robert@464 129 int namesize);
robert@464 130
robert@464 131 EXTERN void sys_reopen_midi( void);
robert@464 132 EXTERN void sys_close_midi( void);
robert@464 133 EXTERN void sys_putmidimess(int portno, int a, int b, int c);
robert@464 134 EXTERN void sys_putmidibyte(int portno, int a);
robert@464 135 EXTERN void sys_poll_midi(void);
robert@464 136 EXTERN void sys_setmiditimediff(double inbuftime, double outbuftime);
robert@464 137 EXTERN void sys_midibytein(int portno, int byte);
robert@464 138
robert@464 139 /* implemented in the system dependent MIDI code (s_midi_pm.c, etc. ) */
robert@464 140 void midi_getdevs(char *indevlist, int *nindevs,
robert@464 141 char *outdevlist, int *noutdevs, int maxndev, int devdescsize);
robert@464 142 void sys_do_open_midi(int nmidiindev, int *midiindev,
robert@464 143 int nmidioutdev, int *midioutdev);
robert@464 144
robert@464 145 #ifdef USEAPI_ALSA
robert@464 146 EXTERN void sys_alsa_putmidimess(int portno, int a, int b, int c);
robert@464 147 EXTERN void sys_alsa_putmidibyte(int portno, int a);
robert@464 148 EXTERN void sys_alsa_poll_midi(void);
robert@464 149 EXTERN void sys_alsa_setmiditimediff(double inbuftime, double outbuftime);
robert@464 150 EXTERN void sys_alsa_midibytein(int portno, int byte);
robert@464 151 EXTERN void sys_alsa_close_midi( void);
robert@464 152
robert@464 153
robert@464 154 /* implemented in the system dependent MIDI code (s_midi_pm.c, etc. ) */
robert@464 155 void midi_alsa_getdevs(char *indevlist, int *nindevs,
robert@464 156 char *outdevlist, int *noutdevs, int maxndev, int devdescsize);
robert@464 157 void sys_alsa_do_open_midi(int nmidiindev, int *midiindev,
robert@464 158 int nmidioutdev, int *midioutdev);
robert@464 159 #endif
robert@464 160
robert@464 161 /* m_sched.c */
robert@464 162 EXTERN void sys_log_error(int type);
robert@464 163 #define ERR_NOTHING 0
robert@464 164 #define ERR_ADCSLEPT 1
robert@464 165 #define ERR_DACSLEPT 2
robert@464 166 #define ERR_RESYNC 3
robert@464 167 #define ERR_DATALATE 4
robert@464 168
robert@464 169 #define SCHED_AUDIO_NONE 0
robert@464 170 #define SCHED_AUDIO_POLL 1
robert@464 171 #define SCHED_AUDIO_CALLBACK 2
robert@464 172 void sched_set_using_audio(int flag);
robert@464 173
robert@464 174 /* s_inter.c */
robert@464 175
robert@464 176 EXTERN void sys_microsleep(int microsec);
robert@464 177 EXTERN void sys_init_fdpoll(void);
robert@464 178
robert@464 179 EXTERN void sys_bail(int exitcode);
robert@464 180 EXTERN int sys_pollgui(void);
robert@464 181
robert@464 182 EXTERN_STRUCT _socketreceiver;
robert@464 183 #define t_socketreceiver struct _socketreceiver
robert@464 184
robert@464 185 typedef void (*t_socketnotifier)(void *x, int n);
robert@464 186 typedef void (*t_socketreceivefn)(void *x, t_binbuf *b);
robert@464 187
robert@464 188 EXTERN t_socketreceiver *socketreceiver_new(void *owner,
robert@464 189 t_socketnotifier notifier, t_socketreceivefn socketreceivefn, int udp);
robert@464 190 EXTERN void socketreceiver_read(t_socketreceiver *x, int fd);
robert@464 191 EXTERN void sys_sockerror(char *s);
robert@464 192 EXTERN void sys_closesocket(int fd);
robert@464 193
robert@464 194 typedef void (*t_fdpollfn)(void *ptr, int fd);
robert@464 195 EXTERN void sys_addpollfn(int fd, t_fdpollfn fn, void *ptr);
robert@464 196 EXTERN void sys_rmpollfn(int fd);
robert@464 197 #if defined(USEAPI_OSS) || defined(USEAPI_ALSA)
robert@464 198 void sys_setalarm(int microsec);
robert@464 199 #endif
robert@464 200
robert@464 201 #define API_NONE 0
robert@464 202 #define API_ALSA 1
robert@464 203 #define API_OSS 2
robert@464 204 #define API_MMIO 3
robert@464 205 #define API_PORTAUDIO 4
robert@464 206 #define API_JACK 5
robert@464 207 #define API_SGI 6 /* gone */
robert@464 208 #define API_AUDIOUNIT 7
robert@464 209 #define API_ESD 8 /* no idea what this was, probably gone now */
robert@464 210 #define API_DUMMY 9
robert@464 211
robert@464 212 /* figure out which API should be the default. The one we judge most
robert@464 213 likely to offer a working device takes precedence so that if you
robert@464 214 start up Pd for the first time there's a reasonable chance you'll have
robert@464 215 sound. (You'd think portaudio would be best but it seems to default
robert@464 216 to jack on linux, and and on Windows we only use it for ASIO).
robert@464 217 If nobody shows up, define DUMMY and make it the default.*/
robert@464 218 #if defined(USEAPI_MMIO)
robert@464 219 # define API_DEFAULT API_MMIO
robert@464 220 # define API_DEFSTRING "MMIO"
robert@464 221 #elif defined(USEAPI_ALSA)
robert@464 222 # define API_DEFAULT API_ALSA
robert@464 223 # define API_DEFSTRING "ALSA"
robert@464 224 #elif defined(USEAPI_OSS)
robert@464 225 # define API_DEFAULT API_OSS
robert@464 226 # define API_DEFSTRING "OSS"
robert@464 227 #elif defined(USEAPI_AUDIOUNIT)
robert@464 228 # define API_DEFAULT API_AUDIOUNIT
robert@464 229 # define API_DEFSTRING "AudioUnit"
robert@464 230 #elif defined(USEAPI_ESD)
robert@464 231 # define API_DEFAULT API_ESD
robert@464 232 # define API_DEFSTRING "ESD (?)"
robert@464 233 #elif defined(USEAPI_PORTAUDIO)
robert@464 234 # define API_DEFAULT API_PORTAUDIO
robert@464 235 # define API_DEFSTRING "portaudio"
robert@464 236 #elif defined(USEAPI_JACK)
robert@464 237 # define API_DEFAULT API_JACK
robert@464 238 # define API_DEFSTRING "Jack audio connection kit"
robert@464 239 #else
robert@464 240 # ifndef USEAPI_DUMMY /* we need at least one so bring in the dummy */
robert@464 241 # define USEAPI_DUMMY
robert@464 242 # endif /* USEAPI_DUMMY */
robert@464 243 # define API_DEFAULT API_DUMMY
robert@464 244 # define API_DEFSTRING "dummy audio"
robert@464 245 #endif
robert@464 246
robert@464 247 #define DEFAULTAUDIODEV 0
robert@464 248
robert@464 249 #define MAXAUDIOINDEV 4
robert@464 250 #define MAXAUDIOOUTDEV 4
robert@464 251
robert@464 252 #define DEFMIDIDEV 0
robert@464 253
robert@464 254 #define DEFAULTSRATE 44100
robert@464 255 #ifdef _WIN32
robert@464 256 #define DEFAULTADVANCE 80
robert@464 257 #else
robert@464 258 #ifdef __APPLE__
robert@464 259 #define DEFAULTADVANCE 5 /* this is in addition to their own delay */
robert@464 260 #else
robert@464 261 #define DEFAULTADVANCE 25
robert@464 262 #endif
robert@464 263 #endif
robert@464 264
robert@464 265 typedef void (*t_audiocallback)(void);
robert@464 266
robert@464 267 int pa_open_audio(int inchans, int outchans, int rate, t_sample *soundin,
robert@464 268 t_sample *soundout, int framesperbuf, int nbuffers,
robert@464 269 int indeviceno, int outdeviceno, t_audiocallback callback);
robert@464 270 void pa_close_audio(void);
robert@464 271 int pa_send_dacs(void);
robert@464 272 void sys_reportidle(void);
robert@464 273 void pa_listdevs(void);
robert@464 274 void pa_getdevs(char *indevlist, int *nindevs,
robert@464 275 char *outdevlist, int *noutdevs, int *canmulti,
robert@464 276 int maxndev, int devdescsize);
robert@464 277
robert@464 278 int oss_open_audio(int naudioindev, int *audioindev, int nchindev,
robert@464 279 int *chindev, int naudiooutdev, int *audiooutdev, int nchoutdev,
robert@464 280 int *choutdev, int rate, int blocksize);
robert@464 281 void oss_close_audio(void);
robert@464 282 int oss_send_dacs(void);
robert@464 283 void oss_reportidle(void);
robert@464 284 void oss_getdevs(char *indevlist, int *nindevs,
robert@464 285 char *outdevlist, int *noutdevs, int *canmulti,
robert@464 286 int maxndev, int devdescsize);
robert@464 287
robert@464 288 int alsa_open_audio(int naudioindev, int *audioindev, int nchindev,
robert@464 289 int *chindev, int naudiooutdev, int *audiooutdev, int nchoutdev,
robert@464 290 int *choutdev, int rate, int blocksize);
robert@464 291 void alsa_close_audio(void);
robert@464 292 int alsa_send_dacs(void);
robert@464 293 void alsa_reportidle(void);
robert@464 294 void alsa_getdevs(char *indevlist, int *nindevs,
robert@464 295 char *outdevlist, int *noutdevs, int *canmulti,
robert@464 296 int maxndev, int devdescsize);
robert@464 297
robert@464 298 int jack_open_audio(int wantinchans, int wantoutchans, int srate,
robert@464 299 t_audiocallback callback);
robert@464 300 void jack_close_audio(void);
robert@464 301 int jack_send_dacs(void);
robert@464 302 void jack_reportidle(void);
robert@464 303 void jack_getdevs(char *indevlist, int *nindevs,
robert@464 304 char *outdevlist, int *noutdevs, int *canmulti,
robert@464 305 int maxndev, int devdescsize);
robert@464 306 void jack_listdevs(void);
robert@464 307
robert@464 308 int mmio_open_audio(int naudioindev, int *audioindev,
robert@464 309 int nchindev, int *chindev, int naudiooutdev, int *audiooutdev,
robert@464 310 int nchoutdev, int *choutdev, int rate, int blocksize);
robert@464 311 void mmio_close_audio( void);
robert@464 312 void mmio_reportidle(void);
robert@464 313 int mmio_send_dacs(void);
robert@464 314 void mmio_getdevs(char *indevlist, int *nindevs,
robert@464 315 char *outdevlist, int *noutdevs, int *canmulti,
robert@464 316 int maxndev, int devdescsize);
robert@464 317
robert@464 318 int audiounit_open_audio(int naudioindev, int *audioindev, int nchindev,
robert@464 319 int *chindev, int naudiooutdev, int *audiooutdev, int nchoutdev,
robert@464 320 int *choutdev, int rate);
robert@464 321 void audiounit_close_audio(void);
robert@464 322 int audiounit_send_dacs(void);
robert@464 323 void audiounit_listdevs(void);
robert@464 324 void audiounit_getdevs(char *indevlist, int *nindevs,
robert@464 325 char *outdevlist, int *noutdevs, int *canmulti,
robert@464 326 int maxndev, int devdescsize);
robert@464 327
robert@464 328 int esd_open_audio(int naudioindev, int *audioindev, int nchindev,
robert@464 329 int *chindev, int naudiooutdev, int *audiooutdev, int nchoutdev,
robert@464 330 int *choutdev, int rate);
robert@464 331 void esd_close_audio(void);
robert@464 332 int esd_send_dacs(void);
robert@464 333 void esd_listdevs(void);
robert@464 334 void esd_getdevs(char *indevlist, int *nindevs,
robert@464 335 char *outdevlist, int *noutdevs, int *canmulti,
robert@464 336 int maxndev, int devdescsize);
robert@464 337
robert@464 338 int dummy_open_audio(int nin, int nout, int sr);
robert@464 339 int dummy_close_audio( void);
robert@464 340 int dummy_send_dacs( void);
robert@464 341 void dummy_getdevs(char *indevlist, int *nindevs, char *outdevlist,
robert@464 342 int *noutdevs, int *canmulti, int maxndev, int devdescsize);
robert@464 343 void dummy_listdevs( void);
robert@464 344
robert@464 345 void sys_listmididevs(void);
robert@464 346 EXTERN void sys_set_midi_api(int whichapi);
robert@464 347 EXTERN void sys_set_audio_api(int whichapi);
robert@464 348 EXTERN int sys_audioapi;
robert@464 349 EXTERN void sys_set_audio_state(int onoff);
robert@464 350
robert@464 351 /* API dependent audio flags and settings */
robert@464 352 void oss_set32bit( void);
robert@464 353 void linux_alsa_devname(char *devname);
robert@464 354
robert@464 355 EXTERN void sys_get_audio_params(
robert@464 356 int *pnaudioindev, int *paudioindev, int *chindev,
robert@464 357 int *pnaudiooutdev, int *paudiooutdev, int *choutdev,
robert@464 358 int *prate, int *padvance, int *callback, int *blocksize);
robert@464 359 void sys_save_audio_params(
robert@464 360 int naudioindev, int *audioindev, int *chindev,
robert@464 361 int naudiooutdev, int *audiooutdev, int *choutdev,
robert@464 362 int rate, int advance, int callback, int blocksize);
robert@464 363
robert@464 364 /* s_file.c */
robert@464 365
robert@464 366 typedef void (*t_printhook)(const char *s);
robert@464 367 extern t_printhook sys_printhook; /* set this to override printing */
robert@464 368 extern int sys_printtostderr;
robert@464 369
robert@464 370 /* jsarlo { */
robert@464 371
robert@464 372 EXTERN double sys_time;
robert@464 373 EXTERN double sys_time_per_dsp_tick;
robert@464 374 EXTERN int sys_externalschedlib;
robert@464 375
robert@464 376 EXTERN t_sample* get_sys_soundout(void ) ;
robert@464 377 EXTERN t_sample* get_sys_soundin(void ) ;
robert@464 378 EXTERN int* get_sys_main_advance(void ) ;
robert@464 379 EXTERN double* get_sys_time_per_dsp_tick(void ) ;
robert@464 380 EXTERN int* get_sys_schedblocksize(void ) ;
robert@464 381 EXTERN double* get_sys_time(void ) ;
robert@464 382 EXTERN t_float* get_sys_dacsr(void ) ;
robert@464 383 EXTERN int* get_sys_sleepgrain(void ) ;
robert@464 384 EXTERN int* get_sys_schedadvance(void ) ;
robert@464 385
robert@464 386 EXTERN void sys_clearhist(void );
robert@464 387 EXTERN void sys_initmidiqueue(void );
robert@464 388 EXTERN int sys_addhist(int phase);
robert@464 389 EXTERN void sys_setmiditimediff(double inbuftime, double outbuftime);
robert@464 390 EXTERN void sched_tick( void);
robert@464 391 EXTERN void sys_pollmidiqueue(void );
robert@464 392 EXTERN int sys_pollgui(void );
robert@464 393 EXTERN void sys_setchsr(int chin, int chout, int sr);
robert@464 394
robert@464 395 EXTERN void inmidi_realtimein(int portno, int cmd);
robert@464 396 EXTERN void inmidi_byte(int portno, int byte);
robert@464 397 EXTERN void inmidi_sysex(int portno, int byte);
robert@464 398 EXTERN void inmidi_noteon(int portno, int channel, int pitch, int velo);
robert@464 399 EXTERN void inmidi_controlchange(int portno,
robert@464 400 int channel,
robert@464 401 int ctlnumber,
robert@464 402 int value);
robert@464 403 EXTERN void inmidi_programchange(int portno, int channel, int value);
robert@464 404 EXTERN void inmidi_pitchbend(int portno, int channel, int value);
robert@464 405 EXTERN void inmidi_aftertouch(int portno, int channel, int value);
robert@464 406 EXTERN void inmidi_polyaftertouch(int portno,
robert@464 407 int channel,
robert@464 408 int pitch,
robert@464 409 int value);
robert@464 410 /* } jsarlo */
robert@464 411 extern t_widgetbehavior text_widgetbehavior;