SND_SetupChannelPsg

Syntax

#include <nitro/snd.h>
void SND_SetupChannelPsg(
        int chNo,
        SNDDuty duty,
        int volume,
        SNDChannelDataShift shift,
        int timer,
        int pan );

Arguments

chNo The channel number. Takes a value between 8 and 13.
duty Duty ratio.
volume The volume. Takes a value between 0 and 127.
shift Data shift specification.
timer The timer. Takes a value between 0x10 and 0xffff.
pan The pan. Takes values in the range of 0 (left) to 64 (center) to 127 (right).

Return Values

None.

Description

This function sets up a channel for playing PSG rectangular waves.

The function sets the parameters for the channel specified by chNo. The channel must first be locked by the SND_LockChannel function. Once the parameters have been set, call the SND_StartTimer function to begin actual playback.

Select the PSG rectangular wave duty ratio duty from the following values:

Table: SNDDuty

Label Description
SND_DUTY_1_8 1/8 (12.5%) duty
SND_DUTY_2_8 2/8 (25.0%) duty
SND_DUTY_3_8 3/8 (37.5%) duty
SND_DUTY_4_8 4/8 (50.0%) duty
SND_DUTY_5_8 5/8 (62.5%) duty
SND_DUTY_6_8 6/8 (75.0%) duty
SND_DUTY_7_8 7/8 (87.5%) duty

Choose from among these values for the data shift setting shift:

Table. SNDChannelDataShift

Label Description
SND_CHANNEL_DATASHIFT_NONE Do not perform a data shift.
SND_CHANNEL_DATASHIFT_1BIT Shift data 1 bit right.
SND_CHANNEL_DATASHIFT_2BIT Shift data 2 bits right.
SND_CHANNEL_DATASHIFT_4BIT Shift data 4 bits right.

timer specifies 8 cycles of white noise by clock count. The number of ticks per second is approximately 16.757 MHz with SND_TIMER_CLOCK. For example, the following calculation will play a pitch that has a frequency freq Hz.

timer = SND_TIMER_CLOCK / ( 8 * freq )

Note

This function is an ARM7 reserved function. After this function is called, its processing will occur only after the command is issued with the SND_FlushCommand function.

If program execution must be synchronized with process completion, first use the SND_GetCurrentCommandTag function to obtain the command tag immediately after calling this function. Then, after the command is issued, use the command tag and call either the SND_IsFinishedCommandTag or SND_WaitForCommandProc function to confirm that processing has finished or to wait for it to complete.

See Also

SND_LockChannel, SND_StartTimer, SND_FlushCommand, SND_GetCurrentCommandTag, SND_IsFinishedCommandTag, SND_WaitForCommandProc

Revision History

2005/02/17 Added a note about ARM7 command processing.
2004/08/10 Initial version.


CONFIDENTIAL