[PD] get samplerate

IOhannes m zmoelnig zmoelnig at iem.at
Mon Jul 4 14:39:58 CEST 2005


Ed Kelly wrote:
> Hi all,
> 
> I'm trying to code a dsp external. Is there any way to
> get the sample rate at runtime? something like:
> t_float sr= sample_rate;

in m_pd.h (the file of reference) i find:

   EXTERN float sys_getsr(void);

which gives you the system-samplerate (the one your adc/dac runs at)

furthermore (also in m_pd.h) i find the definition of the signal-structure:

typedef struct _signal
{
     int s_n;            /* number of points in the array */
     t_sample *s_vec;    /* the array */
     float s_sr;         /* sample rate */
     ...
} t_signal;

the sample rate of the signal is per canvas; this is the value that can 
be changed via the [block~] (or [switch~] object; it is 
sys_getsr()*upsampling
unfortunately, any overlap factor will also get multiplied in, resulting 
in: s_sr = sys_getsr()*upsampling*overlap;
(if you have an overlap of 2 and no up/downsampling, you will get 
something like 96kHz as sample rate)

there is (currently) no way to get upsampling AND overlap factors from 
within your external.
there is a pending feature request for this.


mfg.asdr.asdf
IOhannes




> 
> ?
> Ed
> 
> Dr Edward Kelly
> Research Assistant in Sonic Arts
> London College of Communication
> University of the Arts London
> 
> 
> 	
> 	
> 		
> ___________________________________________________________ 
> Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com
> 
> _______________________________________________
> PD-list at iem.at mailing list
> UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list





More information about the Pd-list mailing list