diff options
author | Josh Blum | 2011-10-08 11:56:36 -0700 |
---|---|---|
committer | Josh Blum | 2011-10-08 11:56:36 -0700 |
commit | fcc0ce92dd20cc231fc79dab3d47fbb3d5487f98 (patch) | |
tree | ce4b50e483291039949a86e3f25f42b586a0b1a2 /gr-audio | |
parent | 7a2d39f425f6bc5df6a4f7206d3fa10f8e1e67c3 (diff) | |
parent | 3b1a26e6e610aed2aa8dee3bb747184f51447cf6 (diff) | |
download | gnuradio-fcc0ce92dd20cc231fc79dab3d47fbb3d5487f98.tar.gz gnuradio-fcc0ce92dd20cc231fc79dab3d47fbb3d5487f98.tar.bz2 gnuradio-fcc0ce92dd20cc231fc79dab3d47fbb3d5487f98.zip |
Merge branch 'next' of http://gnuradio.org/git/gnuradio into digital
Diffstat (limited to 'gr-audio')
-rw-r--r-- | gr-audio/lib/alsa/audio_alsa_sink.cc | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/gr-audio/lib/alsa/audio_alsa_sink.cc b/gr-audio/lib/alsa/audio_alsa_sink.cc index 5fd197ec7..0bda42470 100644 --- a/gr-audio/lib/alsa/audio_alsa_sink.cc +++ b/gr-audio/lib/alsa/audio_alsa_sink.cc @@ -326,7 +326,7 @@ audio_alsa_sink::work_s16 (int noutput_items, gr_vector_void_star &output_items) { typedef gr_int16 sample_t; // the type of samples we're creating - static const int NBITS = 16; // # of bits in a sample + static const float scale_factor = std::pow(2.0f, 16-1) - 1; unsigned int nchan = input_items.size (); const float **in = (const float **) &input_items[0]; @@ -343,7 +343,7 @@ audio_alsa_sink::work_s16 (int noutput_items, bi = 0; for (unsigned int i = 0; i < d_period_size; i++){ for (unsigned int chan = 0; chan < nchan; chan++){ - buf[bi++] = (sample_t) (in[chan][i] * (float) ((1L << (NBITS-1)) - 1)); + buf[bi++] = (sample_t) (in[chan][i] * scale_factor); } } @@ -368,7 +368,7 @@ audio_alsa_sink::work_s32 (int noutput_items, gr_vector_void_star &output_items) { typedef gr_int32 sample_t; // the type of samples we're creating - static const int NBITS = 32; // # of bits in a sample + static const float scale_factor = std::pow(2.0f, 32-1) - 1; unsigned int nchan = input_items.size (); const float **in = (const float **) &input_items[0]; @@ -385,7 +385,7 @@ audio_alsa_sink::work_s32 (int noutput_items, bi = 0; for (unsigned int i = 0; i < d_period_size; i++){ for (unsigned int chan = 0; chan < nchan; chan++){ - buf[bi++] = (sample_t) (in[chan][i] * (float) ((1L << (NBITS-1)) - 1)); + buf[bi++] = (sample_t) (in[chan][i] * scale_factor); } } @@ -410,7 +410,7 @@ audio_alsa_sink::work_s16_1x2 (int noutput_items, gr_vector_void_star &output_items) { typedef gr_int16 sample_t; // the type of samples we're creating - static const int NBITS = 16; // # of bits in a sample + static const float scale_factor = std::pow(2.0f, 16-1) - 1; assert (input_items.size () == 1); static const unsigned int nchan = 2; @@ -427,7 +427,7 @@ audio_alsa_sink::work_s16_1x2 (int noutput_items, // process one period of data bi = 0; for (unsigned int i = 0; i < d_period_size; i++){ - sample_t t = (sample_t) (in[0][i] * (float) ((1L << (NBITS-1)) - 1)); + sample_t t = (sample_t) (in[0][i] * scale_factor); buf[bi++] = t; buf[bi++] = t; } @@ -452,7 +452,7 @@ audio_alsa_sink::work_s32_1x2 (int noutput_items, gr_vector_void_star &output_items) { typedef gr_int32 sample_t; // the type of samples we're creating - static const int NBITS = 32; // # of bits in a sample + static const float scale_factor = std::pow(2.0f, 32-1) - 1; assert (input_items.size () == 1); static unsigned int nchan = 2; @@ -469,7 +469,7 @@ audio_alsa_sink::work_s32_1x2 (int noutput_items, // process one period of data bi = 0; for (unsigned int i = 0; i < d_period_size; i++){ - sample_t t = (sample_t) (in[0][i] * (float) ((1L << (NBITS-1)) - 1)); + sample_t t = (sample_t) (in[0][i] * scale_factor); buf[bi++] = t; buf[bi++] = t; } |