#include "st.h"#include "libst.h"#include "sciprint.h"Include dependency graph for raw.c:

Go to the source code of this file.
Functions | |
| int | rawread (ft_t ft, long int *buf, long int nsamp) |
| void | rawwrite (ft_t ft, long int *buf, long int nsamp) |
Definition at line 38 of file raw.c.
References ALAW, BYTESCI, count, done, FLOATSCI, soundstream::fp, ft, soundstream::ierr, soundstream::info, LEFT, long, rfloat(), rshort(), sciprint(), SIGN2, signalinfo::size, sizes, st_Alaw_to_linear(), st_ulaw_to_linear(), signalinfo::style, styles, ULAW, UNSIGNED, and WORDSCI.
Referenced by wavread().
00041 { 00042 int count; 00043 #if defined(__alpha)|defined(__ia64__) 00044 register int datum; 00045 #else 00046 register long datum; 00047 #endif 00048 int done = 0; 00049 count=0; 00050 switch(ft->info.size) 00051 { 00052 case BYTESCI: switch(ft->info.style) 00053 { 00054 case SIGN2: 00055 while(done < nsamp) 00056 { 00057 datum = getc(ft->fp); 00058 if (feof(ft->fp)) 00059 return done; 00060 /* scale signed up to long's range */ 00061 *buf++ = datum = LEFT(datum, 24); 00062 done++; 00063 } 00064 return done; 00065 case UNSIGNED: 00066 while(done < nsamp) 00067 { 00068 datum = getc(ft->fp); 00069 if (feof(ft->fp)) 00070 return done; 00071 /* Convert to signed */ 00072 datum ^= 128; 00073 /* scale signed up to long's range */ 00074 *buf++ = datum = LEFT(datum, 24); 00075 done++; 00076 } 00077 return done; 00078 case ULAW: 00079 while(done < nsamp) 00080 { 00081 datum = getc(ft->fp); 00082 if (feof(ft->fp)) 00083 return done; 00084 datum = st_ulaw_to_linear((unsigned char)datum); 00085 /* scale signed up to long's range */ 00086 *buf++ = datum = LEFT(datum, 16); 00087 done++; 00088 } 00089 return done; 00090 case ALAW: 00091 while(done < nsamp) 00092 { 00093 datum = getc(ft->fp); 00094 if (feof(ft->fp)) 00095 return done; 00096 datum = st_Alaw_to_linear((unsigned char)datum); 00097 /* scale signed up to long's range */ 00098 *buf++ = datum = LEFT(datum, 16); 00099 done++; 00100 } 00101 return done; 00102 } 00103 case WORDSCI: 00104 switch(ft->info.style) 00105 { 00106 case SIGN2: 00107 while(done < nsamp) 00108 { 00109 datum = rshort(ft); 00110 if (feof(ft->fp)) 00111 return done; 00112 /* scale signed up to long's range */ 00113 *buf++ = datum = LEFT(datum, 16); 00119 done++; 00120 } 00121 return done; 00122 case UNSIGNED: 00123 while(done < nsamp) 00124 { 00125 datum = rshort(ft); 00126 if (feof(ft->fp)) 00127 return done; 00128 /* Convert to signed */ 00129 datum ^= 0x8000; 00130 /* scale signed up to long's range */ 00131 *buf++ = datum = LEFT(datum, 16); 00132 done++; 00133 } 00134 return done; 00135 case ULAW: 00136 sciprint("No U-Law support for shorts\r\n"); 00137 ft->ierr=1; 00138 return done; 00139 case ALAW: 00140 sciprint("No A-Law support for shorts\r\n"); 00141 ft->ierr=1; 00142 return done; 00143 } 00144 case FLOATSCI: 00145 while(done < nsamp) 00146 { 00147 datum = (long) rfloat(ft); 00148 if (feof(ft->fp)) 00149 return done; 00150 *buf++ = datum = LEFT(datum, 16); 00151 done++; 00152 } 00153 return done; 00154 default: 00155 sciprint("Drop through in rawread!\r\n"); 00156 ft->ierr=1; 00157 } 00158 sciprint("Sorry, don't have code to read %s, %s\r\n", 00159 styles[ft->info.style], sizes[ft->info.size]); 00160 ft->ierr=1; 00161 return done; 00162 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 168 of file raw.c.
References ALAW, BYTESCI, done, FLOATSCI, soundstream::fp, ft, soundstream::ierr, soundstream::info, RIGHT, sciprint(), SIGN2, signalinfo::size, sizes, st_linear_to_Alaw(), st_linear_to_ulaw(), signalinfo::style, styles, ULAW, UNSIGNED, wfloat(), WORDSCI, and wshort().
Referenced by wavwrite().
00169 { 00170 register int datum; 00171 int done = 0; 00172 switch(ft->info.size) 00173 { 00174 case BYTESCI: switch(ft->info.style) 00175 { 00176 case SIGN2: 00177 while(done < nsamp) 00178 { 00179 /* scale signed up to long's range */ 00180 datum = RIGHT(*buf++, 24); 00181 putc(datum, ft->fp); 00182 done++; 00183 } 00184 return; 00185 case UNSIGNED: 00186 while(done < nsamp) 00187 { 00188 /* scale signed up to long's range */ 00189 datum = RIGHT(*buf++, 24); 00190 /* Convert to unsigned */ 00191 datum ^= 128; 00192 putc(datum, ft->fp); 00193 done++; 00194 } 00195 return; 00196 case ULAW: 00197 while(done < nsamp) 00198 { 00199 /* scale signed up to long's range */ 00200 datum = RIGHT(*buf++, 16); 00201 /* round up to 12 bits of data */ 00202 datum += 0x8; /* + 0b1000 */ 00203 datum = st_linear_to_ulaw(datum); 00204 putc(datum, ft->fp); 00205 done++; 00206 } 00207 return; 00208 case ALAW: 00209 while(done < nsamp) 00210 { 00211 /* scale signed up to long's range */ 00212 datum = RIGHT(*buf++, 16); 00213 /* round up to 12 bits of data */ 00214 datum += 0x8; /* + 0b1000 */ 00215 datum = st_linear_to_Alaw(datum); 00216 putc(datum, ft->fp); 00217 done++; 00218 } 00219 return; 00220 } 00221 case WORDSCI: switch(ft->info.style) { 00222 case SIGN2: 00223 while(done < nsamp) { 00224 /* scale signed up to long's range */ 00225 datum = RIGHT(*buf++, 16); 00226 wshort(ft, datum); 00227 done++; 00228 } 00229 return; 00230 case UNSIGNED: 00231 while(done < nsamp) { 00232 /* scale signed up to long's range */ 00233 datum = RIGHT(*buf++, 16); 00234 /* Convert to unsigned */ 00235 datum ^= 0x8000; 00236 wshort(ft, datum); 00237 done++; 00238 } 00239 return; 00240 case ULAW: 00241 sciprint("No U-Law support for shorts (try -b option ?)\r\n"); 00242 ft->ierr=1; 00243 return; 00244 case ALAW: 00245 sciprint("No A-Law support for shorts (try -b option ?)\r\n"); 00246 ft->ierr=1; 00247 return; 00248 } 00249 case FLOATSCI: 00250 while(done < nsamp) { 00251 /* scale signed up to long's range */ 00252 datum = RIGHT(*buf++, 16); 00253 wfloat(ft, (float) datum); 00254 done++; 00255 } 00256 return; 00257 default: 00258 { 00259 sciprint("Drop through in rawwrite!\r\n"); 00260 ft->ierr=1; 00261 } 00262 00263 } 00264 sciprint("Sorry, don't have code to write %s, %s\r\n",styles[ft->info.style], sizes[ft->info.size]); 00265 ft->ierr=1; 00266 }
Here is the call graph for this function:

Here is the caller graph for this function:

1.5.1