00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "pent_include.h"
00026
00027 #ifdef USE_TIMIDITY_MIDI
00028
00029 #include "timidity.h"
00030 #include "timidity_output.h"
00031 #include "timidity_tables.h"
00032
00033
00034 #ifdef NS_TIMIDITY
00035 namespace NS_TIMIDITY {
00036 #endif
00037
00038 #ifdef SDL
00039 extern PlayMode sdl_play_mode;
00040 #define DEFAULT_PLAY_MODE &sdl_play_mode
00041 #endif
00042
00043 PlayMode *play_mode_list[] = {
00044 #ifdef DEFAULT_PLAY_MODE
00045 DEFAULT_PLAY_MODE,
00046 #endif
00047 0
00048 };
00049
00050 #ifdef DEFAULT_PLAY_MODE
00051 PlayMode *play_mode=DEFAULT_PLAY_MODE;
00052 #endif
00053
00054
00055
00056
00057 void s32tos8(void *dp, sint32 *lp, sint32 c)
00058 {
00059 sint8 *cp=(sint8 *)(dp);
00060 sint32 l;
00061 while (c--)
00062 {
00063 l=(*lp++)>>(32-8-GUARD_BITS);
00064 if (l>127) l=127;
00065 else if (l<-128) l=-128;
00066 *cp++ = (sint8) (l);
00067 }
00068 }
00069
00070 void s32tou8(void *dp, sint32 *lp, sint32 c)
00071 {
00072 uint8 *cp=(uint8 *)(dp);
00073 sint32 l;
00074 while (c--)
00075 {
00076 l=(*lp++)>>(32-8-GUARD_BITS);
00077 if (l>127) l=127;
00078 else if (l<-128) l=-128;
00079 *cp++ = 0x80 ^ ((uint8) l);
00080 }
00081 }
00082
00083 void s32tos16(void *dp, sint32 *lp, sint32 c)
00084 {
00085 sint16 *sp=(sint16 *)(dp);
00086 sint32 l;
00087 while (c--)
00088 {
00089 l=(*lp++)>>(32-16-GUARD_BITS);
00090 if (l > 32767) l=32767;
00091 else if (l<-32768) l=-32768;
00092 *sp++ = (sint16)(l);
00093 }
00094 }
00095
00096 void s32tou16(void *dp, sint32 *lp, sint32 c)
00097 {
00098 uint16 *sp=(uint16 *)(dp);
00099 sint32 l;
00100 while (c--)
00101 {
00102 l=(*lp++)>>(32-16-GUARD_BITS);
00103 if (l > 32767) l=32767;
00104 else if (l<-32768) l=-32768;
00105 *sp++ = 0x8000 ^ (uint16)(l);
00106 }
00107 }
00108
00109 void s32tos16x(void *dp, sint32 *lp, sint32 c)
00110 {
00111 sint16 *sp=(sint16 *)(dp);
00112 sint32 l;
00113 while (c--)
00114 {
00115 l=(*lp++)>>(32-16-GUARD_BITS);
00116 if (l > 32767) l=32767;
00117 else if (l<-32768) l=-32768;
00118 *sp++ = XCHG_SHORT((sint16)(l));
00119 }
00120 }
00121
00122 void s32tou16x(void *dp, sint32 *lp, sint32 c)
00123 {
00124 uint16 *sp=(uint16 *)(dp);
00125 sint32 l;
00126 while (c--)
00127 {
00128 l=(*lp++)>>(32-16-GUARD_BITS);
00129 if (l > 32767) l=32767;
00130 else if (l<-32768) l=-32768;
00131 *sp++ = XCHG_SHORT(0x8000 ^ (uint16)(l));
00132 }
00133 }
00134
00135 void s32toulaw(void *dp, sint32 *lp, sint32 c)
00136 {
00137 uint8 *up=(uint8 *)(dp);
00138 sint32 l;
00139 while (c--)
00140 {
00141 l=(*lp++)>>(32-13-GUARD_BITS);
00142 if (l > 4095) l=4095;
00143 else if (l<-4096) l=-4096;
00144 *up++ = _l2u[l];
00145 }
00146 }
00147
00148 #ifdef NS_TIMIDITY
00149 };
00150 #endif
00151
00152 #endif //USE_TIMIDITY_MIDI