beeping portably

Discussion in 'Python' started by John J. Lee, Mar 20, 2005.

  1. John J. Lee

    John J. Lee Guest

    "Jim" <> writes:

    > 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.

    [...]

    PyGame? If it's too big for you, you could always borrow code from it.


    John
     
    John J. Lee, Mar 20, 2005
    #1
    1. Advertising

  2. John J. Lee

    Jim Guest

    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.

    Thanks,
    Jim
     
    Jim, Mar 20, 2005
    #2
    1. Advertising

  3. On 20 Mar 2005 09:03:25 -0800, "Jim" <> 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
     
    Bengt Richter, Mar 21, 2005
    #3
  4. Jim 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.


    Maybe pygame helps? You can play sound with it, and the sdl abstracts from
    directx and whatever linux uses.

    --
    Regards,

    Diez B. Roggisch
     
    Diez B. Roggisch, Mar 21, 2005
    #4
  5. John J. Lee

    nicke Guest

    On Mon, 21 Mar 2005 10:13:36 GMT
    (Bengt Richter) wrote:

    > On 20 Mar 2005 09:03:25 -0800, "Jim" <> 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
     
    nicke, Mar 22, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeffrey Silverman
    Replies:
    5
    Views:
    1,424
    Sam Hughes
    Nov 13, 2004
  2. Alexander Schmolck

    beeping under linux

    Alexander Schmolck, Nov 19, 2003, in forum: Python
    Replies:
    5
    Views:
    2,136
    Alexander Schmolck
    Nov 20, 2003
  3. SimonW

    RE: Modem beeping

    SimonW, Jan 23, 2004, in forum: Python
    Replies:
    0
    Views:
    370
    SimonW
    Jan 23, 2004
  4. Herman Geldenhuys

    Modem beeping

    Herman Geldenhuys, Jan 23, 2004, in forum: Python
    Replies:
    1
    Views:
    719
    Dennis Lee Bieber
    Jan 23, 2004
  5. Jeffrey Barish

    Beeping the console

    Jeffrey Barish, Aug 31, 2004, in forum: Python
    Replies:
    3
    Views:
    307
    Jeffrey Barish
    Sep 1, 2004
Loading...

Share This Page