Author: titmuss
Date: Tue May  6 08:11:57 2008
New Revision: 2424

URL: http://svn.slimdevices.com?rev=2424&root=Jive&view=rev
Log:
Bug: N/A
Description:
Patch for portaudio to support 24-bit padded samples.
Fix for Int32 to Int16 dithered converter to support clipping.


Added:
    7.2/trunk/squeezeplay/src/portaudio_v19_1360/test/patest_sine24.c
Modified:
    7.2/trunk/squeezeplay/src/portaudio_v19_1360/include/portaudio.h
    7.2/trunk/squeezeplay/src/portaudio_v19_1360/src/common/pa_converters.c
    7.2/trunk/squeezeplay/src/portaudio_v19_1360/src/common/pa_converters.h
    7.2/trunk/squeezeplay/src/portaudio_v19_1360/src/common/pa_front.c

Modified: 7.2/trunk/squeezeplay/src/portaudio_v19_1360/include/portaudio.h
URL: 
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/portaudio_v19_1360/include/portaudio.h?rev=2424&root=Jive&r1=2423&r2=2424&view=diff
==============================================================================
--- 7.2/trunk/squeezeplay/src/portaudio_v19_1360/include/portaudio.h (original)
+++ 7.2/trunk/squeezeplay/src/portaudio_v19_1360/include/portaudio.h Tue May  6 
08:11:57 2008
@@ -412,7 +412,7 @@
  Pa_ReadStream and Pa_WriteStream.
 
  The standard formats paFloat32, paInt16, paInt32, paInt24, paInt8
- and aUInt8 are usually implemented by all implementations.
+ and paUInt8 are usually implemented by all implementations.
 
  The floating point representation (paFloat32) uses +1.0 and -1.0 as the
  maximum and minimum respectively.
@@ -423,7 +423,7 @@
  as a set of non-interleaved pointers.
 
  @see Pa_OpenStream, Pa_OpenDefaultStream, PaDeviceInfo
- @see paFloat32, paInt16, paInt32, paInt24, paInt8
+ @see paFloat32, paInt16, paInt32, paInt24, paInt24Padded, paInt8
  @see paUInt8, paCustomFormat, paNonInterleaved
 */
 typedef unsigned long PaSampleFormat;
@@ -431,10 +431,11 @@
 
 #define paFloat32        ((PaSampleFormat) 0x00000001) /**< @see 
PaSampleFormat */
 #define paInt32          ((PaSampleFormat) 0x00000002) /**< @see 
PaSampleFormat */
-#define paInt24          ((PaSampleFormat) 0x00000004) /**< Packed 24 bit 
format. @see PaSampleFormat */
-#define paInt16          ((PaSampleFormat) 0x00000008) /**< @see 
PaSampleFormat */
-#define paInt8           ((PaSampleFormat) 0x00000010) /**< @see 
PaSampleFormat */
-#define paUInt8          ((PaSampleFormat) 0x00000020) /**< @see 
PaSampleFormat */
+#define paInt24Padded    ((PaSampleFormat) 0x00000004) /**< Padded 24 bit 
format. @see PaSampleFormat */
+#define paInt24          ((PaSampleFormat) 0x00000008) /**< Packed 24 bit 
format. @see PaSampleFormat */
+#define paInt16          ((PaSampleFormat) 0x00000010) /**< @see 
PaSampleFormat */
+#define paInt8           ((PaSampleFormat) 0x00000020) /**< @see 
PaSampleFormat */
+#define paUInt8          ((PaSampleFormat) 0x00000040) /**< @see 
PaSampleFormat */
 #define paCustomFormat   ((PaSampleFormat) 0x00010000)/**< @see PaSampleFormat 
*/
 
 #define paNonInterleaved ((PaSampleFormat) 0x80000000)

Modified: 
7.2/trunk/squeezeplay/src/portaudio_v19_1360/src/common/pa_converters.c
URL: 
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/portaudio_v19_1360/src/common/pa_converters.c?rev=2424&root=Jive&r1=2423&r2=2424&view=diff
==============================================================================
--- 7.2/trunk/squeezeplay/src/portaudio_v19_1360/src/common/pa_converters.c 
(original)
+++ 7.2/trunk/squeezeplay/src/portaudio_v19_1360/src/common/pa_converters.c Tue 
May  6 08:11:57 2008
@@ -117,12 +117,15 @@
 
 /* -------------------------------------------------------------------------- 
*/
 
