hi list, hi miller,
I've made a little patch to enable externs to modify the dsp chain while the dsp processing is running... this avoids to restart dsp processing when a parameter is changed, this is illustrated by the "spigot~" extern attached.
Without this patch, I had to restart dsp processing and all other dsp objects got interrupted. That was really annoying !!!
What was made basically was adding the following code :
d_ugen.c :
################################################ /* function to dynamically change dsp functions parameters arguments are : f : pointer to your dsp function rank : rank of the argument to change value : new value of this parameter
QUITE DANGEROUS !!! no checking is possible
because the number of arguments is not stored in dsp_chain
Copyleft ydegoyon@free.fr */
void dsp_mod(t_perfroutine f, int rank, int value ) { va_list ap; t_int *pdsp_chain = dsp_chain; t_int i;
while ( pdsp_chain ){
if ( *pdsp_chain == (t_int)f ){
*(pdsp_chain+rank) = value;
post ( "dsp_mod : warning : modifying dsp chain, better know what you're doing!!!!" );
break;
}
pdsp_chain++;
}
} ################################################
This function has to be exported in m_pd.h :
################################################ EXTERN void dsp_mod(t_perfroutine f, int rank, int value); ################################################
An example of use is available in spigot~.c attached.
This is really dangerous to use this, because it enables an extern to transform dsp_chain into a mess, so use it with care !!!
Cheers,
Yves Degoyon.
PS : it seems to be patch day, so I don't deliver this as a patch for incremental reasons ( I've applied some patches myself ).
HI all,
I'm unclear why you'd want to do this... if it's to change parameters to DSP objects, that's better done by storing them as state variables; example, lop~ cutoff frequency change.
cheers Miller
On Fri, Nov 16, 2001 at 01:42:16AM +0100, Yves Degoyon wrote:
hi list, hi miller,
I've made a little patch to enable externs to modify the dsp chain while the dsp processing is running... this avoids to restart dsp processing when a parameter is changed, this is illustrated by the "spigot~" extern attached.
Without this patch, I had to restart dsp processing and all other dsp objects got interrupted. That was really annoying !!!
What was made basically was adding the following code :
d_ugen.c :
################################################ /* function to dynamically change dsp functions parameters arguments are : f : pointer to your dsp function rank : rank of the argument to change value : new value of this parameter
QUITE DANGEROUS !!! no checking is possible because the number of arguments is not stored in dsp_chain Copyleft ydegoyon@free.fr */
void dsp_mod(t_perfroutine f, int rank, int value ) { va_list ap; t_int *pdsp_chain = dsp_chain; t_int i;
while ( pdsp_chain ){ if ( *pdsp_chain == (t_int)f ){ *(pdsp_chain+rank) = value; post ( "dsp_mod : warning : modifying dsp chain, better know what you're doing!!!!" ); break; } pdsp_chain++; }
} ################################################
This function has to be exported in m_pd.h :
################################################ EXTERN void dsp_mod(t_perfroutine f, int rank, int value); ################################################
An example of use is available in spigot~.c attached.
This is really dangerous to use this, because it enables an extern to transform dsp_chain into a mess, so use it with care !!!
Cheers,
Yves Degoyon.
PS : it seems to be patch day, so I don't deliver this as a patch for incremental reasons ( I've applied some patches myself ).
you're right for changing variables, it's cleaner to use namespace's variables, but this patch also enables to change the function itself dynamically and, in an extern, eventually to change the dsp function.
cheers.
yves/
----- Original Message ----- From: "Miller Puckette" mpuckett@man104-1.ucsd.edu To: "Yves Degoyon" ydegoyon@free.fr Cc: pd-list@iem.kug.ac.at Sent: Friday, November 16, 2001 8:06 PM Subject: Re: [PD] Modifying "dsp chain" live !!!
HI all,
I'm unclear why you'd want to do this... if it's to change parameters to DSP objects, that's better done by storing them as state variables;
example,
lop~ cutoff frequency change.
cheers Miller
On Fri, Nov 16, 2001 at 01:42:16AM +0100, Yves Degoyon wrote:
hi list, hi miller,
I've made a little patch to enable externs to modify the dsp chain while the dsp processing is running... this avoids to restart dsp processing when a parameter is changed, this is illustrated by the "spigot~" extern attached.
Without this patch, I had to restart dsp processing and all other dsp objects got interrupted. That was really annoying !!!
What was made basically was adding the following code :
d_ugen.c :
################################################ /* function to dynamically change dsp functions parameters arguments are : f : pointer to your dsp function rank : rank of the argument to change value : new value of this parameter
QUITE DANGEROUS !!! no checking is possible because the number of arguments is not stored in dsp_chain Copyleft ydegoyon@free.fr */
void dsp_mod(t_perfroutine f, int rank, int value ) { va_list ap; t_int *pdsp_chain = dsp_chain; t_int i;
while ( pdsp_chain ){ if ( *pdsp_chain == (t_int)f ){ *(pdsp_chain+rank) = value; post ( "dsp_mod : warning : modifying dsp chain, better know
what you're doing!!!!" );
break; } pdsp_chain++; }
} ################################################
This function has to be exported in m_pd.h :
################################################ EXTERN void dsp_mod(t_perfroutine f, int rank, int value); ################################################
An example of use is available in spigot~.c attached.
This is really dangerous to use this, because it enables an extern to transform dsp_chain into a mess, so use it with care !!!
Cheers,
Yves Degoyon.
PS : it seems to be patch day, so I don't deliver this as a patch for incremental reasons ( I've applied some patches myself ).
hi,
how about using one additional level of indirection, and calling the real routine through a pointer in your `perform' routine?
Krzysztof
Yves Degoyon wrote: ...
but this patch also enables to change the function itself dynamically and, in an extern, eventually to change the dsp function.
I've thought of this possibility but it seems harder to me to handle function pointers then to use the dsp_mod function.
Moreover, what about an extern modifying another extern dsp function ?? I know it's not a current situation and I never had to do this myself, but giving an access to the dsp chain seems to be useful to me.
Cheers,
Yves/
----- Original Message ----- From: "Krzysztof Czaja" czaja@chopin.edu.pl To: "Yves Degoyon" ydegoyon@free.fr Cc: pd-list@iem.kug.ac.at Sent: Saturday, November 17, 2001 6:49 PM Subject: Re: [PD] Modifying "dsp chain" live !!!
hi,
how about using one additional level of indirection, and calling the real routine through a pointer in your `perform' routine?
Krzysztof
Yves Degoyon wrote: ...
but this patch also enables to change the function itself dynamically and, in an extern, eventually to change the dsp function.