CRI Middleware Library Reference Manual : ADXT

Constants

[Menu]

ADXT_STAT_~
Handle status

Description

Sound output status

Define | Remarks
--- | ---
ADXT_STAT_STOP | Stopped
ADXT_STAT_DECINFO | Getting ADX header information
ADXT_STAT_PREP | Preparing for playback
ADXT_STAT_PLAYING | Decoding and playback in progress
ADXT_STAT_DECEND | Decoding completed
ADXT_STAT_PLAYEND | Playback ended
ADXT_STAT_ERROR | Error occurred

[Menu]

ADXT_PLY_~
Play method

Description

The following constants are play method.

These constants are used 'ADXT_CALC_WORK' macro

Define | Remarks
--- | ---
ADXT_PLY_MEM | Play memory data
ADXT_PLY_STM | Stream play from disc

Process Macros

[Menu]

ADXT_CALC_WORK
Calculates work buffer size

Format
int ADXT_CALC_WORK(nch, stmflg, nstm, sfreq);
Input

nch: maximum number of playback (monaural:1, stereo:2)

stmflg: playback mode

ADXT_PLY_MEM: memory playback

ADXT_PLY_STM: stream playback

nstm: maximum number of DISC streams

sfreq: maximum playback sampling frequency

Output

None.

Return Value

Work area size (bytes)

Description

Calculates the work area size for each ADXT handle.

The maximum number of DISC streams specifies the number of streams that can be read from DISC simultaneously.

When reading from DISC, this is the sum of ADXT handles used simultaneously.

Remarks

The work area size calculation formula is as follows.

work area = input buffer size + output buffer size

(sampling frequency 48000Hz, mono)

| Memory playback | DISC stream playback
--- | --- | ---
Input buffer size | 0 byte | 25Kbyte +25Kbyte* number of concurrent playback streams
Output buffer size | 16Kbyte | 16Kbyte

*1 For stereo playback, double the area is required.

*2 The input buffer can be reduced according to the sampling frequency.

[Menu]

ADXT_CALC_WORK_3D
Calculates 3D work buffer size

Format
int ADXT_CALC_WORK_3D(stmflg, nstm, sfreq);
Input

stmflg: playback mode

ADXT_PLY_MEM: memory playback

ADXT_PLY_STM: stream playback

nstm: maximum number of DISC streams

sfreq: maximum playback sampling frequency

Output

None.

Return Value

Work area size (bytes)

Description

Calculates the work area size for each ADXT handle.

The maximum number of DISC streams specifies the number of streams that can be read from DISC simultaneously.

When reading from DISC, this is the sum of ADXT handles and ADXF handles used simultaneously.

Data Types

[Menu]

ADXT
ADXT handle

Description ADXT handle controls ADX playback. It is generated by the ADXT_Creat function.

Functions

[Menu]

ADXT_Init
ADX library initialization

Format
void ADXT_Init(void);
Input

None.

Output

None.

Return Value

None.

Description

Initializes the ADX library.

Remarks

Registers the server function with the Vsync interrupt.

[Menu]

ADXT_Finish
ADX library finalization

Format
void ADXT_Finish(void);
Input

None.

Output

None.

Return Value

None.

Description

Performs shutdown processing for the ADX library. Deletes created handles

Example

    /* ADX library initialization */
    ADXT_Init();
        :
    /* ADX library finalization */
    ADXT_Finish();

[Menu]

ADXT_Create
ADXT handle creation

Format
ADXT ADXT_Create(Sint32 maxnch, void *work, Sint32 worksize);
Input

maxnch: maximum number of playback channels (mono=1, stereo=2)

work: work area

worksize: work area size

Output

None.

Return Value

Pointer to generated ADXT structure element (ADXT handle)

Description

Creates an ADXT handle.

Remarks

maxnch should be set to "1" for mono playback only and to "2" for stereo playback.

Also when maxnch is set to "2", mono playback is possible.

The work area is allocated by the syMalloc function.

[Menu]

ADXT_Destroy
ADXT handle deletion

Format
void ADXT_Destroy(ADXT adxt);
Input

adxt: ADXT handle

Output

None.

Return Value

None.

Description

Deletes the specified ADXT handle.

Example

    /* work area size */
    #define WKSIZE ADXT_CALC_WORK(2, ADXT_PLY_STM, 1, 48000)

    Uint8 *work[WKSIZE];    /* work area */
    ADXT adxt;              /* ADXT handle */

    /* Create ADXT handle */
    adxt = ADXT_Create(2, work, WKSIZE);
        :
    ADXT_Destroy(adxt);/* delete ADXT handle */

[Menu]

ADXT_DestroyAll
All ADXT handle deletion

Format
void ADXT_DestroyAll(void);
Input

None.

Output

None.

Return Value

None.

Description

Deletes the all ADXT handle.

[Menu]

ADXT_StartFname
Start playback from disc

Format
void ADXT_StartFname(ADXT adxt, const Char8 *fname);
Input

adxt: ADXT handle

fnmae: sound file name

Output

None.

Return Value

None.

Description

Starts playback of file specified by fname. When the function is executed for a handle that is already being played, sound output stops and playback of the specified file starts. ADX files and WAV files can be specified as sound files. By executing the function for different handles, several sound files can be played simultaneously.

Example

    /* playing back 1 stream of 48 kHz stereo data */
    #define WKSIZE ADXT_CALC_WORK(2, ADXT_PLY_STM, 1, 48000)

    Uint8 *work[WKSIZE];    /* work area */
    ADXT adxt;              /* ADXT handle */

    /* Create ADXT handle */
    adxt = ADXT_Create(2, work, WKSIZE);
    /* Start playback */
    ADXT_StartFname(adxt, "MUSIC.ADX");
        :
    /* Start playback */
    ADXT_StartFname(adxt, "SE2.WAV");
        :

[Menu]

ADXT_StartFnameRange
Start playback from disc by specified the range

Format
void ADXT_StartFnameRange(ADXT adxt, const Char8 *fname, Sint32 offset_sct, Sint32 range_sct);
Input

adxt: ADXT handle

fname: sound file name

