Sponsored Content
Full Discussion: Play sound
Top Forums Shell Programming and Scripting Play sound Post 302787053 by Corona688 on Thursday 28th of March 2013 03:39:59 PM
Old 03-28-2013
I suppose a brutally simple way would just be a loop:

Code:
tr '[A-Z]' '[a-z]' < inputfile | while read LINE
do
        STR=""
        set -- $LINE
        while [ "$#" -gt 0 ]
        do
                [ -f "wavdir/$1.wav" ] && STR="$STR wavdir/$1.wav"
                shift
        done

        [ ! -z "$STR" ] && play $STR
done

It converts all uppercase into lowercase, then reads every line, splits words on whitespace into $1 $2 ..., loops over $1...$N, and for every word matching a file inside wavdir/, adds it to a list of files to be played then plays it.

You need sox's play command for this...
This User Gave Thanks to Corona688 For This Post:
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

play cd? how?

hi all, How do I set up my cdrom to play some regular audio cd (not cd-r or cd-rw). I know that my cdrom has been mounted as it does pop up the file manager if I put in, e.g., the office52 cd. Thanks in advance. Andre (3 Replies)
Discussion started by: andrec
3 Replies

2. UNIX for Advanced & Expert Users

Need something new to play with

I posted this question in the dummies forums, but I would like to get a more expert opinion... I am looking for a new OS to play with. I have a celron 450 running slackware linux, a powermac G4 450 running Mac OS X (Which by the way has 81 days of uptime as of this moment), a PowerBook G3 running... (5 Replies)
Discussion started by: dewhite04
5 Replies

3. UNIX for Dummies Questions & Answers

How Can I Play A Cd On Unix

HI I AM A FRESH NEW USER ...I MEAN I JUST GOT A COMPUTER ALMOST FOR FREE AND IT RUNS UNIX WHICH I DIDN'T EXPECT AND DONT KNOW HOW TO WORK ON IT I THOUGHT IT'LL BE WITH WINDOWS ..YOU KNOW SO HOW DO I PLAY A CD IN IT. REMEMBER I KNOW NOTHING ABOUT UNIX , BUT I THINK I'LL GET OVER IT... (1 Reply)
Discussion started by: IMOTEB
1 Replies

4. UNIX for Advanced & Expert Users

play

dear friends, i have linux system . can i play songs in linux system. like winamp player in windows. let me know. (2 Replies)
Discussion started by: rajan_ka1
2 Replies

5. Linux

how can i play the gam

can some1 tell me how to start playing? (2 Replies)
Discussion started by: 123456
2 Replies

6. Linux

Can not play sound in Linux RHEL5.

Hi All, Recently I installed Linux RHEL5 on my machine. It seems that I can not play sound on RHEL5. I have real player installed along with RHEL5 but, when I try to play any song, the error message comes up saying "Can not open the audio device.Another application may be using it." Does any... (2 Replies)
Discussion started by: gydave
2 Replies

7. Slackware

Can't play sound files with aplay or cat to /dev/dsp

I am having problems using soundes. Until a few moments ago the following commands produced errors and no sound: cat /usr/share/apps/kolf/sounds/blackhole.wav/ > /dev/dsp yielded: /dev/dsp: Invalid argument cat /usr/share/apps/kolf/sounds/blackhole.wav > /dev/audio yelded: /dev/audio:... (3 Replies)
Discussion started by: slak0
3 Replies

8. Shell Programming and Scripting

Making a play-list

approximately the same question as the last time, but unfortunately I didn't get a working answer. I made a script with bash and gtkdialog that create a play-list. The output is for example : gtk-media-pause | CB60471-05 - Gilbert, Brantley - Country Must Be Country Wide.zip | 28897 |... (3 Replies)
Discussion started by: jkfloris
3 Replies
pods::SDLx::Sound(3pm)					User Contributed Perl Documentation				    pods::SDLx::Sound(3pm)

NAME
SDLx::Sound - SDL sound extension CATEGORY
Extension SYNOPSIS
use SDLx::Sound; my $snd = SDLx::Sound->new(); # loads and plays a single sound now $snd->play('myfile.wav'); # load a single file $snd->load('theSound.aif'); # plays it or all loaded files $snd->play(); # more sounds my %files = ( channel_01 => "/my_sound1.wav", channel_02 => "/my_sound2.ogg" ); # times sounds bangs my %times = ( channel_01 => 0, # start channel_01 => 1256, # milliseconds channel_02 => 2345 ); # Load files in channels for realtime play $snd->load(%files); # sets sound channel_01 loudness $snd->loud('channel_01', 80); # loud at 80% $snd->play(%times); # play loaded files at times $snd->play; # play again # plays sound channel_01 at 578 milliseconds from now $snd->play('channel_01', 578); # fades sound $snd->fade('channel_02', 2345, 3456, -20); # in a single act do the whole Sound my $snd = SDLx::Sound->new( files => ( channel_01 => "/my_sound1.wav", channel_02 => "/my_sound2.ogg" ), loud => ( channel_01 => 80, channel_02 => 75 ), times => ( channel_01 => 0, # start channel_01 => 1256, # milliseconds channel_02 => 2345 ), fade => ( channel_02 => [2345, 3456, -20] ) )->play(); DESCRIPTION
You can think about the SDLx::Sound at 2 approaches. o A simple sound or o The sound of your game or app. Your application will say what the best approach. In a taste that resembles to perl and to SDL, our SDLx:Sound hooks at SDL::Audio and SDL::Mixer with a graceful and simple interface that can offer to monks a modern perlish way to manage sounds. An SDLx::Sound object can load sounds from filesystem, play it, adjust this loudness level or stops the sound. Each sound will play in the next available channel, so it can be handled isolately. METHODS
new Returns a new instance of SDLx::Sound load play $sdlx_sound->play('file.wav'); Play a file pause resume stop AUTHORS
See "AUTHORS" in SDL. COPYRIGHT &; LICENSE This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-05-28 pods::SDLx::Sound(3pm)
All times are GMT -4. The time now is 10:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy