📄 pa_asio.cpp
字号:
{ switch (type) { case ASIOSTInt16MSB: PA_DEBUG(("ASIOSTInt16MSB\n")); break; case ASIOSTInt16LSB: PA_DEBUG(("ASIOSTInt16LSB\n")); break; case ASIOSTFloat32MSB:PA_DEBUG(("ASIOSTFloat32MSB\n"));break; case ASIOSTFloat32LSB:PA_DEBUG(("ASIOSTFloat32LSB\n"));break; case ASIOSTFloat64MSB:PA_DEBUG(("ASIOSTFloat64MSB\n"));break; case ASIOSTFloat64LSB:PA_DEBUG(("ASIOSTFloat64LSB\n"));break; case ASIOSTInt32MSB: PA_DEBUG(("ASIOSTInt32MSB\n")); break; case ASIOSTInt32LSB: PA_DEBUG(("ASIOSTInt32LSB\n")); break; case ASIOSTInt32MSB16:PA_DEBUG(("ASIOSTInt32MSB16\n"));break; case ASIOSTInt32LSB16:PA_DEBUG(("ASIOSTInt32LSB16\n"));break; case ASIOSTInt32MSB18:PA_DEBUG(("ASIOSTInt32MSB18\n"));break; case ASIOSTInt32MSB20:PA_DEBUG(("ASIOSTInt32MSB20\n"));break; case ASIOSTInt32MSB24:PA_DEBUG(("ASIOSTInt32MSB24\n"));break; case ASIOSTInt32LSB18:PA_DEBUG(("ASIOSTInt32LSB18\n"));break; case ASIOSTInt32LSB20:PA_DEBUG(("ASIOSTInt32LSB20\n"));break; case ASIOSTInt32LSB24:PA_DEBUG(("ASIOSTInt32LSB24\n"));break; case ASIOSTInt24MSB: PA_DEBUG(("ASIOSTInt24MSB\n")); break; case ASIOSTInt24LSB: PA_DEBUG(("ASIOSTInt24LSB\n")); break; default: PA_DEBUG(("Custom Format%d\n",type));break; }}static int BytesPerAsioSample( ASIOSampleType sampleType ){ switch (sampleType) { case ASIOSTInt16MSB: case ASIOSTInt16LSB: return 2; case ASIOSTFloat64MSB: case ASIOSTFloat64LSB: return 8; case ASIOSTFloat32MSB: case ASIOSTFloat32LSB: case ASIOSTInt32MSB: case ASIOSTInt32LSB: case ASIOSTInt32MSB16: case ASIOSTInt32LSB16: case ASIOSTInt32MSB18: case ASIOSTInt32MSB20: case ASIOSTInt32MSB24: case ASIOSTInt32LSB18: case ASIOSTInt32LSB20: case ASIOSTInt32LSB24: return 4; case ASIOSTInt24MSB: case ASIOSTInt24LSB: return 3; default: return 0; }}static void Swap16( void *buffer, long shift, long count ){ unsigned short *p = (unsigned short*)buffer; unsigned short temp; (void) shift; /* unused parameter */ while( count-- ) { temp = *p; *p++ = (unsigned short)((temp<<8) | (temp>>8)); }}static void Swap24( void *buffer, long shift, long count ){ unsigned char *p = (unsigned char*)buffer; unsigned char temp; (void) shift; /* unused parameter */ while( count-- ) { temp = *p; *p = *(p+2); *(p+2) = temp; p += 3; }}#define PA_SWAP32_( x ) ((x>>24) | ((x>>8)&0xFF00) | ((x<<8)&0xFF0000) | (x<<24));static void Swap32( void *buffer, long shift, long count ){ unsigned long *p = (unsigned long*)buffer; unsigned long temp; (void) shift; /* unused parameter */ while( count-- ) { temp = *p; *p++ = PA_SWAP32_( temp); }}static void SwapShiftLeft32( void *buffer, long shift, long count ){ unsigned long *p = (unsigned long*)buffer; unsigned long temp; while( count-- ) { temp = *p; temp = PA_SWAP32_( temp); *p++ = temp << shift; }}static void ShiftRightSwap32( void *buffer, long shift, long count ){ unsigned long *p = (unsigned long*)buffer; unsigned long temp; while( count-- ) { temp = *p >> shift; *p++ = PA_SWAP32_( temp); }}static void ShiftLeft32( void *buffer, long shift, long count ){ unsigned long *p = (unsigned long*)buffer; unsigned long temp; while( count-- ) { temp = *p; *p++ = temp << shift; }}static void ShiftRight32( void *buffer, long shift, long count ){ unsigned long *p = (unsigned long*)buffer; unsigned long temp; while( count-- ) { temp = *p; *p++ = temp >> shift; }}#define PA_SWAP_( x, y ) temp=x; x = y; y = temp;static void Swap64ConvertFloat64ToFloat32( void *buffer, long shift, long count ){ double *in = (double*)buffer; float *out = (float*)buffer; unsigned char *p; unsigned char temp; (void) shift; /* unused parameter */ while( count-- ) { p = (unsigned char*)in; PA_SWAP_( p[0], p[7] ); PA_SWAP_( p[1], p[6] ); PA_SWAP_( p[2], p[5] ); PA_SWAP_( p[3], p[4] ); *out++ = (float) (*in++); }}static void ConvertFloat64ToFloat32( void *buffer, long shift, long count ){ double *in = (double*)buffer; float *out = (float*)buffer; (void) shift; /* unused parameter */ while( count-- ) *out++ = (float) (*in++);}static void ConvertFloat32ToFloat64Swap64( void *buffer, long shift, long count ){ float *in = ((float*)buffer) + (count-1); double *out = ((double*)buffer) + (count-1); unsigned char *p; unsigned char temp; (void) shift; /* unused parameter */ while( count-- ) { *out = *in--; p = (unsigned char*)out; PA_SWAP_( p[0], p[7] ); PA_SWAP_( p[1], p[6] ); PA_SWAP_( p[2], p[5] ); PA_SWAP_( p[3], p[4] ); out--; }}static void ConvertFloat32ToFloat64( void *buffer, long shift, long count ){ float *in = ((float*)buffer) + (count-1); double *out = ((double*)buffer) + (count-1); (void) shift; /* unused parameter */ while( count-- ) *out-- = *in--;}#ifdef MAC#define PA_MSB_IS_NATIVE_#undef PA_LSB_IS_NATIVE_#endif#ifdef WINDOWS#undef PA_MSB_IS_NATIVE_#define PA_LSB_IS_NATIVE_#endiftypedef void PaAsioBufferConverter( void *, long, long );static void SelectAsioToPaConverter( ASIOSampleType type, PaAsioBufferConverter **converter, long *shift ){ *shift = 0; *converter = 0; switch (type) { case ASIOSTInt16MSB: /* dest: paInt16, no conversion necessary, possible byte swap*/ #ifdef PA_LSB_IS_NATIVE_ *converter = Swap16; #endif break; case ASIOSTInt16LSB: /* dest: paInt16, no conversion necessary, possible byte swap*/ #ifdef PA_MSB_IS_NATIVE_ *converter = Swap16; #endif break; case ASIOSTFloat32MSB: /* dest: paFloat32, no conversion necessary, possible byte swap*/ #ifdef PA_LSB_IS_NATIVE_ *converter = Swap32; #endif break; case ASIOSTFloat32LSB: /* dest: paFloat32, no conversion necessary, possible byte swap*/ #ifdef PA_MSB_IS_NATIVE_ *converter = Swap32; #endif break; case ASIOSTFloat64MSB: /* dest: paFloat32, in-place conversion to/from float32, possible byte swap*/ #ifdef PA_LSB_IS_NATIVE_ *converter = Swap64ConvertFloat64ToFloat32; #else *converter = ConvertFloat64ToFloat32; #endif break; case ASIOSTFloat64LSB: /* dest: paFloat32, in-place conversion to/from float32, possible byte swap*/ #ifdef PA_MSB_IS_NATIVE_ *converter = Swap64ConvertFloat64ToFloat32; #else *converter = ConvertFloat64ToFloat32; #endif break; case ASIOSTInt32MSB: /* dest: paInt32, no conversion necessary, possible byte swap */ #ifdef PA_LSB_IS_NATIVE_ *converter = Swap32; #endif break; case ASIOSTInt32LSB: /* dest: paInt32, no conversion necessary, possible byte swap */ #ifdef PA_MSB_IS_NATIVE_ *converter = Swap32; #endif break; case ASIOSTInt32MSB16: /* dest: paInt32, 16 bit shift, possible byte swap */ #ifdef PA_LSB_IS_NATIVE_ *converter = SwapShiftLeft32; #else *converter = ShiftLeft32; #endif *shift = 16; break; case ASIOSTInt32MSB18: /* dest: paInt32, 14 bit shift, possible byte swap */ #ifdef PA_LSB_IS_NATIVE_ *converter = SwapShiftLeft32; #else *converter = ShiftLeft32; #endif *shift = 14; break; case ASIOSTInt32MSB20: /* dest: paInt32, 12 bit shift, possible byte swap */ #ifdef PA_LSB_IS_NATIVE_ *converter = SwapShiftLeft32; #else *converter = ShiftLeft32; #endif *shift = 12; break; case ASIOSTInt32MSB24: /* dest: paInt32, 8 bit shift, possible byte swap */ #ifdef PA_LSB_IS_NATIVE_ *converter = SwapShiftLeft32; #else *converter = ShiftLeft32; #endif *shift = 8; break; case ASIOSTInt32LSB16: /* dest: paInt32, 16 bit shift, possible byte swap */ #ifdef PA_MSB_IS_NATIVE_ *converter = SwapShiftLeft32; #else *converter = ShiftLeft32; #endif *shift = 16; break; case ASIOSTInt32LSB18: /* dest: paInt32, 14 bit shift, possible byte swap */ #ifdef PA_MSB_IS_NATIVE_ *converter = SwapShiftLeft32; #else *converter = ShiftLeft32; #endif *shift = 14; break; case ASIOSTInt32LSB20: /* dest: paInt32, 12 bit shift, possible byte swap */ #ifdef PA_MSB_IS_NATIVE_ *converter = SwapShiftLeft32; #else *converter = ShiftLeft32; #endif *shift = 12; break; case ASIOSTInt32LSB24: /* dest: paInt32, 8 bit shift, possible byte swap */ #ifdef PA_MSB_IS_NATIVE_ *converter = SwapShiftLeft32; #else *converter = ShiftLeft32; #endif *shift = 8; break; case ASIOSTInt24MSB: /* dest: paInt24, no conversion necessary, possible byte swap */ #ifdef PA_LSB_IS_NATIVE_ *converter = Swap24; #endif break; case ASIOSTInt24LSB: /* dest: paInt24, no conversion necessary, possible byte swap */ #ifdef PA_MSB_IS_NATIVE_ *converter = Swap24; #endif break; }}static void SelectPaToAsioConverter( ASIOSampleType type, PaAsioBufferConverter **converter, long *shift ){ *shift = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -