Add loop point parsing support

This commit is contained in:
spicyjpeg
2025-12-05 01:50:23 +01:00
parent ac4dea75ea
commit b7dc599771
9 changed files with 241 additions and 71 deletions

View File

@@ -384,11 +384,9 @@ int psx_audio_spu_encode_simple(const int16_t *samples, int sample_count, uint8_
uint8_t *last_block = output + length - PSX_AUDIO_SPU_BLOCK_SIZE;
if (loop_start < 0) {
last_block[1] |= PSX_AUDIO_SPU_LOOP_END;
// Insert trailing looping block
memset(output + length, 0, PSX_AUDIO_SPU_BLOCK_SIZE);
output[length + 1] = PSX_AUDIO_SPU_LOOP_START | PSX_AUDIO_SPU_LOOP_END;
output[length + 1] = PSX_AUDIO_SPU_LOOP_TRAP;
length += PSX_AUDIO_SPU_BLOCK_SIZE;
} else {

View File

@@ -62,9 +62,12 @@ typedef struct {
} psx_audio_encoder_state_t;
enum {
PSX_AUDIO_SPU_LOOP_END = 1 << 0,
PSX_AUDIO_SPU_LOOP_REPEAT = 3 << 0,
PSX_AUDIO_SPU_LOOP_START = 1 << 2
PSX_AUDIO_SPU_LOOP_END = (1 << 0),
PSX_AUDIO_SPU_LOOP_REPEAT = (1 << 0) | (1 << 1),
// Some old tools will not recognize loop start points if bit 1 is not set
// in addition to bit 2. Real hardware does not care.
PSX_AUDIO_SPU_LOOP_START = (1 << 1) | (1 << 2),
PSX_AUDIO_SPU_LOOP_TRAP = (1 << 0) | (1 << 2)
};
uint32_t psx_audio_xa_get_buffer_size(psx_audio_xa_settings_t settings, int sample_count);