Ejemplo n.º 1
0
/*------------------------------------ map1dLoadRangeList ---*/
bool
map1dLoadRangeList(Map1dData * xx,
                   t_symbol *  fileName)
{
    bool         result = false;
    t_filehandle fileRef;

    if (path_opensysfile(fileName->s_name, path_getdefault(), &fileRef, PATH_READ_PERM))
    {
        LOG_ERROR_2(xx, OUTPUT_PREFIX "problem opening file '%s'", fileName->s_name)
    }
    else
    {
        t_handle fileContents = sysmem_newhandle(0);

        if (sysfile_readtextfile(fileRef, fileContents, 0, TEXT_LB_NATIVE))
        {
            LOG_ERROR_2(xx, OUTPUT_PREFIX "problem reading file '%s'", fileName->s_name)
        }
        else if (binbuf_text(xx->fBuffer, fileContents, sysmem_handlesize(fileContents)))
        {
            post("problem processing");
            LOG_ERROR_2(xx, OUTPUT_PREFIX "problem converting file '%s'", fileName->s_name)
        }
        else
        {
Ejemplo n.º 2
0
void pybase::AddCurrentPath(flext_base *o)
{
    char dir[1024];

    // add dir of current patch to path
    o->GetCanvasDir(dir,sizeof(dir));
    if(*dir) AddToPath(dir);

    // add current dir to path
#if FLEXT_SYS == FLEXT_SYS_PD
    AddToPath(GetString(canvas_getcurrentdir()));
#elif FLEXT_SYS == FLEXT_SYS_MAX
    short path = path_getdefault();
    path_topathname(path,NULL,dir);
    AddToPath(dir);
#endif
}
Ejemplo n.º 3
0
void *jsusfx_new(t_symbol *notused, long argc, t_atom *argv) {
	if ( argc < 1 || atom_gettype(argv) != A_SYM ) {
		error("jsusfx~: missing script name");
		return NULL;
	}
    
	t_jsusfx *x = reinterpret_cast<t_jsusfx *>(object_alloc(jsusfx_class));
	t_symbol *s = atom_getsym(argv);
    t_fourcc filetype = 'TEXT', outtype;
    short path;
    char filename[MAX_PATH_CHARS];
    
    strcpy(filename, s->s_name);
    
    if (locatefile_extended(filename, &path, &outtype, &filetype, 1)) {
        t_object *mypatcher;
        object_obex_lookup(x, gensym("#P"), &mypatcher);
        t_symbol *checkExists = object_attr_getsym(mypatcher, gensym("filepath"));
        
        if ( checkExists->s_name[0] == 0 ) {
            error("jsusfx~: patch needs to be saved in order to create new jsusfx script file");
            return NULL;
        }
        
        path = path_getdefault();
                
        t_fourcc type = 'TEXT';
        t_filehandle ref;

        if ( path_createsysfile(filename, path, type, &ref) ) {
            error("jsusfx~: unable to create file");
            return NULL;
        }

        char initText[] = "@sample\nspl0=1\nspl1=-1\n";
        t_handle h = sysmem_newhandle(0);
        sysmem_ptrandhand(initText,h,strlen(initText));
        
        if ( sysfile_writetextfile(ref, h, TEXT_LB_NATIVE) ) {
            error("jsusfx~: unable to write file");
            return NULL;
        }
        
        sysfile_close(ref);
        sysmem_freehandle(h);
    }
    
    strcpy(x->scriptname, filename);
    x->path = path;
    
    char fullpath[MAX_PATH_CHARS];
    path_toabsolutesystempath(path, filename, fullpath);
    std::ifstream is(fullpath);
	if ( ! is.is_open() ) {
		error("jsusfx~: error opening file %s", fullpath);
		return NULL;
	}
    
    x->bypass = false;
    dsp_setup((t_pxobject *)x, 2);
    x->outlet1 = outlet_new((t_object *)x, NULL);
	outlet_new((t_object *)x, "signal");
    outlet_new((t_object *)x, "signal");
    
	critical_new(&(x->critical));
	x->m_editor = NULL;
    JsusFxMax *fx = new JsusFxMax();
    fx->compile(is);
    x->fx = fx;

    /*if ( argc >= 2 && atom_gettype(argv+1) == A_LONG ) {
		x->fx->normalizeSliders = atom_getlong(argv+1);
	} else {
        x->fx->normalizeSliders = 1;
    }
    
    post("normalizer sl %x", x->fx->normalizeSliders);*/
    
	return (x);
}