Japanese

ListReference

function

slInitSound


Initialize the sound library and start the driver

Format

    #include "sgl.h"

    Uint8 *sddrvaddr;
    Uint32 drvsize;
    Uint8 *map;
    Uint32 mapsize;

    void slInitSound( sddrv, drvsize, map, mapsize );

argument

    Uint8 *sddrvaddr - Address of the sound driver
    Uint32 drvsize - Size of the sound driver
    Uint8 *map - Address of the sound area map
    Uint32 mapsize - Size of the sound area map

Return number

    void - returns nothing.

function

Set the sound driver and initialize the sound control CPU (MC68000).
The sound driver is compatible with version 2.00 or later. It cannot be run with earlier sound drivers.

example

    extern Uint8 *sddrvs;
    extern Uint32 sddrvsize;

    Uint8 map[ 256 ];
    Uint32 mapsz = 256;
    slInitSound ( sddrvs, sddrvszize, map, mzpsz );

Note

Be sure to run it before running any sound functions.
The slInitSystem function does not perform any sound-related initialization.

reference

 slBGMOn
 slBGMPause
 slBGMCont
 slBGMOff
 slBGMFade
 slBGMTempo
 slBGMStat
 slSoundAllOff
 slDSPOff
 slSndVolume
 slSequenceOn
 slSequenceOff
 slSequenceFade
 slSequenceTempo
 slSequencePause
 slSequenceCont
 slSequencePan
 slSequenceReset
 slSequenceStat
 slSndMapChange
 slSndSeqNum
 slSndPCMNum
 slWaitSound
 slCDDAOn
 slCDDAOff
 slPCMOn
 slPCMOff
 slPCMParmChange
 slPCMStat
 slSndEffect
 slSndMixParmChange
 slSoundRequest
 slSoundAllPause
 slSoundAllCont
 slSndFlush
 NbPCMBf
 PCMBufFlag 



ListReference

function

slWaitSound


Wait for driver to finish running

Format

    #include "sgl.h"

    void *addr;

    void slWaitSound( addr );

argument

    void *addr - Address you want to monitor.

Return number

    void - returns nothing.

function

Waits until the data at the specified address becomes 0.
Indicates that the sound driver has executed a function.

example

    slWaitSound ( slSndMapChange ( 2 ) );

reference

 slSndMapChange
 slSoundRequest 


★CDDA



ListReference

function

slCDDAOn


CDDA volume setting

Format

    #include "sgl.h"

    Uint8 Lvol;
    Uint8 Rvol;
    Uint8 Lpan;
    Uint8 RPan;

    Bool slCDDAOn( Lvol, Rvol, Lpan, Rpan );

argument

    Uint8 Lvol - Left volume 
    Uint8 Rvol - Volume to the right
    Uint8 Lpan - Pan to the left
    Uint8 RPan - Pan to the right

Return number

    Bool - Flag indicating whether the command was issued correctly.

function

Specify the volume and direction when using CDDA.
Volume is from 0 (Off) to 127 (lower 4 bits are invalid), pan is (left -127 ~ 0 ~ +127 right) (However, the lower 3 bits are invalid).
Returns TRUE if successful, FALSE if unsuccessful.

example

    slCDDAOn ( 127, 127, 0, 0 );

reference

 slCDDAOff
 slSndFlush 



ListReference

function

slCDDAOff


Canceling CDDA playback

Format

    #include "sgl.h"

    Bool slCDDAOff( void );

argument

    void - gives nothing.

Return number

    Bool - Flag indicating whether the command was issued correctly.

function

Stops playing CDDA.
Returns TRUE if successful, FALSE if unsuccessful.

example

    slCDDAOff ();

reference

 slCDDAOn
 slSndFlush 


★PCM



ListReference

function

slPCMOn


PCM starts playing

Format

    #include "sgl.h"

    PCM *pcm;
    void *data;
    Uint32 size;

    Sint8 slPCMOn( pcm, data, size );

argument

    PCM *pcm - PCM data management structure
    void *data - PCM data entity
    Uint32 size - PCM data size

Return number

    Sint8 - PCM channel number or error code.

function

Plays music (sound effects) using a PCM sound source.
data is the PCM data table for playback, and in the case of stereo, please set it separately for the right channel and left channel into the first half and second half, as shown in the figure below. In normal PCM data, the L channel and R channel come alternately and are not separated as shown in the figure below.
      +---------------+
      |               |
      |    R data     |
      | (frame * datasize byte)
      +---------------+
      |               |
      |    L data     |
      |               |
      +---------------+
PCM type data is a structure in the following format.
      typedef struct {
        Uint8 mode; /* Playback mode */
        Uint8 channel; /* Playback channel */
        Uint8 level; /* Playback level */
        Sint8 pan; /* Playback pan */
        Uint16 pitch; /* Playback pitch */
        Uint8 eflevelR; /* Effect level (for right and monaural) */
        Uint8 efselectR; /* Effect number (for right and monaural) */
        Uint8 eflevelL; /* Effect level (for left) */
        Uint8 efselectL; /* Effect number (for left) */
      }PCM;
Set the playback mode as follows.
< _Stereo or _Mono > and < _PCM16Bit is _PCM8Bit The playback channel is set by the slPCMOn function (normal return value upon termination).
Playback level is 0 to 127 (lower 4 bits are invalid), Set the playback pan to (left -127 to 0 to +127 right) (lower 8 bits are invalid).
The playback pitch is 16 bits and specifies the rate for 44.1kHz.
Please specify the effect level from 0 to 7 and the effect number from 0 to 15.
The return value of the function is 0 to 7 for normal termination, -1 if there is not enough command buffer, Returns -2 if there are no free PCM channels, and -3 if there are not enough buffers for PCM.
PCM playback started with this function will stop when the data ends.

example

    slPCMOn ( pcm , dat, datsize );

Note

When transferring PCM playback data to sound RAM. Normally SCU-DMA level 2 is used and transferred at V-Blank In. However, WorkRAM Low is out of SCU control, so in that case, CPU-DMA is used for transfer. Therefore, if the playback data is in the WorkRAM-L area, the following restrictions apply.
- Playback data is treated as being arranged starting from even addresses.
(Use with the lower 1 bit of the address set to 0) Therefore, be sure to place playback data at even-numbered addresses.
- If the playback data is stereo and 8 bits, it is assumed that the left channel data is also arranged starting from an even address.
This means that when playing stereo data, the number of samples must be an even number.
- If the playback data is 8192 frames or more, noise may occur when wrapping the buffer.
Therefore, please define data with 1 byte overlap every 8192 frames.
However, the beginning starts from an offset of 1536 (600H) frames.
Therefore, the first data to be duplicated will be data 6656 (1A00H).
The structure of the PCM structure differs between SGL Ver. 3.20 and later and earlier SGL versions.
If the PCM data was created for an older version of SGL, you will need to add the last member of the PCM structure. please note.

reference

 slPCMOff
 slPCMParmChange
 slPCMStat
 slSndPCMNum
 slSndFlush
 DMASt_CPU0
 DMASt_SCU0 



ListReference

function

slPCMOff


PCM performance stopped

Format

    #include "sgl.h"

    PCM *pcm;

    Bool slPCMOff( pcm );

argument

    PCM *pcm - Management structure for the currently sounding PCM data.

Return number

    Bool - Flag indicating whether the command was issued correctly.

function

Stops PCM playback of the specified channel.
Returns TRUE if successful, FALSE if unsuccessful.

example

    slPCMOff ( pcm );

reference

 slPCMOn
 slPCMParmChange
 slPCMStat
 slSndPCMNum
 slSndFlush 



ListReference

function

slPCMParmChange


Modifying PCM parameters

Format

    #include "sgl.h"

    PCM *pcm;

    Bool slPCMParmChange( pcm );

argument

    PCM *pcm - Management structure for the PCM data you want to change.

Return number

    Bool - Flag indicating whether the command was issued correctly.

function

Change each parameter for PCM playback.
Returns TRUE if successful, FALSE if unsuccessful.

example

    extern PCM pcm;

    pcm.pitch += 100;
    slPCMParmChange ( pcm );

reference

 slPCMOn
 slPCMOff
 slPCMStat
 slSndPCMNum
 slSndFlush 



ListReference

function

slPCMStat


Investigating PCM playback status

Format

    #include "sgl.h"

    PCM *pcm;

    Bool slPCMStat( pcm );

argument

    PCM *pcm - Management structure for the PCM data you want to investigate.

Return number

    Bool - Flag indicating whether the command was issued correctly.

function

