예제 #1
0
    /* send the hard-coded search path to pd-gui */
void sys_set_extrapath( void)
{
    int i;
    t_namelist *nl;

    sys_gui("set ::tmp_path {}\n");
    for (nl = sys_staticpath, i = 0; nl; nl = nl->nl_next, i++)
        sys_vgui("lappend ::tmp_path {%s}\n", nl->nl_string);
    sys_gui("set ::sys_staticpath $::tmp_path\n");
}
예제 #2
0
static int hammergui_setup(void)
{
    ps_hashhammergui = gensym("#hammergui");
    ps__hammergui = gensym("_hammergui");
    ps__up = gensym("_up");
    ps__focus = gensym("_focus");
    ps__vised = gensym("_vised");
    if (ps_hashhammergui->s_thing)
    {
	char *cname = class_getname(*ps_hashhammergui->s_thing);
#ifdef HAMMERGUI_DEBUG
	fprintf(stderr,
		"'%s' already registered as the global hammergui sink \n",
		(cname ? cname : "???"));
#endif
	if (strcmp(cname, ps__hammergui->s_name))
	{
	    /* FIXME protect against the danger of someone else
	       (e.g. receive) binding to #hammergui */
	    bug("hammergui_setup");
	    return (0);
	}
	else
	{
	    /* FIXME compatibility test */
	    hammergui_class = *ps_hashhammergui->s_thing;
	    return (1);
	}
    }
    hammergui_class = class_new(ps__hammergui, 0, 0,
				sizeof(t_hammergui),
				CLASS_PD | CLASS_NOINLET, 0);
    class_addanything(hammergui_class, hammergui_anything);
    class_addmethod(hammergui_class, (t_method)hammergui__remouse,
		    gensym("_remouse"), 0);
    class_addmethod(hammergui_class, (t_method)hammergui__refocus,
		    gensym("_refocus"), 0);
    class_addmethod(hammergui_class, (t_method)hammergui__revised,
		    gensym("_revised"), 0);
    class_addmethod(hammergui_class, (t_method)hammergui__up,
		    ps__up, A_FLOAT, 0);
    class_addmethod(hammergui_class, (t_method)hammergui__focus,
		    ps__focus, A_SYMBOL, A_FLOAT, 0);
    class_addmethod(hammergui_class, (t_method)hammergui__vised,
		    ps__vised, A_SYMBOL, A_FLOAT, 0);

    /* if older than 0.43, create an 0.43-style pdsend */
    sys_gui("if {[llength [info procs ::pdsend]] == 0} {");
    sys_gui("proc ::pdsend {args} {::pd \"[join $args { }] ;\"}}\n");
    
    /* Protect against pdCmd being called (via "Canvas <Destroy>" binding)
       during Tcl_Finalize().  FIXME this should be a standard exit handler. */
    sys_gui("proc hammergui_exithook {cmd op} {proc ::pdsend {} {}}\n");
    sys_gui("if {[info tclversion] >= 8.4} {\n\
 trace add execution exit enter hammergui_exithook}\n");
예제 #3
0
static void comment_draw(t_comment *x)
{
    char buf[COMMENT_OUTBUFSIZE], *outbuf, *outp;
    unsigned long cvid = (unsigned long)x->x_canvas;
    int reqsize = x->x_textbufsize + 250;  /* FIXME estimation */
    if (reqsize > COMMENT_OUTBUFSIZE)
    {
#ifdef COMMENT_DEBUG
	loudbug_post("allocating %d outbuf bytes", reqsize);
#endif
	if (!(outbuf = getbytes(reqsize)))
	    return;
    }
    else outbuf = buf;
    outp = outbuf;
    sprintf(outp, "comment_draw %s .x%lx.c %s %s %f %f %s %d %s %s {%.*s} %d\n",
	    x->x_bindsym->s_name, cvid, x->x_texttag, x->x_tag,
	    (float)(text_xpix((t_text *)x, x->x_glist) + COMMENT_LMARGIN),
	    (float)(text_ypix((t_text *)x, x->x_glist) + COMMENT_TMARGIN),
	    x->x_fontfamily->s_name, x->x_fontsize,
	    (glist_isselected(x->x_glist, &x->x_glist->gl_gobj) ?
	     "blue" : x->x_color),
	    (x->x_encoding ? x->x_encoding->s_name : "\"\""),
	    x->x_textbufsize, x->x_textbuf, x->x_pixwidth);
    x->x_bbpending = 1;
    sys_gui(outbuf);
    if (outbuf != buf) freebytes(outbuf, reqsize);
}
예제 #4
0
파일: Scope.c 프로젝트: amurtet/pd-cyclone
static void scope_redrawmono(t_scope *x, t_canvas *cv)
{
    int nleft = x->x_bufsize;
    float *bp = x->x_xbuffer;
    char chunk[32 * SCOPE_GUICHUNKMONO];  /* LATER estimate */
    char *chunkp = chunk;
    int x1, y1, x2, y2;
    float dx, dy, xx, yy, sc;
    scope_getrect((t_gobj *)x, x->x_glist, &x1, &y1, &x2, &y2);
    dx = (float)(x2 - x1) / (float)x->x_bufsize;
    sc = ((float)x->x_height - 2.) / (float)(x->x_maxval - x->x_minval);
    xx = x1;
    sys_vgui(".x%lx.c coords %s \\\n", cv, x->x_fgtag);
    while (nleft > SCOPE_GUICHUNKMONO)
    {
	int i = SCOPE_GUICHUNKMONO;
	while (i--)
	{
	    yy = (y2 - 1) - sc * (*bp++ - x->x_minval);
#ifndef SCOPE_DEBUG
	    if (yy > y2) yy = y2; else if (yy < y1) yy = y1;
#endif
	    sprintf(chunkp, "%d %d ", (int)xx, (int)yy);
	    chunkp += strlen(chunkp);
	    xx += dx;
	}
	strcpy(chunkp, "\\\n");
	sys_gui(chunk);
	chunkp = chunk;
	nleft -= SCOPE_GUICHUNKMONO;
    }
    while (nleft--)
    {
	yy = (y2 - 1) - sc * (*bp++ - x->x_minval);
#ifndef SCOPE_DEBUG
	if (yy > y2) yy = y2; else if (yy < y1) yy = y1;
#endif
	sprintf(chunkp, "%d %d ", (int)xx, (int)yy);
	chunkp += strlen(chunkp);
	xx += dx;
    }
    strcpy(chunkp, "\n");
    sys_gui(chunk);
}
예제 #5
0
    /* set the global list vars for startup libraries and flags */
void sys_set_startup( void)
{
    int i;
    t_namelist *nl;

    sys_vgui("set ::startup_flags {%s}\n", sys_flags->s_name);
    sys_gui("set ::startup_libraries {}\n");
    for (nl = sys_externlist, i = 0; nl; nl = nl->nl_next, i++)
        sys_vgui("lappend ::startup_libraries {%s}\n", nl->nl_string);
}
예제 #6
0
static void comment__clickhook(t_comment *x, t_symbol *s, int ac, t_atom *av)
{
    int xx, yy, ndx;
    if (ac == 8 && av->a_type == A_SYMBOL
	&& av[1].a_type == A_FLOAT && av[2].a_type == A_FLOAT
	&& av[3].a_type == A_FLOAT
	&& av[4].a_type == A_FLOAT && av[5].a_type == A_FLOAT
	&& av[6].a_type == A_FLOAT && av[7].a_type == A_FLOAT)
    {
	xx = (int)av[1].a_w.w_float;
	yy = (int)av[2].a_w.w_float;
	ndx = (int)av[3].a_w.w_float;
	comment__bboxhook(x, av->a_w.w_symbol,
			  av[4].a_w.w_float, av[5].a_w.w_float,
			  av[6].a_w.w_float, av[7].a_w.w_float);
    }
    else
    {
	loudbug_bug("comment__clickhook");
	return;
    }
    if (x->x_glist->gl_edit)
    {
	if (x->x_active)
	{
	    if (ndx >= 0 && ndx < x->x_textbufsize)
	    {
		/* set selection, LATER shift-click and drag */
		x->x_selstart = x->x_selend = ndx;
		comment_dograb(x);
		comment_update(x);
	    }
	}
	else if (xx > x->x_x2 - COMMENT_HANDLEWIDTH)
	{
	    /* start resizing */
	    char buf[COMMENT_OUTBUFSIZE], *outp = buf;
	    unsigned long cvid = (unsigned long)x->x_canvas;
	    sprintf(outp, ".x%lx.c bind %s <ButtonRelease> \
 {pdsend {%s _release %s}}\n", cvid, x->x_texttag,
		    x->x_bindsym->s_name, x->x_bindsym->s_name);
	    outp += strlen(outp);
	    sprintf(outp, ".x%lx.c bind %s <Motion> \
 {pdsend {%s _motion %s %%x %%y}}\n", cvid, x->x_texttag,
		    x->x_bindsym->s_name, x->x_bindsym->s_name);
	    outp += strlen(outp);
	    sprintf(outp, ".x%lx.c create rectangle %d %d %d %d -outline blue \
 -tags {%s %s}\n",
		    cvid, x->x_x1, x->x_y1, x->x_x2, x->x_y2,
		    x->x_outlinetag, x->x_tag);
	    sys_gui(buf);
	    x->x_newx2 = x->x_x2;
	    x->x_dragon = 1;
	}
    }
예제 #7
0
파일: s_path.c 프로젝트: bryansum/ijam
    /* start a search path dialog window */
void glob_start_path_dialog(t_pd *dummy)
{
    char buf[MAXPDSTRING];
    int i;
    t_namelist *nl;

    sys_gui("global pd_path; set pd_path {}\n");
    for (nl = sys_searchpath, i = 0; nl; nl = nl->nl_next, i++)
        sys_vgui("lappend pd_path {%s}\n", nl->nl_string);
    sprintf(buf, "pdtk_path_dialog %%s %d %d\n", sys_usestdpath, sys_verbose);
    gfxstub_new(&glob_pdobject, (void *)glob_start_path_dialog, buf);
}
예제 #8
0
파일: x_misc.c 프로젝트: Tzero2/pd
static void serial_float(t_serial *x, t_float f)
{
    int n = f;
    char message[MAXSERIAL * 4 + 100];
    if (!x->x_open)
    {
        sys_vgui("com%d_open\n", x->x_portno);
        x->x_open = 1;
    }
    sprintf(message, "com%d_send \"\\%3.3o\"\n", x->x_portno, n);
    sys_gui(message);
}
예제 #9
0
파일: s_path.c 프로젝트: bryansum/ijam
    /* start a startup dialog window */
void glob_start_startup_dialog(t_pd *dummy)
{
    char buf[MAXPDSTRING];
    int i;
    t_namelist *nl;

    sys_gui("global pd_startup; set pd_startup {}\n");
    for (nl = sys_externlist, i = 0; nl; nl = nl->nl_next, i++)
        sys_vgui("lappend pd_startup {%s}\n", nl->nl_string);
//    sprintf(buf, "pdtk_startup_dialog %%s %d \"%s\"\n", sys_defeatrt,
//        sys_flags->s_name);
    gfxstub_new(&glob_pdobject, (void *)glob_start_startup_dialog, buf);
}
예제 #10
0
static void comment_update(t_comment *x)
{
    char buf[COMMENT_OUTBUFSIZE], *outbuf, *outp;
    unsigned long cvid = (unsigned long)x->x_canvas;
    int reqsize = x->x_textbufsize + 250;  /* FIXME estimation */
    if (reqsize > COMMENT_OUTBUFSIZE)
    {
#ifdef COMMENT_DEBUG
	loudbug_post("allocating %d outbuf bytes", reqsize);
#endif
	if (!(outbuf = getbytes(reqsize)))
	    return;
    }
    else outbuf = buf;
    outp = outbuf;
    sprintf(outp, "comment_update .x%lx.c %s %s {%.*s} %d\n", cvid,
	    x->x_texttag, (x->x_encoding ? x->x_encoding->s_name : "\"\""),
	    x->x_textbufsize, x->x_textbuf, x->x_pixwidth);
    outp += strlen(outp);
    if (x->x_active)
    {
	if (x->x_selend > x->x_selstart)
	{
	    sprintf(outp, ".x%lx.c select from %s %d\n",
		    cvid, x->x_texttag, x->x_selstart);
	    outp += strlen(outp);
	    sprintf(outp, ".x%lx.c select to %s %d\n",
		    cvid, x->x_texttag, x->x_selend);
	    outp += strlen(outp);
	    sprintf(outp, ".x%lx.c focus {}\n", cvid);
	}
	else
	{
	    sprintf(outp, ".x%lx.c select clear\n", cvid);
	    outp += strlen(outp);
	    sprintf(outp, ".x%lx.c icursor %s %d\n",
		    cvid, x->x_texttag, x->x_selstart);
	    outp += strlen(outp);
	    sprintf(outp, ".x%lx.c focus %s\n", cvid, x->x_texttag);
	}
	outp += strlen(outp);
    }
    sprintf(outp, "comment_bbox %s .x%lx.c %s\n",
	    x->x_bindsym->s_name, cvid, x->x_texttag);
    x->x_bbpending = 1;
    sys_gui(outbuf);
    if (outbuf != buf) freebytes(outbuf, reqsize);
}
예제 #11
0
파일: x_gui.c 프로젝트: IvanKhodorich/pd
void gfxstub_new(t_pd *owner, void *key, const char *cmd)
{
    char buf[4*MAXPDSTRING];
    char namebuf[80];
    char sprintfbuf[MAXPDSTRING];
    char *afterpercent;
    t_int afterpercentlen;
    t_gfxstub *x;
    t_symbol *s;
        /* if any exists with matching key, burn it. */
    for (x = gfxstub_list; x; x = x->x_next)
        if (x->x_key == key)
            gfxstub_deleteforkey(key);
    if (strlen(cmd) + 50 > 4*MAXPDSTRING)
    {
        bug("audio dialog too long");
        bug("%s", cmd);
        return;
    }
    x = (t_gfxstub *)pd_new(gfxstub_class);
    sprintf(namebuf, ".gfxstub%lx", (t_int)x);

    s = gensym(namebuf);
    pd_bind(&x->x_pd, s);
    x->x_owner = owner;
    x->x_sym = s;
    x->x_key = key;
    x->x_next = gfxstub_list;
    gfxstub_list = x;
    /* only replace first %s so sprintf() doesn't crash */
    afterpercent = strchr(cmd, '%') + 2;
    afterpercentlen = afterpercent - cmd;
    strncpy(sprintfbuf, cmd, afterpercentlen);
    sprintfbuf[afterpercentlen] = '\0';
    sprintf(buf, sprintfbuf, s->s_name);
    strncat(buf, afterpercent, (4*MAXPDSTRING) - afterpercentlen);
    sys_gui(buf);
}
예제 #12
0
static void hammereditor_guidefs(void)
{
    /* if older than 0.43, create an 0.43-style pdsend */
    sys_gui("if {[llength [info procs ::pdsend]] == 0} {");
    sys_gui("proc ::pdsend {args} {::pd \"[join $args { }] ;\"}}\n");

    sys_gui("proc hammereditor_open {name geometry title sendable} {\n");
    sys_gui(" if {[winfo exists $name]} {\n");
    sys_gui("  $name.text delete 1.0 end\n");
    sys_gui(" } else {\n");
    sys_gui("  toplevel $name\n");
    sys_gui("  wm title $name $title\n");
    sys_gui("  wm geometry $name $geometry\n");
    sys_gui("  if {$sendable} {\n");
    sys_gui("   wm protocol $name WM_DELETE_WINDOW \\\n");
    sys_gui("    [concat hammereditor_close $name 1]\n");
    sys_gui("   bind $name <<Modified>> \"hammereditor_dodirty $name\"\n");
    sys_gui("  }\n");
    sys_gui("  text $name.text -relief raised -bd 2 \\\n");
    sys_gui("   -font -*-courier-medium--normal--12-* \\\n");
    sys_gui("   -yscrollcommand \"$name.scroll set\" -background lightgrey\n");
    sys_gui("  scrollbar $name.scroll -command \"$name.text yview\"\n");
    sys_gui("  pack $name.scroll -side right -fill y\n");
    sys_gui("  pack $name.text -side left -fill both -expand 1\n");
    sys_gui(" }\n");
    sys_gui("}\n");

    sys_gui("proc hammereditor_dodirty {name} {\n");
    sys_gui(" if {[catch {$name.text edit modified} dirty]} {set dirty 1}\n");
    sys_gui(" set title [wm title $name]\n");
    sys_gui(" set dt [string equal -length 1 $title \"*\"]\n");
    sys_gui(" if {$dirty} {\n");
    sys_gui("  if {$dt == 0} {wm title $name *$title}\n");
    sys_gui(" } else {\n");
    sys_gui("  if {$dt} {wm title $name [string range $title 1 end]}\n");
    sys_gui(" }\n");
    sys_gui("}\n");

    sys_gui("proc hammereditor_setdirty {name flag} {\n");
    sys_gui(" if {[winfo exists $name]} {\n");
    sys_gui("  catch {$name.text edit modified $flag}\n");
    sys_gui(" }\n");
    sys_gui("}\n");

    sys_gui("proc hammereditor_doclose {name} {\n");
    sys_gui(" destroy $name\n");
    sys_gui("}\n");

    sys_gui("proc hammereditor_append {name contents} {\n");
    sys_gui(" if {[winfo exists $name]} {\n");
    sys_gui("  $name.text insert end $contents\n");
    sys_gui(" }\n");
    sys_gui("}\n");

    /* FIXME make it more reliable */
    sys_gui("proc hammereditor_send {name} {\n");
    sys_gui(" if {[winfo exists $name]} {\n");
    sys_gui("  pdsend \"miXed$name clear\"\n");
    sys_gui("  for {set i 1} \\\n");
    sys_gui("   {[$name.text compare $i.end < end]} \\\n");
    sys_gui("  	{incr i 1} {\n");
    sys_gui("   set lin [$name.text get $i.0 $i.end]\n");
    sys_gui("   if {$lin != \"\"} {\n");
    /* LATER rethink semi/comma mapping */
    sys_gui("    regsub -all \\; $lin \"  _semi_ \" tmplin\n");
    sys_gui("    regsub -all \\, $tmplin \"  _comma_ \" lin\n");
    sys_gui("    pdsend \"miXed$name addline $lin\"\n");
    sys_gui("   }\n");
    sys_gui("  }\n");
    sys_gui("  pdsend \"miXed$name end\"\n");
    sys_gui(" }\n");
    sys_gui("}\n");

    sys_gui("proc hammereditor_close {name ask} {\n");
    sys_gui(" if {[winfo exists $name]} {\n");
    sys_gui("  if {[catch {$name.text edit modified} dirty]} {set dirty 1}\n");
    sys_gui("  if {$ask && $dirty} {\n");
    sys_gui("   set title [wm title $name]\n");
    sys_gui("   if {[string equal -length 1 $title \"*\"]} {\n");
    sys_gui("    set title [string range $title 1 end]\n");
    sys_gui("   }\n");
    sys_gui("   set answer [tk_messageBox \\-type yesnocancel \\\n");
    sys_gui("    \\-icon question \\\n");
    sys_gui("    \\-message [concat Save changes to \\\"$title\\\"?]]\n");
    sys_gui("   if {$answer == \"yes\"} {hammereditor_send $name}\n");
    sys_gui("   if {$answer != \"cancel\"} {hammereditor_doclose $name}\n");
    sys_gui("  } else {hammereditor_doclose $name}\n");
    sys_gui(" }\n");
    sys_gui("}\n");
}
예제 #13
0
static void hammerpanel_guidefs(void)
{
    sys_gui("proc hammerpanel_open {target inidir} {\n");
    sys_gui(" global pd_opendir\n");
    sys_gui(" if {$inidir == \"\"} {\n");
    sys_gui("  set $inidir $pd_opendir\n");
    sys_gui(" }\n");
    sys_gui(" set filename [tk_getOpenFile \\\n");
    sys_gui("  -initialdir $inidir]\n");
    sys_gui(" if {$filename != \"\"} {\n");
    sys_gui("  set directory [string range $filename 0 \\\n");
    sys_gui("   [expr [string last / $filename ] - 1]]\n");
    sys_gui("  if {$directory == \"\"} {set directory \"/\"}\n");
#if 1
    sys_gui("  puts stderr [concat $directory]\n");
#endif
    sys_gui("  pdsend \"$target path \\\n");
    sys_gui("   [enquote_path $filename] [enquote_path $directory] \"\n");
    sys_gui(" }\n");
    sys_gui("}\n");

    sys_gui("proc hammerpanel_save {target inidir inifile} {\n");
    sys_gui(" if {$inifile != \"\"} {\n");
    sys_gui("  set filename [tk_getSaveFile \\\n");
    sys_gui("   -initialdir $inidir -initialfile $inifile]\n");
    sys_gui(" } else {\n");
    sys_gui("  set filename [tk_getSaveFile]\n");
    sys_gui(" }\n");
    sys_gui(" if {$filename != \"\"} {\n");
    sys_gui("  set directory [string range $filename 0 \\\n");
    sys_gui("   [expr [string last / $filename ] - 1]]\n");
    sys_gui("  if {$directory == \"\"} {set directory \"/\"}\n");
    sys_gui("  pdsend \"$target path \\\n");
    sys_gui("   [enquote_path $filename] [enquote_path $directory] \"\n");
    sys_gui(" }\n");
    sys_gui("}\n");
}
예제 #14
0
static void dsp_tilde_open(t_dsp_tilde *x)
{
    sys_gui("pdsend \"pd audio-properties\"\n");
}
예제 #15
0
파일: Scope.c 프로젝트: amurtet/pd-cyclone
static void scope_drawfgxy(t_scope *x, t_canvas *cv,
			   int x1, int y1, int x2, int y2)
{
    int nleft = x->x_bufsize;
    float *xbp = x->x_xbuffer, *ybp = x->x_ybuffer;
    char chunk[200 * SCOPE_GUICHUNKXY];  /* LATER estimate */
    char *chunkp = chunk;
    char cmd1[64], cmd2[64];
    float xx, yy, xsc, ysc;
    xx = yy = 0;
    /* subtract 1-pixel margins, see below */
    xsc = ((float)x->x_width - 2.) / (float)(x->x_maxval - x->x_minval);
    ysc = ((float)x->x_height - 2.) / (float)(x->x_maxval - x->x_minval);
    sprintf(cmd1, ".x%lx.c create line", (unsigned long)cv);
    sprintf(cmd2, "-fill #%2.2x%2.2x%2.2x -width %f -tags {%s %s}\n ",
	    x->x_fgred, x->x_fggreen, x->x_fgblue,
	    SCOPE_FGWIDTH, x->x_fgtag, x->x_tag);
    while (nleft > SCOPE_GUICHUNKXY)
    {
	int i = SCOPE_GUICHUNKXY;
	while (i--)
	{
	    float oldx = xx, oldy = yy, dx, dy;
	    xx = x1 + xsc * (*xbp++ - x->x_minval);
	    yy = y2 - ysc * (*ybp++ - x->x_minval);
	    /* using 1-pixel margins */
	    dx = (xx > oldx ? 1. : -1.);
	    dy = (yy > oldy ? 1. : -1.);
#ifndef SCOPE_DEBUG
	    if (xx < x1 || xx > x2 || yy < y1 || yy > y2)
		continue;
#endif
	    sprintf(chunkp, "%s %d %d %d %d %s", cmd1,
		    (int)(xx - dx), (int)(yy - dy),
		    (int)(xx + dx), (int)(yy + dy), cmd2);
	    chunkp += strlen(chunkp);
	}
	if (chunkp > chunk)
	    sys_gui(chunk);
	chunkp = chunk;
	nleft -= SCOPE_GUICHUNKXY;
    }
    while (nleft--)
    {
	float oldx = xx, oldy = yy, dx, dy;
	xx = x1 + xsc * (*xbp++ - x->x_minval);
	yy = y2 - ysc * (*ybp++ - x->x_minval);
	/* using 1-pixel margins */
	dx = (xx > oldx ? 1. : -1.);
	dy = (yy > oldy ? 1. : -1.);
#ifndef SCOPE_DEBUG
	if (xx < x1 || xx > x2 || yy < y1 || yy > y2)
	    continue;
#endif
	sprintf(chunkp, "%s %d %d %d %d %s", cmd1,
		(int)(xx - dx), (int)(yy - dy),
		(int)(xx + dx), (int)(yy + dy), cmd2);
	chunkp += strlen(chunkp);
    }
    if (chunkp > chunk)
	sys_gui(chunk);
}
예제 #16
0
파일: s_audio.c 프로젝트: danomatika/ofxPd
    /* start an audio settings dialog window */
void glob_audio_properties(t_pd *dummy, t_floatarg flongform)
{
    char buf[1024 + 2 * MAXNDEV*(DEVDESCSIZE+4)];
        /* these are the devices you're using: */
    int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV];
    int naudiooutdev, audiooutdev[MAXAUDIOOUTDEV], choutdev[MAXAUDIOOUTDEV];
    int audioindev1, audioindev2, audioindev3, audioindev4,
        audioinchan1, audioinchan2, audioinchan3, audioinchan4,
        audiooutdev1, audiooutdev2, audiooutdev3, audiooutdev4,
        audiooutchan1, audiooutchan2, audiooutchan3, audiooutchan4;
    int rate, advance, callback, blocksize;
        /* these are all the devices on your system: */
    char indevlist[MAXNDEV*DEVDESCSIZE], outdevlist[MAXNDEV*DEVDESCSIZE];
    int nindevs = 0, noutdevs = 0, canmulti = 0, cancallback = 0, i;

    audio_getdevs(indevlist, &nindevs, outdevlist, &noutdevs, &canmulti,
         &cancallback, MAXNDEV, DEVDESCSIZE);

    sys_gui("global audio_indevlist; set audio_indevlist {}\n");
    for (i = 0; i < nindevs; i++)
        sys_vgui("lappend audio_indevlist {%s}\n",
            indevlist + i * DEVDESCSIZE);

    sys_gui("global audio_outdevlist; set audio_outdevlist {}\n");
    for (i = 0; i < noutdevs; i++)
        sys_vgui("lappend audio_outdevlist {%s}\n",
            outdevlist + i * DEVDESCSIZE);

    sys_get_audio_params(&naudioindev, audioindev, chindev,
        &naudiooutdev, audiooutdev, choutdev, &rate, &advance, &callback,
            &blocksize);

    /* post("naudioindev %d naudiooutdev %d longform %f",
            naudioindev, naudiooutdev, flongform); */
    if (naudioindev > 1 || naudiooutdev > 1)
        flongform = 1;

    audioindev1 = (naudioindev > 0 &&  audioindev[0]>= 0 ? audioindev[0] : 0);
    audioindev2 = (naudioindev > 1 &&  audioindev[1]>= 0 ? audioindev[1] : 0);
    audioindev3 = (naudioindev > 2 &&  audioindev[2]>= 0 ? audioindev[2] : 0);
    audioindev4 = (naudioindev > 3 &&  audioindev[3]>= 0 ? audioindev[3] : 0);
    audioinchan1 = (naudioindev > 0 ? chindev[0] : 0);
    audioinchan2 = (naudioindev > 1 ? chindev[1] : 0);
    audioinchan3 = (naudioindev > 2 ? chindev[2] : 0);
    audioinchan4 = (naudioindev > 3 ? chindev[3] : 0);
    audiooutdev1 = (naudiooutdev > 0 && audiooutdev[0]>=0 ? audiooutdev[0] : 0);
    audiooutdev2 = (naudiooutdev > 1 && audiooutdev[1]>=0 ? audiooutdev[1] : 0);
    audiooutdev3 = (naudiooutdev > 2 && audiooutdev[2]>=0 ? audiooutdev[2] : 0);
    audiooutdev4 = (naudiooutdev > 3 && audiooutdev[3]>=0 ? audiooutdev[3] : 0);
    audiooutchan1 = (naudiooutdev > 0 ? choutdev[0] : 0);
    audiooutchan2 = (naudiooutdev > 1 ? choutdev[1] : 0);
    audiooutchan3 = (naudiooutdev > 2 ? choutdev[2] : 0);
    audiooutchan4 = (naudiooutdev > 3 ? choutdev[3] : 0);
    sprintf(buf,
"pdtk_audio_dialog %%s \
%d %d %d %d %d %d %d %d \
%d %d %d %d %d %d %d %d \
%d %d %d %d %d %d\n",
        audioindev1, audioindev2, audioindev3, audioindev4,
        audioinchan1, audioinchan2, audioinchan3, audioinchan4,
        audiooutdev1, audiooutdev2, audiooutdev3, audiooutdev4,
        audiooutchan1, audiooutchan2, audiooutchan3, audiooutchan4,
        rate, advance, canmulti, (cancallback ? callback : -1),
        (flongform != 0), blocksize);
    gfxstub_deleteforkey(0);
    gfxstub_new(&glob_pdobject, (void *)glob_audio_properties, buf);
}
예제 #17
0
파일: xeq.c 프로젝트: pure-data/xeq
static void xeq_gui_defs(void)
{
    /* Generic window definition.  Ideally, some variant of
       what is defined below should find its way into pd.tk */
    sys_gui("proc xeq_window {name geometry title contents} {\n");
    sys_gui(" if {[winfo exists $name]} {\n");
    sys_gui("  $name.text delete 1.0 end\n");
    sys_gui(" } else {\n");
    sys_gui("  toplevel $name\n");
    sys_gui("  wm title $name $title\n");
    sys_gui("  wm geometry $name $geometry\n");
    sys_gui("  text $name.text -relief raised -bd 2 \\\n");
    sys_gui("   -font -*-courier-medium--normal--12-* \\\n");
    sys_gui("   -yscrollcommand \"$name.scroll set\" -background lightgrey\n");
    sys_gui("  scrollbar $name.scroll -command \"$name.text yview\"\n");
    sys_gui("  pack $name.scroll -side right -fill y\n");
    sys_gui("  pack $name.text -side left -fill both -expand 1\n");
#if 0
    sys_gui("  raise $name\n");
#endif
    sys_gui(" }\n");
    sys_gui(" $name.text insert end $contents\n");
    sys_gui("}\n");

    sys_gui("proc xeq_window_ok {name} {\n");
    sys_gui(" if {[winfo exists $name]} {\n");
    sys_gui("  set ii [$name.text index [concat end - 1 lines]]\n");
    sys_gui("  pd [concat $name.editok clear \\;]\n");
    sys_gui("  for {set i 1} \\\n");
    sys_gui("   {[$name.text compare $i.end < $ii]} \\\n");
    sys_gui("  	{incr i 1} {\n");
    sys_gui("   set lin [$name.text get $i.0 $i.end]\n");
    sys_gui("   if {$lin != \"\"} {\n");
    sys_gui("    regsub -all \\; $lin \"  _semi_ \" tmplin\n");
    sys_gui("    regsub -all \\, $tmplin \"  _comma_ \" lin\n");
    sys_gui("    pd [concat $name.editok addline $lin \\;]\n");
    sys_gui("   }\n");
    sys_gui("  }\n");
    sys_gui(" }\n");
    sys_gui("}\n");
}