[alsa-devel] [PATCH 2/4] alsabat: add channels parameter for adjust_waveform()
han.lu at intel.com
han.lu at intel.com
Wed Jun 8 21:42:47 CEST 2016
From: "Lu, Han" <han.lu at intel.com>
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 at intel.com>
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;
--
2.5.0
More information about the Alsa-devel
mailing list