Audio Playback


The 3DO system accepts both AIFF files and MIDI files for playback. This section looks at playback of AIFF files, which is done with the SAudio subscriber and player.

This section discusses:

Weaver script commands for audio

When streaming audio, you need to add certain information to the Weaver script and perform some special initialization not needed for other subscribers.

Add the following script commands to the Weaver script:

Initialization for audio

When you use audio, some additional initialization is required. The following example shows code from PlayCPackStream.c in NuPlayer.

Example 1: Initializing the streaming application for audio.

/* If the stream has audio, then do some additional initializations.
     */
    if ( fStreamHasAudio )
        {
        /* Preload audio instrument templates, if any are specified
         */
        if ( ctx->hdr.preloadInstList != 0 )
            {
            ctlBlock.loadTemplates.tagListPtr = ctx->hdr.preloadInstList;
        
            status = DSControl( ctx->messageItem, NULL, ctx->streamCBPtr, 

                                SNDS_CHUNK_TYPE, kSAudioCtlOpLoadTemplates, &ctlBlock );
            if ( status != 0 )
                goto CLEANUP;
            }
    
        /* Enable any audio channels whose enable bit is set.
         * NOTE: Channel zero is enabled by default, so we don't check it.*/
        for ( channelNum = 1; channelNum < 32; channelNum++ )
            {
            /* If the bit corresponding to the channel number is set,
             * then tell the audio subscriber to enable that channel.
             */
            if ( ctx->hdr.enableAudioChan & (1L << channelNum) )
                {
                status = DSSetChannel( ctx->messageItem, NULL, ctx->streamCBPtr, 
                                        SNDS_CHUNK_TYPE, channelNum, CHAN_ENABLED );
                CHECK_DS_RESULT( "DSSetChannel", status );
                if ( status != 0 )
                    goto CLEANUP;
                }
            }
    
        /* Set the audio clock to use the selected channel */    
        ctlBlock.clock.channelNumber = ctx->hdr.audioClockChan;
        status = DSControl( ctx->messageItem, NULL, ctx->streamCBPtr,
                                SNDS_CHUNK_TYPE, kSAudioCtlOpSetClockChan, &ctlBlock );
        CHECK_DS_RESULT( "DSControl - setting audio clock chan", status );
        }