Checks whether the specified channel's PCM is being played and returns the flag.
Returns TRUE if the playback is in progress, FALSE if the playback has ended.

example

    if ( slPCMStat ( pcm ) == TRUE ) {
      /* Playing */
    } else {
      /* End of playback */
    }

reference

 slPCMOn
 slPCMOff
 slPCMParmChange
 slSndPCMNum
 slSndFlush 



ListReference

function

slSndPCMNum


Check for free PCM ports

Format

    #include "sgl.h"

    Uint8 mode;

    Sint8 slSndPCMNum( mode );

argument

    Uint8 mode - Mode (stereo or monaural) (described later)

Return number

    Sint8 - number of free PCM channel.

function

Returns the free PCM channel number.
-1 is returned if there is no space, and 0 to 7 is returned if it completes normally.
Specify _Stereo or _Mono for mode.
PCM can play up to 8 sounds, but when playing in stereo, Please note that two notes are required, so even if only four are playing, there may be eight notes.

example

    if ( slSndPCMNum ( _Stereo ) != -1 ) {
      slPCMOn ( ... )
    }

reference

 slPCMOn
 slPCMOff
 slPCMParmChange
 slPCMStat
 DMASt_CPU0
 DMASt_SCU0 


★Effects/Mixer



ListReference

function

slSndEffect


Change effects

Format

    #include "sgl.h"

    Uint8 effect;

    Bool slSndEffect( effect );

argument

    Uint8 efct - Effect number.

Return number

    Bool - Flag indicating whether the command was issued correctly.

function

Switch the sound effects by DSP.
Returns TRUE if successful, FALSE if unsuccessful.

example

    If the mixer that outputs no effect is 0, and the original mixer is 1, then
    slSndMixParmChange ( 0, 127, 0 );
    slSndEffect ( 1 );
    for ( i = 0 ; i < 60 ; ++i ) slSynch();
    slSndMixParmChange ( 1, 127, 0 );
    This is an example of how to suppress noise when changing effects.

Note

Depending on the type of effect, a considerable amount of noise may be generated when changing effects.
As a way to suppress this, first create a mixer that does not output any effects, and then before changing the effect, Switch to that effect using the slSndMixParmChange function.
After that, execute slSndEffect , switch the effect, and wait for about 1 second until the sound stabilizes. Then again, Use the slSndMixParmChange function to return to the original mixer.
However, there may be a slight noise when first switching to a mixer that does not output effects. In that case, you can fool the problem by lowering the total volume using the slSndVolume function, but be careful as this will affect all sound sources.

reference

 slSndMixParmChange
 slSndVolume
 slSndFlush 



ListReference

function

slSndMixParmChange


Change mixer

Format

    #include "sgl.h"

    Uint8 mix;
    Uint8 vol;
    Sint8 pan;

    Bool slSndMixParmChange( mix, vol, pan );

argument

    Uint8 mix - Mixer number
    Uint8 vol - Volume
    Sint8 pan - Pan

Return number

    Bool - Flag indicating whether the command was issued correctly.

function

Change mixer parameters.
vol is 0 to 127 (lower 4 bits are invalid), pan is (left -128 to 0 to +127 right) (lower 3 bits are invalid).
Returns TRUE on success, FALSE on failure.

example

    slSndMixParmChange ( 1, 127, 0 );

reference

 slSndFlush 


★Command issue



ListReference

function

slSoundRequest


Issuing commands to the sound driver

Format

    #include "sgl.h"

    const char *form;
    /* arg1, arg2, ... */

    Sint8 slSoundRequest( form[], ...);

argument

    const char *form - Format of next argument arg1, arg2, ... - Parameter

Return number

    Sint8 - Function execution status (status)

function

Sets data to be passed directly to the sound driver.
form represents the size of each piece of data that follows as string data.
However, the first data is a function code and is not included in the string.
The return value is -2 if there is an illegal character in the form string, If you try to set word data from an odd address, -1 is returned.
Returns 0 if it completes normally.

example

    Uint16 Lev;
    Uint8 *data;
    Uint16 StreamBuf;
    Uint16 StreamSize;
    Uint16 Pitch;

    StreamBuf = ( Uint16 )( data >> 4 );
    Lev = 7; /* Set Volume to max */

    slSoundRequest ( "bbwwwbb", SND_PCM_START , _Stereo | _PCM16Bit , Lev << 5 | 0,
                    StreamBuf, StreamSize, Pitch, 0, 0 );
    In this case, SND_PCM_START becomes the function code and is not included in the string.
