Re: [ecasound] sample rate madness

New Message Reply Date view Thread view Subject view Author view Other groups

Subject: Re: [ecasound] sample rate madness
From: Kai Vehmanen (kaiv@wakkanet.fi)
Date: Sat Oct 16 1999 - 15:28:25 EEST


On Fri, 15 Oct 1999, Kali Griffin wrote:

> ECA_SESSION esession;
> ECA_CONTROLLER ectrl (&esession);
[...]
> ectrl.add_audio_device(in.wav, ECA_CONTROLLER::input);
> ectrl.get_audio_format(in.wav, &in_aio_params);
> ectrl.add_audio_device(out.raw, ECA_CONTROLLER::output);
> ectrl.set_audio_format(16,2,22050);
[more code]
> This spits my output out at 44,100. should this be the case, or am
> I doin something screwy? also, if I were reading in from /dev/dsp
> is there a way I can make the sound card read in at some specific
> sampling rate rather than making the processor do resampling? thanks.

Yes, the problem here is the order of commands. set_audio_format()
works just like "-f:x,y,x" command like parameter. In other words
it sets default the audio format. In some cases this information
is not needed (opening a .wav file for input, opening an existing
.wav file for writing, etc.). Otherwise the default audio format is
used (opening a .raw input file, opening soundcard device, etc.).
So...:

ectrl.set_audio_format(16,2,22050);
        // set default audio format
ectrl.add_audio_device(in.wav, ECA_CONTROLLER::input);
        // default format isn't needed as .wav header contains
        // the necessary info
ectrl.set_audio_format(16,2,22050);
        // set default format
ectrl.add_audio_device(out.raw, ECA_CONTROLLER::output);
        // now the default format is used
          
... this is the same thing as:

ectrl.set_audio_format(16,2,22050); // let's set the default format
ectrl.add_audio_device(in.wav, ECA_CONTROLLER::input);
ectrl.add_audio_device(out.raw, ECA_CONTROLLER::output);

"Internal sample rate" is another thing. In 1.5.12r6 ECA_CONTROLLER
class doesn't have a routine for changing this, but you can use:

SAMPLE_BUFFER::set_sample_rate(44100)

in the beginning of your program.

--
Kai Vehmanen <kaiv@wakkanet.fi> -------- CS, University of Turku, Finland
 . http://www.wakkanet.fi/ecasound/ - linux audio processing
 . http://www.wakkanet.fi/sculpscape/ - ambient-idm-rock-... mp3/ra/wav


New Message Reply Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2a24 : Sat Oct 16 1999 - 17:11:52 EEST