Core
PT3_Init
void PT3_Init()

Initialize the PT3 player

PT3_InitSong
void PT3_InitSong(
const voidsongADDR
)

Initialize a given song to make it ready to playback

Parameters
songAddr
const void*

Start address of the data. If PT3_SKIP_HEADER is set, this address must be header address + 100 (if the data are not troncated)

PT3_Pause
void PT3_Pause()

Pause song playback

PT3_Resume
void PT3_Resume()

Resume song playback

PT3_SetLoop
void PT3_SetLoop(
bool loop
)

Change state of playback loop

Parameters
loop
bool

Either loop or not (TRUE: do loop; FALSE: don't loop)

PT3_Silence
void PT3_Silence()

Silence the PSG

PT3_Decode
void PT3_Decode()

Decode a frame from PT3 song

PT3_UpdatePSG
void PT3_UpdatePSG()

Send data to PSG registers Must be executed on each V-Blank interruption

Inline
PT3_SetNoteTable
inline void PT3_SetNoteTable(
const voidnt
)

Set notes table

Parameters
nt
const void*

Address of the note table to use

PT3_GetLoop
inline bool PT3_GetLoop()

Check if loop flag is set

Returns

FALSE if loop flag is not set

PT3_IsPlaying
inline bool PT3_IsPlaying()

Check if playback flag is set

Returns

FALSE if playback flag is not set

PT3_Play
inline void PT3_Play()

Play the current music

PT3_GetVolume
inline u8 PT3_GetVolume(
u8 chan
)

Get the current amplitude of a given channel

Parameters
chan
u8

The channel number (0: channel A, 1: channel B, 2: channel C)

Returns

Volume in bits #0 to #3 and envelope seting in bit #4

7   6   5   4   3   2   1   0
x x x M L3 L2 L1 L0
│ └───┴───┴───┴── Channel A Amplitude (volume)
└────────────────── Volume controlled by Envelope enable/disable
PT3_GetFrequency
inline u16 PT3_GetFrequency(
u8 chan
)

Get the current frequency of a given channel

Parameters
chan
u8

The channel number (0: channel A, 1: channel B, 2: channel C)

Returns

12-bits tone period (1 to 4095).  Frequency = 111,861 Hz / Period.  Reange from 111,861 Hz (divide by 1) down to 27.3 Hz (divide by 4095)

PT3_GetPSGRegister
inline u8 PT3_GetPSGRegister(
u8 reg
)

Get a given PSG register value

Parameters
reg
u8

The PSG register number (0-13)

Returns

Value of the given register in the PT3 buffer

Extra
PT3_GetPattern
inline u8 PT3_GetPattern()

Get the current pattern number

Returns

Pattern number between 0 and max

PT3_Mute
inline void PT3_Mute(
u8 chan,
bool mute
)

Mute a given channel

Parameters
chan
u8

The channel number (0: channel A, 1: channel B, 2: channel C)

mute
bool

Mute (TRUE) or un-mute (FALSE) the given channel

PT3_SetFinishCB
inline void PT3_SetFinishCB(
callback cb
)

Set the function to be call when the music ended

Parameters
cb
callback

Function to be called when music ends

PT3_ResetFinishCB
inline void PT3_ResetFinishCB()

Reset the function to be call when the music ended