mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-04-08 08:21:04 -04:00
examples: adapt samplerate in audio-dsp-src
Follow the graph rate to generate the sine wav instead of using a hardcoded value. See #5135
This commit is contained in:
parent
5a285602e2
commit
6961bfeaa1
1 changed files with 3 additions and 2 deletions
|
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
#define M_PI_M2f (float)(M_PI+M_PI)
|
#define M_PI_M2f (float)(M_PI+M_PI)
|
||||||
|
|
||||||
#define DEFAULT_RATE 44100
|
|
||||||
#define DEFAULT_FREQ 440
|
#define DEFAULT_FREQ 440
|
||||||
#define DEFAULT_VOLUME 0.7f
|
#define DEFAULT_VOLUME 0.7f
|
||||||
|
|
||||||
|
|
@ -61,7 +60,9 @@ static void on_process(void *userdata, struct spa_io_position *position)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < n_samples; i++) {
|
for (i = 0; i < n_samples; i++) {
|
||||||
out_port->accumulator += M_PI_M2f * DEFAULT_FREQ / DEFAULT_RATE;
|
out_port->accumulator += M_PI_M2f * DEFAULT_FREQ *
|
||||||
|
position->clock.rate.num / position->clock.rate.denom;
|
||||||
|
|
||||||
if (out_port->accumulator >= M_PI_M2f)
|
if (out_port->accumulator >= M_PI_M2f)
|
||||||
out_port->accumulator -= M_PI_M2f;
|
out_port->accumulator -= M_PI_M2f;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue