Re: [linux-audio-dev] initial (incomplete) version of ALSA Audio API tutorial

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] initial (incomplete) version of ALSA Audio API tutorial
From: Paul Winkler (pw_lists_AT_slinkp.com)
Date: Fri Mar 22 2002 - 00:47:41 EET


On Thu, Mar 21, 2002 at 04:31:06PM -0500, Paul Davis wrote:
> I would appreciate it if anybody has any ideas on a really simple
> way to get the playback examples to make a nice noise without
> burdening the examples with either waveform generating code and/or
> calls to some kind of audio file library.

don't want to embarass myself in the company of real audio hackers,
but why not just put sin() in a loop?
I'm sorry my C syntax is not up to snuff-- I'm sure
there are basic errors in the following (like
totally glossing over type declarations) -- BUT
I *think* something like this will work once it's
syntactically correct:

sr=44100;
freq=440;
wavelength_samples= sr / freq;
/* IIRC, sin() takes an arg in radians */
radian_factor=2 * PI / wavelength_samples

while 1 {
        for (x=0; x < wavelength_samples; x++) {
                write(output_file, sin(x * radian_factor));
        }
}

that's probably pretty close to an audio "hello world"...
of course you'd have to scale the output appropriately
and make sure it's an int...

hmm, wonder if that works :)

--PW


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Fri Mar 22 2002 - 00:37:52 EET