offset_sct:offset[sector]

range_sct:size[sector]

Output

None.

Return Value

None.

Description

Starts playback of file specified by fname and the range.

[Menu]

ADXT_StartMem
Start playback from memory

Format
void ADXT_StartMem(ADXT adxt, void *adxdat);
Input

adxt: ADXT handle

adxdat: sound data address

Output

None.

Return Value

None.

Description

Plays sound data in memory specified by adxdat. Allows sound playback with better response than DISC stream playback. Delay time is approx. 50 milliseconds.

Example

    /* When playing mono data */
    #define WKSIZE ADXT_CALC_WORK(1, ADXT_PLY_MEM, 0, 0)

    Uint8 *work[WKSIZE];        /* work area */
    Uint8 adxdat[ADXDAT_SIZE];  /* data area */
    ADXT adxt;                  /* ADXT handle */

    /* read sound data */
    load_data(adxdat);
    /* Create ADXT handle */
    adxt = ADXT_Create(1, work, WKSIZE);
    /* Start playback */
    ADXT_StartMem(adxt, adxdat);
      :

[Menu]

ADXT_StartMem2
Start playback from memory (TYPE2)

Format
void ADXT_StartMem2(ADXT adxt, void *adxdat, Sint32 datlen);
Input

adxt: ADXT handle

adxdat: sound data address

datlen: Length of playing ADX data

Output

None.

Return Value

None.

Description

Plays sound data in memory specified by adxdat. Plays to specified length.

[Menu]

ADXT_StartMemIdx
Start index playback from memory

Format
void ADXT_StartMemIdx(ADXT adxt, void *acxdat, Sint32 no);
Input

adxt: ADXT handle

acxdat: ACX data address

no: index number

Output

None.

Return Value

None.

Description

Plays data of specified number within ACX data.

Example

    /* mono data playback */
    #define WKSIZE ADXT_CALC_WORK(1, ADXT_PLY_MEM, 0, 0)

    Uint8 *work[WKSIZE];       /* work area */
    Uint8 acxdat[ADXDAT_SIZE]; /* data area */
    ADXT adxt;                 /* ADXT handle */

    /* read sound data */
    load_data(acxdat);
    /* Create ADXT handle */
    adxt = ADXT_Create(1, work, WKSIZE);
    /* Start playback */
    ADXT_StartMem(adxt, acxdat, 5);
        :
    /* Start playback */
    ADXT_StartMem(adxt, acxdat, 8);
        :

[Menu]

ADXT_StartAfs
Start index playback from disc

Format
void ADXT_StartAfs(ADXT adxt, Sint32 pat_id, Sint32 file_id);
Input

adxt: ADXT handle

pat_id: partition ID

file_id: file ID

Output

None.

Return Value

None.

Description

Plays data from AFS file on the disc.

The ADXF_LoadPartitionNw function serves for correlating the par_id and the AFS file name. The file_id refers to the sequential number inside the AFS file.

AFSLNK.EXE outputs a header file specifying the file ID. A message corresponding to the file name can also be specified.

Example

    /* simultaneous playback of 48 kHz stereo and 24 kHz mono */
    /* 48 kHz stereo playback work area */
    #define WKSIZE48 ADXT_CALC_WORK(2, ADXT_PLY_STM, 2, 48000)
    /* 24 kHz mono playback work area */
    #define WKSIZE24 ADXT_CALC_WORK(1, ADXT_PLY_STM, 2, 24000)
    /* maximum number of files in partition */
    #define MAX_NFILES 10000

    /* partition information area */
    Uint8 ptinfo[ADXF_CALC_PTINFO_SIZE(MAX_NFILES)];
    Uint8 *work1[WKSIZE48];  /* work area */
    Uint8 *work2[WKSIZE24];  /* work area */
    ADXT adxt1, adxt2;       /* ADXT handle */

    /* partition information read-in */
    ADXF_LoadPartitionNw(PAT01, "pat01.afs", NULL, ptinfo);
    for (;;) {
        if (ADXF_GetPtStat(PAT01) == ADXF_STAT_READEND) {
            break;
        }

        /* Server function */
        ADXM_ExecMain();
    }

    /* create ADXT handles */
    adxt1 = ADXT_Create(2, work1, WKSIZE48);
    adxt2 = ADXT_Create(1, work2, WKSIZE24);
    /* Start playback */
    ADXT_StartAfs(adxt1, PATID, BGM);
        :
    /* Start playback */
    ADXT_StartAfs(adxt1, PATID, SRF137);
        :

[Menu]

ADXT_StartSj
Start playback from stream joint

Format
void ADXT_StartSj(ADXT adxt, SJ sj);
Input

adxt: ADXT handle

sj: Stream Joint

Output

None.

Return Value

None.

Description

Plays data of specified Stream Joint.

[Menu]

ADXT_Stop
Stop playback

Format
void ADXT_Stop(ADXT adxt);
Input

adxt: ADXT handle

Output

None.

Return Value

None.

Description

Stops ADX playback.

