diff options
author | Lu, Han <han.lu@intel.com> | 2016-06-09 03:42:47 +0800 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2016-06-08 15:13:53 +0200 |
commit | e0c1c86a90ebefb681c01f5c9571f3157cab5c34 (patch) | |
tree | 757fc2c54da50d1677533b2ceb5fb34267c01a42 | |
parent | 09cb66f40c99a9ea90ceea6d00a87faf092628e0 (diff) | |
download | alsa-utils-e0c1c86a90ebefb681c01f5c9571f3157cab5c34.tar.gz |
alsabat: add channels parameter for adjust_waveform()
The function adjust_waveform() is a component of generate_sine_wave(),
and depended on bat->channels parameter. Add parameter "channels" to
remove the dependency, and then adjust_waveform() can be applied on
other use cases, e.g. a single channel sine wave generator.
Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | bat/signal.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/bat/signal.c b/bat/signal.c index 15bea0a..2047f53 100644 --- a/bat/signal.c +++ b/bat/signal.c @@ -109,7 +109,8 @@ static int reorder(struct bat *bat, float *val, int frames) return 0; } -static int adjust_waveform(struct bat *bat, float *val, int frames) +static int adjust_waveform(struct bat *bat, float *val, int frames, + int channels) { int i, nsamples, max; float factor, offset = 0.0; @@ -134,7 +135,7 @@ static int adjust_waveform(struct bat *bat, float *val, int frames) } factor = max * RANGE_FACTOR; - nsamples = bat->channels * frames; + nsamples = channels * frames; for (i = 0; i < nsamples; i++) val[i] = val[i] * factor + offset; @@ -171,7 +172,7 @@ int generate_sine_wave(struct bat *bat, int frames, void *buf) goto exit; /* adjust amplitude and offset of waveform */ - err = adjust_waveform(bat, sinus_f, frames); + err = adjust_waveform(bat, sinus_f, frames, bat->channels); if (err != 0) goto exit; |