Lines Matching +full:convert +full:- +full:rate

1 /* libSoX Yamaha TX-16W sampler file support
8 * provided. This code is furnished AS-IS as a component of the
10 * Much appreciation to ross-c for his sampConv utility for SGI/IRIX
15 * Handles reading of files which do not have the sample rate field
18 * rate is still unknown.
56 format, /* 0x49 = looped, 0xC9 = non-looped */
69 * Find out sampling rate,
84 priv_t * sk = (priv_t *) ft->priv; in startread()
86 if (! ft->seekable) in startread()
95 num_samp_bytes -= 32; /* calculate num samples by sub header size */ in startread()
97 sk->rest = num_samp_bytes; /* set how many sample bytes to read */ in startread()
100 lsx_readchars(ft, filetype, sizeof(filetype) - 1); in startread()
102 for( c = 16; c > 0 ; c-- ) /* Discard next 16 bytes */ in startread()
107 * save next 8 bytes - if sample rate is 0, then we need in startread()
108 * to look at gunk[2] and gunk[5] to get real rate in startread()
124 * Set up the sample rate as indicated by the header in startread()
129 ft->signal.rate = 1e5 / 3; in startread()
132 ft->signal.rate = 1e5 / 2; in startread()
135 ft->signal.rate = 1e5 / 6; in startread()
143 ft->signal.rate = 1e5 / 3; in startread()
149 ft->signal.rate = 1e5 / 2; in startread()
155 ft->signal.rate = 1e5 / 6; in startread()
160 lsx_debug("Invalid sample rate identifier found %d", sample_rate); in startread()
161 ft->signal.rate = 1e5 / 3; in startread()
164 lsx_debug("Sample rate = %g", ft->signal.rate); in startread()
166 ft->signal.channels = 1 ; /* not sure about stereo sample data yet ??? */ in startread()
167 ft->encoding.bits_per_sample = 12; in startread()
168 ft->encoding.encoding = SOX_ENCODING_SIGN2; in startread()
175 * Convert to sox_sample_t.
182 priv_t * sk = (priv_t *) ft->priv; in read_samples()
193 * won't be any. Something to look out for though :-( in read_samples()
205 * Convert unsigned short to sox_sample_t then shift up the result in read_samples()
206 * so that the 12-bit sample lives in the most significant in read_samples()
207 * 12-bits of the sox_sample_t. in read_samples()
212 if(sk->rest < 3) break; /* Finished reading from file? */ in read_samples()
216 sk->rest -= 3; /* adjust remaining for bytes we just read */ in read_samples()
232 priv_t * sk = (priv_t *) ft->priv; in startwrite()
240 if (! ft->seekable) in startwrite()
250 sk->bytes_out = 32; in startwrite()
256 priv_t * sk = (priv_t *) ft->priv; in write_samples()
257 size_t last_i, i = 0, len = min(len0, TXMAXLEN - sk->samples_out); in write_samples()
262 if (sk->odd_flag) { in write_samples()
263 w1 = sk->odd; in write_samples()
264 sk->odd_flag = sox_false; in write_samples()
276 sk->samples_out += 2; in write_samples()
277 sk->bytes_out += 3; in write_samples()
280 sk->odd = w1; in write_samples()
281 sk->odd_flag = sox_true; in write_samples()
289 priv_t * sk = (priv_t *) ft->priv; in stopwrite()
293 if (sk->odd_flag) { in stopwrite()
314 /* the actual sample rate is not that important ! */ in stopwrite()
315 if (ft->signal.rate < 24000) WH.sample_rate = 3; in stopwrite()
316 else if (ft->signal.rate < 41000) WH.sample_rate = 1; in stopwrite()
319 if (sk->samples_out >= TXMAXLEN) { in stopwrite()
324 else if (sk->samples_out >=TXMAXLEN/2) { in stopwrite()
326 LoopLength = sk->samples_out - TXMAXLEN/2; in stopwrite()
329 AttackLength -= 0x40; in stopwrite()
332 else if (sk->samples_out >= 0x80) { in stopwrite()
333 AttackLength = sk->samples_out -0x40; in stopwrite()
339 for(i=sk->samples_out;i<0x80;i++) { in stopwrite()
343 sk->bytes_out += 3; in stopwrite()
349 while ((sk->bytes_out % 0x100) != 0) { in stopwrite()
351 sk->bytes_out++; in stopwrite()
376 "Yamaha TX-16W sampler", names, SOX_FILE_MONO, in LSX_FORMAT_HANDLER()