mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-10 07:05:42 +01:00
alsabat: add a single channel sine wave generator
Add function generate_sine_wave_raw_mono(). It serves as a single channel sine wave generator, to provide data for calculation (e.g. for noise analysis). The function is similar to generate_sine_wave(), but a lite revision. It has no dependency on bat channels and target frequency, no malloc inside, no data conversion from float to integer samples, and supports one channel only. Signed-off-by: Lu, Han <han.lu@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
e0c1c86a90
commit
e1b7a5f376
2 changed files with 19 additions and 0 deletions
|
@ -28,3 +28,4 @@ int sin_generator_init(struct sin_generator *, float, float, float);
|
||||||
float sin_generator_next_sample(struct sin_generator *);
|
float sin_generator_next_sample(struct sin_generator *);
|
||||||
void sin_generator_vfill(struct sin_generator *, float *, int);
|
void sin_generator_vfill(struct sin_generator *, float *, int);
|
||||||
int generate_sine_wave(struct bat *, int, void *);
|
int generate_sine_wave(struct bat *, int, void *);
|
||||||
|
int generate_sine_wave_raw_mono(struct bat *, float *, float, int);
|
||||||
|
|
18
bat/signal.c
18
bat/signal.c
|
@ -183,3 +183,21 @@ exit:
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* generate single channel sine waveform without sample conversion */
|
||||||
|
int generate_sine_wave_raw_mono(struct bat *bat, float *buf,
|
||||||
|
float freq, int nsamples)
|
||||||
|
{
|
||||||
|
int err = 0;
|
||||||
|
struct sin_generator sg;
|
||||||
|
|
||||||
|
err = sin_generator_init(&sg, 1.0, freq, bat->rate);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
sin_generator_vfill(&sg, buf, nsamples);
|
||||||
|
|
||||||
|
/* adjust amplitude and offset of waveform */
|
||||||
|
err = adjust_waveform(bat, buf, nsamples, 1);
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue