Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19550
Modified Files:
Tag: devel_0_38
d_dac.c m_sched.c s_audio.c s_audio_alsa.c s_audio_alsa.h
s_audio_alsamm.c s_audio_asio.cpp s_audio_jack.c
s_audio_mmio.c s_audio_oss.c s_audio_pa.c s_audio_sgi.c
s_file.c s_main.c s_stuff.h u_main.tk
Log Message:
added settable "dacblocksize" so [dac~] and [adc~] can run on other blo cksizes than 64. might give us some less latency
Index: s_audio_asio.cpp
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/s_audio_asio.cpp,v
retrieving revision 1.1.4.8
retrieving revision 1.1.4.9
diff -C2 -d -r1.1.4.8 -r1.1.4.9
*** s_audio_asio.cpp 9 Nov 2004 15:30:37 -0000 1.1.4.8
--- s_audio_asio.cpp 10 Nov 2004 13:47:09 -0000 1.1.4.9
***************
*** 361,368 ****
/* calculate ringbuffer length */
/* a strange way to find the least common multiple,
! * but works, since DEFDACBLKSIZE (expt 2 x) */
! asio_ringbuffer_length = asio_bufsize * DEFDACBLKSIZE;
! while ( !(asio_ringbuffer_length % DEFDACBLKSIZE) &&
!(asio_ringbuffer_length % asio_bufsize))
{
--- 361,368 ----
/* calculate ringbuffer length */
/* a strange way to find the least common multiple,
! * but works, since sys_dacblocksize (expt 2 x) */
! asio_ringbuffer_length = asio_bufsize * sys_dacblocksize;
! while ( !(asio_ringbuffer_length % sys_dacblocksize) &&
!(asio_ringbuffer_length % asio_bufsize))
{
***************
*** 513,522 ****
}
! #if SIMD_CHKCNT(DEFDACBLKSIZE)
! inline void copyblock(t_sample *dst,t_sample *src) { copyvec_simd(dst,src,DEFDACBLKSIZE); }
! inline void zeroblock(t_sample *dst) { zerovec_simd(dst,DEFDACBLKSIZE); }
#else
! inline void copyblock(t_sample *dst,t_sample *src) { memcpy(dst,src,DEFDACBLKSIZE*sizeof(t_sample)); }
! inline void zeroblock(t_sample *dst) { memset(dst,0,DEFDACBLKSIZE*sizeof(t_sample)); }
#endif
--- 513,522 ----
}
! #if SIMD_CHKCNT(sys_dacblocksize)
! inline void copyblock(t_sample *dst,t_sample *src) { copyvec_simd(dst,src,sys_dacblocksize); }
! inline void zeroblock(t_sample *dst) { zerovec_simd(dst,sys_dacblocksize); }
#else
! inline void copyblock(t_sample *dst,t_sample *src) { memcpy(dst,src,sys_dacblocksize*sizeof(t_sample)); }
! inline void zeroblock(t_sample *dst) { memset(dst,0,sys_dacblocksize*sizeof(t_sample)); }
#endif
***************
*** 546,550 ****
copyblock(asio_ringbuffer[i] + asio_ringbuffer_inoffset, sp);
zeroblock(sp);
! sp+=DEFDACBLKSIZE;
}
--- 546,550 ----
copyblock(asio_ringbuffer[i] + asio_ringbuffer_inoffset, sp);
zeroblock(sp);
! sp+=sys_dacblocksize;
}
***************
*** 566,573 ****
copyblock(sp, asio_ringbuffer[i+j] + asio_ringbuffer_inoffset);
#endif
! sp+=DEFDACBLKSIZE;
}
! asio_ringbuffer_inoffset += DEFDACBLKSIZE;
#if 1
--- 566,573 ----
copyblock(sp, asio_ringbuffer[i+j] + asio_ringbuffer_inoffset);
#endif
! sp+=sys_dacblocksize;
}
! asio_ringbuffer_inoffset += sys_dacblocksize;
#if 1
Index: d_dac.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/d_dac.c,v
retrieving revision 1.3.4.1
retrieving revision 1.3.4.2
diff -C2 -d -r1.3.4.1 -r1.3.4.2
*** d_dac.c 5 Nov 2004 13:39:55 -0000 1.3.4.1
--- d_dac.c 10 Nov 2004 13:47:08 -0000 1.3.4.2
***************
*** 52,66 ****
{
int ch = *ip - 1;
! if ((*sp2)->s_n != DEFDACBLKSIZE)
error("dac~: bad vector size");
else
if (ch >= 0 && ch < sys_get_outchannels())
! if(SIMD_CHECK3(DEFDACBLKSIZE,sys_soundout + DEFDACBLKSIZE*ch,
! (*sp2)->s_vec,sys_soundout + DEFDACBLKSIZE*ch))
! dsp_add(plus_perf_simd, 4, sys_soundout + DEFDACBLKSIZE*ch,
! (*sp2)->s_vec, sys_soundout + DEFDACBLKSIZE*ch, DEFDACBLKSIZE);
else
! dsp_add(plus_perform, 4, sys_soundout + DEFDACBLKSIZE*ch,
! (*sp2)->s_vec, sys_soundout + DEFDACBLKSIZE*ch, DEFDACBLKSIZE);
}
}
--- 52,66 ----
{
int ch = *ip - 1;
! if ((*sp2)->s_n != sys_dacblocksize)
error("dac~: bad vector size");
else
if (ch >= 0 && ch < sys_get_outchannels())
! if(SIMD_CHECK3(sys_dacblocksize,sys_soundout + sys_dacblocksize*ch,
! (*sp2)->s_vec,sys_soundout + sys_dacblocksize*ch))
! dsp_add(plus_perf_simd, 4, sys_soundout + sys_dacblocksize*ch,
! (*sp2)->s_vec, sys_soundout + sys_dacblocksize*ch, sys_dacblocksize);
else
! dsp_add(plus_perform, 4, sys_soundout + sys_dacblocksize*ch,
! (*sp2)->s_vec, sys_soundout + sys_dacblocksize*ch, sys_dacblocksize);
}
}
***************
*** 167,176 ****
{
int ch = *ip - 1;
! if ((*sp2)->s_n != DEFDACBLKSIZE)
error("adc~: bad vector size");
else if (ch >= 0 && ch < sys_get_inchannels())
! dsp_add_copy(sys_soundin + DEFDACBLKSIZE*ch,
! (*sp2)->s_vec, DEFDACBLKSIZE);
! else dsp_add_zero((*sp2)->s_vec, DEFDACBLKSIZE);
}
}
--- 167,176 ----
{
int ch = *ip - 1;
! if ((*sp2)->s_n != sys_dacblocksize)
error("adc~: bad vector size");
else if (ch >= 0 && ch < sys_get_inchannels())
! dsp_add_copy(sys_soundin + sys_dacblocksize*ch,
! (*sp2)->s_vec, sys_dacblocksize);
! else dsp_add_zero((*sp2)->s_vec, sys_dacblocksize);
}
}
Index: s_main.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_main.c,v
retrieving revision 1.7.4.1
retrieving revision 1.7.4.2
diff -C2 -d -r1.7.4.1 -r1.7.4.2
*** s_main.c 5 Nov 2004 14:27:47 -0000 1.7.4.1
--- s_main.c 10 Nov 2004 13:47:09 -0000 1.7.4.2
***************
*** 77,80 ****
--- 77,81 ----
char sys_font[] = "courier"; /* tb: font name */
static int sys_main_srate;
+ static int sys_main_dacblocksize = DEFDACBLKSIZE;
static int sys_main_advance;
***************
*** 351,354 ****
--- 352,356 ----
"-audiobuf <n> -- specify size of audio buffer in msec\n",
"-blocksize <n> -- specify audio I/O block size in sample frames\n",
+ "-dacblocksize <n>-- specify audio dac~block size in samples\n",
"-sleepgrain <n> -- specify number of milliseconds to sleep when idle\n",
"-nodac -- suppress audio output\n",
***************
*** 606,609 ****
--- 608,617 ----
argc -= 2; argv += 2;
}
+ else if (!strcmp(*argv, "-dacblocksize") && argc > 1 &&
+ sscanf(argv[1], "%d", &sys_main_dacblocksize) >= 1)
+ {
+ argc -= 2;
+ argv += 2;
+ }
else if (!strcmp(*argv, "-sleepgrain"))
{
***************
*** 904,908 ****
int sys_getblksize(void)
{
! return (DEFDACBLKSIZE);
}
--- 912,916 ----
int sys_getblksize(void)
{
! return (sys_dacblocksize);
}
***************
*** 916,920 ****
int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV];
int naudiooutdev, audiooutdev[MAXAUDIOOUTDEV], choutdev[MAXAUDIOOUTDEV];
! int nchindev, nchoutdev, rate, advance;
int nmidiindev = 0, midiindev[MAXMIDIINDEV];
int nmidioutdev = 0, midioutdev[MAXMIDIOUTDEV];
--- 924,928 ----
int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV];
int naudiooutdev, audiooutdev[MAXAUDIOOUTDEV], choutdev[MAXAUDIOOUTDEV];
! int nchindev, nchoutdev, rate, dacblksize, advance;
int nmidiindev = 0, midiindev[MAXMIDIINDEV];
int nmidioutdev = 0, midioutdev[MAXMIDIOUTDEV];
***************
*** 950,954 ****
of argument parsing, and store them again. */
sys_get_audio_params(&naudioindev, audioindev, chindev,
! &naudiooutdev, audiooutdev, choutdev, &rate, &advance);
if (sys_nchin >= 0)
{
--- 958,962 ----
of argument parsing, and store them again. */
sys_get_audio_params(&naudioindev, audioindev, chindev,
! &naudiooutdev, audiooutdev, choutdev, &rate, &dacblksize, &advance);
if (sys_nchin >= 0)
{
***************
*** 994,999 ****
if (sys_main_srate)
rate = sys_main_srate;
sys_open_audio(naudioindev, audioindev, naudioindev, chindev,
! naudiooutdev, audiooutdev, naudiooutdev, choutdev, rate, advance, 0);
sys_open_midi(nmidiindev, midiindev, nmidioutdev, midioutdev, 0);
}
--- 1002,1009 ----
if (sys_main_srate)
rate = sys_main_srate;
+ if (sys_main_dacblocksize)
+ dacblksize = sys_main_dacblocksize;
sys_open_audio(naudioindev, audioindev, naudioindev, chindev,
! naudiooutdev, audiooutdev, naudiooutdev, choutdev, rate, dacblksize, advance, 0);
sys_open_midi(nmidiindev, midiindev, nmidioutdev, midioutdev, 0);
}
Index: s_file.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_file.c,v
retrieving revision 1.2.4.2
retrieving revision 1.2.4.3
diff -C2 -d -r1.2.4.2 -r1.2.4.3
*** s_file.c 7 Nov 2004 11:13:14 -0000 1.2.4.2
--- s_file.c 10 Nov 2004 13:47:09 -0000 1.2.4.3
***************
*** 270,274 ****
int nmidiindev, midiindev[MAXMIDIINDEV];
int nmidioutdev, midioutdev[MAXMIDIOUTDEV];
! int i, rate = 0, advance = 0, api, nolib;
char prefbuf[MAXPDSTRING], keybuf[80];
sys_initloadpreferences();
--- 270,274 ----
int nmidiindev, midiindev[MAXMIDIINDEV];
int nmidioutdev, midioutdev[MAXMIDIOUTDEV];
! int i, rate = 0, advance = 0, dacblocksize = 0, api, nolib;
char prefbuf[MAXPDSTRING], keybuf[80];
sys_initloadpreferences();
***************
*** 314,319 ****
if (sys_getpreference("audiobuf", prefbuf, MAXPDSTRING))
sscanf(prefbuf, "%d", &advance);
sys_open_audio(naudioindev, audioindev, naudioindev, chindev,
! naudiooutdev, audiooutdev, naudiooutdev, choutdev, rate, advance, 0);
/* load MIDI preferences */
--- 314,321 ----
if (sys_getpreference("audiobuf", prefbuf, MAXPDSTRING))
sscanf(prefbuf, "%d", &advance);
+ if (sys_getpreference("dacblocksize", prefbuf, MAXPDSTRING))
+ sscanf(prefbuf, "%d", &dacblocksize);
sys_open_audio(naudioindev, audioindev, naudioindev, chindev,
! naudiooutdev, audiooutdev, naudiooutdev, choutdev, rate, dacblocksize, advance, 0);
/* load MIDI preferences */
***************
*** 385,389 ****
int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV];
int naudiooutdev, audiooutdev[MAXAUDIOOUTDEV], choutdev[MAXAUDIOOUTDEV];
! int i, rate, advance;
char buf1[MAXPDSTRING], buf2[MAXPDSTRING];
int nmidiindev, midiindev[MAXMIDIINDEV];
--- 387,391 ----
int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV];
int naudiooutdev, audiooutdev[MAXAUDIOOUTDEV], choutdev[MAXAUDIOOUTDEV];
! int i, rate, dacblocksize, advance;
char buf1[MAXPDSTRING], buf2[MAXPDSTRING];
int nmidiindev, midiindev[MAXMIDIINDEV];
***************
*** 398,402 ****
sys_get_audio_params(&naudioindev, audioindev, chindev,
! &naudiooutdev, audiooutdev, choutdev, &rate, &advance);
if (naudioindev <= 0)
--- 400,404 ----
sys_get_audio_params(&naudioindev, audioindev, chindev,
! &naudiooutdev, audiooutdev, choutdev, &rate, &dacblocksize, &advance);
if (naudioindev <= 0)
***************
*** 423,426 ****
--- 425,431 ----
sys_putpreference("rate", buf1);
+ sprintf(buf1, "%d", dacblocksize);
+ sys_putpreference("dacblocksize", buf1);
+
/* MIDI settings */
sys_get_midi_params(&nmidiindev, midiindev, &nmidioutdev, midioutdev);
Index: s_audio_sgi.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_audio_sgi.c,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** s_audio_sgi.c 6 Sep 2004 20:20:35 -0000 1.1
--- s_audio_sgi.c 10 Nov 2004 13:47:09 -0000 1.1.4.1
***************
*** 274,278 ****
int sgi_send_dacs(void)
{
! float buf[SGI_MAXCH * DEFDACBLKSIZE], *fp1, *fp2, *fp3, *fp4;
static int xferno = 0;
static int callno = 0;
--- 274,278 ----
int sgi_send_dacs(void)
{
! float buf[SGI_MAXCH * sys_dacblocksize], *fp1, *fp2, *fp3, *fp4;
static int xferno = 0;
static int callno = 0;
***************
*** 287,292 ****
int i, n, channel;
int result;
! unsigned int outtransfersize = DEFDACBLKSIZE;
! unsigned int intransfersize = DEFDACBLKSIZE;
/* no audio channels open, return */
--- 287,292 ----
int i, n, channel;
int result;
! unsigned int outtransfersize = sys_dacblocksize;
! unsigned int intransfersize = sys_dacblocksize;
/* no audio channels open, return */
***************
*** 334,349 ****
for (channel = 0, fp1 = buf;
! channel < outdevchannels; channel++, fp1++, fp2 += DEFDACBLKSIZE)
{
! for (i = 0, fp3 = fp1, fp4 = fp2; i < DEFDACBLKSIZE;
i++, fp3 += outdevchannels, fp4++)
*fp3 = *fp4, *fp4 = 0;
}
! alWriteFrames(sgi_oport[n], buf, DEFDACBLKSIZE);
}
}
/* zero out the output buffer */
! memset(sys_soundout, 0, DEFDACBLKSIZE * sizeof(*sys_soundout) * sys_outchannels);
if (sys_getrealtime() - timenow > 0.002)
{
--- 334,349 ----
for (channel = 0, fp1 = buf;
! channel < outdevchannels; channel++, fp1++, fp2 += sys_dacblocksize)
{
! for (i = 0, fp3 = fp1, fp4 = fp2; i < sys_dacblocksize;
i++, fp3 += outdevchannels, fp4++)
*fp3 = *fp4, *fp4 = 0;
}
! alWriteFrames(sgi_oport[n], buf, sys_dacblocksize);
}
}
/* zero out the output buffer */
! memset(sys_soundout, 0, sys_dacblocksize * sizeof(*sys_soundout) * sys_outchannels);
if (sys_getrealtime() - timenow > 0.002)
{
***************
*** 364,370 ****
indevchannels = sgi_ninchans[n]; /* channels supported by this device */
! if (alGetFilled(sgi_iport[n]) > DEFDACBLKSIZE)
{
! alReadFrames(sgi_iport[n], buf, DEFDACBLKSIZE);
}
else /* have to read but nothing's there... */
--- 364,370 ----
indevchannels = sgi_ninchans[n]; /* channels supported by this device */
! if (alGetFilled(sgi_iport[n]) > sys_dacblocksize)
{
! alReadFrames(sgi_iport[n], buf, sys_dacblocksize);
}
else /* have to read but nothing's there... */
***************
*** 375,381 ****
}
for (channel = 0, fp1 = buf;
! channel < indevchannels; channel++, fp1++, fp2 += DEFDACBLKSIZE)
{
! for (i = 0, fp3 = fp1, fp4 = fp2; i < DEFDACBLKSIZE;
i++, fp3 += indevchannels, fp4++)
*fp4 = *fp3;
--- 375,381 ----
}
for (channel = 0, fp1 = buf;
! channel < indevchannels; channel++, fp1++, fp2 += sys_dacblocksize)
{
! for (i = 0, fp3 = fp1, fp4 = fp2; i < sys_dacblocksize;
i++, fp3 += indevchannels, fp4++)
*fp4 = *fp3;
Index: s_stuff.h
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_stuff.h,v
retrieving revision 1.5.4.1
retrieving revision 1.5.4.2
diff -C2 -d -r1.5.4.1 -r1.5.4.2
*** s_stuff.h 5 Nov 2004 14:27:47 -0000 1.5.4.1
--- s_stuff.h 10 Nov 2004 13:47:09 -0000 1.5.4.2
***************
*** 56,60 ****
#define SENDDACS_SLEPT 2
! #define DEFDACBLKSIZE 64
extern int sys_schedblocksize; /* audio block size for scheduler */
extern int sys_hipriority; /* real-time flag, true if priority boosted */
--- 56,61 ----
#define SENDDACS_SLEPT 2
! #define DEFDACBLKSIZE 64 /* the default dac~blocksize */
! extern int sys_dacblocksize; /* the real dac~blocksize */
extern int sys_schedblocksize; /* audio block size for scheduler */
extern int sys_hipriority; /* real-time flag, true if priority boosted */
***************
*** 71,75 ****
int nchindev, int *chindev,
int naudiooutdev, int *audiooutdev, int nchoutdev, int *choutdev,
! int srate, int advance, int enable);
void sys_reopen_audio( void);
void sys_close_audio(void);
--- 72,76 ----
int nchindev, int *chindev,
int naudiooutdev, int *audiooutdev, int nchoutdev, int *choutdev,
! int srate, int dacblocksize, int advance, int enable);
void sys_reopen_audio( void);
void sys_close_audio(void);
***************
*** 257,265 ****
int *pnaudioindev, int *paudioindev, int *chindev,
int *pnaudiooutdev, int *paudiooutdev, int *choutdev,
! int *prate, int *padvance);
void sys_save_audio_params(
int naudioindev, int *audioindev, int *chindev,
int naudiooutdev, int *audiooutdev, int *choutdev,
! int rate, int advance);
/* s_file.c */
--- 258,266 ----
int *pnaudioindev, int *paudioindev, int *chindev,
int *pnaudiooutdev, int *paudiooutdev, int *choutdev,
! int *prate, int *dacblocksize, int *padvance);
void sys_save_audio_params(
int naudioindev, int *audioindev, int *chindev,
int naudiooutdev, int *audiooutdev, int *choutdev,
! int rate, int dacblocksize, int advance);
/* s_file.c */
***************
*** 295,299 ****
EXTERN void sys_pollmidiqueue(void );
EXTERN int sys_pollgui(void );
! EXTERN void sys_setchsr(int chin, int chout, int sr);
EXTERN void inmidi_noteon(int portno, int channel, int pitch, int velo);
--- 296,300 ----
EXTERN void sys_pollmidiqueue(void );
EXTERN int sys_pollgui(void );
! EXTERN void sys_setchsr(int chin, int chout, int sr, int dacblocksize);
EXTERN void inmidi_noteon(int portno, int channel, int pitch, int velo);
Index: s_audio_jack.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_audio_jack.c,v
retrieving revision 1.5
retrieving revision 1.5.4.1
diff -C2 -d -r1.5 -r1.5.4.1
*** s_audio_jack.c 6 Sep 2004 20:20:35 -0000 1.5
--- s_audio_jack.c 10 Nov 2004 13:47:09 -0000 1.5.4.1
***************
*** 344,354 ****
fp = sys_soundout;
for (j = 0; j < sys_outchannels; j++) {
! memcpy(jack_outbuf + (j * BUF_JACK) + jack_filled,fp, DEFDACBLKSIZE*sizeof(float));
! fp += DEFDACBLKSIZE;
}
fp = sys_soundin;
for (j = 0; j < sys_inchannels; j++) {
! memcpy(fp, jack_inbuf + (j * BUF_JACK) + jack_filled, DEFDACBLKSIZE*sizeof(float));
! fp += DEFDACBLKSIZE;
}
--- 344,354 ----
fp = sys_soundout;
for (j = 0; j < sys_outchannels; j++) {
! memcpy(jack_outbuf + (j * BUF_JACK) + jack_filled,fp, sys_dacblocksize*sizeof(float));
! fp += sys_dacblocksize;
}
fp = sys_soundin;
for (j = 0; j < sys_inchannels; j++) {
! memcpy(fp, jack_inbuf + (j * BUF_JACK) + jack_filled, sys_dacblocksize*sizeof(float));
! fp += sys_dacblocksize;
}
***************
*** 357,363 ****
rtnval = SENDDACS_SLEPT;
}
!
! memset(sys_soundout,0,DEFDACBLKSIZE*sizeof(float)*sys_outchannels);
! jack_filled += DEFDACBLKSIZE;
return rtnval;
}
--- 357,363 ----
rtnval = SENDDACS_SLEPT;
}
!
! memset(sys_soundout,0,sys_dacblocksize*sizeof(float)*sys_outchannels);
! jack_filled += sys_dacblocksize;
return rtnval;
}
Index: m_sched.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/m_sched.c,v
retrieving revision 1.5.4.1
retrieving revision 1.5.4.2
diff -C2 -d -r1.5.4.1 -r1.5.4.2
*** m_sched.c 8 Nov 2004 20:27:10 -0000 1.5.4.1
--- m_sched.c 10 Nov 2004 13:47:08 -0000 1.5.4.2
***************
*** 23,27 ****
static double sys_time_per_msec = TIMEUNITPERSEC / 1000.;
- int sys_schedblocksize = DEFDACBLKSIZE;
int sys_usecsincelastsleep(void);
int sys_sleepgrain;
--- 23,26 ----
Index: s_audio_alsa.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_audio_alsa.c,v
retrieving revision 1.5.4.1
retrieving revision 1.5.4.2
diff -C2 -d -r1.5.4.1 -r1.5.4.2
*** s_audio_alsa.c 5 Nov 2004 14:27:47 -0000 1.5.4.1
--- s_audio_alsa.c 10 Nov 2004 13:47:09 -0000 1.5.4.2
***************
*** 167,171 ****
/* set up the buffer */
! bufsizeforthis = DEFDACBLKSIZE * dev->a_sampwidth * *channels;
if (alsa_snd_buf)
{
--- 167,171 ----
/* set up the buffer */
! bufsizeforthis = sys_dacblocksize * dev->a_sampwidth * *channels;
if (alsa_snd_buf)
{
***************
*** 307,316 ****
if (outchans)
{
! i = (frag_size * nfrags)/DEFDACBLKSIZE + 1;
while (i--)
{
for (iodev = 0; iodev < alsa_noutdev; iodev++)
snd_pcm_writei(alsa_outdev[iodev].a_handle, alsa_snd_buf,
! DEFDACBLKSIZE);
}
}
--- 307,316 ----
if (outchans)
{
! i = (frag_size * nfrags)/sys_dacblocksize + 1;
while (i--)
{
for (iodev = 0; iodev < alsa_noutdev; iodev++)
snd_pcm_writei(alsa_outdev[iodev].a_handle, alsa_snd_buf,
! sys_dacblocksize);
}
}
***************
*** 371,375 ****
chansintogo = sys_inchannels;
chansouttogo = sys_outchannels;
! transfersize = DEFDACBLKSIZE;
timelast = timenow;
--- 371,375 ----
chansintogo = sys_inchannels;
chansouttogo = sys_outchannels;
! transfersize = sys_dacblocksize;
timelast = timenow;
***************
*** 407,412 ****
if (alsa_outdev[iodev].a_sampwidth == 4)
{
! for (i = 0; i < chans; i++, ch++, fp1 += DEFDACBLKSIZE)
! for (j = ch, k = DEFDACBLKSIZE, fp2 = fp1; k--;
j += thisdevchans, fp2++)
{
--- 407,412 ----
if (alsa_outdev[iodev].a_sampwidth == 4)
{
! for (i = 0; i < chans; i++, ch++, fp1 += sys_dacblocksize)
! for (j = ch, k = sys_dacblocksize, fp2 = fp1; k--;
j += thisdevchans, fp2++)
{
***************
*** 415,425 ****
}
for (; i < thisdevchans; i++, ch++)
! for (j = ch, k = DEFDACBLKSIZE; k--; j += thisdevchans)
((t_alsa_sample32 *)alsa_snd_buf)[j] = 0;
}
else
{
! for (i = 0; i < chans; i++, ch++, fp1 += DEFDACBLKSIZE)
! for (j = ch, k = DEFDACBLKSIZE, fp2 = fp1; k--;
j += thisdevchans, fp2++)
{
--- 415,425 ----
}
for (; i < thisdevchans; i++, ch++)
! for (j = ch, k = sys_dacblocksize; k--; j += thisdevchans)
((t_alsa_sample32 *)alsa_snd_buf)[j] = 0;
}
else
{
! for (i = 0; i < chans; i++, ch++, fp1 += sys_dacblocksize)
! for (j = ch, k = sys_dacblocksize, fp2 = fp1; k--;
j += thisdevchans, fp2++)
{
***************
*** 432,436 ****
}
for (; i < thisdevchans; i++, ch++)
! for (j = ch, k = DEFDACBLKSIZE; k--; j += thisdevchans)
((t_alsa_sample16 *)alsa_snd_buf)[j] = 0;
}
--- 432,436 ----
}
for (; i < thisdevchans; i++, ch++)
! for (j = ch, k = sys_dacblocksize; k--; j += thisdevchans)
((t_alsa_sample16 *)alsa_snd_buf)[j] = 0;
}
***************
*** 457,461 ****
/* zero out the output buffer */
! memset(sys_soundout, 0, DEFDACBLKSIZE * sizeof(*sys_soundout) *
sys_outchannels);
if (sys_getrealtime() - timenow > 0.002)
--- 457,461 ----
/* zero out the output buffer */
! memset(sys_soundout, 0, sys_dacblocksize * sizeof(*sys_soundout) *
sys_outchannels);
if (sys_getrealtime() - timenow > 0.002)
***************
*** 499,505 ****
if (alsa_indev[iodev].a_sampwidth == 4)
{
! for (i = 0; i < chans; i++, ch++, fp1 += DEFDACBLKSIZE)
{
! for (j = ch, k = DEFDACBLKSIZE, fp2 = fp1; k--;
j += thisdevchans, fp2++)
*fp2 = (float) ((t_alsa_sample32 *)alsa_snd_buf)[j]
--- 499,505 ----
if (alsa_indev[iodev].a_sampwidth == 4)
{
! for (i = 0; i < chans; i++, ch++, fp1 += sys_dacblocksize)
{
! for (j = ch, k = sys_dacblocksize, fp2 = fp1; k--;
j += thisdevchans, fp2++)
*fp2 = (float) ((t_alsa_sample32 *)alsa_snd_buf)[j]
***************
*** 509,515 ****
else
{
! for (i = 0; i < chans; i++, ch++, fp1 += DEFDACBLKSIZE)
{
! for (j = ch, k = DEFDACBLKSIZE, fp2 = fp1; k--;
j += thisdevchans, fp2++)
*fp2 = (float) ((t_alsa_sample16 *)alsa_snd_buf)[j]
--- 509,515 ----
else
{
! for (i = 0; i < chans; i++, ch++, fp1 += sys_dacblocksize)
{
! for (j = ch, k = sys_dacblocksize, fp2 = fp1; k--;
j += thisdevchans, fp2++)
*fp2 = (float) ((t_alsa_sample16 *)alsa_snd_buf)[j]
***************
*** 571,580 ****
memset(alsa_snd_buf, 0,
alsa_indev[iodev].a_sampwidth *
! DEFDACBLKSIZE * sys_outchannels);
for (i = 0; i < 1000000; i++)
{
result = snd_pcm_writei(alsa_outdev[iodev].a_handle, alsa_snd_buf,
! DEFDACBLKSIZE);
! if (result != (int)DEFDACBLKSIZE)
break;
}
--- 571,580 ----
memset(alsa_snd_buf, 0,
alsa_indev[iodev].a_sampwidth *
! sys_dacblocksize * sys_outchannels);
for (i = 0; i < 1000000; i++)
{
result = snd_pcm_writei(alsa_outdev[iodev].a_handle, alsa_snd_buf,
! sys_dacblocksize);
! if (result != (int)sys_dacblocksize)
break;
}
***************
*** 586,597 ****
int i, result;
memset(alsa_snd_buf, 0,
! alsa_outdev[iodev].a_sampwidth * DEFDACBLKSIZE *
alsa_outdev[iodev].a_channels);
for (i = 0; i < n; i++)
{
result = snd_pcm_writei(alsa_outdev[iodev].a_handle, alsa_snd_buf,
! DEFDACBLKSIZE);
#if 0
! if (result != DEFDACBLKSIZE)
post("result %d", result);
#endif
--- 586,597 ----
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
***************
*** 606,612 ****
{
result = snd_pcm_readi(alsa_indev[iodev].a_handle, alsa_snd_buf,
! DEFDACBLKSIZE);
#if 0
! if (result != DEFDACBLKSIZE)
post("result %d", result);
#endif
--- 606,612 ----
{
result = snd_pcm_readi(alsa_indev[iodev].a_handle, alsa_snd_buf,
! sys_dacblocksize);
#if 0
! if (result != sys_dacblocksize)
post("result %d", result);
#endif
***************
*** 680,687 ****
}
/* the "correct" position is for all the phases to be exactly
! equal; but since we only make corrections DEFDACBLKSIZE samples
at a time, we just ask that the spread be not more than 3/4
of a block. */
! if (maxphase <= minphase + (3 * DEFDACBLKSIZE / 4))
break;
--- 680,687 ----
}
/* the "correct" position is for all the phases to be exactly
! equal; but since we only make corrections sys_dacblocksize samples
at a time, we just ask that the spread be not more than 3/4
of a block. */
! if (maxphase <= minphase + (3 * sys_dacblocksize / 4))
break;
***************
*** 694,698 ****
break;
thisphase = alsa_buf_samps - outdelay;
! if (thisphase > minphase + DEFDACBLKSIZE)
{
alsa_putzeros(iodev, 1);
--- 694,698 ----
break;
thisphase = alsa_buf_samps - outdelay;
! if (thisphase > minphase + sys_dacblocksize)
{
alsa_putzeros(iodev, 1);
***************
*** 707,711 ****
if (result < 0)
break;
! if (thisphase > minphase + DEFDACBLKSIZE)
{
alsa_getzeros(iodev, 1);
--- 707,711 ----
if (result < 0)
break;
! if (thisphase > minphase + sys_dacblocksize)
{
alsa_getzeros(iodev, 1);
Index: s_audio_oss.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_audio_oss.c,v
retrieving revision 1.6
retrieving revision 1.6.4.1
diff -C2 -d -r1.6 -r1.6.4.1
*** s_audio_oss.c 6 Sep 2004 20:20:35 -0000 1.6
--- s_audio_oss.c 10 Nov 2004 13:47:09 -0000 1.6.4.1
***************
*** 37,43 ****
typedef int32_t t_oss_int32;
#define OSS_MAXSAMPLEWIDTH sizeof(t_oss_int32)
! #define OSS_BYTESPERCHAN(width) (DEFDACBLKSIZE * (width))
! #define OSS_XFERSAMPS(chans) (DEFDACBLKSIZE* (chans))
! #define OSS_XFERSIZE(chans, width) (DEFDACBLKSIZE * (chans) * (width))
/* GLOBALS */
--- 37,43 ----
typedef int32_t t_oss_int32;
#define OSS_MAXSAMPLEWIDTH sizeof(t_oss_int32)
! #define OSS_BYTESPERCHAN(width) (sys_dacblocksize * (width))
! #define OSS_XFERSAMPS(chans) (sys_dacblocksize* (chans))
! #define OSS_XFERSIZE(chans, width) (sys_dacblocksize * (chans) * (width))
/* GLOBALS */
***************
*** 189,193 ****
{
linux_fragsize = OSS_DEFFRAGSIZE;
! while (linux_fragsize > DEFDACBLKSIZE
&& linux_fragsize * 6 > sys_advance_samples)
linux_fragsize = linux_fragsize/2;
--- 189,193 ----
{
linux_fragsize = OSS_DEFFRAGSIZE;
! while (linux_fragsize > sys_dacblocksize
&& linux_fragsize * 6 > sys_advance_samples)
linux_fragsize = linux_fragsize/2;
***************
*** 275,279 ****
char devname[20];
int n, i, fd, flags;
! char buf[OSS_MAXSAMPLEWIDTH * DEFDACBLKSIZE * OSS_MAXCHPERDEV];
int num_devs = 0;
int wantmore=0;
--- 275,279 ----
char devname[20];
int n, i, fd, flags;
! char buf[OSS_MAXSAMPLEWIDTH * sys_dacblocksize * OSS_MAXCHPERDEV];
int num_devs = 0;
int wantmore=0;
***************
*** 468,472 ****
read(linux_adcs[0].d_fd, buf,
linux_adcs[0].d_bytespersamp *
! linux_adcs[0].d_nchannels * DEFDACBLKSIZE);
if (sys_verbose)
fprintf(stderr, "...done.\n");
--- 468,472 ----
read(linux_adcs[0].d_fd, buf,
linux_adcs[0].d_bytespersamp *
! linux_adcs[0].d_nchannels * sys_dacblocksize);
if (sys_verbose)
fprintf(stderr, "...done.\n");
***************
*** 477,485 ****
int j;
memset(buf, 0, linux_dacs[i].d_bytespersamp *
! linux_dacs[i].d_nchannels * DEFDACBLKSIZE);
! for (j = 0; j < sys_advance_samples/DEFDACBLKSIZE; j++)
write(linux_dacs[i].d_fd, buf,
linux_dacs[i].d_bytespersamp *
! linux_dacs[i].d_nchannels * DEFDACBLKSIZE);
}
sys_setalarm(0);
--- 477,485 ----
int j;
memset(buf, 0, linux_dacs[i].d_bytespersamp *
! linux_dacs[i].d_nchannels * sys_dacblocksize);
! for (j = 0; j < sys_advance_samples/sys_dacblocksize; j++)
write(linux_dacs[i].d_fd, buf,
linux_dacs[i].d_bytespersamp *
! linux_dacs[i].d_nchannels * sys_dacblocksize);
}
sys_setalarm(0);
***************
*** 553,557 ****
{
int dev, zeroed = 0, wantsize;
! char buf[OSS_MAXSAMPLEWIDTH * DEFDACBLKSIZE * OSS_MAXCHPERDEV];
audio_buf_info ainfo;
--- 553,557 ----
{
int dev, zeroed = 0, wantsize;
! char buf[OSS_MAXSAMPLEWIDTH * sys_dacblocksize * OSS_MAXCHPERDEV];
audio_buf_info ainfo;
***************
*** 633,637 ****
long fill;
int i, j, dev, rtnval = SENDDACS_YES;
! char buf[OSS_MAXSAMPLEWIDTH * DEFDACBLKSIZE * OSS_MAXCHPERDEV];
t_oss_int16 *sp;
t_oss_int32 *lp;
--- 633,637 ----
long fill;
int i, j, dev, rtnval = SENDDACS_YES;
! char buf[OSS_MAXSAMPLEWIDTH * sys_dacblocksize * OSS_MAXCHPERDEV];
t_oss_int16 *sp;
t_oss_int32 *lp;
***************
*** 727,732 ****
if (linux_dacs[dev].d_bytespersamp == 4)
{
! for (i = DEFDACBLKSIZE * nchannels, fp1 = sys_soundout +
! DEFDACBLKSIZE*thischan,
lp = (t_oss_int32 *)buf; i--; fp1++, lp++)
{
--- 727,732 ----
if (linux_dacs[dev].d_bytespersamp == 4)
{
! for (i = sys_dacblocksize * nchannels, fp1 = sys_soundout +
! sys_dacblocksize*thischan,
lp = (t_oss_int32 *)buf; i--; fp1++, lp++)
{
***************
*** 738,746 ****
else
{
! for (i = DEFDACBLKSIZE, fp1 = sys_soundout +
! DEFDACBLKSIZE*thischan,
sp = (t_oss_int16 *)buf; i--; fp1++, sp += nchannels)
{
! for (j=0, fp2 = fp1; j<nchannels; j++, fp2 += DEFDACBLKSIZE)
{
int s = *fp2 * 32767.;
--- 738,746 ----
else
{
! for (i = sys_dacblocksize, fp1 = sys_soundout +
! sys_dacblocksize*thischan,
sp = (t_oss_int16 *)buf; i--; fp1++, sp += nchannels)
{
! for (j=0, fp2 = fp1; j<nchannels; j++, fp2 += sys_dacblocksize)
{
int s = *fp2 * 32767.;
***************
*** 764,768 ****
}
memset(sys_soundout, 0,
! sys_outchannels * (sizeof(float) * DEFDACBLKSIZE));
/* do input */
--- 764,768 ----
}
memset(sys_soundout, 0,
! sys_outchannels * (sizeof(float) * sys_dacblocksize));
/* do input */
***************
*** 785,790 ****
if (linux_adcs[dev].d_bytespersamp == 4)
{
! for (i = DEFDACBLKSIZE*nchannels,
! fp1 = sys_soundin + thischan*DEFDACBLKSIZE,
lp = (t_oss_int32 *)buf; i--; fp1++, lp++)
{
--- 785,790 ----
if (linux_adcs[dev].d_bytespersamp == 4)
{
! for (i = sys_dacblocksize*nchannels,
! fp1 = sys_soundin + thischan*sys_dacblocksize,
lp = (t_oss_int32 *)buf; i--; fp1++, lp++)
{
***************
*** 794,802 ****
else
{
! for (i = DEFDACBLKSIZE,fp1 = sys_soundin + thischan*DEFDACBLKSIZE,
sp = (t_oss_int16 *)buf; i--; fp1++, sp += nchannels)
{
for (j=0;j<nchannels;j++)
! fp1[j*DEFDACBLKSIZE] = (float)sp[j]*(float)3.051850e-05;
}
}
--- 794,802 ----
else
{
! for (i = sys_dacblocksize,fp1 = sys_soundin + thischan*sys_dacblocksize,
sp = (t_oss_int16 *)buf; i--; fp1++, sp += nchannels)
{
for (j=0;j<nchannels;j++)
! fp1[j*sys_dacblocksize] = (float)sp[j]*(float)3.051850e-05;
}
}
Index: s_audio_alsamm.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_audio_alsamm.c,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -C2 -d -r1.1.4.1 -r1.1.4.2
*** s_audio_alsamm.c 5 Nov 2004 14:27:47 -0000 1.1.4.1
--- s_audio_alsamm.c 10 Nov 2004 13:47:09 -0000 1.1.4.2
***************
*** 91,95 ****
static unsigned int alsamm_buffertime = 0;
static unsigned int alsamm_buffersize = 0;
- static int alsamm_transfersize = DEFDACBLKSIZE;
/* bad style: we asume all cards give the same answer at init so we make this vars global
--- 91,94 ----
***************
*** 729,733 ****
snd_pcm_sw_params_get_avail_min(swparams, &ops);
! err = snd_pcm_sw_params_set_avail_min(handle, swparams, alsamm_transfersize/2);
if (err < 0) {
check_error(err,"Unable to set avail min for");
--- 728,732 ----
snd_pcm_sw_params_get_avail_min(swparams, &ops);
! err = snd_pcm_sw_params_set_avail_min(handle, swparams, sys_dacblocksize/2);
if (err < 0) {
check_error(err,"Unable to set avail min for");
***************
*** 1033,1037 ****
all DAC data is in sys_soundout array with
! DEFDACBLKSIZE (mostly 64) for each channels which
if we have more channels opened then dac-channels = sys_outchannels
we have to zero (silence them), which should be done once.
--- 1032,1036 ----
all DAC data is in sys_soundout array with
! sys_dacblocksize (mostly 64) for each channels which
if we have more channels opened then dac-channels = sys_outchannels
we have to zero (silence them), which should be done once.
***************
*** 1161,1170 ****
this should only happen on first card otherwise we got a problem :-(()*/
! if(oavail < alsamm_transfersize){
return SENDDACS_NO;
}
/* transfer now */
! size = alsamm_transfersize;
fp1 = fpo;
ooffset = 0;
--- 1160,1169 ----
this should only happen on first card otherwise we got a problem :-(()*/
! if(oavail < sys_dacblocksize){
return SENDDACS_NO;
}
/* transfer now */
! size = sys_dacblocksize;
fp1 = fpo;
ooffset = 0;
***************
*** 1207,1211 ****
*/
! for (i = 0, fp2 = fp1 + chn*alsamm_transfersize; i < oframes; i++,fp2++)
{
float s1 = *fp2 * F32MAX;
--- 1206,1210 ----
*/
! for (i = 0, fp2 = fp1 + chn*sys_dacblocksize; i < oframes; i++,fp2++)
{
float s1 = *fp2 * F32MAX;
***************
*** 1233,1237 ****
size -= oframes;
} /* while size */
! fpo += ochannels*alsamm_transfersize;
}/* for devno */
--- 1232,1236 ----
size -= oframes;
} /* while size */
! fpo += ochannels*sys_dacblocksize;
}/* for devno */
***************
*** 1277,1284 ****
/* only transfer full transfersize or nothing */
! if(iavail < alsamm_transfersize){
return SENDDACS_NO;
}
! size = alsamm_transfersize;
fp1 = fpi;
ioffset = 0;
--- 1276,1283 ----
/* only transfer full transfersize or nothing */
! if(iavail < sys_dacblocksize){
return SENDDACS_NO;
}
! size = sys_dacblocksize;
fp1 = fpi;
ioffset = 0;
***************
*** 1314,1318 ****
t_alsa_sample32 *buf = (t_alsa_sample32 *) dev->a_addr[chn];
! for (i = 0, fp2 = fp1 + chn*alsamm_transfersize; i < iframes; i++,fp2++)
{
/* mask the lowest bits, since subchannels info can make zero samples nonzero */
--- 1313,1317 ----
t_alsa_sample32 *buf = (t_alsa_sample32 *) dev->a_addr[chn];
! for (i = 0, fp2 = fp1 + chn*sys_dacblocksize; i < iframes; i++,fp2++)
{
/* mask the lowest bits, since subchannels info can make zero samples nonzero */
***************
*** 1333,1337 ****
size -= iframes;
}
! fpi += ichannels*alsamm_transfersize;
} /* for out devno < alsamm_outcards*/
--- 1332,1336 ----
size -= iframes;
}
! fpi += ichannels*sys_dacblocksize;
} /* for out devno < alsamm_outcards*/
Index: s_audio_alsa.h
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_audio_alsa.h,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** s_audio_alsa.h 6 Sep 2004 20:20:35 -0000 1.1
--- s_audio_alsa.h 10 Nov 2004 13:47:09 -0000 1.1.4.1
***************
*** 9,14 ****
#define ALSA_SAMPLEWIDTH_16 sizeof(t_alsa_sample16)
#define ALSA_SAMPLEWIDTH_32 sizeof(t_alsa_sample32)
! #define ALSA_XFERSIZE16 (signed int)(sizeof(t_alsa_sample16) * DEFDACBLKSIZE)
! #define ALSA_XFERSIZE32 (signed int)(sizeof(t_alsa_sample32) * DEFDACBLKSIZE)
#define ALSA_MAXDEV 4
#define ALSA_JITTER 1024
--- 9,14 ----
#define ALSA_SAMPLEWIDTH_16 sizeof(t_alsa_sample16)
#define ALSA_SAMPLEWIDTH_32 sizeof(t_alsa_sample32)
! #define ALSA_XFERSIZE16 (signed int)(sizeof(t_alsa_sample16) * sys_dacblocksize)
! #define ALSA_XFERSIZE32 (signed int)(sizeof(t_alsa_sample32) * sys_dacblocksize)
#define ALSA_MAXDEV 4
#define ALSA_JITTER 1024
Index: s_audio_mmio.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_audio_mmio.c,v
retrieving revision 1.4
retrieving revision 1.4.4.1
diff -C2 -d -r1.4 -r1.4.4.1
*** s_audio_mmio.c 6 Sep 2004 20:20:35 -0000 1.4
--- s_audio_mmio.c 10 Nov 2004 13:47:09 -0000 1.4.4.1
***************
*** 28,32 ****
int nt_realdacblksize;
! #define DEFREALDACBLKSIZE (4 * DEFDACBLKSIZE) /* larger underlying bufsize */
#define MAXBUFFER 100 /* number of buffers in use at maximum advance */
--- 28,32 ----
int nt_realdacblksize;
! #define DEFREALDACBLKSIZE (4 * sys_dacblocksize) /* larger underlying bufsize */
#define MAXBUFFER 100 /* number of buffers in use at maximum advance */
***************
*** 509,513 ****
int i, n;
float maxsamp;
! for (i = 0, n = 2 * nt_nwavein * DEFDACBLKSIZE, maxsamp = nt_inmax;
i < n; i++)
{
--- 509,513 ----
int i, n;
float maxsamp;
! for (i = 0, n = 2 * nt_nwavein * sys_dacblocksize, maxsamp = nt_inmax;
i < n; i++)
{
***************
*** 517,521 ****
}
nt_inmax = maxsamp;
! for (i = 0, n = 2 * nt_nwaveout * DEFDACBLKSIZE, maxsamp = nt_outmax;
i < n; i++)
{
--- 517,521 ----
}
nt_inmax = maxsamp;
! for (i = 0, n = 2 * nt_nwaveout * sys_dacblocksize, maxsamp = nt_outmax;
i < n; i++)
{
***************
*** 573,579 ****
for (i = 0, sp1 = (short *)(ntsnd_outvec[nda][phase].lpData) +
CHANNELS_PER_DEVICE * nt_fill;
! i < 2; i++, fp1 += DEFDACBLKSIZE, sp1++)
{
! for (j = 0, fp2 = fp1, sp2 = sp1; j < DEFDACBLKSIZE;
j++, fp2++, sp2 += CHANNELS_PER_DEVICE)
{
--- 573,579 ----
for (i = 0, sp1 = (short *)(ntsnd_outvec[nda][phase].lpData) +
CHANNELS_PER_DEVICE * nt_fill;
! i < 2; i++, fp1 += sys_dacblocksize, sp1++)
{
! for (j = 0, fp2 = fp1, sp2 = sp1; j < sys_dacblocksize;
j++, fp2++, sp2 += CHANNELS_PER_DEVICE)
{
***************
*** 586,590 ****
}
memset(sys_soundout, 0,
! (DEFDACBLKSIZE *sizeof(t_sample)*CHANNELS_PER_DEVICE)*nt_nwaveout);
/* vice versa for the input buffer */
--- 586,590 ----
}
memset(sys_soundout, 0,
! (sys_dacblocksize *sizeof(t_sample)*CHANNELS_PER_DEVICE)*nt_nwaveout);
/* vice versa for the input buffer */
***************
*** 596,602 ****
for (i = 0, sp1 = (short *)(ntsnd_invec[nad][phase].lpData) +
CHANNELS_PER_DEVICE * nt_fill;
! i < 2; i++, fp1 += DEFDACBLKSIZE, sp1++)
{
! for (j = 0, fp2 = fp1, sp2 = sp1; j < DEFDACBLKSIZE;
j++, fp2++, sp2 += CHANNELS_PER_DEVICE)
{
--- 596,602 ----
for (i = 0, sp1 = (short *)(ntsnd_invec[nad][phase].lpData) +
CHANNELS_PER_DEVICE * nt_fill;
! i < 2; i++, fp1 += sys_dacblocksize, sp1++)
{
! for (j = 0, fp2 = fp1, sp2 = sp1; j < sys_dacblocksize;
j++, fp2++, sp2 += CHANNELS_PER_DEVICE)
{
***************
*** 606,610 ****
}
! nt_fill = nt_fill + DEFDACBLKSIZE;
if (nt_fill == nt_realdacblksize)
{
--- 606,610 ----
}
! nt_fill = nt_fill + sys_dacblocksize;
if (nt_fill == nt_realdacblksize)
{
Index: s_audio_pa.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_audio_pa.c,v
retrieving revision 1.4
retrieving revision 1.4.4.1
diff -C2 -d -r1.4 -r1.4.4.1
*** s_audio_pa.c 6 Sep 2004 20:20:35 -0000 1.4
--- s_audio_pa.c 10 Nov 2004 13:47:09 -0000 1.4.4.1
***************
*** 26,30 ****
#define MAX_PA_CHANS 32
! #define MAX_SAMPLES_PER_FRAME MAX_PA_CHANS * DEFDACBLKSIZE
#ifndef PA19
--- 26,30 ----
#define MAX_PA_CHANS 32
! #define MAX_SAMPLES_PER_FRAME MAX_PA_CHANS * sys_dacblocksize
#ifndef PA19
***************
*** 143,156 ****
timebefore = sys_getrealtime();
! if ((pa_inchans && GetAudioStreamReadable(pa_stream) < DEFDACBLKSIZE) ||
! (pa_outchans && GetAudioStreamWriteable(pa_stream) < DEFDACBLKSIZE))
{
if (pa_inchans && pa_outchans)
{
int synced = 0;
! while (GetAudioStreamWriteable(pa_stream) > 2*DEFDACBLKSIZE)
{
for (j = 0; j < pa_outchans; j++)
! for (i = 0, fp2 = samples + j; i < DEFDACBLKSIZE; i++,
fp2 += pa_outchans)
{
--- 143,156 ----
timebefore = sys_getrealtime();
! if ((pa_inchans && GetAudioStreamReadable(pa_stream) < sys_dacblocksize) ||
! (pa_outchans && GetAudioStreamWriteable(pa_stream) < sys_dacblocksize))
{
if (pa_inchans && pa_outchans)
{
int synced = 0;
! while (GetAudioStreamWriteable(pa_stream) > 2*sys_dacblocksize)
{
for (j = 0; j < pa_outchans; j++)
! for (i = 0, fp2 = samples + j; i < sys_dacblocksize; i++,
fp2 += pa_outchans)
{
***************
*** 158,167 ****
}
synced = 1;
! WriteAudioStream(pa_stream, samples, DEFDACBLKSIZE);
}
! while (GetAudioStreamReadable(pa_stream) > 2*DEFDACBLKSIZE)
{
synced = 1;
! ReadAudioStream(pa_stream, samples, DEFDACBLKSIZE);
}
/* if (synced)
--- 158,167 ----
}
synced = 1;
! WriteAudioStream(pa_stream, samples, sys_dacblocksize);
}
! while (GetAudioStreamReadable(pa_stream) > 2*sys_dacblocksize)
{
synced = 1;
! ReadAudioStream(pa_stream, samples, sys_dacblocksize);
}
/* if (synced)
***************
*** 172,178 ****
if (pa_inchans)
{
! ReadAudioStream(pa_stream, samples, DEFDACBLKSIZE);
! for (j = 0, fp1 = pa_soundin; j < pa_inchans; j++, fp1 += DEFDACBLKSIZE)
! for (i = 0, fp2 = samples + j; i < DEFDACBLKSIZE; i++,
fp2 += pa_inchans)
{
--- 172,178 ----
if (pa_inchans)
{
! ReadAudioStream(pa_stream, samples, sys_dacblocksize);
! for (j = 0, fp1 = pa_soundin; j < pa_inchans; j++, fp1 += sys_dacblocksize)
! for (i = 0, fp2 = samples + j; i < sys_dacblocksize; i++,
fp2 += pa_inchans)
{
***************
*** 195,200 ****
{
for (j = 0, fp1 = pa_soundout; j < pa_outchans; j++,
! fp1 += DEFDACBLKSIZE)
! for (i = 0, fp2 = samples + j; i < DEFDACBLKSIZE; i++,
fp2 += pa_outchans)
{
--- 195,200 ----
{
for (j = 0, fp1 = pa_soundout; j < pa_outchans; j++,
! fp1 += sys_dacblocksize)
! for (i = 0, fp2 = samples + j; i < sys_dacblocksize; i++,
fp2 += pa_outchans)
{
***************
*** 202,206 ****
fp1[i] = 0;
}
! WriteAudioStream(pa_stream, samples, DEFDACBLKSIZE);
}
--- 202,206 ----
fp1[i] = 0;
}
! WriteAudioStream(pa_stream, samples, sys_dacblocksize);
}
Index: s_audio.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_audio.c,v
retrieving revision 1.5.4.1
retrieving revision 1.5.4.2
diff -C2 -d -r1.5.4.1 -r1.5.4.2
*** s_audio.c 5 Nov 2004 14:27:46 -0000 1.5.4.1
--- s_audio.c 10 Nov 2004 13:47:08 -0000 1.5.4.2
***************
*** 23,28 ****
typedef long t_pa_sample;
#define SYS_SAMPLEWIDTH sizeof(t_pa_sample)
! #define SYS_BYTESPERCHAN (DEFDACBLKSIZE * SYS_SAMPLEWIDTH)
! #define SYS_XFERSAMPS (SYS_DEFAULTCH*DEFDACBLKSIZE)
#define SYS_XFERSIZE (SYS_SAMPLEWIDTH * SYS_XFERSAMPS)
--- 23,28 ----
typedef long t_pa_sample;
#define SYS_SAMPLEWIDTH sizeof(t_pa_sample)
! #define SYS_BYTESPERCHAN (sys_dacblocksize * SYS_SAMPLEWIDTH)
! #define SYS_XFERSAMPS (SYS_DEFAULTCH*sys_dacblocksize)
#define SYS_XFERSIZE (SYS_SAMPLEWIDTH * SYS_XFERSAMPS)
***************
*** 35,38 ****
--- 35,41 ----
int sys_audioapi = API_DEFAULT;
+ int sys_dacblocksize;
+ int sys_schedblocksize;
+
static int sys_meters; /* true if we're metering */
static float sys_inmax; /* max input amplitude */
***************
*** 59,62 ****
--- 62,66 ----
static int audio_audiochoutdev[MAXAUDIOOUTDEV];
static int audio_rate;
+ static int audio_dacblocksize;
static int audio_advance;
***************
*** 71,75 ****
int *pnaudioindev, int *paudioindev, int *chindev,
int *pnaudiooutdev, int *paudiooutdev, int *choutdev,
! int *prate, int *padvance)
{
int i;
--- 75,79 ----
int *pnaudioindev, int *paudioindev, int *chindev,
int *pnaudiooutdev, int *paudiooutdev, int *choutdev,
! int *prate, int *pdacblocksize, int *padvance)
{
int i;
***************
*** 83,86 ****
--- 87,91 ----
choutdev[i] = audio_audiochoutdev[i];
*prate = audio_rate;
+ *pdacblocksize = audio_dacblocksize;
*padvance = audio_advance;
}
***************
*** 89,93 ****
int naudioindev, int *audioindev, int *chindev,
int naudiooutdev, int *audiooutdev, int *choutdev,
! int rate, int advance)
{
int i;
--- 94,98 ----
int naudioindev, int *audioindev, int *chindev,
int naudiooutdev, int *audiooutdev, int *choutdev,
! int rate, int dacblocksize, int advance)
{
int i;
***************
*** 101,104 ****
--- 106,110 ----
audio_audiochoutdev[i] = choutdev[i];
audio_rate = rate;
+ audio_dacblocksize = dacblocksize;
audio_advance = advance;
}
***************
*** 123,131 ****
/* set channels and sample rate. */
! void sys_setchsr(int chin, int chout, int sr)
{
int nblk;
! int inbytes = (chin ? chin : 2) * (DEFDACBLKSIZE*sizeof(float));
! int outbytes = (chout ? chout : 2) * (DEFDACBLKSIZE*sizeof(float));
sys_inchannels = chin;
--- 129,147 ----
/* set channels and sample rate. */
! void sys_setchsr(int chin, int chout, int sr, int dacblocksize)
{
int nblk;
! int inbytes;
! int outbytes;
!
! if (dacblocksize != (1 << ilog2(dacblocksize)))
! post("warning: adjusting dac~blocksize to power of 2: %d",
! (dacblocksize = (1 << ilog2(dacblocksize))));
!
! sys_dacblocksize = dacblocksize;
! sys_schedblocksize = dacblocksize;
!
! inbytes = (chin ? chin : 2) * (sys_dacblocksize*sizeof(float));
! outbytes = (chout ? chout : 2) * (sys_dacblocksize*sizeof(float));
sys_inchannels = chin;
***************
*** 133,138 ****
sys_dacsr = sr;
sys_advance_samples = (sys_schedadvance * sys_dacsr) / (1000000.);
! if (sys_advance_samples < 3 * DEFDACBLKSIZE)
! sys_advance_samples = 3 * DEFDACBLKSIZE;
if (sys_soundin)
--- 149,154 ----
sys_dacsr = sr;
sys_advance_samples = (sys_schedadvance * sys_dacsr) / (1000000.);
! if (sys_advance_samples < 3 * sys_dacblocksize)
! sys_advance_samples = 3 * sys_dacblocksize;
if (sys_soundin)
***************
*** 161,165 ****
void sys_open_audio(int naudioindev, int *audioindev, int nchindev,
int *chindev, int naudiooutdev, int *audiooutdev, int nchoutdev,
! int *choutdev, int rate, int advance, int enable)
{
int i, *ip;
--- 177,181 ----
void sys_open_audio(int naudioindev, int *audioindev, int nchindev,
int *chindev, int naudiooutdev, int *audiooutdev, int nchoutdev,
! int *choutdev, int rate, int dacblocksize, int advance, int enable)
{
int i, *ip;
***************
*** 180,183 ****
--- 196,201 ----
if (rate < 1)
rate = DEFAULTSRATE;
+ if (dacblocksize < 1)
+ dacblocksize = DEFDACBLKSIZE;
if (advance <= 0)
advance = DEFAULTADVANCE;
***************
*** 289,293 ****
enable = 0;
sys_schedadvance = advance * 1000;
! sys_setchsr(inchans, outchans, rate);
sys_log_error(ERR_NOTHING);
if (enable)
--- 307,311 ----
enable = 0;
sys_schedadvance = advance * 1000;
! sys_setchsr(inchans, outchans, rate, dacblocksize);
sys_log_error(ERR_NOTHING);
if (enable)
***************
*** 351,355 ****
}
sys_save_audio_params(naudioindev, audioindev, chindev,
! naudiooutdev, audiooutdev, choutdev, sys_dacsr, advance);
if (sys_inchannels == 0 && sys_outchannels == 0)
enable = 0;
--- 369,373 ----
}
sys_save_audio_params(naudioindev, audioindev, chindev,
! naudiooutdev, audiooutdev, choutdev, sys_dacsr, sys_dacblocksize, advance);
if (sys_inchannels == 0 && sys_outchannels == 0)
enable = 0;
***************
*** 416,424 ****
int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV];
int naudiooutdev, audiooutdev[MAXAUDIOOUTDEV], choutdev[MAXAUDIOOUTDEV];
! int rate, advance;
sys_get_audio_params(&naudioindev, audioindev, chindev,
! &naudiooutdev, audiooutdev, choutdev, &rate, &advance);
sys_open_audio(naudioindev, audioindev, naudioindev, chindev,
! naudiooutdev, audiooutdev, naudiooutdev, choutdev, rate, advance, 1);
}
--- 434,442 ----
int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV];
int naudiooutdev, audiooutdev[MAXAUDIOOUTDEV], choutdev[MAXAUDIOOUTDEV];
! int rate, dacblocksize, advance;
sys_get_audio_params(&naudioindev, audioindev, chindev,
! &naudiooutdev, audiooutdev, choutdev, &rate, &dacblocksize, &advance);
sys_open_audio(naudioindev, audioindev, naudioindev, chindev,
! naudiooutdev, audiooutdev, naudiooutdev, choutdev, rate, dacblocksize, advance, 1);
}
***************
*** 429,433 ****
int i, n;
float maxsamp;
! for (i = 0, n = sys_inchannels * DEFDACBLKSIZE, maxsamp = sys_inmax;
i < n; i++)
{
--- 447,451 ----
int i, n;
float maxsamp;
! for (i = 0, n = sys_inchannels * sys_dacblocksize, maxsamp = sys_inmax;
i < n; i++)
{
***************
*** 437,441 ****
}
sys_inmax = maxsamp;
! for (i = 0, n = sys_outchannels * DEFDACBLKSIZE, maxsamp = sys_outmax;
i < n; i++)
{
--- 455,459 ----
}
sys_inmax = maxsamp;
! for (i = 0, n = sys_outchannels * sys_dacblocksize, maxsamp = sys_outmax;
i < n; i++)
{
***************
*** 645,649 ****
audiooutdev1, audiooutdev2, audiooutdev3, audiooutdev4,
audiooutchan1, audiooutchan2, audiooutchan3, audiooutchan4;
! int rate, advance;
/* these are all the devices on your system: */
char indevlist[MAXNDEV*DEVDESCSIZE], outdevlist[MAXNDEV*DEVDESCSIZE];
--- 663,667 ----
audiooutdev1, audiooutdev2, audiooutdev3, audiooutdev4,
audiooutchan1, audiooutchan2, audiooutchan3, audiooutchan4;
! int rate, dacblocksize, advance;
/* these are all the devices on your system: */
char indevlist[MAXNDEV*DEVDESCSIZE], outdevlist[MAXNDEV*DEVDESCSIZE];
***************
*** 675,679 ****
sys_get_audio_params(&naudioindev, audioindev, chindev,
! &naudiooutdev, audiooutdev, choutdev, &rate, &advance);
/* post("naudioindev %d naudiooutdev %d longform %f",
--- 693,697 ----
sys_get_audio_params(&naudioindev, audioindev, chindev,
! &naudiooutdev, audiooutdev, choutdev, &rate, &dacblocksize, &advance);
/* post("naudioindev %d naudiooutdev %d longform %f",
***************
*** 703,707 ****
%s %d %d %d %d %d %d %d %d \
%s %d %d %d %d %d %d %d %d \
! %d %d %d %d\n",
indevliststring,
audioindev1, audioindev2, audioindev3, audioindev4,
--- 721,725 ----
%s %d %d %d %d %d %d %d %d \
%s %d %d %d %d %d %d %d %d \
! %d %d %d %d %d\n",
indevliststring,
audioindev1, audioindev2, audioindev3, audioindev4,
***************
*** 710,714 ****
audiooutdev1, audiooutdev2, audiooutdev3, audiooutdev4,
audiooutchan1, audiooutchan2, audiooutchan3, audiooutchan4,
! rate, advance, canmulti, (flongform != 0));
gfxstub_deleteforkey(0);
gfxstub_new(&glob_pdobject, (void *)glob_audio_properties, buf);
--- 728,732 ----
audiooutdev1, audiooutdev2, audiooutdev3, audiooutdev4,
audiooutchan1, audiooutchan2, audiooutchan3, audiooutchan4,
! rate, dacblocksize, advance, canmulti, (flongform != 0));
gfxstub_deleteforkey(0);
gfxstub_new(&glob_pdobject, (void *)glob_audio_properties, buf);
***************
*** 720,724 ****
int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV];
int naudiooutdev, audiooutdev[MAXAUDIOOUTDEV], choutdev[MAXAUDIOOUTDEV];
! int rate, advance, audioon, i, nindev, noutdev;
int audioindev1, audioinchan1, audiooutdev1, audiooutchan1;
int newaudioindev[4], newaudioinchan[4],
--- 738,742 ----
int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV];
int naudiooutdev, audiooutdev[MAXAUDIOOUTDEV], choutdev[MAXAUDIOOUTDEV];
! int rate, dacblocksize, advance, audioon, i, nindev, noutdev;
int audioindev1, audioinchan1, audiooutdev1, audiooutchan1;
int newaudioindev[4], newaudioinchan[4],
***************
*** 726,730 ****
/* the new values the dialog came back with: */
int newrate = atom_getintarg(16, argc, argv);
! int newadvance = atom_getintarg(17, argc, argv);
int statewas;
--- 744,749 ----
/* the new values the dialog came back with: */
int newrate = atom_getintarg(16, argc, argv);
! int newdacblocksize = atom_getintarg(17, argc, argv);
! int newadvance = atom_getintarg(18, argc, argv);
int statewas;
***************
*** 763,767 ****
sys_open_audio(nindev, newaudioindev, nindev, newaudioinchan,
noutdev, newaudiooutdev, noutdev, newaudiooutchan,
! newrate, newadvance, 1);
}
--- 782,786 ----
sys_open_audio(nindev, newaudioindev, nindev, newaudioinchan,
noutdev, newaudiooutdev, noutdev, newaudiooutchan,
! newrate, newdacblocksize, newadvance, 1);
}
Index: u_main.tk
===================================================================
RCS file: /cvsroot/pure-data/pd/src/u_main.tk,v
retrieving revision 1.4.4.2
retrieving revision 1.4.4.3
diff -C2 -d -r1.4.4.2 -r1.4.4.3
*** u_main.tk 7 Nov 2004 12:38:56 -0000 1.4.4.2
--- u_main.tk 10 Nov 2004 13:47:09 -0000 1.4.4.3
***************
*** 2961,2965 ****
global audio_outchan1 audio_outchan2 audio_outchan3 audio_outchan4
global audio_outenable1 audio_outenable2 audio_outenable3 audio_outenable4
! global audio_sr audio_advance
pd [concat pd audio-dialog \
--- 2961,2965 ----
global audio_outchan1 audio_outchan2 audio_outchan3 audio_outchan4
global audio_outenable1 audio_outenable2 audio_outenable3 audio_outenable4
! global audio_sr audio_dacblocksize audio_advance
pd [concat pd audio-dialog \
***************
*** 2981,2984 ****
--- 2981,2985 ----
[expr $audio_outchan4 * ( $audio_outenable4 ? 1 : -1 ) ]\
$audio_sr \
+ $audio_dacblocksize \
$audio_advance \
\;]
***************
*** 3025,3029 ****
inchan1 inchan2 inchan3 inchan4 \
outdevlist outdev1 outdev2 outdev3 outdev4 \
! outchan1 outchan2 outchan3 outchan4 sr advance multi longform} {
global audio_indev1 audio_indev2 audio_indev3 audio_indev4
global audio_inchan1 audio_inchan2 audio_inchan3 audio_inchan4
--- 3026,3030 ----
inchan1 inchan2 inchan3 inchan4 \
outdevlist outdev1 outdev2 outdev3 outdev4 \
! outchan1 outchan2 outchan3 outchan4 sr dacblocksize advance multi longform} {
global audio_indev1 audio_indev2 audio_indev3 audio_indev4
global audio_inchan1 audio_inchan2 audio_inchan3 audio_inchan4
***************
*** 3032,3036 ****
global audio_outchan1 audio_outchan2 audio_outchan3 audio_outchan4
global audio_outenable1 audio_outenable2 audio_outenable3 audio_outenable4
! global audio_sr audio_advance
global audio_indevlist audio_outdevlist
--- 3033,3037 ----
global audio_outchan1 audio_outchan2 audio_outchan3 audio_outchan4
global audio_outenable1 audio_outenable2 audio_outenable3 audio_outenable4
! global audio_sr audio_dacblocksize audio_advance
global audio_indevlist audio_outdevlist
***************
*** 3064,3067 ****
--- 3065,3069 ----
set audio_sr $sr
+ set audio_dacblocksize $dacblocksize
set audio_advance $advance
set audio_indevlist $indevlist
***************
*** 3092,3096 ****
label $id.srf.l2 -text "delay (msec):"
entry $id.srf.x2 -textvariable audio_advance -width 4
! pack $id.srf.l1 $id.srf.x1 $id.srf.l2 $id.srf.x2 -side left
# input device 1
--- 3094,3100 ----
label $id.srf.l2 -text "delay (msec):"
entry $id.srf.x2 -textvariable audio_advance -width 4
! label $id.srf.l3 -text "dacblocksize:"
! entry $id.srf.x3 -textvariable audio_dacblocksize -width 4
! pack $id.srf.l1 $id.srf.x1 $id.srf.l2 $id.srf.x2 $id.srf.l3 $id.srf.x3 -side left
# input device 1