Re: how to send a sound in real time?

Bennett Todd <[email protected]>
Newsgroups gmane.comp.lang.perl.fun
Message-ID <[email protected]>
2004-08-18T22:06:16 jerome_pub:
> i'ld like to send a beep as long as i'm pressing a key in Tk (with
> bind event)

So I presume you've got the problem of capturing the key
press/release solved (I don't do GUIs:-).

> and i can't... i've tryed with Audio::Play... but it's impossible
> to stop the sound before the end of data called...
>
> i've tryed to with threads and DESTROY methode of Audio::Play...

I think you need a different approach. That API is cool for
preparing sounds in a batch fashion, then spitting them at the audio
device, but that's not what you're looking for.

If it were me, I'd write a sample of the sound you want to beep with
to a file, convert as necessary to get something you can cat
>/dev/... to play, then examine that data. You want to spit small
amounts of this data into the device at a time, and refrain from
spitting them faster than it can play --- but you also don't want
the device to completely drain while the key is held down, since you
don't want gaps in the beep while the key is held down. So the
timing of this spitting will be awfully tight indeed. If there were
a way to query the device to find out how much it's got left in its
queue, that'd be a big help.

Hmm. Maybe you could go ahead with the approach you're using now,
but use something like Audio::DSP::reset to clobber the device when
you want it to shut up.

Interesting problem, although the tricky bits of it seem to like
outside of perl.

-Bennett
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQFBJMPCHZWg9mCTffwRAiYtAJ9GJjEPnjHMhBYRI0PnDpEzBfzaggCfcmqv
WloGjE3bT8cQHpHQYWuMzf8=
=p/W4
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.