generating audio signals

2005-03-20 Thread nicke
I'm running linux and would like to generate specific frequencies and
play them(in OSS) or alternatively save them as wav files, how should I
accomplish this? Using python to play and generate is not strictly
necessary, as long as I can invoke the command from python.
I know for example xmms can do this, but I want a command-line only solution.

thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


typo in the library reference?

2005-03-22 Thread nicke
from http://docs.python.org/lib/ossaudio-device-objects.html:

AFMT_U8 Unsigned, 8-bit audio
AFMT_S16_LE Unsigned, 16-bit audio, little-endian byte order
(as used by Intel processors)
AFMT_S16_BE Unsigned, 16-bit audio, big-endian byte order
(as used by 68k, PowerPC, Sparc)
AFMT_S8 Signed, 8 bit audio
AFMT_U16_LE Signed, 16-bit little-endian audio
AFMT_U16_BE Signed, 16-bit big-endian audio

Note how the U:s and S:s are switched compared to signed and unsigned,
this should surely not be like this? If it really is like this it is
uncoherent and quite stupid :P
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: beeping portably

2005-03-22 Thread nicke
On Mon, 21 Mar 2005 10:13:36 GMT
[EMAIL PROTECTED] (Bengt Richter) wrote:

> On 20 Mar 2005 09:03:25 -0800, "Jim" <[EMAIL PROTECTED]> wrote:
> 
> >Hello,
> >
> >I'd like to emit beeps.  The twists are that (1) I hope to have control
> >over the frequency of the beeps and their duration and (2) I'd like the
> >solution to be portable across Linux, Windows, and OS X.
> >
> >I've done some searching of this group and the solutions that people
> >have offered in the past seem not to satisfy both points. For instance,
> >that I can tell, "\a" or curses.beep() doesn't give you control over
> >the frequency or duration.  I also looked at wxWindows but there were
> >warnings about the MMedia module ("status is unclear") that made me
> >leery.
> >
> for windows, I think it's
> http://docs.python.org/lib/module-winsound.html
> but I don't know if there's a corresponding *nix module.
> Or maybe you can make one just writing to some /dev/somethingorother,
> and conditionally set up the appropriate thing for limited
> platform-appropriateness if not independence.
> 
> Regards,
> Bengt Richter
> -- 
> http://mail.python.org/mailman/listinfo/python-list


You could generate sine tones quite easily. see e.g.
http://www.onlamp.com/pub/a/python/2001/01/31/numerically.html, which
you save in an array or list. What you have then is the amplitude for
sound frames, which is just what is stored in a sound file(and played).
For audio of 11025Hz that would be 11025 frames(values) per second. I
don't know about other sound devices, but ossaudiodev accepts these more
or less directly.

At least array.array can then pack those values into strings. Those you
could then save to sound files with the wave module. Playing you could
do with for example tkSnack, which is cross-platform. (haven't tried
though)

good luck, Niklas
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: generating audio signals

2005-03-22 Thread nicke
On Tue, 22 Mar 2005 00:51:57 GMT
[EMAIL PROTECTED] (Bengt Richter) wrote:

> On 21 Mar 2005 11:12:38 -0800, "Cappy2112" <[EMAIL PROTECTED]> wrote:
> 
> >>>Maybe make yourself a little utility first that will show you the
> >specs for any .wav file (i.e.,
> >>>sampling frequency, bytes per sample, channels, etc.)
> >
> >You can do this with one function call - wave.Wave_read.getparams()
> >import wave
> >wave.open("filename","b")
> >wave.Wave_read.getparams()
> >
> Yeah, I know ;-) I expected the OP to discover that really quick,
> and enjoy an early tidbit of success, maybe printing the parameters
> in a pretty format to his taste ;-)
> 
> Regards,
> Bengt Richter
> -- 
> http://mail.python.org/mailman/listinfo/python-list

already found it and used it, but did some more research...
packed/unpacked the wave files, made programs for generating
frequencies, playing them, saving them, and plotting the files as
amplitude as a function of time.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: typo in the library reference?

2005-03-22 Thread nicke
On Tue, 22 Mar 2005 23:30:51 -0500
Peter Hansen <[EMAIL PROTECTED]> wrote:

> Scott David Daniels wrote:
> > nicke wrote:
> >> If it really is like this it is uncoherent and quite stupid :P
> > 
> > Name-calling won't make anyone more likely to help you out.  This is a
> > _collective_ effort.  You spotted a problem; submit at least a bug
> > report if not a fix.
> 
> To be fair, Scott, I think he was saying in effect "if
> the docs are really accurate about this, then the
> design is f**ked", which would be a fair and reasonable
> statement.  I don't think he's saying that the docs
> are incoherent and stupid as written... just wrong.
> 
> -Peter
> -- 

Thanks for sticking up for me, and yes, this was what i meant. I could
have formulated myself a bit annorlund though, have to blame the late
hours :P

I'm going to submit a bug report, just don't have much experience with
that... but hey, sometime must be the first! ;)

nicke
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: typo in the library reference?

2005-03-22 Thread nicke
[...]

>I could
> have formulated myself a bit annorlund though, ...

uups, forgot to look up the word that I directly just didn't come up
with; annorlunda is swedish for differently
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: typo in the library reference?

2005-03-23 Thread nicke
On Wed, 23 Mar 2005 05:13:45 -0800
Scott David Daniels <[EMAIL PROTECTED]> wrote:

> 
> My apologies belong in this thread. 

No worries, apology accepted


On Wed, 23 Mar 2005 11:44:27 -0500
"Terry Reedy" <[EMAIL PROTECTED]> wrote:

> 
> "nicke" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
> > I'm going to submit a bug report, just don't have much experience with
> > that... but hey, sometime must be the first! ;)
> 
> If you can, you might also look at the ossaudio source to verify that the 
> mixup is strictly in the doc and not the code.
> 
> TJR
> 

Well, sorry, the ossaudiodev module seem to be coded in c or c++ (?)
which i don't have any experience with. However, according to the python
interpreter help the AFMT_U8...etc are differently ordered and have
numeric values, which probably means that the sources doesn't say
anythin to anyone without deep understanding of the oss interface. (if
they aren't very well documented)

nicke
-- 
http://mail.python.org/mailman/listinfo/python-list