Sound in UNIX

Discussion in 'Mac Programming' started by -aggie-, Feb 25, 2010.

  1. -aggie- macrumors P6

    -aggie-

    Joined:
    Jun 19, 2009
    Location:
    Where bunnies are welcome.
    #1
    Does anyone know how to use other sounds other than a beep in a Bash shell script in UNIX?

    I have this:

    echo -e '\a'

    But that only make a boring beep noise. I'd like to be able to use any sound file.
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    Location:
    Brobdingnag
    #2
    Paste this into a Terminal window:
    Code:
    say -v Princess "I'm not boring you, am I?"
    
    It's not "any sound file", but it may be useful.


    For sound files, there's the afplay command. Enter:
    Code:
    afplay -h
    
    to print its builtin help, which is all there is unless you read its source. The source for afplay and its relatives is installed with Xcode 3.1.

    There's also afinfo and afconvert. Again, no man pages of any consequence, so afinfo -h and afconvert -h.


    There's also "Play Sound.app":
    http://microcosmsoftware.com/playsound/

    It's scriptable, so you can use the osascript command to tell it files to play, and how to play them.
     
  3. -aggie- thread starter macrumors P6

    -aggie-

    Joined:
    Jun 19, 2009
    Location:
    Where bunnies are welcome.
    #3
    say and afplay were exactly what I needed. Thanks.

    I've taken a battery script and made it my own to tell me when my battery is below a certain charge on my MBP when I'm not running on the charger. I do that like once a week to keep my battery healthy, and sometimes I forget and it goes dead, which I don't want. So, say will be helpful for just saying the battery is running low. Afplay was able to play all the other sound files I have. Again, thanks.
     

Share This Page