mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-08 22:45:43 +01:00
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>
This commit is contained in:
parent
09cb66f40c
commit
e0c1c86a90
1 changed files with 4 additions and 3 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue