Pontus Nyman:
Hi all.
I have one short question. Is there a way to set the sample rate of the audio device from an external?
I think so. If you look at the source for k_jack~ on sourceforge, I close and open audio to be able to change the number of input and output channels. And the function to open audio includes a parameter to set the sample rate. This is code from k_jack~:
static void set_pd_channels(int inc_ins,int inc_outs){ int num_recs=sys_get_inchannels(); int num_plays=sys_get_outchannels();
int t1[1]={0}; int t2[1]={0}; int t3[1]={num_recs+inc_ins}; int t4[1]={num_plays+inc_outs}; sys_close_audio(); sys_open_audio(1,t1, 1,t3, 1,t2, 1,t4, sys_getsr(),sys_schedadvance/1000,1); }
Note that although the function works now, I don't know how long its going to last.
Hi all, hi Kjetil.
Kjetil Svalastog Matheussen wrote:
I think so. If you look at the source for k_jack~ on sourceforge, I close and open audio to be able to change the number of input and output channels. And the function to open audio includes a parameter to set the sample rate. This is code from k_jack~:
static void set_pd_channels(int inc_ins,int inc_outs){ int num_recs=sys_get_inchannels(); int num_plays=sys_get_outchannels();
int t1[1]={0}; int t2[1]={0}; int t3[1]={num_recs+inc_ins}; int t4[1]={num_plays+inc_outs}; sys_close_audio(); sys_open_audio(1,t1, 1,t3, 1,t2, 1,t4, sys_getsr(),sys_schedadvance/1000,1); }
Note that although the function works now, I don't know how long its going to last.
This is exactly what I was looking for. The problem now is that I get linking errors. It seems as if sys_close_audio() and sys_open_audio() cannot be found in pd.lib. I looked in the makefile for k_jack~ and it does nothing that I don't do. I use pd version 0.37.1. Am I doing something wrong or doesn't this work anymore?
/Pontus
Pontus Nyman wrote:
Hi all, hi Kjetil.
This is exactly what I was looking for. The problem now is that I get linking errors. It seems as if sys_close_audio() and sys_open_audio() cannot be found in pd.lib. I looked in the makefile for k_jack~ and it does nothing that I don't do. I use pd version 0.37.1. Am I doing something wrong or doesn't this work anymore?
just a wild guess: under linux (like k_jack~) linking is very dirty - you can use all (non-static) functions that are defined somewhere.
windows is exporting is done more properly: functions have to be explicitly declared to be exported. now sys_open_audio() is *not* exported by pd; thus you cannot access it under windows but it is possible under linux.
workaround: use the EXPORT macro (m_pd.h) to make sys_open_audio() available to externals.
mfg.a.sdr IOhannes