[Vorbis] Write pure sine to *.ogg directly?

Monty xiphmont at localhost.localdomain
Mon Feb 20 11:49:06 PST 2006




On Mon, Feb 20, 2006 at 09:39:35AM -0500, Gan Uesli Starling wrote:
> I'd like some means of writing a pure sine wave straight
> to *.ogg just as I currently can to *.wav (using the Perl
> Audio::Wav module). 

Slightly more fundamnetally complex, but it wouldn't bee too hard if
you're not *too* picky about the *exact* frequency you want to output.

What will probably suck, though, is getting ahold of a perl binding
for libogg and enough of libvorbis to set a few packet fields.

> This would involve turning on and off a sine wave of N mS
> duration with silences between. And the leading edges of
> these sine-wave segments require a not-too-abrupt rise time
> to avoid what Morse folks call "key clicks" and, if I read
> correctly, cause "pre echos" in compressed audio. 

I'd expect you'd want to build the tone packets directly from the
spectral math you'd need for a given sine wave; preecho would be
vaguely irrelevant.

> Bearing in mind that I know nothing about audio codecs beyond
> being able to use Perl's Audio::Wav module, have I any hope of
> accomplishing such a task in Perl with output direct to *.ogg?
> Where would I start in such a case? 

Yes... but it depends on what perl bindings already exist.  Building
the vorbis packets in Perl wouldn't be too bad (I expect you only need
a couple 'canned' packets), but stitching them into the Ogg stream
would require a bit more code if Ogg code isn;t already available.

Monty


More information about the Vorbis mailing list