Copyright (c) Hyperion Entertainment and contributors.

Difference between revisions of "AmigaOS Manual: Sounds"

From AmigaOS Documentation Wiki
Jump to navigation Jump to search
(Added example program)
m
Line 1: Line 1:
 
= Playing =
 
= Playing =
/* Program 16. Play.rexx */
+
== Program 16. Play.rexx ==
 
<syntaxhighlight lang="rexx">
 
<syntaxhighlight lang="rexx">
 
/*
 
/*

Revision as of 21:48, 7 August 2017

Playing

Program 16. Play.rexx

/*
** Play AIFF audio file
*/
 
fileName   = 'test.aiff' /* Audio file name */
frequency  = 22050       /* Playback frequency */
volume     = 100         /* Full volume */
unit       = 0           /* Use device unit 0 */
 
/* Audio stream properties */
properties = 'TYPE=AIFF/'
properties = properties || 'FREQUENCY=' || frequency || '/'
properties = properties || 'VOLUME=' || volume || '/'
properties = properties || 'UNIT=0'
 
/* Open 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