mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-12-16 08:56:42 -05:00
Maarten de Boer <mdeboer@iua.upf.es>
The attached patch makes the alsa-lib/test/pmc.c generate_sine code slightly more simple, efficient and readable (but not less accurate), taking quite some calculation out of the loop.
This commit is contained in:
parent
b282b1458c
commit
23ed7623c6
1 changed files with 3 additions and 3 deletions
|
|
@ -29,9 +29,9 @@ static void generate_sine(const snd_pcm_channel_area_t *areas,
|
||||||
snd_pcm_uframes_t offset,
|
snd_pcm_uframes_t offset,
|
||||||
int count, double *_phase)
|
int count, double *_phase)
|
||||||
{
|
{
|
||||||
|
static double max_phase = 2. * M_PI;
|
||||||
double phase = *_phase;
|
double phase = *_phase;
|
||||||
double max_phase = 1.0 / freq;
|
double step = max_phase*freq/(double)rate;
|
||||||
double step = 1.0 / (double)rate;
|
|
||||||
double res;
|
double res;
|
||||||
signed short *samples[channels];
|
signed short *samples[channels];
|
||||||
int steps[channels];
|
int steps[channels];
|
||||||
|
|
@ -53,7 +53,7 @@ static void generate_sine(const snd_pcm_channel_area_t *areas,
|
||||||
}
|
}
|
||||||
/* fill the channel areas */
|
/* fill the channel areas */
|
||||||
while (count-- > 0) {
|
while (count-- > 0) {
|
||||||
res = sin((phase * 2 * M_PI) / max_phase - M_PI) * 32767;
|
res = sin(phase) * 32767;
|
||||||
ires = res;
|
ires = res;
|
||||||
for (chn = 0; chn < channels; chn++) {
|
for (chn = 0; chn < channels; chn++) {
|
||||||
*samples[chn] = ires;
|
*samples[chn] = ires;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue