Play recorded sounds: Difference between revisions
Content added Content deleted
m (wording) |
(→Tcl: Added implementation) |
||
Line 15: | Line 15: | ||
Where applicable, please categorize examples primarily by the audio facility used (library/API/program/platform) rather than the language if the language is incidental (e.g. "Mac OS X CoreAudio" or "mplayer" rather than "C" or "bash"). |
Where applicable, please categorize examples primarily by the audio facility used (library/API/program/platform) rather than the language if the language is incidental (e.g. "Mac OS X CoreAudio" or "mplayer" rather than "C" or "bash"). |
||
=={{header|Tcl}}== |
|||
{{libheader|snack}} |
|||
<lang tcl>package require sound |
|||
# Potentially also require driver support for particular formats |
|||
# Load some sounds in |
|||
snack::sound s1 |
|||
s1 read $soundFile1 |
|||
snack::sound s2 |
|||
s2 read $soundFile2 |
|||
# Play a sound for a while (10 seconds) |
|||
s1 play |
|||
after 10000 set done 1; vwait done; # Run the event loop for a while |
|||
s1 stop |
|||
# Play two sounds at once (for 30 seconds) while mixing together |
|||
s1 play |
|||
s2 play |
|||
after 30000 set done 1; vwait done |
|||
s1 stop |
|||
s2 stop</lang> |
Revision as of 08:39, 11 June 2009
Play recorded sounds
You are encouraged to solve this task according to the task description, using any language you may know.
You are encouraged to solve this task according to the task description, using any language you may know.
Load at least two prerecorded sounds, and demonstrate as many of these features as you can:
- playing them individually and simultaneously
- stopping before the end of the sound
- looping (preferably glitch-free)
- setting the volume of each sound
- stereo or 3D positional mixing
- performing other actions when marked times in the sound arrive
Describe:
- The supported audio formats, briefly.
- Whether it is suitable for game sound effects (low-latency start, resource efficiency, supports many simultaneous sounds, etc.)
- Whether it is suitable for playing music (long duration ).
[Note: If it seems to be a good idea, this task may be revised to specify a particular timeline rather than just 'demonstrate these features'.]
Where applicable, please categorize examples primarily by the audio facility used (library/API/program/platform) rather than the language if the language is incidental (e.g. "Mac OS X CoreAudio" or "mplayer" rather than "C" or "bash").
Tcl
<lang tcl>package require sound
- Potentially also require driver support for particular formats
- Load some sounds in
snack::sound s1 s1 read $soundFile1 snack::sound s2 s2 read $soundFile2
- Play a sound for a while (10 seconds)
s1 play after 10000 set done 1; vwait done; # Run the event loop for a while s1 stop
- Play two sounds at once (for 30 seconds) while mixing together
s1 play s2 play after 30000 set done 1; vwait done s1 stop s2 stop</lang>