Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15616
Modified Files:
Tag: desiredata
makefile.in s_audio.c s_audio_alsa.c s_audio_jack.c
Log Message:
switch audio and midi to C++
Index: makefile.in
===================================================================
RCS file: /cvsroot/pure-data/pd/src/makefile.in,v
retrieving revision 1.4.4.2.2.21.2.30
retrieving revision 1.4.4.2.2.21.2.31
diff -C2 -d -r1.4.4.2.2.21.2.30 -r1.4.4.2.2.21.2.31
*** makefile.in 30 Jun 2007 00:35:35 -0000 1.4.4.2.2.21.2.30
--- makefile.in 9 Jul 2007 17:41:02 -0000 1.4.4.2.2.21.2.31
***************
*** 22,33 ****
SRCXX = desire.c kernel.c builtins.c builtins_dsp.c s_path.c s_inter.c s_main.c \
! m_sched.c s_loader.c d_soundfile.c d_ugen.c
! SRC = m_fifo.c m_simd.c s_audio.c s_midi.c d_mayer_fft.c d_fftroutine.c
!
! # audio drivers and midi drivers
! SRC += @AUDIOSRC@ @MIDISRC@
!
OBJ = $(SRCXX:.c=.o) $(SRC:.c=.o)
-
SO = libpd$(LIBSUFFIX)
--- 22,28 ----
SRCXX = desire.c kernel.c builtins.c builtins_dsp.c s_path.c s_inter.c s_main.c \
! m_sched.c s_loader.c d_soundfile.c d_ugen.c s_audio.c s_midi.c @AUDIOSRC@ @MIDISRC@
! SRC = m_fifo.c m_simd.c d_mayer_fft.c d_fftroutine.c
OBJ = $(SRCXX:.c=.o) $(SRC:.c=.o)
SO = libpd$(LIBSUFFIX)
Index: s_audio_alsa.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_audio_alsa.c,v
retrieving revision 1.5.4.5.2.2.2.6
retrieving revision 1.5.4.5.2.2.2.7
diff -C2 -d -r1.5.4.5.2.2.2.6 -r1.5.4.5.2.2.2.7
*** s_audio_alsa.c 30 Jun 2007 20:22:38 -0000 1.5.4.5.2.2.2.6
--- s_audio_alsa.c 9 Jul 2007 17:41:02 -0000 1.5.4.5.2.2.2.7
***************
*** 166,170 ****
if (alsa_snd_buf) {
if (alsa_snd_bufsize < bufsizeforthis) {
! if (!(alsa_snd_buf = realloc(alsa_snd_buf, bufsizeforthis))) {
post("out of memory");
return 0;
--- 166,170 ----
if (alsa_snd_buf) {
if (alsa_snd_bufsize < bufsizeforthis) {
! if (!(alsa_snd_buf = (char *)realloc(alsa_snd_buf, bufsizeforthis))) {
post("out of memory");
return 0;
***************
*** 174,178 ****
}
} else {
! if (!(alsa_snd_buf = (void *)malloc(bufsizeforthis))) {
post("out of memory");
return 0;
--- 174,178 ----
}
} else {
! if (!(alsa_snd_buf = (char *)malloc(bufsizeforthis))) {
post("out of memory");
return 0;
***************
*** 187,191 ****
int alsa_open_audio(
int naudioindev, int * audioindev, int nchindev, int * chindev,
! int naudiooutdev, int *audiooutdev, int nchoutdev, int *choutdev, int rate/*, int dummy*/) {
int err, inchans = 0, outchans = 0;
char devname[512];
--- 187,191 ----
int alsa_open_audio(
int naudioindev, int * audioindev, int nchindev, int * chindev,
! int naudiooutdev, int *audiooutdev, int nchoutdev, int *choutdev, int rate, int dummy) {
int err, inchans = 0, outchans = 0;
char devname[512];
***************
*** 193,197 ****
int nfrags, i, iodev, dev2;
! nfrags = sys_schedadvance * (float)rate / (1e6 * frag_size);
/* save our belief as to ALSA's buffer size for later */
alsa_buf_samps = nfrags * frag_size;
--- 193,197 ----
int nfrags, i, iodev, dev2;
! nfrags = int(sys_schedadvance * (float)rate / (1e6 * frag_size));
/* save our belief as to ALSA's buffer size for later */
alsa_buf_samps = nfrags * frag_size;
***************
*** 373,377 ****
j += thisdevchans, fp2++) {
float s1 = *fp2 * INT32_MAX;
! ((t_alsa_sample32 *)alsa_snd_buf)[j] = CLIP32(s1);
}
for (; i < thisdevchans; i++, ch++)
--- 373,377 ----
j += thisdevchans, fp2++) {
float s1 = *fp2 * INT32_MAX;
! ((t_alsa_sample32 *)alsa_snd_buf)[j] = CLIP32(int(s1));
}
for (; i < thisdevchans; i++, ch++)
***************
*** 382,386 ****
for (j = ch, k = sys_dacblocksize, fp2 = fp1; k--;
j += thisdevchans, fp2++) {
! int s = *fp2 * 32767.;
if (s > 32767)
s = 32767;
--- 382,386 ----
for (j = ch, k = sys_dacblocksize, fp2 = fp1; k--;
j += thisdevchans, fp2++) {
! int s = int(*fp2 * 32767.);
if (s > 32767)
s = 32767;
***************
*** 526,537 ****
int i, result;
memset(alsa_snd_buf, 0,
! alsa_outdev[iodev].a_sampwidth * sys_dacblocksize *
! alsa_outdev[iodev].a_channels);
for (i = 0; i < n; i++) {
! result = snd_pcm_writei(alsa_outdev[iodev].a_handle, alsa_snd_buf,
! sys_dacblocksize);
#if 0
! if (result != sys_dacblocksize)
! post("result %d", result);
#endif
}
--- 526,534 ----
int i, result;
memset(alsa_snd_buf, 0,
! alsa_outdev[iodev].a_sampwidth * sys_dacblocksize * alsa_outdev[iodev].a_channels);
for (i = 0; i < n; i++) {
! result = snd_pcm_writei(alsa_outdev[iodev].a_handle, alsa_snd_buf, sys_dacblocksize);
#if 0
! if (result != sys_dacblocksize) post("result %d", result);
#endif
}
Index: s_audio.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_audio.c,v
retrieving revision 1.5.4.16.2.20.2.12
retrieving revision 1.5.4.16.2.20.2.13
diff -C2 -d -r1.5.4.16.2.20.2.12 -r1.5.4.16.2.20.2.13
*** s_audio.c 6 Jul 2007 22:43:09 -0000 1.5.4.16.2.20.2.12
--- s_audio.c 9 Jul 2007 17:41:02 -0000 1.5.4.16.2.20.2.13
***************
*** 7,10 ****
--- 7,11 ----
*/
+ #define PD_PLUSPLUS_FACE
#include "m_pd.h"
#include "s_stuff.h"
***************
*** 82,95 ****
float sys_outmax; /* max output amplitude */
! /* exported variables */
int sys_schedadvance; /* scheduler advance in microseconds */
- float sys_dacsr;
-
- t_sample *sys_soundout;
- t_sample *sys_soundin;
! /* the "state" is normally one if we're open and zero otherwise;
! but if the state is one, we still haven't necessarily opened the
! audio hardware; see audio_isopen() below. */
static int audio_state;
--- 83,92 ----
float sys_outmax; /* max output amplitude */
! /* exported variables */
int sys_schedadvance; /* scheduler advance in microseconds */
! /* the "state" is normally one if we're open and zero otherwise;
! but if the state is one, we still haven't necessarily opened the
! audio hardware; see audio_isopen() below. */
static int audio_state;
***************
*** 178,183 ****
sys_inchannels = chin;
sys_outchannels = chout;
! sys_dacsr = sr;
! sys_advance_samples = (sys_schedadvance * sys_dacsr) / (1000000.);
if (sys_advance_samples < /* 3 * */sys_dacblocksize)
sys_advance_samples = /* 3 * */sys_dacblocksize;
--- 175,180 ----
sys_inchannels = chin;
sys_outchannels = chout;
! sys_dacsr = double(sr);
! sys_advance_samples = int(sys_schedadvance*sys_dacsr/1000000.);
if (sys_advance_samples < /* 3 * */sys_dacblocksize)
sys_advance_samples = /* 3 * */sys_dacblocksize;
***************
*** 331,336 ****
post("unknown audio API specified");
}
! sys_save_audio_params(naudioindev, audioindev, chindev,
! naudiooutdev, audiooutdev, choutdev, sys_dacsr, sys_dacblocksize, advance, schedmode);
if (sys_inchannels == 0 && sys_outchannels == 0) enable = 0;
audio_state = enable;
--- 328,333 ----
post("unknown audio API specified");
}
! sys_save_audio_params(naudioindev, audioindev, chindev, naudiooutdev, audiooutdev, choutdev, int(sys_dacsr),
! sys_dacblocksize, advance, schedmode);
if (sys_inchannels == 0 && sys_outchannels == 0) enable = 0;
audio_state = enable;
***************
*** 574,579 ****
}
! void glob_audio_setapi(void *dummy, t_floatarg f) {
! int newapi = f;
if (newapi != sys_audioapi) {
if (newapi != sys_audioapi) {
--- 571,576 ----
}
! void glob_audio_setapi(t_pd *dummy, t_floatarg f) {
! int newapi = int(f);
if (newapi != sys_audioapi) {
if (newapi != sys_audioapi) {
***************
*** 634,640 ****
#ifdef USEAPI_ALSA
! void alsa_putzeros(int n);
! void alsa_getzeros(int n);
! void alsa_printstate( void);
#endif
--- 631,637 ----
#ifdef USEAPI_ALSA
! void alsa_putzeros(int iodev, int n);
! void alsa_getzeros(int iodev, int n);
! void alsa_printstate(void);
#endif
***************
*** 644,649 ****
if (arg == gensym("restart")) sys_reopen_audio();
#ifdef USEAPI_ALSA
! else if (arg == gensym("alsawrite")) alsa_putzeros(atom_getintarg(1, argc, argv));
! else if (arg == gensym("alsaread")) alsa_getzeros(atom_getintarg(1, argc, argv));
else if (arg == gensym("print")) alsa_printstate();
#endif
--- 641,647 ----
if (arg == gensym("restart")) sys_reopen_audio();
#ifdef USEAPI_ALSA
! /* what's the matter here? what should be the value of iodev??? */
! else if (arg == gensym("alsawrite")) alsa_putzeros(0, atom_getintarg(1, argc, argv));
! else if (arg == gensym("alsaread")) alsa_getzeros(0, atom_getintarg(1, argc, argv));
else if (arg == gensym("print")) alsa_printstate();
#endif
***************
*** 722,727 ****
naudiooutdev = naudioindev = (int)atom_getfloatarg(0, argc, argv);
for (i = 0; i != MAXAUDIOINDEV; i++) {
! audiooutdev[i] = audioindev[i] = atom_getfloatarg(i*2+1, argc, argv);
! audiochoutdev[i] = audiochindev[i] = atom_getfloatarg(i*2+2, argc, argv);
}
sys_close_audio();
--- 720,725 ----
naudiooutdev = naudioindev = (int)atom_getfloatarg(0, argc, argv);
for (i = 0; i != MAXAUDIOINDEV; i++) {
! audiooutdev [i] = audioindev [i] = int(atom_getfloatarg(i*2+1, argc, argv));
! audiochoutdev[i] = audiochindev[i] = int(atom_getfloatarg(i*2+2, argc, argv));
}
sys_close_audio();
***************
*** 738,743 ****
naudioindev = (int)atom_getfloatarg(0, argc, argv);
for (i = 0; i != MAXAUDIOINDEV; i=i+2) {
! audioindev[i] = atom_getfloatarg(i+1, argc, argv);
! audiochindev[i] = atom_getfloatarg(i+2, argc, argv);
}
sys_close_audio();
--- 736,741 ----
naudioindev = (int)atom_getfloatarg(0, argc, argv);
for (i = 0; i != MAXAUDIOINDEV; i=i+2) {
! audioindev [i] = atom_getintarg(i+1, argc, argv);
! audiochindev[i] = atom_getintarg(i+2, argc, argv);
}
sys_close_audio();
***************
*** 754,759 ****
naudiooutdev = (int)atom_getfloatarg(0, argc, argv);
for (i = 0; i != MAXAUDIOOUTDEV; i=i+2) {
! audiooutdev[i] = atom_getfloatarg(i+1, argc, argv);
! audiochoutdev[i] = atom_getfloatarg(i+2, argc, argv);
}
sys_close_audio();
--- 752,757 ----
naudiooutdev = (int)atom_getfloatarg(0, argc, argv);
for (i = 0; i != MAXAUDIOOUTDEV; i=i+2) {
! audiooutdev [i] = atom_getintarg(i+1, argc, argv);
! audiochoutdev[i] = atom_getintarg(i+2, argc, argv);
}
sys_close_audio();
Index: s_audio_jack.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_audio_jack.c,v
retrieving revision 1.5.4.8.2.7.2.5
retrieving revision 1.5.4.8.2.7.2.6
diff -C2 -d -r1.5.4.8.2.7.2.5 -r1.5.4.8.2.7.2.6
*** s_audio_jack.c 30 Jun 2007 20:28:14 -0000 1.5.4.8.2.7.2.5
--- s_audio_jack.c 9 Jul 2007 17:41:02 -0000 1.5.4.8.2.7.2.6
***************
*** 38,47 ****
if (jack_filled != nframes) fprintf(stderr,"Partial read");
for (j = 0; j < sys_outchannels; j++) {
! out = jack_port_get_buffer (output_port[j], nframes);
! memcpy(out, jack_outbuf + (j * BUF_JACK), sizeof (float) * nframes);
}
for (j = 0; j < sys_inchannels; j++) {
! in = jack_port_get_buffer( input_port[j], nframes);
! memcpy(jack_inbuf + (j * BUF_JACK), in, sizeof (float) * nframes);
}
jack_filled -= nframes;
--- 38,47 ----
if (jack_filled != nframes) fprintf(stderr,"Partial read");
for (j = 0; j < sys_outchannels; j++) {
! out = (float *)jack_port_get_buffer(output_port[j], nframes);
! memcpy(out, jack_outbuf + (j * BUF_JACK), sizeof(float)*nframes);
}
for (j = 0; j < sys_inchannels; j++) {
! in = (float *)jack_port_get_buffer( input_port[j], nframes);
! memcpy(jack_inbuf + (j * BUF_JACK), in, sizeof(float)*nframes);
}
jack_filled -= nframes;
***************
*** 49,53 ****
if (jack_started) jack_dio_error = 1;
for (j = 0; j < outport_count; j++) {
! out = jack_port_get_buffer (output_port[j], nframes);
memset(out, 0, sizeof (float) * nframes);
}
--- 49,53 ----
if (jack_started) jack_dio_error = 1;
for (j = 0; j < outport_count; j++) {
! out = (float *)jack_port_get_buffer (output_port[j], nframes);
memset(out, 0, sizeof (float) * nframes);
}
***************
*** 74,82 ****
static int cb_process (jack_nframes_t nframes, void *arg) {
int i,j;
! int timeout = nframes * 1e6 / sys_dacsr;
if (canvas_dspstate == 0) {
/* dsp is switched off, the audio is open ... */
for (j = 0; j < sys_outchannels; j++) {
! t_sample * out = jack_port_get_buffer (output_port[j], nframes);
zeroblock(out, dspticks_per_jacktick * sys_dacblocksize);
}
--- 74,82 ----
static int cb_process (jack_nframes_t nframes, void *arg) {
int i,j;
! int timeout = int(nframes * 1e6 / sys_dacsr);
if (canvas_dspstate == 0) {
/* dsp is switched off, the audio is open ... */
for (j = 0; j < sys_outchannels; j++) {
! t_sample *out = (t_sample *)jack_port_get_buffer (output_port[j], nframes);
zeroblock(out, dspticks_per_jacktick * sys_dacblocksize);
}
***************
*** 97,101 ****
/* get sound from the inputs */
for (j = 0; j < sys_inchannels; j++) {
! t_sample * in = jack_port_get_buffer(input_port[j], nframes);
copyblock(sys_soundin + j * sys_dacblocksize,
in + i * sys_dacblocksize,
--- 97,101 ----
/* get sound from the inputs */
for (j = 0; j < sys_inchannels; j++) {
! t_sample *in = (t_sample *)jack_port_get_buffer(input_port[j], nframes);
copyblock(sys_soundin + j * sys_dacblocksize,
in + i * sys_dacblocksize,
***************
*** 106,110 ****
/* send sound to the output */
for (j = 0; j < sys_outchannels; j++) {
! t_sample * out = jack_port_get_buffer (output_port[j], nframes);
copyblock(out + i * sys_dacblocksize, sys_soundout + j * sys_dacblocksize, sys_dacblocksize);
}
--- 106,110 ----
/* send sound to the output */
for (j = 0; j < sys_outchannels; j++) {
! t_sample *out = (t_sample *)jack_port_get_buffer (output_port[j], nframes);
copyblock(out + i * sys_dacblocksize, sys_soundout + j * sys_dacblocksize, sys_dacblocksize);
}
***************
*** 131,135 ****
jack_close_audio();
/* try to reconnect to jack server */
! jack_open_audio(sys_inchannels, sys_outchannels, sys_dacsr, jack_scheduler);
/* restore last connection state */
jack_restore_connection_state();
--- 131,135 ----
jack_close_audio();
/* try to reconnect to jack server */
! jack_open_audio(sys_inchannels, sys_outchannels, int(sys_dacsr), jack_scheduler);
/* restore last connection state */
jack_restore_connection_state();
***************
*** 318,322 ****
}
/* tb: get advance from jack server */
! sys_schedadvance = (float)jack_port_get_total_latency(jack_client,output_port[0]) * 1000. / sys_dacsr * 1000;
return 0;
bailout:
--- 318,322 ----
}
/* tb: get advance from jack server */
! sys_schedadvance = int((float)jack_port_get_total_latency(jack_client,output_port[0]) * 1000. / sys_dacsr * 1000);
return 0;
bailout:
***************
*** 345,349 ****
int rtnval = SENDDACS_YES;
int timenow;
! int timeref = sys_getrealtime();
if (!jack_client) return SENDDACS_NO;
if (!sys_inchannels && !sys_outchannels) return SENDDACS_NO;
--- 345,349 ----
int rtnval = SENDDACS_YES;
int timenow;
! int timeref = int(sys_getrealtime());
if (!jack_client) return SENDDACS_NO;
if (!sys_inchannels && !sys_outchannels) return SENDDACS_NO;
***************
*** 367,371 ****
fp += sys_dacblocksize;
}
! if ((timenow = sys_getrealtime()) - timeref > sys_sleepgrain * 1e-6) {
rtnval = SENDDACS_SLEPT;
}
--- 367,371 ----
fp += sys_dacblocksize;
}
! if ((timenow = int(sys_getrealtime()) - timeref > sys_sleepgrain * 1e-6)) {
rtnval = SENDDACS_SLEPT;
}