Revision 334f45e5 gr-audio/lib/alsa/audio_alsa_source.cc
| b/gr-audio/lib/alsa/audio_alsa_source.cc | ||
|---|---|---|
| 308 | 308 |
gr_vector_void_star &output_items) |
| 309 | 309 |
{
|
| 310 | 310 |
typedef gr_int16 sample_t; // the type of samples we're creating |
| 311 |
static const int NBITS = 16; // # of bits in a sample
|
|
| 311 |
static const float scale_factor = 1.0 / std::pow(2.0f, 16-1);
|
|
| 312 | 312 |
|
| 313 | 313 |
unsigned int nchan = output_items.size (); |
| 314 | 314 |
float **out = (float **) &output_items[0]; |
| ... | ... | |
| 329 | 329 |
bi = 0; |
| 330 | 330 |
for (unsigned int i = 0; i < d_period_size; i++){
|
| 331 | 331 |
for (unsigned int chan = 0; chan < nchan; chan++){
|
| 332 |
out[chan][i] = (float) buf[bi++] * (1.0 / (float) ((1L << (NBITS-1)) - 1));
|
|
| 332 |
out[chan][i] = (float) buf[bi++] * scale_factor;
|
|
| 333 | 333 |
} |
| 334 | 334 |
} |
| 335 | 335 |
|
| ... | ... | |
| 346 | 346 |
gr_vector_void_star &output_items) |
| 347 | 347 |
{
|
| 348 | 348 |
typedef gr_int16 sample_t; // the type of samples we're creating |
| 349 |
static const int NBITS = 16; // # of bits in a sample
|
|
| 349 |
static const float scale_factor = 1.0 / std::pow(2.0f, 16-1);
|
|
| 350 | 350 |
|
| 351 | 351 |
unsigned int nchan = output_items.size (); |
| 352 | 352 |
float **out = (float **) &output_items[0]; |
| ... | ... | |
| 370 | 370 |
for (unsigned int i = 0; i < d_period_size; i++){
|
| 371 | 371 |
int t = (buf[bi] + buf[bi+1]) / 2; |
| 372 | 372 |
bi += 2; |
| 373 |
out[0][i] = (float) t * (1.0 / (float) ((1L << (NBITS-1)) - 1));
|
|
| 373 |
out[0][i] = (float) t * scale_factor;
|
|
| 374 | 374 |
} |
| 375 | 375 |
|
| 376 | 376 |
return d_period_size; |
| ... | ... | |
| 385 | 385 |
gr_vector_void_star &output_items) |
| 386 | 386 |
{
|
| 387 | 387 |
typedef gr_int32 sample_t; // the type of samples we're creating |
| 388 |
static const int NBITS = 32; // # of bits in a sample
|
|
| 388 |
static const float scale_factor = 1.0 / std::pow(2.0f, 32-1);
|
|
| 389 | 389 |
|
| 390 | 390 |
unsigned int nchan = output_items.size (); |
| 391 | 391 |
float **out = (float **) &output_items[0]; |
| ... | ... | |
| 406 | 406 |
bi = 0; |
| 407 | 407 |
for (unsigned int i = 0; i < d_period_size; i++){
|
| 408 | 408 |
for (unsigned int chan = 0; chan < nchan; chan++){
|
| 409 |
out[chan][i] = (float) buf[bi++] * (1.0 / (float) ((1L << (NBITS-1)) - 1));
|
|
| 409 |
out[chan][i] = (float) buf[bi++] * scale_factor;
|
|
| 410 | 410 |
} |
| 411 | 411 |
} |
| 412 | 412 |
|
| ... | ... | |
| 423 | 423 |
gr_vector_void_star &output_items) |
| 424 | 424 |
{
|
| 425 | 425 |
typedef gr_int32 sample_t; // the type of samples we're creating |
| 426 |
static const int NBITS = 32; // # of bits in a sample
|
|
| 426 |
static const float scale_factor = 1.0 / std::pow(2.0f, 32-1);
|
|
| 427 | 427 |
|
| 428 | 428 |
unsigned int nchan = output_items.size (); |
| 429 | 429 |
float **out = (float **) &output_items[0]; |
| ... | ... | |
| 447 | 447 |
for (unsigned int i = 0; i < d_period_size; i++){
|
| 448 | 448 |
int t = (buf[bi] + buf[bi+1]) / 2; |
| 449 | 449 |
bi += 2; |
| 450 |
out[0][i] = (float) t * (1.0 / (float) ((1L << (NBITS-1)) - 1));
|
|
| 450 |
out[0][i] = (float) t * scale_factor;
|
|
| 451 | 451 |
} |
| 452 | 452 |
|
| 453 | 453 |
return d_period_size; |
Also available in: Unified diff