Copyright (c) Hyperion Entertainment and contributors.
AmigaOS Manual: Sounds: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
mNo edit summary |
mNo edit summary |
||
| Line 3: | Line 3: | ||
<syntaxhighlight lang="rexx"> |
<syntaxhighlight lang="rexx"> |
||
/* |
/* |
||
** Play AIFF audio file |
** Play an AIFF audio file |
||
*/ |
*/ |
||
fileName = ' |
fileName = 'recording.aiff' /* Audio file name */ |
||
frequency = 22050 /* Playback frequency */ |
frequency = 22050 /* Playback frequency */ |
||
volume = 100 /* Full volume */ |
volume = 100 /* Full volume */ |
||
unit = 0 /* Use device unit 0 */ |
unit = 0 /* Use device unit 0 */ |
||
/* |
/* Playback properties */ |
||
properties = 'TYPE=AIFF/' |
properties = 'TYPE=AIFF/' |
||
properties = properties || 'FREQUENCY=' || frequency || '/' |
properties = properties || 'FREQUENCY=' || frequency || '/' |
||
| Line 17: | Line 17: | ||
properties = properties || 'UNIT=0' |
properties = properties || 'UNIT=0' |
||
/* Open stream */ |
/* Open audio stream */ |
||
IF ( ~OPEN( 'audio', 'AUDIO:' || properties, |
IF ( ~OPEN( 'audio', 'AUDIO:' || properties, 'W' ) ) THEN DO |
||
SAY 'Failed to open audio stream.' |
SAY 'Failed to open audio stream.' |
||
exit 0 |
|||
END |
END |
||
/* Open audio file */ |
/* Open audio file */ |
||
IF ( OPEN( 'file', fileName, |
IF ( OPEN( 'file', fileName, 'R' ) ) THEN DO |
||
/* Play */ |
/* Play */ |
||
DO UNTIL ( EOF( 'file' ) = 1 ) |
DO UNTIL ( EOF( 'file' ) = 1 ) |
||
Revision as of 19:24, 8 August 2017
Playing
Program 16. Play.rexx
/*
** Play an AIFF audio file
*/
fileName = 'recording.aiff' /* Audio file name */
frequency = 22050 /* Playback frequency */
volume = 100 /* Full volume */
unit = 0 /* Use device unit 0 */
/* Playback properties */
properties = 'TYPE=AIFF/'
properties = properties || 'FREQUENCY=' || frequency || '/'
properties = properties || 'VOLUME=' || volume || '/'
properties = properties || 'UNIT=0'
/* Open audio stream */
IF ( ~OPEN( 'audio', 'AUDIO:' || properties, 'W' ) ) THEN DO
SAY 'Failed to open audio stream.'
exit 0
END
/* Open audio file */
IF ( OPEN( 'file', fileName, 'R' ) ) THEN DO
/* Play */
DO UNTIL ( EOF( 'file' ) = 1 )
buffer = READCH( 'file', 4096 )
WRITECH( 'audio', buffer )
END
/* Close audio file */
CLOSE( 'file' )
END
ELSE DO
SAY 'Failed to open file "' || fileName || '".'
END
/* Close stream */
CLOSE( 'audio' )