ListReference

function

slInitSound


Sound library initialization and driver startup

Form

    #include "sgl.h"

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

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

argument

    Uint8 * sddrvaddr --Sound driver address Uint32 drvsize --Sound driver size Uint8 * map --Sound area map address Uint32 mapsize --Sound area map size

Number of returns

    void --Nothing is returned.

function

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

Example

    extern Uint8 * sddrvs;
    extern Uint32 sddrvsize;

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

caution


    Be sure to execute it before executing all sound functions.
The slInitSystem function does not perform any sound 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 the driver to finish executing

Form

    #include "sgl.h"

    void * addr;

    void slWaitSound (addr);

argument

    void * addr --The address you want to monitor.

Number of returns

    void --Nothing is returned.

function

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

Example

    slWaitSound ( slSndMapChange (2));

reference

 slSndMapChange
 slSoundRequest 


★ CDDA



ListReference

function

slCDDAOn


CDDA volume settings

Form

    #include "sgl.h"

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

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

argument

    Uint8 Lvol --Left volume 
    Uint8 Rvol --Right volume Uint8 Lpan --Left pan Uint8 RPan --Right pan

Number of returns

    Bool- A flag that indicates whether the command was issued correctly.

function

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

Example

    slCDDAOn (127, 127, 0, 0);

reference

 slCDDAOff
 slSndFlush 



ListReference

function

slCDDAOff


CDDA playback stopped

Form

    #include "sgl.h"

    Bool slCDDAOff (void);

argument

    void --Do not give anything.

Number of returns

    Bool- A flag that indicates whether the command was issued correctly.

function

    CDDA playback will stop.
Returns TRUE on success and FALSE on failure.

Example

    slCDDAOff ();

reference

 slCDDAOn
 slSndFlush 


★ PCM



ListReference

function

slPCMOn


Start playing PCM

Form

    #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

Number of returns

    Sint8 --PCM channel number or error code.

function

    Plays music (sound effects) using a PCM sound source.
data is a PCM data table for playback. In the case of stereo, set the right channel and left channel separately for the first half and the second half as shown in the figure below. In normal PCM data, L channel and R channel alternate, and they 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 (normally the return value at the end).
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.
Specify an effect level of 0 to 7 and an effect number of 0 to 15.
The return value of the function is 0 to 7 for normal termination, -1 for insufficient command buffer, Returns -2 if the PCM channel is not free and -3 if there is not enough buffer for the PCM.
The PCM playback started by this function will stop when the data ends.

Example

    slPCMOn (pcm, dat, datsize);

caution


    When transferring PCM playback data to sound RAM. SCU-DMA level 2 is normally used and is forwarded during V-Blank In. However, WorkRAM Low is out of the control of the SCU, so in that case, transfer using CPU-DMA. Therefore, if the playback data is in the WorkRAM-L area, there are the following restrictions.
-Reproduced data is treated as if it is arranged from even-numbered addresses.
(Use with the lower 1 bit of the address set to 0) Therefore, be sure to place the playback data at even-numbered addresses.
-If the playback data is stereo and 8-bit, it is assumed that the data on the left channel is also arranged from even-numbered addresses.
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, define the data by duplicating 1 byte for every 8192 frames.
However, it starts at the 1536 (600H) frame offset.
Therefore, the first data to be duplicated is 6656 (1A00H).
The structure of the PCM structure is different between SGL Ver. 3.20 or later and SGL before that.
If the PCM data was created for an older version of SGL, you need to add the last member of the PCM structure. Please be careful.

reference

 slPCMOff
 slPCMParmChange
 slPCMStat
 slSndPCMNum
 slSndFlush
 DMASt_CPU0
 DMASt_SCU0 



ListReference

function

slPCMOff


Stop playing PCM

Form

    #include "sgl.h"

    PCM * pcm;

    Bool slPCMOff (pcm);

argument

    PCM * pcm-A management structure for the PCM data that is currently ringing.

Number of returns

    Bool- A flag that indicates whether the command was issued correctly.

function

    Stops PCM playback on the specified channel.
Returns TRUE on success and FALSE on failure.

Example

    slPCMOff (pcm);

reference

 slPCMOn
 slPCMParmChange
 slPCMStat
 slSndPCMNum
 slSndFlush 



ListReference

function

slPCMParmChange


Change PCM parameters

Form

    #include "sgl.h"

    PCM * pcm;

    Bool slPCMParmChange (pcm);

argument

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

Number of returns

    Bool- A flag that indicates whether the command was issued correctly.

function

    Change each parameter for PCM playback.
Returns TRUE on success and FALSE on failure.

Example

    extern PCM pcm;

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

reference

 slPCMOn
 slPCMOff
 slPCMStat
 slSndPCMNum
 slSndFlush 



ListReference

function

slPCMStat


Investigation of PCM playback status

Form

    #include "sgl.h"

    PCM * pcm;

    Bool slPCMStat (pcm);

argument

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

Number of returns

    Bool- A flag that indicates whether the command was issued correctly.

function

    Checks if the PCM for the specified channel is playing and returns a flag.
TRUE is returned if it is playing, and FALSE is returned if it is finished.

Example

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

reference

 slPCMOn
 slPCMOff
 slPCMParmChange
 slSndPCMNum
 slSndFlush 



ListReference

function

slSndPCMNum


Check for free PCM ports

Form

    #include "sgl.h"

    Uint8 mode;

    Sint8 slSndPCMNum (mode);

argument

    Uint8 mode-Mode (stereo or monaural) (see below)

Number of returns

    Sint8 --The number of the free PCM channel.