-#define PA_SELECT_FORMAT_( format, float32, int32, int24, int16, int8, uint8 ) 
\
+#define PA_SELECT_FORMAT_( format, float32, int32, int24Padded, int24, int16,  
\
+                           int8,  uint8 )                                      
\
     switch( format & ~paNonInterleaved ){                                      
\
     case paFloat32:                                                            
\
         float32                                                                
\
     case paInt32:                                                              
\
         int32                                                                  
\
+    case paInt24Padded:                                                        
\
+        int24Padded                                                            
\
     case paInt24:                                                              
\
         int24                                                                  
\
     case paInt16:                                                              
\
@@ -180,6 +183,7 @@
                        PA_SELECT_FORMAT_( destinationFormat,
                                           /* paFloat32: */        
PA_UNITY_CONVERSION_( 32 ),
                                           /* paInt32: */          
PA_SELECT_CONVERTER_DITHER_CLIP_( flags, Float32, Int32 ),
+                                          /* paInt24Padded: */    
PA_SELECT_CONVERTER_DITHER_CLIP_( flags, Float32, Int24Padded ),
                                           /* paInt24: */          
PA_SELECT_CONVERTER_DITHER_CLIP_( flags, Float32, Int24 ),
                                           /* paInt16: */          
PA_SELECT_CONVERTER_DITHER_CLIP_( flags, Float32, Int16 ),
                                           /* paInt8: */           
PA_SELECT_CONVERTER_DITHER_CLIP_( flags, Float32, Int8 ),
@@ -189,15 +193,27 @@
                        PA_SELECT_FORMAT_( destinationFormat,
                                           /* paFloat32: */        
PA_USE_CONVERTER_( Int32, Float32 ),
                                           /* paInt32: */          
PA_UNITY_CONVERSION_( 32 ),
+                                          /* paInt24Padded: */    
PA_SELECT_CONVERTER_DITHER_( flags, Int32, Int24Padded ),
                                           /* paInt24: */          
PA_SELECT_CONVERTER_DITHER_( flags, Int32, Int24 ),
                                           /* paInt16: */          
PA_SELECT_CONVERTER_DITHER_( flags, Int32, Int16 ),
                                           /* paInt8: */           
PA_SELECT_CONVERTER_DITHER_( flags, Int32, Int8 ),
                                           /* paUInt8: */          
PA_SELECT_CONVERTER_DITHER_( flags, Int32, UInt8 )
                                         ),
+                       /* paInt24Padded: */
+                       PA_SELECT_FORMAT_( destinationFormat,
+                                          /* paFloat32: */        
PA_USE_CONVERTER_( Int24Padded, Float32 ),
+                                          /* paInt32: */          
PA_SELECT_CONVERTER_DITHER_( flags, Int24Padded, Int32 ),
+                                          /* paInt24Padded: */    
PA_UNITY_CONVERSION_( 32 ),
+                                          /* paInt24: */          
PA_SELECT_CONVERTER_DITHER_( flags, Int24Padded, Int24 ),
+                                          /* paInt16: */          
PA_SELECT_CONVERTER_DITHER_( flags, Int24Padded, Int16 ),
+                                          /* paInt8: */           
PA_SELECT_CONVERTER_DITHER_( flags, Int24Padded, Int8 ),
+                                          /* paUInt8: */          
PA_SELECT_CONVERTER_DITHER_( flags, Int24Padded, UInt8 )
+                                        ),
                        /* paInt24: */
                        PA_SELECT_FORMAT_( destinationFormat,
                                           /* paFloat32: */        
PA_USE_CONVERTER_( Int24, Float32 ),
                                           /* paInt32: */          
PA_USE_CONVERTER_( Int24, Int32 ),
+                                          /* paInt24Padded: */    
PA_USE_CONVERTER_( Int24, Int24Padded ),
                                           /* paInt24: */          
PA_UNITY_CONVERSION_( 24 ),
                                           /* paInt16: */          
PA_SELECT_CONVERTER_DITHER_( flags, Int24, Int16 ),
                                           /* paInt8: */           
PA_SELECT_CONVERTER_DITHER_( flags, Int24, Int8 ),
@@ -207,6 +223,7 @@
                        PA_SELECT_FORMAT_( destinationFormat,
                                           /* paFloat32: */        
PA_USE_CONVERTER_( Int16, Float32 ),
                                           /* paInt32: */          
PA_USE_CONVERTER_( Int16, Int32 ),
+                                          /* paInt24Padded: */    
PA_USE_CONVERTER_( Int16, Int24Padded ),
                                           /* paInt24: */          
PA_USE_CONVERTER_( Int16, Int24 ),
                                           /* paInt16: */          
PA_UNITY_CONVERSION_( 16 ),
                                           /* paInt8: */           
PA_SELECT_CONVERTER_DITHER_( flags, Int16, Int8 ),
@@ -216,6 +233,7 @@
                        PA_SELECT_FORMAT_( destinationFormat,
                                           /* paFloat32: */        
PA_USE_CONVERTER_( Int8, Float32 ),
                                           /* paInt32: */          
PA_USE_CONVERTER_( Int8, Int32 ),
+                                          /* paInt24Padded: */    
PA_USE_CONVERTER_( Int8, Int24Padded ),
                                           /* paInt24: */          
PA_USE_CONVERTER_( Int8, Int24 ),
                                           /* paInt16: */          
PA_USE_CONVERTER_( Int8, Int16 ),
                                           /* paInt8: */           
PA_UNITY_CONVERSION_( 8 ),
@@ -225,6 +243,7 @@
                        PA_SELECT_FORMAT_( destinationFormat,
                                           /* paFloat32: */        
PA_USE_CONVERTER_( UInt8, Float32 ),
                                           /* paInt32: */          
PA_USE_CONVERTER_( UInt8, Int32 ),
+                                          /* paInt24Padded: */    
PA_USE_CONVERTER_( UInt8, Int24Padded ),
                                           /* paInt24: */          
PA_USE_CONVERTER_( UInt8, Int24 ),
                                           /* paInt16: */          
PA_USE_CONVERTER_( UInt8, Int16 ),
                                           /* paInt8: */           
PA_USE_CONVERTER_( UInt8, Int8 ),
@@ -245,6 +264,11 @@
     0, /* PaUtilConverter *Float32_To_Int32_Clip; */
     0, /* PaUtilConverter *Float32_To_Int32_DitherClip; */
 
+    0, /* PaUtilConverter *Float32_To_Int24Padded; */
+    0, /* PaUtilConverter *Float32_To_Int24Padded_Dither; */
+    0, /* PaUtilConverter *Float32_To_Int24Padded_Clip; */
+    0, /* PaUtilConverter *Float32_To_Int24Padded_DitherClip; */
+
     0, /* PaUtilConverter *Float32_To_Int24; */
     0, /* PaUtilConverter *Float32_To_Int24_Dither; */
     0, /* PaUtilConverter *Float32_To_Int24_Clip; */
@@ -266,6 +290,8 @@
     0, /* PaUtilConverter *Float32_To_UInt8_DitherClip; */
 
     0, /* PaUtilConverter *Int32_To_Float32; */
+    0, /* PaUtilConverter *Int32_To_Int24Padded; */
+    0, /* PaUtilConverter *Int32_To_Int24Padded_Dither; */
     0, /* PaUtilConverter *Int32_To_Int24; */
     0, /* PaUtilConverter *Int32_To_Int24_Dither; */
     0, /* PaUtilConverter *Int32_To_Int16; */
@@ -275,8 +301,21 @@
     0, /* PaUtilConverter *Int32_To_UInt8; */
     0, /* PaUtilConverter *Int32_To_UInt8_Dither; */
 
+    0, /* PaUtilConverter *Int24Padded_To_Float32; */
+    0, /* PaUtilConverter *Int24Padded_To_Int32; */
+    0, /* PaUtilConverter *Int24Padded_To_Int32_Dither; */
+    0, /* PaUtilConverter *Int24Padded_To_Int24; */
+    0, /* PaUtilConverter *Int24Padded_To_Int24_Dither; */
+    0, /* PaUtilConverter *Int24Padded_To_Int16; */
+    0, /* PaUtilConverter *Int24Padded_To_Int16_Dither; */
+    0, /* PaUtilConverter *Int24Padded_To_Int8; */
+    0, /* PaUtilConverter *Int24Padded_To_Int8_Dither; */
+    0, /* PaUtilConverter *Int24Padded_To_UInt8; */
+    0, /* PaUtilConverter *Int24Padded_To_UInt8_Dither; */
+
     0, /* PaUtilConverter *Int24_To_Float32; */
     0, /* PaUtilConverter *Int24_To_Int32; */
+    0, /* PaUtilConverter *Int24_To_Int24Padded; */
     0, /* PaUtilConverter *Int24_To_Int16; */
     0, /* PaUtilConverter *Int24_To_Int16_Dither; */
     0, /* PaUtilConverter *Int24_To_Int8; */
@@ -286,6 +325,7 @@
     
     0, /* PaUtilConverter *Int16_To_Float32; */
     0, /* PaUtilConverter *Int16_To_Int32; */
+    0, /* PaUtilConverter *Int16_To_Int24Padded; */
     0, /* PaUtilConverter *Int16_To_Int24; */
     0, /* PaUtilConverter *Int16_To_Int8; */
     0, /* PaUtilConverter *Int16_To_Int8_Dither; */
@@ -294,12 +334,14 @@
 
     0, /* PaUtilConverter *Int8_To_Float32; */
     0, /* PaUtilConverter *Int8_To_Int32; */
+    0, /* PaUtilConverter *Int8_To_Int24Padded; */
     0, /* PaUtilConverter *Int8_To_Int24 */
     0, /* PaUtilConverter *Int8_To_Int16; */
     0, /* PaUtilConverter *Int8_To_UInt8; */
 
     0, /* PaUtilConverter *UInt8_To_Float32; */
     0, /* PaUtilConverter *UInt8_To_Int32; */
+    0, /* PaUtilConverter *UInt8_To_Int24Padded; */
     0, /* PaUtilConverter *UInt8_To_Int24; */
     0, /* PaUtilConverter *UInt8_To_Int16; */
     0, /* PaUtilConverter *UInt8_To_Int8; */
@@ -445,6 +487,70 @@
 
 /* -------------------------------------------------------------------------- 
*/
 
+static void Float32_To_Int24Padded(
+    void *destinationBuffer, signed int destinationStride,
+    void *sourceBuffer, signed int sourceStride,
+    unsigned int count, struct PaUtilTriangularDitherGenerator 
*ditherGenerator )
+{
+    (void) destinationBuffer; /* unused parameters */
+    (void) destinationStride; /* unused parameters */
+    (void) sourceBuffer; /* unused parameters */
+    (void) sourceStride; /* unused parameters */
+    (void) count; /* unused parameters */
+    (void) ditherGenerator; /* unused parameters */
+    /* IMPLEMENT ME */
+}
+
+/* -------------------------------------------------------------------------- 
*/
+
+static void Float32_To_Int24Padded_Clip(
+    void *destinationBuffer, signed int destinationStride,
+    void *sourceBuffer, signed int sourceStride,
+    unsigned int count, struct PaUtilTriangularDitherGenerator 
*ditherGenerator )
+{
+    (void) destinationBuffer; /* unused parameters */
+    (void) destinationStride; /* unused parameters */
+    (void) sourceBuffer; /* unused parameters */
+    (void) sourceStride; /* unused parameters */
+    (void) count; /* unused parameters */
+    (void) ditherGenerator; /* unused parameters */
+    /* IMPLEMENT ME */
+}
+
+/* -------------------------------------------------------------------------- 
*/
+
+static void Float32_To_Int24Padded_Dither(
+    void *destinationBuffer, signed int destinationStride,
+    void *sourceBuffer, signed int sourceStride,
+    unsigned int count, struct PaUtilTriangularDitherGenerator 
*ditherGenerator )
+{
+    (void) destinationBuffer; /* unused parameters */
+    (void) destinationStride; /* unused parameters */
+    (void) sourceBuffer; /* unused parameters */
+    (void) sourceStride; /* unused parameters */
+    (void) count; /* unused parameters */
+    (void) ditherGenerator; /* unused parameters */
+    /* IMPLEMENT ME */
+}
+
+/* -------------------------------------------------------------------------- 
*/
+
+static void Float32_To_Int24Padded_DitherClip(
+    void *destinationBuffer, signed int destinationStride,
+    void *sourceBuffer, signed int sourceStride,
+    unsigned int count, struct PaUtilTriangularDitherGenerator 
*ditherGenerator )
+{
+    (void) destinationBuffer; /* unused parameters */
+    (void) destinationStride; /* unused parameters */
+    (void) sourceBuffer; /* unused parameters */
+    (void) sourceStride; /* unused parameters */
+    (void) count; /* unused parameters */
+    (void) ditherGenerator; /* unused parameters */
+    /* IMPLEMENT ME */
+}
+
+/* -------------------------------------------------------------------------- 
*/
+
 static void Float32_To_Int24(
     void *destinationBuffer, signed int destinationStride,
     void *sourceBuffer, signed int sourceStride,
@@ -890,6 +996,41 @@
 
 /* -------------------------------------------------------------------------- 
*/
 
+static void Int32_To_Int24Padded(
+    void *destinationBuffer, signed int destinationStride,
+    void *sourceBuffer, signed int sourceStride,
+    unsigned int count, struct PaUtilTriangularDitherGenerator 
*ditherGenerator )
+{
+    PaInt32 *src = (PaInt32*)sourceBuffer;
+    PaInt32 *dest = (PaInt32*)destinationBuffer;
+    (void) ditherGenerator; /* unused parameter */
+
+    while( count-- )
+    {
+       *dest = *src >> 8;
+        src += sourceStride;
+        dest += destinationStride;
+    }
+}
+
+/* -------------------------------------------------------------------------- 
*/
+
+static void Int32_To_Int24Padded_Dither(
+    void *destinationBuffer, signed int destinationStride,
+    void *sourceBuffer, signed int sourceStride,
+    unsigned int count, struct PaUtilTriangularDitherGenerator 
*ditherGenerator )
+{
+    (void) destinationBuffer; /* unused parameters */
+    (void) destinationStride; /* unused parameters */
+    (void) sourceBuffer; /* unused parameters */
+    (void) sourceStride; /* unused parameters */
+    (void) count; /* unused parameters */
+    (void) ditherGenerator; /* unused parameters */
+    /* IMPLEMENT ME */
+}
+
+/* -------------------------------------------------------------------------- 
*/
+
 static void Int32_To_Int24(
     void *destinationBuffer, signed int destinationStride,
     void *sourceBuffer, signed int sourceStride,
@@ -962,12 +1103,15 @@
     PaInt32 *src = (PaInt32*)sourceBuffer;
     PaInt16 *dest =  (PaInt16*)destinationBuffer;
     PaInt32 dither;
+    PaInt32 dithered;
 
     while( count-- )
     {
         /* REVIEW */
         dither = PaUtil_Generate16BitTriangularDither( ditherGenerator );
-        *dest = (PaInt16) ((((*src)>>1) + dither) >> 15);
+       dithered = ((((*src)>>1) + (dither>>1)) >> 15);
+       PA_CLIP_( dithered, -0x8000, 0x7FFF );
+       *dest = (PaInt16) dithered;
 
         src += sourceStride;
         dest += destinationStride;
@@ -1054,6 +1198,195 @@
         src += sourceStride;
         dest += destinationStride;
     }
+}
+
+/* -------------------------------------------------------------------------- 
*/
+
+static void Int24Padded_To_Float32(
+    void *destinationBuffer, signed int destinationStride,
+    void *sourceBuffer, signed int sourceStride,
+    unsigned int count, struct PaUtilTriangularDitherGenerator 
*ditherGenerator )
+{
+    (void) destinationBuffer; /* unused parameters */
+    (void) destinationStride; /* unused parameters */
+    (void) sourceBuffer; /* unused parameters */
+    (void) sourceStride; /* unused parameters */
+    (void) count; /* unused parameters */
+    (void) ditherGenerator; /* unused parameters */
+    /* IMPLEMENT ME */
+}
+
+/* -------------------------------------------------------------------------- 
*/
+
+static void Int24Padded_To_Int32(
+    void *destinationBuffer, signed int destinationStride,
+    void *sourceBuffer, signed int sourceStride,
+    unsigned int count, struct PaUtilTriangularDitherGenerator 
*ditherGenerator )
+{
+    (void) destinationBuffer; /* unused parameters */
+    (void) destinationStride; /* unused parameters */
+    (void) sourceBuffer; /* unused parameters */
+    (void) sourceStride; /* unused parameters */
+    (void) count; /* unused parameters */
+    (void) ditherGenerator; /* unused parameters */
+    /* IMPLEMENT ME */
+}
+
+/* -------------------------------------------------------------------------- 
*/
+
+static void Int24Padded_To_Int32_Dither(
+    void *destinationBuffer, signed int destinationStride,
+    void *sourceBuffer, signed int sourceStride,
+    unsigned int count, struct PaUtilTriangularDitherGenerator 
*ditherGenerator )
+{
+    (void) destinationBuffer; /* unused parameters */
+    (void) destinationStride; /* unused parameters */
+    (void) sourceBuffer; /* unused parameters */
+    (void) sourceStride; /* unused parameters */
+    (void) count; /* unused parameters */
+    (void) ditherGenerator; /* unused parameters */
+    /* IMPLEMENT ME */
+}
+
+/* -------------------------------------------------------------------------- 
*/
+
+static void Int24Padded_To_Int24(
+    void *destinationBuffer, signed int destinationStride,
+    void *sourceBuffer, signed int sourceStride,
+    unsigned int count, struct PaUtilTriangularDitherGenerator 
*ditherGenerator )
+{
+    (void) destinationBuffer; /* unused parameters */
+    (void) destinationStride; /* unused parameters */
+    (void) sourceBuffer; /* unused parameters */
+    (void) sourceStride; /* unused parameters */
+    (void) count; /* unused parameters */
+    (void) ditherGenerator; /* unused parameters */
+    /* IMPLEMENT ME */
+}
+
+/* -------------------------------------------------------------------------- 
*/
+
+static void Int24Padded_To_Int24_Dither(
+    void *destinationBuffer, signed int destinationStride,
+    void *sourceBuffer, signed int sourceStride,
+    unsigned int count, struct PaUtilTriangularDitherGenerator 
*ditherGenerator )
+{
+    (void) destinationBuffer; /* unused parameters */
+    (void) destinationStride; /* unused parameters */
+    (void) sourceBuffer; /* unused parameters */
+    (void) sourceStride; /* unused parameters */
+    (void) count; /* unused parameters */
+    (void) ditherGenerator; /* unused parameters */
+    /* IMPLEMENT ME */
+}
+
+/* -------------------------------------------------------------------------- 
*/
+
+static void Int24Padded_To_Int16(
+    void *destinationBuffer, signed int destinationStride,
+    void *sourceBuffer, signed int sourceStride,
+    unsigned int count, struct PaUtilTriangularDitherGenerator 
*ditherGenerator )
+{
+    PaInt32 *src = (PaInt32*)sourceBuffer;
+    PaInt16 *dest = (PaInt16*)destinationBuffer;
+    (void) ditherGenerator; /* unused parameter */
+
+    while( count-- )
+    {
+       *dest = (PaInt16)(*src >> 8);
+        src += sourceStride;
+        dest += destinationStride;
+    }
+
+}
+
+/* -------------------------------------------------------------------------- 
*/
+
+static void Int24Padded_To_Int16_Dither(
+    void *destinationBuffer, signed int destinationStride,
+    void *sourceBuffer, signed int sourceStride,
+    unsigned int count, struct PaUtilTriangularDitherGenerator 
*ditherGenerator )
+{
+    PaInt32 *src = (PaInt32*)sourceBuffer;
+    PaInt16 *dest =  (PaInt16*)destinationBuffer;
+    PaInt32 dither;
+    PaInt32 dithered;
+
+    while( count-- )
+    {
+        /* REVIEW */
+        dither = PaUtil_Generate16BitTriangularDither( ditherGenerator );
+       dithered = ((*src + (dither>>8)) >> 8);
+       PA_CLIP_( dithered, -0x8000, 0x7FFF );
+       *dest = (PaInt16) dithered;
+
+        src += sourceStride;
+        dest += destinationStride;
+    }
+}
+
+/* -------------------------------------------------------------------------- 
*/
+
+static void Int24Padded_To_Int8(
+    void *destinationBuffer, signed int destinationStride,
+    void *sourceBuffer, signed int sourceStride,
+    unsigned int count, struct PaUtilTriangularDitherGenerator 
*ditherGenerator )
+{
+    (void) destinationBuffer; /* unused parameters */
+    (void) destinationStride; /* unused parameters */
+    (void) sourceBuffer; /* unused parameters */
+    (void) sourceStride; /* unused parameters */
+    (void) count; /* unused parameters */
+    (void) ditherGenerator; /* unused parameters */
+    /* IMPLEMENT ME */
+}
+
+/* -------------------------------------------------------------------------- 
*/
+
+static void Int24Padded_To_Int8_Dither(
+    void *destinationBuffer, signed int destinationStride,
+    void *sourceBuffer, signed int sourceStride,
+    unsigned int count, struct PaUtilTriangularDitherGenerator 
*ditherGenerator )
+{
+    (void) destinationBuffer; /* unused parameters */
+    (void) destinationStride; /* unused parameters */
+    (void) sourceBuffer; /* unused parameters */
+    (void) sourceStride; /* unused parameters */
+    (void) count; /* unused parameters */
+    (void) ditherGenerator; /* unused parameters */
+    /* IMPLEMENT ME */
+}
+
+/* -------------------------------------------------------------------------- 
*/
+
+static void Int24Padded_To_UInt8(
+    void *destinationBuffer, signed int destinationStride,
+    void *sourceBuffer, signed int sourceStride,
+    unsigned int count, struct PaUtilTriangularDitherGenerator 
*ditherGenerator )
+{
+    (void) destinationBuffer; /* unused parameters */
+    (void) destinationStride; /* unused parameters */
+    (void) sourceBuffer; /* unused parameters */
+    (void) sourceStride; /* unused parameters */
+    (void) count; /* unused parameters */
+    (void) ditherGenerator; /* unused parameters */
+    /* IMPLEMENT ME */
+}
+
+/* -------------------------------------------------------------------------- 
*/
+
+static void Int24Padded_To_UInt8_Dither(
+    void *destinationBuffer, signed int destinationStride,
+    void *sourceBuffer, signed int sourceStride,
+    unsigned int count, struct PaUtilTriangularDitherGenerator 
*ditherGenerator )
+{
+    (void) destinationBuffer; /* unused parameters */
+    (void) destinationStride; /* unused parameters */
+    (void) sourceBuffer; /* unused parameters */
+    (void) sourceStride; /* unused parameters */
+    (void) count; /* unused parameters */
+    (void) ditherGenerator; /* unused parameters */
+    /* IMPLEMENT ME */
 }
 
 /* -------------------------------------------------------------------------- 
*/
@@ -1120,6 +1453,22 @@
         src += sourceStride * 3;
         dest += destinationStride;
     }
+}
+
+/* -------------------------------------------------------------------------- 
*/
+
+static void Int24_To_Int24Padded(
+    void *destinationBuffer, signed int destinationStride,
+    void *sourceBuffer, signed int sourceStride,
+    unsigned int count, struct PaUtilTriangularDitherGenerator 
*ditherGenerator )
+{
+    (void) destinationBuffer; /* unused parameters */
+    (void) destinationStride; /* unused parameters */
+    (void) sourceBuffer; /* unused parameters */
+    (void) sourceStride; /* unused parameters */
+    (void) count; /* unused parameters */
+    (void) ditherGenerator; /* unused parameters */
+    /* IMPLEMENT ME */
 }
 
 /* -------------------------------------------------------------------------- 
*/
@@ -1311,6 +1660,22 @@
 
 /* -------------------------------------------------------------------------- 
*/
 
+static void Int16_To_Int24Padded(
+    void *destinationBuffer, signed int destinationStride,
+    void *sourceBuffer, signed int sourceStride,
+    unsigned int count, struct PaUtilTriangularDitherGenerator 
*ditherGenerator )
+{
+    (void) destinationBuffer; /* unused parameters */
+    (void) destinationStride; /* unused parameters */
+    (void) sourceBuffer; /* unused parameters */
+    (void) sourceStride; /* unused parameters */
+    (void) count; /* unused parameters */
+    (void) ditherGenerator; /* unused parameters */
+    /* IMPLEMENT ME */
+}
+
+/* -------------------------------------------------------------------------- 
*/
+
 static void Int16_To_Int24(
     void *destinationBuffer, signed int destinationStride,
     void *sourceBuffer, signed int sourceStride,
@@ -1464,6 +1829,22 @@
 
 /* -------------------------------------------------------------------------- 
*/
 
+static void Int8_To_Int24Padded(
+    void *destinationBuffer, signed int destinationStride,
+    void *sourceBuffer, signed int sourceStride,
+    unsigned int count, struct PaUtilTriangularDitherGenerator 
*ditherGenerator )
+{
+    (void) destinationBuffer; /* unused parameters */
+    (void) destinationStride; /* unused parameters */
+    (void) sourceBuffer; /* unused parameters */
+    (void) sourceStride; /* unused parameters */
+    (void) count; /* unused parameters */
+    (void) ditherGenerator; /* unused parameters */
+    /* IMPLEMENT ME */
+}
+
+/* -------------------------------------------------------------------------- 
*/
+
 static void Int8_To_Int24(
     void *destinationBuffer, signed int destinationStride,
     void *sourceBuffer, signed int sourceStride,
@@ -1570,6 +1951,23 @@
         src += sourceStride;
         dest += destinationStride;
     }
+}
+
+/* -------------------------------------------------------------------------- 
*/
+
+
+static void UInt8_To_Int24Padded(
+    void *destinationBuffer, signed int destinationStride,
+    void *sourceBuffer, signed int sourceStride,
+    unsigned int count, struct PaUtilTriangularDitherGenerator 
*ditherGenerator )
+{
+    (void) destinationBuffer; /* unused parameters */
+    (void) destinationStride; /* unused parameters */
+    (void) sourceBuffer; /* unused parameters */
+    (void) sourceStride; /* unused parameters */
+    (void) count; /* unused parameters */
+    (void) ditherGenerator; /* unused parameters */
+    /* IMPLEMENT ME */
 }
 
 /* -------------------------------------------------------------------------- 
*/
@@ -1727,6 +2125,7 @@
     }
 }
 
+
 /* -------------------------------------------------------------------------- 
*/
 
 PaUtilConverterTable paConverters = {
@@ -1734,6 +2133,11 @@
     Float32_To_Int32_Dither,       /* PaUtilConverter 
*Float32_To_Int32_Dither; */
     Float32_To_Int32_Clip,         /* PaUtilConverter *Float32_To_Int32_Clip; 
*/
     Float32_To_Int32_DitherClip,   /* PaUtilConverter 
*Float32_To_Int32_DitherClip; */
+
+    Float32_To_Int24Padded,            /* PaUtilConverter 
*Float32_To_Int24Padded; */
+    Float32_To_Int24Padded_Dither,     /* PaUtilConverter 
*Float32_To_Int24Padded_Dither; */
+    Float32_To_Int24Padded_Clip,       /* PaUtilConverter 
*Float32_To_Int24Padded_Clip; */
+    Float32_To_Int24Padded_DitherClip, /* PaUtilConverter 
*Float32_To_Int24Padded_DitherClip; */
 
     Float32_To_Int24,              /* PaUtilConverter *Float32_To_Int24; */
     Float32_To_Int24_Dither,       /* PaUtilConverter 
*Float32_To_Int24_Dither; */
@@ -1756,6 +2160,8 @@
     Float32_To_UInt8_DitherClip,   /* PaUtilConverter 
*Float32_To_UInt8_DitherClip; */
 
     Int32_To_Float32,              /* PaUtilConverter *Int32_To_Float32; */
+    Int32_To_Int24Padded,          /* PaUtilConverter *Int32_To_Int24Padded; */
+    Int32_To_Int24Padded_Dither,   /* PaUtilConverter 
*Int32_To_Int24Padded_Dither; */
     Int32_To_Int24,                /* PaUtilConverter *Int32_To_Int24; */
     Int32_To_Int24_Dither,         /* PaUtilConverter *Int32_To_Int24_Dither; 
*/
     Int32_To_Int16,                /* PaUtilConverter *Int32_To_Int16; */
@@ -1765,8 +2171,21 @@
     Int32_To_UInt8,                /* PaUtilConverter *Int32_To_UInt8; */
     Int32_To_UInt8_Dither,         /* PaUtilConverter *Int32_To_UInt8_Dither; 
*/
 
+    Int24Padded_To_Float32,        /* PaUtilConverter *Int24Padded_To_Float32; 
*/
+    Int24Padded_To_Int32,          /* PaUtilConverter *Int24Padded_To_Int32; */
+    Int24Padded_To_Int32_Dither,   /* PaUtilConverter 
*Int24Padded_To_Int32_Dither; */
+    Int24Padded_To_Int24,          /* PaUtilConverter *Int24Padded_To_Int24; */
+    Int24Padded_To_Int24_Dither,   /* PaUtilConverter 
*Int24Padded_To_Int24_Dither; */
+    Int24Padded_To_Int16,          /* PaUtilConverter *Int24Padded_To_Int16; */
+    Int24Padded_To_Int16_Dither,   /* PaUtilConverter 
*Int24Padded_To_Int16_Dither; */
+    Int24Padded_To_Int8,           /* PaUtilConverter *Int24Padded_To_Int8; */
+    Int24Padded_To_Int8_Dither,    /* PaUtilConverter 
*Int24Padded_To_Int8_Dither; */
+    Int24Padded_To_UInt8,          /* PaUtilConverter *Int24Padded_To_UInt8; */
+    Int24Padded_To_UInt8_Dither,   /* PaUtilConverter 
*Int24Padded_To_UInt8_Dither; */
+
     Int24_To_Float32,              /* PaUtilConverter *Int24_To_Float32; */
     Int24_To_Int32,                /* PaUtilConverter *Int24_To_Int32; */
+    Int24_To_Int24Padded,          /* PaUtilConverter *Int24_To_Int24Padded; */
     Int24_To_Int16,                /* PaUtilConverter *Int24_To_Int16; */
     Int24_To_Int16_Dither,         /* PaUtilConverter *Int24_To_Int16_Dither; 
*/
     Int24_To_Int8,                 /* PaUtilConverter *Int24_To_Int8; */
@@ -1776,6 +2195,7 @@
 
     Int16_To_Float32,              /* PaUtilConverter *Int16_To_Float32; */
     Int16_To_Int32,                /* PaUtilConverter *Int16_To_Int32; */
+    Int16_To_Int24Padded,          /* PaUtilConverter *Int16_To_Int24Padded; */
     Int16_To_Int24,                /* PaUtilConverter *Int16_To_Int24; */
     Int16_To_Int8,                 /* PaUtilConverter *Int16_To_Int8; */
     Int16_To_Int8_Dither,          /* PaUtilConverter *Int16_To_Int8_Dither; */
@@ -1784,12 +2204,14 @@
 
     Int8_To_Float32,               /* PaUtilConverter *Int8_To_Float32; */
     Int8_To_Int32,                 /* PaUtilConverter *Int8_To_Int32; */
+    Int8_To_Int24Padded,           /* PaUtilConverter *Int8_To_Int24Padded; */
     Int8_To_Int24,                 /* PaUtilConverter *Int8_To_Int24 */
     Int8_To_Int16,                 /* PaUtilConverter *Int8_To_Int16; */
     Int8_To_UInt8,                 /* PaUtilConverter *Int8_To_UInt8; */
 
     UInt8_To_Float32,              /* PaUtilConverter *UInt8_To_Float32; */
     UInt8_To_Int32,                /* PaUtilConverter *UInt8_To_Int32; */
+    UInt8_To_Int24Padded,          /* PaUtilConverter *UInt8_To_Int24Padded; */
     UInt8_To_Int24,                /* PaUtilConverter *UInt8_To_Int24; */
     UInt8_To_Int16,                /* PaUtilConverter *UInt8_To_Int16; */
     UInt8_To_Int8,                 /* PaUtilConverter *UInt8_To_Int8; */
@@ -1812,6 +2234,8 @@
     case paFloat32:
         return paZeroers.Zero32;
     case paInt32:
+        return paZeroers.Zero32;
+    case paInt24Padded:
         return paZeroers.Zero32;
     case paInt24:
         return paZeroers.Zero24;

Modified: 
7.2/trunk/squeezeplay/src/portaudio_v19_1360/src/common/pa_converters.h
URL: 
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/portaudio_v19_1360/src/common/pa_converters.h?rev=2424&root=Jive&r1=2423&r2=2424&view=diff
==============================================================================
--- 7.2/trunk/squeezeplay/src/portaudio_v19_1360/src/common/pa_converters.h 
(original)
+++ 7.2/trunk/squeezeplay/src/portaudio_v19_1360/src/common/pa_converters.h Tue 
May  6 08:11:57 2008
@@ -141,6 +141,11 @@
     PaUtilConverter *Float32_To_Int32_Clip;
     PaUtilConverter *Float32_To_Int32_DitherClip;
 
+    PaUtilConverter *Float32_To_Int24Padded;
+    PaUtilConverter *Float32_To_Int24Padded_Dither;
+    PaUtilConverter *Float32_To_Int24Padded_Clip;
+    PaUtilConverter *Float32_To_Int24Padded_DitherClip;
+
     PaUtilConverter *Float32_To_Int24;
     PaUtilConverter *Float32_To_Int24_Dither;
     PaUtilConverter *Float32_To_Int24_Clip;
@@ -162,6 +167,8 @@
     PaUtilConverter *Float32_To_UInt8_DitherClip;
 
     PaUtilConverter *Int32_To_Float32;
+    PaUtilConverter *Int32_To_Int24Padded;
+    PaUtilConverter *Int32_To_Int24Padded_Dither;
     PaUtilConverter *Int32_To_Int24;
     PaUtilConverter *Int32_To_Int24_Dither;
     PaUtilConverter *Int32_To_Int16;
@@ -171,8 +178,21 @@
     PaUtilConverter *Int32_To_UInt8;
     PaUtilConverter *Int32_To_UInt8_Dither;
 
+    PaUtilConverter *Int24Padded_To_Float32;
+    PaUtilConverter *Int24Padded_To_Int32;
+    PaUtilConverter *Int24Padded_To_Int32_Dither;
+    PaUtilConverter *Int24Padded_To_Int24;
+    PaUtilConverter *Int24Padded_To_Int24_Dither;
+    PaUtilConverter *Int24Padded_To_Int16;
+    PaUtilConverter *Int24Padded_To_Int16_Dither;
+    PaUtilConverter *Int24Padded_To_Int8;
+    PaUtilConverter *Int24Padded_To_Int8_Dither;
+    PaUtilConverter *Int24Padded_To_UInt8;
+    PaUtilConverter *Int24Padded_To_UInt8_Dither;
+
     PaUtilConverter *Int24_To_Float32;
     PaUtilConverter *Int24_To_Int32;
+    PaUtilConverter *Int24_To_Int24Padded;
     PaUtilConverter *Int24_To_Int16;
     PaUtilConverter *Int24_To_Int16_Dither;
     PaUtilConverter *Int24_To_Int8;
@@ -182,6 +202,7 @@
 
     PaUtilConverter *Int16_To_Float32;
     PaUtilConverter *Int16_To_Int32;
+    PaUtilConverter *Int16_To_Int24Padded;
     PaUtilConverter *Int16_To_Int24;
     PaUtilConverter *Int16_To_Int8;
     PaUtilConverter *Int16_To_Int8_Dither;
@@ -190,12 +211,14 @@
 
     PaUtilConverter *Int8_To_Float32;
     PaUtilConverter *Int8_To_Int32;
+    PaUtilConverter *Int8_To_Int24Padded;
     PaUtilConverter *Int8_To_Int24;
     PaUtilConverter *Int8_To_Int16;
     PaUtilConverter *Int8_To_UInt8;
     
     PaUtilConverter *UInt8_To_Float32;
     PaUtilConverter *UInt8_To_Int32;
+    PaUtilConverter *UInt8_To_Int24Padded;
     PaUtilConverter *UInt8_To_Int24;
     PaUtilConverter *UInt8_To_Int16;
     PaUtilConverter *UInt8_To_Int8;

Modified: 7.2/trunk/squeezeplay/src/portaudio_v19_1360/src/common/pa_front.c
URL: 
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/portaudio_v19_1360/src/common/pa_front.c?rev=2424&root=Jive&r1=2423&r2=2424&view=diff
==============================================================================
--- 7.2/trunk/squeezeplay/src/portaudio_v19_1360/src/common/pa_front.c 
(original)
+++ 7.2/trunk/squeezeplay/src/portaudio_v19_1360/src/common/pa_front.c Tue May  
6 08:11:57 2008
@@ -750,6 +750,7 @@
     case paFloat32: return 1;
     case paInt16: return 1;
     case paInt32: return 1;
+    case paInt24Padded: return 1;
     case paInt24: return 1;
     case paInt8: return 1;
     case paUInt8: return 1;
@@ -1750,6 +1751,7 @@
 
     case paFloat32:
     case paInt32:
+    case paInt24Padded:
         result = 4;
         break;
 

Added: 7.2/trunk/squeezeplay/src/portaudio_v19_1360/test/patest_sine24.c
URL: 
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/portaudio_v19_1360/test/patest_sine24.c?rev=2424&root=Jive&view=auto
==============================================================================
--- 7.2/trunk/squeezeplay/src/portaudio_v19_1360/test/patest_sine24.c (added)
+++ 7.2/trunk/squeezeplay/src/portaudio_v19_1360/test/patest_sine24.c Tue May  
6 08:11:57 2008
@@ -1,0 +1,168 @@
+/** @file patest_sine.c
+       @ingroup test_src
+       @brief Play a sine wave for several seconds.
+       @author Ross Bencina <[EMAIL PROTECTED]>
+    @author Phil Burk <[EMAIL PROTECTED]>
+*/
+/*
+ * $Id: patest_sine.c 1294 2007-10-24 20:51:22Z bjornroche $
+ *
+ * This program uses the PortAudio Portable Audio Library.
+ * For more information see: http://www.portaudio.com/
+ * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * The text above constitutes the entire PortAudio license; however, 
+ * the PortAudio community also makes the following non-binding requests:
+ *
+ * Any person wishing to distribute modifications to the Software is
+ * requested to send the modifications to the original developer so that
+ * they can be incorporated into the canonical version. It is also 
+ * requested that these non-binding requests be included along with the 
+ * license above.
+ */
+#include <stdio.h>
+#include <math.h>
+#include "portaudio.h"
+
+#define NUM_SECONDS   (5)
+#define SAMPLE_RATE   (44100)
+#define FRAMES_PER_BUFFER  (64)
+
+typedef struct
+{
+    int count;
+    char message[20];
+}
+paTestData;
+
+
+const int sine40[] = { /* amplitude 2^24-2.  40 samples per cycle gives 
1102.5Hz */
+0,1312267,2592222,3808348,4930699,5931641,6786526,7474304,7978039,8285329,8388607,8285329,7978039,7474304,6786526,5931641,4930700,3808348,2592222,1312267,
+0,-1312267,-2592222,-3808348,-4930699,-5931641,-6786526,-7474304,-7978039,-8285329,-8388607,-8285329,-7978039,-7474304,-6786526,-5931641,-4930700,-3808348,-2592222,-1312267
+};
+
+
+/* This routine will be called by the PortAudio engine when audio is needed.
+** It may called at interrupt level on some machines so don't do anything
+** that could mess up the system like calling malloc() or free().
+*/
+static int patestCallback( const void *inputBuffer, void *outputBuffer,
+                            unsigned long framesPerBuffer,
+                            const PaStreamCallbackTimeInfo* timeInfo,
+                            PaStreamCallbackFlags statusFlags,
+                            void *userData )
+{
+    paTestData *data = (paTestData*)userData;
+    int *out = (int*)outputBuffer;
+    unsigned long i;
+
+    (void) timeInfo; /* Prevent unused variable warnings. */
+    (void) statusFlags;
+    (void) inputBuffer;
+    
+
+    for (i = 0; i < framesPerBuffer; i++)
+    {
+       *out++ = sine40[data->count]; /* left */
+       *out++ = sine40[data->count]; /* right */
+               
+       if (++data->count == 40) {
+           data->count = 0;
+       }
+    }
+    
+    return paContinue;
+}
+
+/*
+ * This routine is called by portaudio when playback is done.
+ */
+static void StreamFinished( void* userData )
+{
+   paTestData *data = (paTestData *) userData;
+   printf( "Stream Completed: %s\n", data->message );
+}
+
+/*******************************************************************/
+int main(void);
+int main(void)
+{
+    PaStreamParameters outputParameters;
+    PaStream *stream;
+    PaError err;
+    paTestData data;
+    int i;
+
+    
+    printf("PortAudio Test: output sine wave. SR = %d, BufSize = %d\n", 
SAMPLE_RATE, FRAMES_PER_BUFFER);
+
+    data.count = 0;
+    
+    err = Pa_Initialize();
+    if( err != paNoError ) goto error;
+
+    outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output 
device */
+    outputParameters.channelCount = 2;       /* stereo output */
+    outputParameters.sampleFormat = paInt24Padded; /* 24 bit padded output */
+    outputParameters.suggestedLatency = Pa_GetDeviceInfo( 
outputParameters.device )->defaultLowOutputLatency;
+    outputParameters.hostApiSpecificStreamInfo = NULL;
+
+    err = Pa_OpenStream(
+              &stream,
+              NULL, /* no input */
+              &outputParameters,
+              SAMPLE_RATE,
+              FRAMES_PER_BUFFER,
+              paClipOff /*| paDitherOff*/,      /* we won't output out of 
range samples so don't bother clipping them */
+              patestCallback,
+              &data );
+    if( err != paNoError ) goto error;
+
+    sprintf( data.message, "No Message" );
+    err = Pa_SetStreamFinishedCallback( stream, &StreamFinished );
+    if( err != paNoError ) goto error;
+
+    err = Pa_StartStream( stream );
+    if( err != paNoError ) goto error;
+
+    printf("Play for %d seconds.\n", NUM_SECONDS );
+    Pa_Sleep( NUM_SECONDS * 1000 );
+
+    err = Pa_StopStream( stream );
+    if( err != paNoError ) goto error;
+
+    err = Pa_CloseStream( stream );
+    if( err != paNoError ) goto error;
+
+    Pa_Terminate();
+    printf("Test finished.\n");
+    
+    return err;
+error:
+    Pa_Terminate();
+    fprintf( stderr, "An error occured while using the portaudio stream\n" );
+    fprintf( stderr, "Error number: %d\n", err );
+    fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
+    return err;
+}

_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins

Reply via email to