Copyright (c) Hyperion Entertainment and contributors.

AmigaOS Manual: Sounds

From AmigaOS Documentation Wiki
Revision as of 20:24, 8 August 2017 by Janne Peräaho (talk | contribs)
Jump to navigation Jump to search

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' )

Recording