/* this is called from main() in s_entry.c */ int sys_main(int argc, char **argv) { int i, noprefs; sys_externalschedlib = 0; sys_extraflags = 0; #ifdef PD_DEBUG fprintf(stderr, "Pd: COMPILED FOR DEBUGGING\n"); #endif /* use Win32 "binary" mode by default since we don't want the * translation that Win32 does by default */ #ifdef _WIN32 # ifdef _MSC_VER /* MS Visual Studio */ _set_fmode( _O_BINARY ); # else /* MinGW */ { extern int _fmode; _fmode = _O_BINARY; } # endif /* _MSC_VER */ #endif /* WIN32 */ pd_init(); /* start the message system */ sys_findprogdir(argv[0]); /* set sys_progname, guipath */ for (i = noprefs = 0; i < argc; i++) /* prescan args for noprefs */ if (!strcmp(argv[i], "-noprefs")) noprefs = 1; if (!noprefs) sys_loadpreferences(); /* load default settings */ #ifndef _WIN32 if (!noprefs) sys_rcfile(); /* parse the startup file */ #endif if (sys_argparse(argc-1, argv+1)) /* parse cmd line */ return (1); sys_afterargparse(); /* post-argparse settings */ if (sys_verbose || sys_version) fprintf(stderr, "%s compiled %s %s\n", pd_version, pd_compiletime, pd_compiledate); if (sys_version) /* if we were just asked our version, exit here. */ return (0); sys_setsignalhandlers(); if (sys_startgui(sys_libdir->s_name)) /* start the gui */ return (1); if (sys_externalschedlib) return (sys_run_scheduler(sys_externalschedlibname, sys_extraflagsstring)); else if (sys_batch) return (m_batchmain()); else { /* open audio and MIDI */ sys_reopen_midi(); if (audio_shouldkeepopen()) sys_reopen_audio(); /* run scheduler until it quits */ return (m_mainloop()); } }
/* this is called from main() in s_entry.c */ int sys_main(int argc, char **argv) { int i, noprefs; sys_externalschedlib = 0; sys_extraflags = 0; #ifdef PD_DEBUG fprintf(stderr, "Pd: COMPILED FOR DEBUGGING\n"); #endif pd_init(); /* start the message system */ logpost(NULL, 2, "PD_FLOATPRECISION = %lu bits", sizeof(t_float)*8); sys_findprogdir(argv[0]); /* set sys_progname, guipath */ for (i = noprefs = 0; i < argc; i++) /* prescan args for noprefs */ if (!strcmp(argv[i], "-noprefs")) noprefs = 1; if (!noprefs) sys_loadpreferences(); /* load default settings */ #ifndef MSW if (!noprefs) sys_rcfile(); /* parse the startup file */ #endif if (sys_argparse(argc-1, argv+1)) /* parse cmd line */ return (1); sys_afterargparse(); /* post-argparse settings */ if (sys_verbose || sys_version) fprintf(stderr, "%s compiled %s %s\n", pd_version, pd_compiletime, pd_compiledate); if (sys_version) /* if we were just asked our version, exit here. */ return (0); if (sys_startgui(sys_libdir->s_name)) /* start the gui */ return(1); if (sys_externalschedlib) return (sys_run_scheduler(sys_externalschedlibname, sys_extraflagsstring)); else if (sys_batch) return (m_batchmain()); else { /* open audio and MIDI */ sys_reopen_midi(); sys_reopen_audio(); /* run scheduler until it quits */ return (m_mainloop()); } }
void cpd_init() { int devices = 0; int ioputs = 2; static char initialized = 0; assert("Pure Data is already initialized." && !initialized); if(!initialized) { cpd_mutex_init(&c_mutex); sys_soundin = NULL; sys_soundout = NULL; c_current_instance = NULL; sys_printhook = (t_printhook)(cpd_print); signal(SIGFPE, SIG_IGN); sys_soundin = NULL; sys_soundout = NULL; sys_schedblocksize = DEFDACBLKSIZE; sys_externalschedlib = 0; sys_printtostderr = 0; sys_usestdpath = 0; sys_debuglevel = 1; sys_verbose = 4; sys_noloadbang = 0; sys_nogui = 1; sys_hipriority = 0; sys_nmidiin = 0; sys_nmidiout = 0; sys_init_fdpoll(); pd_init(); sys_startgui(NULL); sys_set_audio_api(API_DUMMY); sys_searchpath = NULL; sys_set_audio_settings(1, &devices, 1, &ioputs, 1, &devices, 1, &ioputs, 44100, -1, 1, DEFDACBLKSIZE); sched_set_using_audio(SCHED_AUDIO_CALLBACK); sys_reopen_audio(); c_sample_ins = sys_soundin; c_sample_outs = sys_soundout; c_first_instance = pd_this; c_sym_bng = gensym("bng"); c_sym_hsl = gensym("hsl"); c_sym_vsl = gensym("vsl"); c_sym_tgl = gensym("tgl"); c_sym_nbx = gensym("nbx"); c_sym_vradio = gensym("vradio"); c_sym_hradio = gensym("hradio"); c_sym_vu = gensym("vu"); c_sym_cnv = gensym("cnv"); c_sym_empty = gensym("empty"); bob_tilde_setup(); bonk_tilde_setup(); choice_setup(); fiddle_tilde_setup(); loop_tilde_setup(); lrshift_tilde_setup(); pique_setup(); sigmund_tilde_setup(); stdout_setup(); initialized = 1; } }
/* this is called from main() in s_entry.c */ int sys_main(int argc, char **argv) { int i, noprefs; char *prefsfile = ""; sys_externalschedlib = 0; sys_extraflags = 0; #ifdef PD_DEBUG fprintf(stderr, "Pd: COMPILED FOR DEBUGGING\n"); #endif /* use Win32 "binary" mode by default since we don't want the * translation that Win32 does by default */ #ifdef _WIN32 # ifdef _MSC_VER /* MS Visual Studio */ _set_fmode( _O_BINARY ); # else /* MinGW */ { extern int _fmode; _fmode = _O_BINARY; } # endif /* _MSC_VER */ #endif /* _WIN32 */ #ifndef _WIN32 /* long ago Pd used setuid to promote itself to real-time priority. Just in case anyone's installation script still makes it setuid, we complain to stderr and lose setuid here. */ if (getuid() != geteuid()) { fprintf(stderr, "warning: canceling setuid privilege\n"); setuid(getuid()); } #endif /* _WIN32 */ pd_init(); /* start the message system */ sys_findprogdir(argv[0]); /* set sys_progname, guipath */ for (i = noprefs = 0; i < argc; i++) /* prescan for prefs override */ { if (!strcmp(argv[i], "-noprefs")) noprefs = 1; else if (!strcmp(argv[i], "-prefsfile") && i < argc-1) prefsfile = argv[i+1]; } if (!noprefs) /* load preferences before parsing args to allow ... */ sys_loadpreferences(prefsfile, 1); /* args to override prefs */ if (sys_argparse(argc-1, argv+1)) /* parse cmd line args */ return (1); sys_afterargparse(); /* post-argparse settings */ if (sys_verbose || sys_version) fprintf(stderr, "%s compiled %s %s\n", pd_version, pd_compiletime, pd_compiledate); if (sys_version) /* if we were just asked our version, exit here. */ return (0); sys_setsignalhandlers(); if (sys_dontstartgui) clock_set((sys_fakefromguiclk = clock_new(0, (t_method)sys_fakefromgui)), 0); else if (sys_startgui(sys_libdir->s_name)) /* start the gui */ return (1); if (sys_hipriority) sys_setrealtime(sys_libdir->s_name); /* set desired process priority */ if (sys_externalschedlib) return (sys_run_scheduler(sys_externalschedlibname, sys_extraflagsstring)); else if (sys_batch) return (m_batchmain()); else { /* open audio and MIDI */ sys_reopen_midi(); if (audio_shouldkeepopen()) sys_reopen_audio(); /* run scheduler until it quits */ return (m_mainloop()); } }
/* this is called from main() in s_entry.c */ int sys_main(int argc, char **argv) { int i, noprefs; sys_externalschedlib = 0; sys_extraflags = 0; char * filenames; #ifdef PD_DEBUG fprintf(stderr, "Pd-L2Ork: COMPILED FOR DEBUGGING\n"); #endif pd_init(); /* start the message system */ sys_findprogdir(argv[0]); /* set sys_progname, guipath */ for (i = noprefs = 0; i < argc; i++) /* prescan args for noprefs */ if (!strcmp(argv[i], "-noprefs")) noprefs = 1; if (!noprefs) sys_loadpreferences(); /* load default settings */ #ifndef MSW if (!noprefs) sys_rcfile(); /* parse the startup file */ #endif if (sys_argparse(argc-1, argv+1)) /* parse cmd line */ return (1); sys_afterargparse(); /* post-argparse settings */ /* build version string from defines in m_pd.h */ pd_makeversion(); if (sys_verbose || sys_version) fprintf(stderr, "%scompiled %s %s\n", pd_version, pd_compiletime, pd_compiledate); if (sys_version) /* if we were just asked our version, exit here. */ return (0); if (sys_startgui(sys_guidir->s_name)) /* start the gui */ return(1); /* check if we are unique, otherwise, just focus existing instance, and if necessary open file inside it */\ if (sys_openlist) { // let's create one continuous string from all files int length = 0; t_namelist *nl; for (nl = sys_openlist; nl; nl = nl->nl_next) length = length + strlen(nl->nl_string) + 1; if((filenames = malloc(length)) != NULL) { filenames[0] = '\0'; // ensures the memory is an empty string if (sys_openlist) { for (nl = sys_openlist; nl; nl = nl->nl_next) { strcat(filenames,nl->nl_string); if (nl->nl_next) strcat(filenames," "); } } //fprintf(stderr,"final list: <%s>\n", filenames); } else { error("filelist malloc failed!\n"); return(1); } } sys_vgui("pdtk_check_unique %d %s\n", sys_unique, (filenames ? filenames : "0")); if (sys_externalschedlib) return (sys_run_scheduler(sys_externalschedlibname, sys_extraflagsstring)); else if (sys_batch) return (m_batchmain()); else { /* open audio and MIDI */ sys_reopen_midi(); sys_reopen_audio(); if (sys_console) sys_vgui("pdtk_toggle_console 1\n"); if (sys_k12_mode) { t_namelist *path = pd_extrapath; while (path->nl_next) path = path->nl_next; sys_vgui("pdtk_enable_k12_mode %s\n", path->nl_string); } /* run scheduler until it quits */ return (m_mainloop()); } }