[PATCH 2/4] alsabat: add channels parameter for adjust_waveform()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Lu, Han" <han.lu@xxxxxxxxx>

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@xxxxxxxxx>

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

_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux