Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13083
Modified Files:
Tag: devel_0_38
s_audio_asio.cpp
Log Message:
dithering and (hopefully) reduced latency
Index: s_audio_asio.cpp
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/s_audio_asio.cpp,v
retrieving revision 1.1.4.11
retrieving revision 1.1.4.12
diff -C2 -d -r1.1.4.11 -r1.1.4.12
*** s_audio_asio.cpp 10 Nov 2004 22:37:31 -0000 1.1.4.11
--- s_audio_asio.cpp 18 Nov 2004 09:19:48 -0000 1.1.4.12
***************
*** 3,7 ****
* WARRANTIES, see the file, "LICENSE.txt" in this distribution. */
! /* native ASIO interface for windows and mac osx
* adapted from hostsample.cpp (ASIO SDK)
*/
--- 3,7 ----
* WARRANTIES, see the file, "LICENSE.txt" in this distribution. */
! /* native ASIO interface for windows
* adapted from hostsample.cpp (ASIO SDK)
*/
***************
*** 397,400 ****
--- 397,401 ----
bailout:
+ if(status) post("error: %s", asio_driver->errorMessage);
post("ASIO: couldn't start");
asio_close_audio();
***************
*** 550,555 ****
{
/* clipping here, we are sure, we can use simd instructions */
! t_int lo = -1;
! t_int hi = 1;
t_int clipargs[6];
clipargs[1] = (t_int)sp;
--- 551,556 ----
{
/* clipping here, we are sure, we can use simd instructions */
! t_float lo = -1.f;
! t_float hi = 1.f;
t_int clipargs[6];
clipargs[1] = (t_int)sp;
***************
*** 560,563 ****
--- 561,565 ----
clipblock(clipargs);
+
zeroblock(sp);
sp+=sys_dacblocksize;
***************
*** 569,581 ****
{
/* we should be able to read from the ringbuffer on a different position
! * to reduce latency for asio buffer sizes that aren't multiples of 64...
! * rethink this: */
! #if 0
! int offset = 2 * asio_bufsize;
! if (asio_ringbuffer_inoffset <= offset )
! copyblock(sp, asio_ringbuffer[i+j] + asio_ringbuffer_length +
! asio_ringbuffer_inoffset - offset);
! else
! copyblock(sp, asio_ringbuffer[i+j] + asio_ringbuffer_inoffset - offset);
#else /* working but higher latency */
copyblock(sp, asio_ringbuffer[i+j] + asio_ringbuffer_inoffset);
--- 571,586 ----
{
/* we should be able to read from the ringbuffer on a different position
! * to reduce latency for asio buffer sizes that aren't multiples of 64... */
! #if 1
! int offset = asio_bufsize + DEFDACBLKSIZE;
! offset += DEFDACBLKSIZE - offset % DEFDACBLKSIZE;
!
! if (asio_ringbuffer_inoffset < offset)
! {
! memcpy(sp, asio_ringbuffer[i+j] + asio_ringbuffer_length +
! asio_ringbuffer_inoffset - offset, 64 *sizeof(t_sample));
! }
! else
! memcpy(sp, asio_ringbuffer[i+j] + asio_ringbuffer_inoffset - offset, 64*sizeof(t_sample));
#else /* working but higher latency */
copyblock(sp, asio_ringbuffer[i+j] + asio_ringbuffer_inoffset);
***************
*** 691,723 ****
long i, j;
- // todo: store the timeInfo for later use
-
-
/* todo: i'm not sure if we'll have to synchronize with other media ...
* probably yes ... */
! /* sys_reftime = get_sys_reference_time(); */
! /* perform the processing
! * todo: improve input latency
! */
for (i = 0; i < sys_outchannels + sys_inchannels; i++)
{
if(asio_converter[i])
! if (asio_bufferinfo[i].isInput != ASIOTrue)
! {
! asio_converter[i](
! asio_ringbuffer[i]+asio_ringbuffer_outoffset,
! asio_bufferinfo[i].buffers[db_idx],
! asio_bufsize);
! }
! else /* these are the input channels */
! {
! asio_converter[i](
! asio_bufferinfo[i].buffers[db_idx],
! asio_ringbuffer[i]+asio_ringbuffer_outoffset,
! asio_bufsize);
! }
}
--- 696,721 ----
long i, j;
/* todo: i'm not sure if we'll have to synchronize with other media ...
* probably yes ... */
! /* sys_reftime = get_sys_reference_time(); */
! /* perform the processing */
for (i = 0; i < sys_outchannels + sys_inchannels; i++)
{
if(asio_converter[i])
! if (asio_bufferinfo[i].isInput != ASIOTrue)
! {
! asio_converter[i](asio_ringbuffer[i]+asio_ringbuffer_outoffset,
! asio_bufferinfo[i].buffers[db_idx],
! asio_bufsize);
! }
! else /* these are the input channels */
! {
! asio_converter[i](asio_bufferinfo[i].buffers[db_idx],
! asio_ringbuffer[i]+asio_ringbuffer_outoffset,
! asio_bufsize);
! }
}
***************
*** 933,936 ****
--- 931,936 ----
}
+ /* todo: check dithering */
+
static void float32tofloat32(void* inbuffer, void* outbuffer, long frames)
{
***************
*** 969,986 ****
while (frames--)
{
! // TODO: do some dithering!!
!
! float o = *(in++) * SCALE_INT16;
#ifdef __GNUC__
! __int16 srt = lrintf(o);
#else
! __int16 srt;
__asm
{
fld o
! fistp srt
}
#endif
! *out++ = srt;
}
}
--- 969,984 ----
while (frames--)
{
! float o = *(in++) * SCALE_INT16 + triangulardither() * DITHER_SCALE;
#ifdef __GNUC__
! __int16 lng = lrintf(o);
#else
! __int16 lng;
__asm
{
fld o
! fistp lng
}
#endif
! *out++ = lng ;
}
}
***************
*** 1000,1004 ****
while (frames--)
{
! float o = *(in++) * SCALE_INT24;
#ifdef __GNUC__
__int32 intg = (__int32)lrintf(o);
--- 998,1002 ----
while (frames--)
{
! float o = *(in++) * SCALE_INT24 + triangulardither() * DITHER_SCALE;
#ifdef __GNUC__
__int32 intg = (__int32)lrintf(o);
***************
*** 1029,1033 ****
while (frames--)
{
! float o = (float)*(in++) * SCALE_INT32;
#ifdef __GNUC__
*out++ = lrintf(o);
--- 1027,1031 ----
while (frames--)
{
! float o = (float)*(in++) * SCALE_INT32 + triangulardither() * DITHER_SCALE;
#ifdef __GNUC__
*out++ = lrintf(o);
***************
*** 1058,1063 ****
while (frames--)
{
! // TODO: do some dithering!!
! float o = (float)*(in++) * SCALE_INT16;
#ifdef __GNUC__
__int16 reverse = (__int16)lrintf(o);
--- 1056,1060 ----
while (frames--)
{
! float o = (float)*(in++) * SCALE_INT16 + triangulardither() * DITHER_SCALE;
#ifdef __GNUC__
__int16 reverse = (__int16)lrintf(o);
***************
*** 1088,1092 ****
while (frames--)
{
! float o = (float)*(in++) * SCALE_INT24;
#ifdef __GNUC__
__int32 reverse = (__int32)lrintf(o);
--- 1085,1089 ----
while (frames--)
{
! float o = (float)*(in++) * SCALE_INT24 + triangulardither() * DITHER_SCALE;
#ifdef __GNUC__
__int32 reverse = (__int32)lrintf(o);
***************
*** 1127,1131 ****
while (frames--)
{
! float o = (float)*(in++) * SCALE_INT32;
#ifdef __GNUC__
__int32 reverse = (__int32)lrintf(o);
--- 1124,1128 ----
while (frames--)
{
! float o = (float)*(in++) * SCALE_INT32 + triangulardither() * DITHER_SCALE;
#ifdef __GNUC__
__int32 reverse = (__int32)lrintf(o);