[alsa-devel] Problem with setting period time and buffer time.

Clemens Ladisch clemens at ladisch.de
Tue Feb 19 15:45:50 CET 2008


Ignacy Kasperowicz wrote:
>> Just write the data to the device.
>
> Ok, but when I just write data to the device I don't really know how
> long it'll be playing.

But you know how many sample you are writing, and you know the sample
rate.

> There is no problem when I've infinite loop with writei inside. but I
> need to change freq of my sound signal with exact 843 us period time.

Assuming a sample rate of 48 kHz, 1/1200 s corresponds to exactly
40 samples.  At 44.1 kHz, this would be 36.75 samples, so you'd have to
use groups of 37+37+37+36 samples with appropriate phase shifting.

BTW: 1 / 1200 Hz = 833.33... µs


HTH
Clemens


More information about the Alsa-devel mailing list