_Stereo | _PCM16Bit , Lev << 5 | 0 are byte data, StreamBuf >> 4, StreamSize, Pitch are each passed to the sound driver as word data.

reference

 slSndFlush 



ListReference

function

slDSPOff


Stopping DSP

Format

    #include "sgl.h"

    Bool slDSPOff( void );

argument

    void - gives nothing.

Return number

    Bool - Flag indicating whether the command was issued correctly.

function

Initialize (stop) the DSP.
If successful, returns the address of the command buffer where the parameter was set; otherwise, returns FALSE .

example

    slDSPOff ();

reference

 slSndFlush
 SoundRdCount 



ListReference

function

slSndVolume


Change overall volume

Format

    #include "sgl.h"

    Uint8 vol;

    Bool slSndVolume( vol );

argument

    Uint8 vol - Overall volume of the sound.

Return number

    Bool - Flag indicating whether the command was issued correctly.

function

Sets the overall volume of the sound output.
Specify vol from 0 to 127 (however, the lower 4 bits are invalid).
Also, if it is 0, no sound will be output.
Returns TRUE if the volume change is successful, otherwise returns FALSE .

example

    slSndVolume( 10 << 3 );

reference



ListReference

function

slSoundAllOff


Stop playing all sequences

Format

    #include "sgl.h"

    Bool slSoundAllOff( void );

argument

    void - gives nothing.

Return number

    Bool - Flag indicating whether the command was issued correctly.

function

Stop all sound sequences.
Returns TRUE if successful, FALSE if unsuccessful.

example

    slSoundAllOff ();

Note

Executing this function cancels all unprocessed sound processing in the sound command buffer.
Also, execution occurs immediately without waiting for slSynch .

reference

 slSoundAllPause
 slSoundAllCont
 slSndFlush
 SoundRdCount 



ListReference

function

slSoundAllPause


Pause playback of all sequences

Format

    #include "sgl.h"

    void slSoundAllPause( void );

argument

    void - gives nothing.

Return number

    void - returns nothing.

function

Pauses the entire sequence being played (including BGM). (However, the PCM stream does not stop)

example

    slSoundAllPause ();

reference

 slSoundAllCont
 slSoundAllOff
 slSndFlush
 SoundRdCount 



ListReference

function

slSoundAllCont


Resume playing all sequences

Format

    #include "sgl.h"

    void slSoundAllCont( void );

argument

    void - gives nothing.

Return number

    void - returns nothing.

function

Resumes all paused sequences (including BGM).

example

    slSoundAllCont ();

reference

 slSoundAllPause
 slSoundAllOff
 slSndFlush
 SoundRdCount 



ListReference

function

slSndFlush


Sending a command request

Format

    #include "sgl.h"

    void slSndFlush( void );

argument

    void - gives nothing.

Return number

    void - returns nothing.

function

Outputs the control commands remaining in the sound control buffer to the sound driver.
Normally, sound control commands are set in a buffer provided by the system, and are output to the sound driver when the buffer becomes full or when the slSynch () function is executed.
However, in the following functions, the buffer is output immediately.
slSndMapChange () slDSPOff () slPCMOff () slSoundRequest () slSoundAllPause () slSoundAllCont () Additionally, if you execute the following function, the commands in the buffer will be discarded.
slSoundAllOff ()

example

    slSndFlush ();

reference

 slBGMOn
 slBGMPause
 slBGMCont
 slBGMOff
 slBGMFade
 slBGMTempo
 slBGMStat
 slSoundAllOff
 slDSPOff
 slSndVolume
 slSequenceOn
 slSequenceOff
 slSequenceFade
 slSequenceTempo
 slSequencePause
 slSequenceCont
 slSequencePan
 slSequenceReset
 slSequenceStat
 slSndMapChange
 slSndSeqNum
 slSndPCMNum
 slCDDAOn
 slCDDAOff
 slPCMOn
 slPCMOff
 slPCMParmChange
 slPCMStat
 slSndEffect
 slSndMixParmChange
 slSoundRequest
 slSoundAllPause
 slSoundAllCont

return
Copyright SEGA ENTERPRISES, LTD., 1997