Example

    /* 48 kHz stereo data 1 stream playback */
    #define WKSIZE ADXT_CALC_WORK(2, ADXT_PLY_STM, 1, 48000)

    Uint8 *work[WKSIZE];  /* work area */
    ADXT adxt;            /* ADXT handle */

    /* Create ADXT handle */
    adxt = ADXT_Create(2, work, WKSIZE);
    /* Start playback */
    ADXT_StartFname(adxt, "MUSIC.ADX");
        :
    /* button pressed for stop */
    if (PRESSED(Button)) {
        /* stop playback */
        ADXT_Stop(adxt);
          :

[Menu]

ADXT_GetStat
Get status

Format
Sint32 ADXT_GetStat(ADXT adxt);
Input

adxt: ADXT handle

Output

None.

Return Value

Operation status of current ADXT handle

Description

Gets current operation condition of adxt.

Possible status modes are as follows.

Member | Type | Remarks
--- | --- | ---
ADXT_STAT_STOP | 0 | Stopped
ADXT_STAT_DECINFO | 1 | Getting ADX header information
ADXT_STAT_PREP | 2 | Preparing for playback
ADXT_STAT_PLAYING | 3 | Decoding & playback in progress
ADXT_STAT_DECEND | 4 | Decoding completed
ADXT_STAT_PLAYEND | 5 | Playback completed
ADXT_STAT_ERROR | 6 | Error occurred

Example

    /* 48 kHz mono data 1 stream playback */
    #define WKSIZE ADXT_CALC_WORK(1, ADXT_PLY_STM, 1, 48000)

    Uint8 *work[WKSIZE];  /* work area */
    ADXT adxt;            /* ADXT handle */
    Sint32 stat;          /* operation status */

    /* Create ADXT handle */
    adxt = ADXT_Create(1, work, WKSIZE);
    /* Start playback */
    ADXT_StartAfs(adxt, pat_id, 0);

    for (;;) {
        /* activate animation while sound is produced */
        stat = ADXT_GetStat(adxt);
        if (stat == ADXT_STAT_PLAYING || stat == ADXT_STAT_DECEND) {
            user_animate_obj();
        }

        /* play next sound when playback ends */
        if (stat == ADXT_STAT_PLAYEND) {
            ADXT_StartAfs(adxt, pat_id, 1);
        }

        /* Server function */
        ADXM_ExecMain();
    }

[Menu]

ADXT_GetTime
Get playback time in sample units

Format
void ADXT_GetTime(ADXT adxt, Sint32 *ncount, Sint32 *tscale);
Input

adxt: ADXT handle

Output

ncount: playback sample number

tscale:sampling frequency [Hz]

Return Value

None.

Description

Gets playback time in sample units.

Example

    /* 48 kHz stereo data 1 stream playback */
    #define WKSIZE ADXT_CALC_WORK(2, ADXT_PLY_STM, 1, 48000)

    Uint8 *work[WKSIZE];          /* work area */
    ADXT adxt;                    /* ADXT handle */
    Sint32 nsmpl, sfreq;          /* playback time */
    Sint32 nfrm, hh, mm, ss, ff;  /* time */

    /* Create ADXT handle */
    adxt = ADXT_Create(2, work, WKSIZE);
    /* Start playback */
    ADXT_StartFname(adxt, "music.adx");

    for (;;) {
        /* playback time display (frame unit 1/60) */
        ADXT_GetTime(adxt, &nsmpl, &sfreq);
        nfrm = (Sint32)((Float32)nsmpl / (Float32)sfreq * 60.0f);
        hh = nfrm / (60*60*60);/* hours */
        mm = (nfrm - hh*60*60*60) / (60*60);/* minutes */
        ss = (nfrm - (hh*60+mm)*60*60) / 60;/* seconds */
        ff = nfrm % 1000;/* frames */
        disp_time(hh, mm, ss, ff);

        /* Server function */
        ADXM_ExecMain();
    }

[Menu]

ADXT_GetTimeReal
Get playback time in real time

Format
Sint32 ADXT_GetTimeReal(ADXT adxt);
Input

adxt: ADXT handle

Output

None.

Return Value

Playback time [1/100sec]

Description

Gets playback time in real time, using units of 1/100 seconds.

Example

    /* 48 kHz stereo data 1 stream playback */
    #define WKSIZE ADXT_CALC_WORK(2, ADXT_PLY_STM, 1, 48000)

    Uint8 *work[WKSIZE];   /* work area */
    ADXT adxt;             /* ADXT handle */
    Sint32 time;           /* playback time */
    Sint32 hh, mm, ss, ff; /* time */

    adxt = ADXT_Create(2, work, WKSIZE); /* Create ADXT handle */
    ADXT_StartFname(adxt, "music.adx");  /* Start playback */
        :
    for (;;) {
        /* playback time display (frame unit 1/100) */
        time = ADXT_GetTimeReal(adxt);
        hh = time / (60*60*100);/* hours */
        mm = (time - hh*60*60*100)/(60*100);/* minutes */
        ss = (time - (hh*60+mm)*60*100)/100;/* seconds */
        ff = time % 100;/* frames */

        /* display time */
        disp_time(hh, mm, ss, ff);

        /* Server function */
        ADXM_ExecMain();
    }

[Menu]

ADXT_Pause
Playback pause and resume

Format
void ADXT_Pause(ADXT adxt, Sint32 sw);
Input

adxt: ADXT handle

sw: pause switch (1 = pause, 0 = resume)

Output

None.

Return Value

None.

Description

Carries out playback pause and resume. When the switch is set to 1, play pauses; when the switch is set to 0, play resumes. When pause is set when playback is in the STOP state, sound cannot be played back even if the start function is run. When pause is set in the PLAYING state, playback pauses. By releasing pause in the PLAYING state, sound instantly plays back.

Example

    (1)pause
    /* Playback for only one stream of 48Khz stereo data */
    #define WKSIZE ADXT_CALC_WORK(2, ADXT_PLY_STM, 1, 48000)

    Uint8 *work[WKSIZE];      /* work area */
    ADXT adxt;                /* ADXT handle */
    Sint32 pause_flag = 0;    /* pause flag */

    /* ADXT handle creation */
    adxt = ADXT_Create(2, work, WKSIZE);
    /* Start playback */
    ADXT_StartFname(adxt, "music.adx");

    for (;;) {
        if (PRESSED(Button)) {
            if (pause_flag == 0) {
                /* pause */
                pause_flag = 1;
            } else {
                /* resume */
                pause_flag = 0
            }
            ADXT_Pause(adxt, pause_flag);
        }

        /* Server function */
        ADXM_ExecMain();
    }

    (2)Immediately playing back sound data on the disc
    /* ADXT handle creation */
    adxt = ADXT_Create(2, work, WKSIZE);
    /* pause */
    ADXT_Pause(adxt, 1);
    /* playback start */
    ADXT_StartFname(adxt, "music.adx");

    /* Sound is not played back, state is PLAYING */
    for (;;) {
        /* When the button is pressed, sound is immediately output */
        if (PRESSED(Button)) {
            ADXT_Pause(adxt, 0);
        }

        /* Server function */
        ADXM_ExecMain();
    }

[Menu]

ADXT_GetStatPause
Get pause status

Format
Sint32 ADXT_GetStatPause(ADXT adxt);
Input

adxt: ADXT handle

Output

None.

Return Value

1=pause, 0=not pause

Description

Obtains the status of pause.

[Menu]

ADXT_SetOutVol
Set output volume

Format
void ADXT_SetOutVol(ADXT adxt, Sint32 vol);
Input

adxt: ADXT handle

vol:attenuation level (from 0: 0dB to -960: -96.0dB)

Output

None.

Return Value

None.

Description

Sets the output volume. Can be used before or during playback.

vol setting values0:-0dB no attenuation (maximum)

-30:-3dB approx. 70%

-60:-6dB approx. 50%

-960:-96dB mute

[Menu]

ADXT_GetOutVol
Get output volume setting

Format
void ADXT_GetOutVol(ADXT adxt);
Input

adxt: ADXT handle

Output

None.

Return Value

Output volume setting value (from 0: 0dB to -960: -96.0dB)

Description

Gets the output volume setting.

Example

    /* 48 kHz stereo data 1 stream playback */
    #define WKSIZE ADXT_CALC_WORK(2, ADXT_PLY_STM, 1, 48000)

    Uint8 *work[WKSIZE]; /* work area */
    ADXT adxt;           /* ADXT handle */
    Sint32 vol;          /* current volume */
    Sint32 fade_vol;     /* fader range */

    /* set fade time as 3 seconds */
    fade_vol = 960 / (60 * 3);
        :
    /* Create ADXT handle */
    adxt = ADXT_Create(2, work, WKSIZE);
    /* Start playback */
    ADXT_StartFname(adxt, "music.adx");

    for (;;) {
        /* fade-in */
        if (PRESSED(Button1)) {
            vol = ADXT_GetOutVol(adxt);
            ADXT_SetOutVol(adxt, vol+fade_vol);
        }
        /* fade-out */
        if (PRESSED(Button2)) {
            vol = ADXT_GetOutVol(adxt);
            ADXT_SetOutVol(adxt, vol-fade_vol);
        }

        /* Server function */
        ADXM_ExecMain();
    }

[Menu]

ADXT_SetOutPan
Set panpot

Format
void ADXT_SetOutPan(ADXT adxt, Sint32 ch, Sint32 pan);
Input

adxt:ADXT handle

ch: channel number (0 or 1)

ADXT_CH_L(0)=left channel, ADXT_CH_R(1)=right channel

pan: panpot setting value (from -15 to +15, -128)

ADXT_PAN_LEFT = -15, ADXT_PAN_CENTER = 0

ADXT_PAN_RIGHT = 15, ADXT_PAN_AUTO = -128

Output

None.

Return Value

None.

Description

Sets the output panpot.

When the setting is AUTO, panning is performed automatically, depending on whether the sound data are mono or stereo. This setting can be made also during sound playback.

[Menu]

ADXT_GetOutPan
Get panpot setting

Format
Sint32 ADXT_GetOutPan(ADXT adxt, Sint32 ch);
Input

adxt: ADXT handle

ch: channel number

ADXT_CH_L(0): left channel, ADXT_CH_R(1): right channel

Output

None.

Return Value

Panpot setting value (from -15 to +15, -128)

Description

Gets the output panpot setting.

Example

    /* 48 kHz mono data 1 stream playback */
    #define WKSIZE ADXT_CALC_WORK(1, ADXT_PLY_STM, 1, 48000)

    Uint8 *work[WKSIZE]; /* work area */
    ADXT adxt;           /* ADXT handle */
    Sint32 pan;          /* current panpot value */

    /* Create ADXT handle */
    adxt = ADXT_Create(1, work, WKSIZE);
    /* Start playback */
    ADXT_StartFname(adxt, "srf01.adx");

    for (;;) {
        if (PRESSED(Button1)) {              /* shift panpot to right */
            pan = ADXT_GetOutPan(adxt, 0);
            pan = min(ADXT_PAN_RIGHT, pan+1);
            ADXT_SetOutPan(adxt, 0, pan);
        }
        if (PRESSED(Button2)) {              /* shift panpot to left */
            pan = ADXT_GetOutPan(adxt, 0);
            pan = max(ADXT_PAN_LEFT, pan-1);
            ADXT_SetOutPan(adxt, 0, pan);
        }

        /* Server function */
        ADXM_ExecMain();
    }

[Menu]

ADXT_SetOutputMono
Set monaural output

Format
void ADXT_SetOutputMono(Sint32 flag);
Input

flag: monaural output flag (OFF=0, ON=1)

Output

None.

Return Value

None.

Description

Sets the monaural output.

When the setting is ON, all stereo data is outputted as monaural data. Both channel data is mixed down.

[Menu]

ADXT_SetLpFlg
Set loop flag

Format
void ADXT_SetLpFlg(ADXT adxt, Sint32 flg);
Input

adxt: ADXT handle

flg: 1=loop, 0=not loop

Output

None.

Return Value

None.

Description

Sets whether play a loop or not.

You can only release looping play while playing.

If you set this flag again, you have to set just before start playing.

[Menu]

ADXT_GetLpCnt
Get the number of times played a loop

Format
Sint32 ADXT_GetLpCnt(ADXT adxt);
Input

adxt: ADXT handle

Output

None.

Return Value

Number of times played a loop

Description

Obtains the number of times that played a loop.

[Menu]

ADXT_SetWaitPlayStart
Set waiting for output

Format
void ADXT_SetWaitPlayStart(ADXT adxt, Sint32 flg);
Input

adxt: ADXT handle

flg: 1=waits, 0=starts to output sound

Output

None.

Return Value

None.

Description

Sets waiting for starting to output the sound.

[Menu]

ADXT_GetNumSmpl
Get total number of samples

Format
Sint32 ADXT_GetNumSmpl( ADXT adxt );
Input

adxt: ADXT handle

Output

None.

Return Value

Total number of sound data samples

Description

Gets total number of sound data samples for current playback.

Remarks

This information can be obtained in the interval extending from playback preparation (ADXT_STAT_PREP = 2) to playback end (ADXT_STAT_PLAYEND = 5).

Example

    /* 48 kHz stereo data 1 stream playback */
    #define WKSIZE ADXT_CALC_WORK(2, ADXT_PLY_STM, 1, 48000)

    Uint8 *work[WKSIZE]; /* work area */
    ADXT adxt;           /* ADXT handle */
    Sint32 total_nsmpl;  /* total number of sample */
    Sint32 nsmpl, sfreq; /* playback time */
    Sint32 percent;      /* percent */

    /* Create ADXT handle */
    adxt = ADXT_Create(2, work, WKSIZE);
    /* Start playback */
    ADXT_StartFname(adxt, "music.adx");

    for (;;) {
        /* display playback progress (percent) */
        if ( ADXT_GetStat(adxt) >= ADXT_STAT_PREP ) {
            total_nsmpl = ADXT_GetNumSmpl(adxt);
            ADXT_GetTime(adxt, &nsmpl, &sfreq);
            percent = nsmpl * 100 / total_nsmpl;
        } else {
            percent = 0;
        }
        disp_progress(percent);

        /* Server function */
        ADXM_ExecMain();
    }

[Menu]

ADXT_GetDecNumSmpl
Get decoded number of samples

Format
Sint32 ADXT_GetDecNumSmpl(ADXT adxt);
Input

adxt: ADXT handle

Output

None.

Return Value

Number of samples decoded

Description

Obtains a decoded sample number of sound data.

Remarks

This information can be obtained in the interval extending from playback preparation (ADXT_STAT_PREP) to playback end (ADXT_STAT_PLAYEND).

[Menu]

ADXT_GetSfreq
Get sampling frequency

Format
Sint32 ADXT_GetSfreq(ADXT adxt);
Input

adxt: ADXT handle

Output

None.

Return Value

Sound data sampling frequency [Hz]

Description

Gets sampling frequency of currently playing sound data.

Remarks

This information can be obtained in the interval extending from playback preparation (ADXT_STAT_PREP = 2) to playback end (ADXT_STAT_PLAYEND = 5).

Example

    /* 48 kHz stereo data 1 stream playback */
    #define WKSIZE ADXT_CALC_WORK(2, ADXT_PLY_STM, 1, 48000)

    Uint8 *work[WKSIZE];  /* work area */
    ADXT adxt;            /* ADXT handle */
    Sint32 sfreq;         /* sampling frequency */

    /* Create ADXT handle */
    adxt = ADXT_Create(2, work, WKSIZE);
    /* Start playback */
    ADXT_StartFname(adxt, "music.adx");
    for (;;) {
        /* get sampling frequency (Hz) */
        if (ADXT_GetStat(adxt) >= ADXT_STAT_PREP) {
            sfreq = ADXT_GetSfreq(adxt);
        }

        /* Server function */
        ADXM_ExecMain();
    }

[Menu]

ADXT_GetNumChan
Get number of channels

Format
Sint32 ADXT_GetNumChan(ADXT adxt);
Input

adxt: ADXT handle

Output

None.

Return Value

Number of channels

Description

Gets sampling frequency of currently playing sound data.

Remarks

This information can be obtained in the interval extending from playback preparation (ADXT_STAT_PREP) to playback end (ADXT_STAT_PLAYEND).

[Menu]

ADXT_GetFmtBps
Get number of quantization bits

Format
Sint32 ADXT_GetFmtBps(ADXT adxt);
Input

adxt: ADXT handle

Output

None.

Return Value

Number of quantization bits

Description

Gets the number of quantization bits of currently playing sound data.

Remarks

This information can be obtained in the interval extending from playback preparation (ADXT_STAT_PREP) to playback end (ADXT_STAT_PLAYEND).

[Menu]

ADXT_GetHdrLen
Get header length

Format
Sint32 ADXT_GetHdrLen(ADXT adxt);
Input

adxt: ADXT handle

Output

None.

Return Value

Header length

Description

Gets header length of currently playing sound data.

Remarks

This information can be obtained in the interval extending from playback preparation (ADXT_STAT_PREP) to playback end (ADXT_STAT_PLAYEND).

[Menu]

ADXT_GetInputSj
Get input Stream Joint

Format
SJ ADXT_GetInputSj(ADXT adxt);
Input

adxt: ADXT handle

Output

None.

Return Value

Stream Joint

Description

Obtains Stream Joint for the input.

[Menu]

ADXT_GetNumSctIbuf
Get the amount of data in an input buffer

Format
Sint32 ADXT_GetNumSctIbuf(ADXT adxt);
Input

adxt: ADXT handle

Output

None.

Return Value

Number of sector

Description

Obtains the amount of data that is stored in input buffer.

[Menu]

ADXT_GetIbufRemainTime
Get the playback time of the data in an input buffer

Format
float ADXT_GetIbufRemainTime(ADXT adxt);
Input

adxt: ADXT handle

Output

None.

Return Value

Playable time (sec)

Description

Obtains playable time using only data in input buffer.

You can use this function only playing ADX data.

[Menu]

ADXT_IsIbufSafety
Check the input buffer is having enough data or not

Format
Sint32 ADXT_IsIbufSafety(ADXT adxt);
Input

adxt: ADXT handle

Output

None.

Return Value

1=Has enough data, 0=Data are insufficient

Description

Checks whether the input buffer is having enough data or not.

Returns 'TRUE' when data more than the number of sector appointed exist in the input buffer.

[Menu]

ADXT_GetNumSmplObuf
Get number of samples in an output buffer

Format
Sint32 ADXT_GetNumSmplObuf(ADXT adxt, Sint32 chno);
Input

adxt: ADXT handle

chno: channel (0=left channel, 1=right channel)

Output

None.

Return Value

Number of samples in an output buffer

Description

Obtains the number of samples in an output buffer.

[Menu]

ADXT_GetStatRead
Get file read status

Format
Sint32 ADXT_GetStatRead(ADXT adxt);
Input

adxt: ADXT handle

Output

None.

Return Value

1=read is in progress, 0=read is stopped

Description

Obtains current status of file read.

[Menu]

ADXT_IsReadyPlayStart
Check playback preparation

Format
Sint32 ADXT_IsReadyPlayStart(ADXT adxt);
Input

adxt: ADXT handle

Output

None.

Return Value

None.

Description

Checks whether ADXT handle was preparations completion.

[Menu]

ADXT_IsCompleted
Check playback end

Format
Sint32 ADXT_IsCompleted(ADXT adxt);
Input

adxt: ADXT handle

Output

None.

Return Value

1=Finished, 0=Playing

Description

Checks whether the play finished or not.

[Menu]

ADXT_SetReloadTime
Set the time starting to reload.

Format
void ADXT_SetReloadTime(ADXT adxt,float time,Sint32 nch,Sint32 sfreq);
Input

adxt: ADXT handle

time: start remain time

nch: number of channel

sfreq: sampling frequency

Output

None.

Return Value

None.

Description

Sets of the time of start sector to reload into input buffer.

Reads data from disc when a quantity of data in the input buffer becomes less than 'time' (second).

[Menu]

ADXT_SetReloadSct
Set the number of sectors starting to reload

Format
void ADXT_SetReloadSct(ADXT adxt, Sint32 minsct);
Input

adxt: ADXT handle

minsct: start sector number

Output

None.

Return Value

None.

Description

Sets of the number of start sector to reload into input buffer.

Reads data from disc when a quantity of data in the input buffer becomes less than 'minsct' (sector).

[Menu]

ADXT_SetNumRetry
Set the number of retry

Format
void ADXT_SetNumRetry(Sint32 num);
Input

num: the number of retry(-1: infinite retry)

Output

None.

Return Value

None.

Description

Sets the number of retry inside ADX regardless of hardware.

[Menu]

ADXT_GetNumRetry
Get retry setting value

Format
Sint32 ADXT_GetNumRetry(void);
Input

None.

Output

None.

Return Value

the number of retry(-1: infinite retry)

Description

Gets the number of retry set by ADXT_SetNumRetry function.

[Menu]

ADXT_GetNumErr
Get the number of error

Format
Sint32 ADXT_GetNumErr(ADXT adxt);
Input

adxt : ADXT handle

Output

None.

Return Value

the number of error

Description

Gets the number of error occurrences that needs retry.

[Menu]

ADXT_SetDefSvrFreq
Set server function call frequency

Format
void ADXT_SetDefSvrFreq(Sint32 freq);
Input

freq: server function call frequency (number of calls per second)

Output

None.

Return Value

None.

Description

Sets the call frequency for the server function (ADXT_ExecServer function).

This function can be used to control the amount of decoding performed by each server function.

The default setting is 60 (Vsync).

Remarks

This function is not required because the server function is called by the Vsync interrupt.

[Menu]

ADXT_SetSvrFreq
Set server function call frequency (each handle)

Format
void ADXT_SetSvrFreq(ADXT adxt, Sint32 freq);
Input

adxt: ADXT handle

freq: server function call frequency (number of calls per second)

Output

None.

Return Value

None.

Description

Sets the call frequency for the server function (ADXT_ExecServer function).

This function can be used to control the amount of decoding performed by each server function.

The default setting is 60 (Vsync).

Remarks

This function is not required because the server function is called by the Vsync interrupt.

[Menu]

ADXT_ExecServer
Server function (update internal status)

Format
void ADXT_ExecServer(void);
Input

None.

Output

None.

Return Value

None.

Description

Updates the internal status of the library and performs decoding processing.

Remarks

Because the ADXT_Init function registers Vsync interrupt processing, the user does not need to call this function.

[Menu]

ADXT_ExecHndl
Server function of each handle

Format
void ADXT_ExecHndl(ADXT adxt);
Input

None.

Output

None.

Return Value

None.

Description

Updates the internal status of an ADXT handle.

Remarks

Because this function is called from 'ADXT_ExecServer' function, the user does not need to call this function.

[Menu]

ADXT_GetErrCode
Get error code

Format
Sint32 ADXT_GetErrCode(ADXT adxt);
Input

adxt: ADXT handle

Output

None.

Return Value

Error code

Description

Gets error code.

This value is held until cleared by the ADXT_ClearErrCode function.

Error code table

Mode definition | Constant | Error condition
--- | --- | ---
ADXT_ERR_OK | 0 | Normal
ADXT_ERR_SHRTBUF | 1 | No data supplied to input buffer read error has occurred
ADXT_ERR_SNDBLK | 2 | Sound block error Sound block has stopped.

[Menu]

ADXT_ClearErrCode
Clear error code

Format
void ADXT_ClearErrCode(ADXT adxt);
Input

adxt: ADXT handle

Output

None.

Return Value

None.

Description

Clears error code.

Example

    /* 48 kHz mono data 1 stream playback */
    #define WKSIZE ADXT_CALC_WORK(1, ADXT_PLY_STM, 1, 48000)

    Uint8 *work[WKSIZE];  /* work area */
    ADXT adxt;            /* ADXT handle */
    Sint32 errcode;       /* error code */

    /* Create ADXT handle */
    adxt = ADXT_Create(1, work, WKSIZE);
    /* Start playback */
    ADXT_StartFname(adxt, "srf01.adx");

    for (;;) {
        errcode = ADXT_GetErrCode(adxt);
        if ( errcode != ADXT_ERR_OK ) {
            ADXT_ClearErrCode(adxt);
            ADXT_Stop(adxt);
        }

        /* Server function */
        ADXM_ExecMain();
    }

[Menu]

ADXT_EntryFname
Register seamless continuous playback file

Format
void ADXT_EntryFname(ADXT adxt, const Char8 *fname);
Input

adxt: ADXT handle

fname:Audio file name

Output

None.

Return Value

None.

Description

Registers the audio file specified by "fname" as a file for seamless continuous playback. Only ADX data with no loop settings can be registered.

Example

    /* ADXT handle creation */
    adxt = ADXT_Create(1, adxt_work, ADXT_WKSIZE);

    /* Register ADX file */
    ADXT_EntryFname(adxt, "smpsl1.adx");
    ADXT_EntryFname(adxt, "smpsl2.adx");
    ADXT_EntryFname(adxt, "smpsl3.adx");

    /* Set loop */
    ADXT_SetSeamlessLp(adxt, 1);
    /* Start seamless */
    ADXT_StartSeamless(adxt);

[Menu]

ADXT_EntryFnameRange
Register seamless continuous playback file by specified the range

Format
void ADXT_EntryFnameRange(ADXT adxt, const Char8 *fname, Sint32 ofst_sct, Sint32 range_sct);
Input

adxt: ADXT handle

fname:Audio file name

offset_sct:offset[sector]

range_sct:size[sector]

Output

None.

Return Value

None.

Description

Registers the audio file specified by filename and the range for seamless continuous playback.

[Menu]

ADXT_EntryAfs
Register seamless continuous playback AFS file

Format
void ADXT_EntryAfs(ADXT adxt, Sint32 patid, Sint32 fid);
Input

adxt: ADXT handle

patid: partition ID

fid: file ID

Output

None.

Return Value

None.

Description

Registers AFS file as seamless continuous playback data.

[Menu]

ADXT_ResetEntry
Reset registration of seamless continuous playback

Format
void ADXT_ResetEntry(ADXT adxt);
Input

adxt: ADXT handle

Output

None.

Return Value

None.

Description

Reset file registration of seamless continuous playback.

Remarks

This function can be used only when playback has stopped (ADXT_STAT_STOP).

[Menu]

ADXT_StartSeamless
Start seamless continuous playback

Format
void ADXT_StartSeamless(ADXT adxt);
Input

adxt: ADXT handle

Output

None.

Return Value

None.

Description

Starts seamless continuous playback.

[Menu]

ADXT_SetSeamlessLp
Set seamless loop playback

Format
void ADXT_SetSeamlessLp(ADXT adxt, Sint32 flg);
Input

adxt: ADXT handle

flg:0=Loop playback off, 1=Loop playback on.

Output

None.

Return Value

None.

Description

Sets seamless loop playback.

[Menu]

ADXT_StartFnameLp
Start seamless loop playback

Format
void ADXT_StartFnameLp(ADXT adxt, const Char8 *fname);
Input

adxt: ADXT handle

fname:Audio file name

Output

None.

Return Value

None.

Description

Plays back the specified audio file repeatedly.

[Menu]

ADXT_StartFnameRangeLp
Start seamless loop playback by specified the range

Format
void ADXT_StartFnameRangeLp(ADXT adxt, const Char8 *fname, Sint32 ofst_sct, Sint32 range_sct);
Input

adxt: ADXT handle

fname:Audio file name

offset_sct:offset[sector]

range_sct:size[sector]

Output

None.

Return Value

None.

Description

Plays back the specified filename and the range.

[Menu]

ADXT_ReleaseSeamless
Release seamless continuous playback

Format
void ADXT_ReleaseSeamless(ADXT adxt);
Input

adxt: ADXT handle

Output

None.

Return Value

None.

Description

Ends seamless continuous playback.

[Menu]

ADXT_GetNumFiles
Get number of files registered

Format
Sint32 ADXT_GetNumFiles(ADXT adxt);
Input

adxt: ADXT handle

Output

None.

Return Value

Number of files registered

Description

Gets the number of files that have been registered.

[Menu]

ADXT_AttachAhx
Attach AHX function

Format
void ADXT_AttachAhx(ADXT adxt, void *work, Sint32 worksize);
Input

adxt: ADXT handle

work: working area for AHX

worksize: size of AHX working area(byte)

Output

None.

Return Value

None.

Description

Attach AHX function.

Using this function, it becomes possible to playback an AHX file.

[Menu]

ADXT_DetachAhx
Detach AHX function

Format
void ADXT_DetachAhx(ADXT adxt);
Input

adxt: ADXT handle

Output

None.

Return Value

None.

Description

Detach AHX function.

Unuse of AHX is attained.

Example

    /* Calculation of work size */
    #define ADXWKSZ ADXT_CALC_WORK(2, ADXT_PLY_STM, 1, 48000)
    #define AHXWKSZ ADXT_WORKSIZE_AHX

    Uint8 adxwk[ADXWKSZ];  /* work area for ADX */
    Uint8 ahxwk[AIXWKSZ];  /* work area for AHX */
    ADXT adxt;             /* ADXT handle */

    /* Create ADXT handle */
    adxt = ADXT_Create(2, adxwk, ADXWKSZ);
    /* Attach AHX function */
    ADXT_AttachAhx(adxt, ahxwk, AHXWKSZ);
        :
    /* Detach AHX function */
    ADXT_DetachAhx(adxt);
    /* Delete ADXT handle */
    ADXT_Destroy(adxt);

[Menu]

ADXT_SetDefKeyString
Set key strings

Format
void ADXT_SetDefKeyString(Char8 *str);
Input

str: key strings

Output

None.

Return Value

None.

Description

Sets default key strings. You have to input the same key strings as the key strings input at the time of encoding. When a different key strings from the time of encoding is input, it will become a noise and will be reproduced. NULL is specified to be 'str' when reproducing the ADX data which is not enciphered.

Example

    /* Set key strings */
    ADXT_SetDefKeyString("CRI");

    /* ADXT handle creation */
    adxt = ADXT_Create(2, work, WKSIZE);

    /* Start playback */
    ADXT_StartFname(adxt, "MUSIC.ADX");
        :

[Menu]

ADXT_SetKeyString
Set key strings to each handle

Format
void ADXT_SetKeyString(ADXT adxt, Char8 *str);
Input

adxt: ADXT handle

str: key strings

Output

None.

Return Value

None.

Description

Sets key strings to each handle. You have to input the same key ode as the key strings input at the time of encoding. When a different key strings from the time of encoding is input, it will become a noise and will be reproduced. NULL is specified to be 'str' when reproducing the ADX data which is not enciphered.

Example

    /* ADXT handle creation */
    adxt = ADXT_Create(2, work, WKSIZE);

    /* Set key strings */
    ADXT_SetDefKeyString(adxt, "CRI");

    /* Start playback */
    ADXT_StartFname(adxt, "MUSIC.ADX");
        :

[Menu]

ADXT_GetDefOutVol
Get default volume

Format
Sint32 ADXT_GetDefOutVol(ADXT adxt);
Input

adxt: ADXT handle

Output

None.

Return Value

Default volume(0:-0dB ... -960:-96.0dB)

Description

Gets default volume included in the ADX data.

[Menu]

ADXT_GetDefOutPan
Get default panpot

Format
Sint32 ADXT_GetDefOutPan(ADXT adxt Sint32 chno);
Input

adxt: ADXT handle

chno: Channel number

ADXT_CH_L(0):Left channel, ADXT_CH_R(1):Right channel

Output

None.

Return Value

Default panpot(-15:left ... 0:center ... +15:right)

Description

Gets default panpot included in the ADX data.

[Menu]

ADXT_GetDataId
Get data ID

Format
Char8 *ADXT_GetDataId(ADXT adxt);
Input

adxt: ADXT handle

Output

None.

Return Value

The data ID

Description

Gets the data ID included in the ADX data.

Format
int ADXT_CALC_WORK_3D(stmflg, nstm, sfreq);
Input

stmflg: playback mode

ADXT_PLY_MEM: memory playback

ADXT_PLY_STM: stream playback

nstm: maximum number of DISC streams

sfreq: maximum playback sampling frequency

Output

None

Return Value

Work area size [bytes]

Description

Calculates the work area size for each ADXT handle.

The maximum number of DISC streams specifies the number of streams that can be read from DISC simultaneously.

When reading from DISC, this is the sum of ADXT handles and ADXF handles used simultaneously.

[Menu]

ADXT_Create3D
ADXT surround handle creation

Format
ADXT ADXT_Create3D(void *work, Sint32 worksize);
Input

work: work area

worksize: work area size

Output

None.

Return Value

Pointer to generated ADXT structure element (ADXT handle)

Description

Creates an ADXT handle.

ADXT handle created using this function supports surround panning.

Remarks

The work area size is calculated by ADXT_CALC_WORK_3D macro.

[Menu]

ADXT_SetOutPos
Set output position

Format
ADXT ADXT_SetOutPos(ADXT adxt, Sint32 x, Sint32 y);
Input

adxt: ADXT handle

x: x-coordinate (-127:left...0:center...+127:right)

y: y-coordinate (-127:front...0:center...+127:rear)

Output

None.

Return Value

None.

Description

Sets the position of sound source.

Remarks

This function is usable only for ADXT handle which was created by ADXT_Create3D function. And, this function has an effect only for mono ADX playback (stereo panning is not supported).

NOTE: Hardware decoder (which supports Dolby Digital or Dolby Pro Logic II) is required in order to preview the 3D sound.

[Menu]

ADXM_SetupThrd
Setup of ADX thread system

Format
void ADXM_SetupThrd(ADXM_TPRM *tprm);
Input

tprm: parameter structure of ADX thread

Output

None.

Return Value

None.

Description

Sets up ADX thread system. Creates thread and registers ADX server function.in Vsync thread.

Please call ADXM_SetupThrd() in front of ADXT_Init().

Example

    /* Setup threads */
    ADXM_SetupThrd(NULL);

    /* ADX library initialization */
    ADXT_Init();
        :
    for (;;) {
        /* Wait Vsync */
        ADXM_WaitVsync();

        /* Server function */
        ADXM_ExecMain();
            :
    }

Note

This function exists only for compatibility. You should use the ADXM_SetupFramework function rather than this function.

[Menu]

ADXM_ShutdownThrd
Shutdown of ADX thread system

Format
void ADXM_ShutdownThrd(void);
Input

None.

Output

None.

Return Value

None.

Description

Shuts down ADX thread system. Deletes thread that was created by ADXM_SetupThrd function.

Note

This function exists only for compatibility. You should use the ADXM_ShutdownFramework function rather than this function.

[Menu]

ADXM_ExecMain
Vsync server function

Format
Sint32 ADXM_ExecMain(void);
Input

None.

Output

None.

Return Value

None.

Description

Updates the internal status of the library.

Remarks

Application must call this function in main loop periodically.

Example

    /* Setup framework */
    ADXM_SetupFramework(ADXM_FRAMEWORK_DEFAULT, NULL);

    /* ADX library initialization */
    ADXT_Init();
        :
    for (;;) {
        /* Wait Vsync */
        ADXM_WaitVsync();

        /* Server function */
        ADXM_ExecMain();
            :
    }

[Menu]

ADXM_WaitVsync
Waits for Vsync

Format
void ADXM_WaitVsync(void);
Input

None.

Output

None.

Return Value

None.

Description

Waits for the next Vsync. The main thread sleeps while it is waiting, and the processing time is given to the idle thread.

When Sofdec is reproducing, Sofdec decodes by the idle thread while executing this function.

Remarks

Please do not use this function in the case of single thread framework.

Example

    /* Setup framework */
    ADXM_SetupFramework(ADXM_FRAMEWORK_DEFAULT, NULL);

    /* ADX library initialization */
    ADXT_Init();
        :
    for (;;) {
        /* Wait Vsync */
        ADXM_WaitVsync();

        /* Server function */
        ADXM_ExecMain();
            :
    }

[Menu]

ADXM_SetCbErr
Register error callback function

Format
void ADXM_SetCbErr(void (*func)(void *obj, Char8 *emsg), void *obj)
Input

func: user callback function

obj: 1st argument of callback function

Output

None.

Return Value

None.

Description

Registers an error callback function.

When an error occurs, the registered function is called in the following format.

void (*func)(*obj, char *emsg);

The 1st argument (obj) of this function becomes the 2nd argument of the ADXM_SetCbErr function. The second argument (emsg) is the error message. Because this function is intended for debugging purposes, it should be replaces with a do-nothing function during mastering.

Example

    void user_adx_error(void *obj, char *msg)
    {
        /* On debugging, pause process and solve problems */
        ...
    }

    void main(void)
    {
        /* Register error callback */
        ADXM_SetCbErr(user_adx_error, NULL);
           :
    }

Copyright (c) 2001-2006 CRI Middleware Co.,LTD.