function

    Returns a free PCM channel number.
If there is no space, -1 is returned, and if it ends normally, 0 to 7 is returned.
Specify _Stereo or _Mono for mode.
PCM can play up to 8 sounds, but for stereo playback, Please note that you will need two notes, so even if you only have four notes, you may have eight notes.

Example

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

reference

 slPCMOn
 slPCMOff
 slPCMParmChange
 slPCMStat
 DMASt_CPU0
 DMASt_SCU0 


★ Effects / mixer



ListReference

function

slSndEffect


Change effect

Form

    #include "sgl.h"

    Uint8 effect;

    Bool slSndEffect (effect);

argument

    Uint8 efct-Effect number.

Number of returns

    Bool- A flag that indicates whether the command was issued correctly.

function

    Switches the sound effect by DSP.
Returns TRUE on success and FALSE on failure.

Example

    Assuming that the mixer that outputs no effect is 0 and the original mixer is 1,
    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 the generation of noise when changing effects.

caution


    When changing effects, considerable noise may occur depending on the type of effect.
As a way to suppress this, first make a mixer that does not output any effect in advance, and before changing the effect, Use the slSndMixParmChange function to switch to that effect.
After that, execute slSndEffect , switch the effect, and then wait for about 1 second until the sound stabilizes. Then again Use the slSndMixParmChange function to revert 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, the slSndVolume function can be used to deceive by lowering the total volume, but in this case, all sound sources will be affected, so be careful.

reference

 slSndMixParmChange
 slSndVolume
 slSndFlush 



ListReference

function

slSndMixParmChange


Mixer changes

Form

    #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

Number of returns

    Bool- A flag that indicates whether the command was issued correctly.

function

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

Example

    slSndMixParmChange (1, 127, 0);

reference

 slSndFlush 


★ Command issuance



ListReference

function

slSoundRequest


Issuing commands to the sound driver

Form

    #include "sgl.h"

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

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

argument

    const char * form --Format of the following arguments arg1, arg2, ... --Parameters

Number of returns

    Sint8 --Function execution status (status)

function

    Set the data to be passed directly to the sound driver.
The form represents the individual size of the data that follows it as string data.
However, the first data is the function code and is not included in the character string.
The return value is -2, if there are invalid characters in the form string. Returns -1 if you try to set word data from an odd address.
Returns 0 if successful.

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 is the function code and is not included in the string.
_Stereo | _PCM16Bit , Lev << 5 | 0 is byte data, respectively StreamBuf >> 4, StreamSize, Pitch are passed to the sound driver as word data respectively.

reference

 slSndFlush 



ListReference

function

slDSPOff


DSP stop

Form

    #include "sgl.h"

    Bool slDSPOff (void);

argument

    void --Do not give anything.

Number of returns

    Bool- A flag that indicates whether the command was issued correctly.

function

    Initializes (stops) the DSP.
If it succeeds, the address of the command buffer in which the parameter is set is returned, and if it fails, FALSE is returned as the return value.

Example

    slDSPOff ();

reference

 slSndFlush
 SoundRdCount 



ListReference

function

slSndVolume


Change the overall volume

Form

    #include "sgl.h"

    Uint8 vol;

    Bool slSndVolume (vol);

argument

    Uint8 vol --The volume of the entire sound.

Number of returns

    Bool- A flag that indicates whether the command was issued correctly.

function

    Sets the volume of the entire sound output.
vol specifies 0 to 127 (however, the lower 4 bits are invalid).
If it is 0, no sound is output.
If the volume change is successful, TRUE is returned, and if it is unsuccessful, FALSE is returned as the return value.

Example

    slSndVolume (10 << 3);

reference



ListReference

function

slSoundAllOff


Stop playing all sequences

Form

    #include "sgl.h"

    Bool slSoundAllOff (void);

argument

    void --Do not give anything.

Number of returns

    Bool-A flag that indicates whether the command was issued correctly.

function

    Stops all sound sequences.
Returns TRUE on success and FALSE on failure.

Example

    slSoundAllOff ();

caution


    Executing this function cancels any unprocessed sound processing in the sound command buffer.
Also, execution is immediate without waiting for slSynch.

reference

 slSoundAllPause
 slSoundAllCont
 slSndFlush
 SoundRdCount 



ListReference

function

slSoundAllPause


Pause playing all sequences

Form

    #include "sgl.h"

    void slSoundAllPause (void);

argument

    void --Do not give anything.

Number of returns

    void --Nothing is returned.

function

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

Example

    slSoundAllPause ();

reference

 slSoundAllCont
 slSoundAllOff
 slSndFlush
 SoundRdCount 



ListReference

function

slSoundAllCont


Resume playing all sequences

Form

    #include "sgl.h"

    void slSoundAllCont (void);

argument

    void --Do not give anything.

Number of returns

    void --Nothing is returned.

function

    Resume all paused sequences (including background music).

Example

    slSoundAllCont ();

reference

 slSoundAllPause
 slSoundAllOff
 slSndFlush
 SoundRdCount 



ListReference

function

slSndFlush


Sending a command request

Form

    #include "sgl.h"

    void slSndFlush (void);

argument

    void --Do not give anything.

Number of returns

    void --Nothing is returned.

function

     Outputs the control commands remaining in the sound control buffer to the sound driver.
Sound control commands are usually set in a system-provided buffer and output to the sound driver when the buffer is full or the slSynch () function is executed.
However, in the following functions, the buffer is output immediately.
slSndMapChange () slDSPOff () slPCMOff () slSoundRequest () slSoundAllPause () slSoundAllCont () Also, if you execute the following function, the command 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