PSPSDK 2026-04-21
Loading...
Searching...
No Matches
pspsascore.h
Go to the documentation of this file.
1/*
2 * PSP Software Development Kit - https://github.com/pspdev
3 * -----------------------------------------------------------------------
4 * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
5 *
6 * pspsascore.h - Prototypes for the sceSasCore library.
7 *
8 * Copyright (c) 2026 IsaacTCB
9 *
10 */
11
12#ifndef __SCELIBSAS_H__
13#define __SCELIBSAS_H__
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
27#include <psptypes.h>
28
34#define PSP_SAS_GET_VOICE_BIT(voice) (1u << (voice % 32))
35
43#define PSP_SAS_GET_FLAG_AT(flags, voice) (((flags) & (PSP_SAS_GET_VOICE_BIT(voice))) != 0)
44
46#define PSP_SAS_GRAIN_SIZE (256)
47
49#define PSP_SAS_GRAIN_SIZE_MIN (64)
50
52#define PSP_SAS_GRAIN_SIZE_MAX (2048)
53
55#define PSP_SAS_VOICES_MAX (32)
56
58#define PSP_SAS_SAMPLE_RATE (44100)
59
61#define PSP_SAS_VOLUME_MAX (0x1000)
62
64#define PSP_SAS_PITCH_BASE (0x1000)
65
67#define PSP_SAS_PITCH_MIN (0x1)
68
70#define PSP_SAS_PITCH_MAX (0x4000)
71
73#define PSP_SAS_NOISE_FREQ_MAX (0x3F)
74
76#define PSP_SAS_ENVELOPE_HEIGHT_MAX (0x40000000)
77
79#define PSP_SAS_ENVELOPE_FREQ_MAX (0x7FFFFFFF)
80
87
100
113
134
142
143#define PSP_SAS_ADSR_EVERYTHING (PSP_SAS_ADSR_ATTACK | PSP_SAS_ADSR_DECAY | PSP_SAS_ADSR_SUSTAIN | PSP_SAS_ADSR_RELEASE)
144
151typedef struct {
152 u8 pad[3616];
153} SceSasCore;
154
176int __sceSasInit(SceSasCore* core, int grainsize, int maxvoices, PspSasOutputModes outputmode, int samplerate);
177
186
197
208
220int __sceSasRevEVOL(SceSasCore* core, int leftvol, int rightvol);
221
233int __sceSasRevVON(SceSasCore* core, int dry, int wet);
234
246int __sceSasRevParam(SceSasCore* core, int delay, int feedback);
247
256
267int __sceSasSetGrain(SceSasCore* core, int grainsize);
268
285
305int __sceSasSetVoice(SceSasCore* core, int voice, void* vag, int size, int loop);
306
325int __sceSasSetVoicePCM(SceSasCore* core, int voice, void* pcm, int samplecount, int loopstart);
326
336int __sceSasSetKeyOn(SceSasCore* core, int voice);
337
347int __sceSasSetKeyOff(SceSasCore* core, int voice);
348
366int __sceSasSetPitch(SceSasCore* core, int voice, int pitch);
367
393int __sceSasSetADSRmode(SceSasCore* core, int voice, u32 mask, PspSasADSRCurveModes attackcurve, PspSasADSRCurveModes decaycurve, PspSasADSRCurveModes sustaincurve, PspSasADSRCurveModes releasecurve);
394
418int __sceSasSetADSR(SceSasCore* core, int voice, u32 mask, int attackrate, int decayrate, int sustainrate, int releaserate);
419
439int __sceSasSetSimpleADSR(SceSasCore* core, int voice, u32 envelope1, u32 envelope2);
440
452int __sceSasSetSL(SceSasCore* core, int voice, int level);
453
471int __sceSasSetVolume(SceSasCore* core, int voice, int leftvol, int rightvol, int sendleftvol, int sendrightvol);
472
486int __sceSasCore(SceSasCore* core, void* dst);
487
504int __sceSasCoreWithMix(SceSasCore* core, void* dst, int leftvol, int rightvol);
505
519
531
541int __sceSasGetAllEnvelopeHeights(SceSasCore* core, int heights[32]);
542
557int __sceSasSetPause(SceSasCore* core, u32 voicebit, int pause);
558
571int __sceSasSetNoise(SceSasCore* core, int voice, int freq);
572
585int __sceSasSetTrianglarWave(SceSasCore* core, int voice, int unk);
586
588int __sceSasSetTriangularWave(SceSasCore* core, int voice, int unk);
589
602int __sceSasSetSteepWave(SceSasCore* core, int voice, int duty);
603
604/* TODO: Expose Atrac3 context struct */
605int __sceSasSetVoiceATRAC3(SceSasCore* core, int voice, void* atrac3ctx);
606int __sceSasConcatenateATRAC3(SceSasCore* core, int voice, void* data, int size);
607int __sceSasUnsetATRAC3(SceSasCore* core, int voice);
608
611#ifdef __cplusplus
612}
613#endif
614
615#endif /* __SCELIBSAS_H__ */
u32 __sceSasGetEndFlag(SceSasCore *core)
Gets the end status of the voices from an SceSasCore nstance.
int __sceSasSetTrianglarWave(SceSasCore *core, int voice, int unk)
Configures the voice to play a triangular waveform.
PspSasOutputModes
Definition pspsascore.h:81
int __sceSasSetVoiceATRAC3(SceSasCore *core, int voice, void *atrac3ctx)
int __sceSasGetEnvelopeHeight(SceSasCore *core, int voice)
Gets the current envelope height of a voice.
int __sceSasSetTriangularWave(SceSasCore *core, int voice, int unk)
A function alias of __sceSasSetTrianglarWave.
int __sceSasCoreWithMix(SceSasCore *core, void *dst, int leftvol, int rightvol)
Runs a sceSas cycle iteration and mixes samples onto destination buffer.
int __sceSasRevType(SceSasCore *core, PspSasEffectTypes type)
Sets the reverb effect of the SceSasCore instance.
int __sceSasSetADSR(SceSasCore *core, int voice, u32 mask, int attackrate, int decayrate, int sustainrate, int releaserate)
Sets the voice ADSR envelope rates for a voice.
int __sceSasSetVolume(SceSasCore *core, int voice, int leftvol, int rightvol, int sendleftvol, int sendrightvol)
Sets the output volume of the voice.
int __sceSasSetPitch(SceSasCore *core, int voice, int pitch)
Sets the pitch value of a voice.
int __sceSasSetVoicePCM(SceSasCore *core, int voice, void *pcm, int samplecount, int loopstart)
Sets PCM data for the given sceSas voice.
int __sceSasSetSteepWave(SceSasCore *core, int voice, int duty)
Configures the voice to play a square waveform.
int __sceSasGetAllEnvelopeHeights(SceSasCore *core, int heights[32])
Gets the current envelope height of all voices.
int __sceSasGetOutputmode(SceSasCore *core)
Gets the current output mode from the SceSasCore instance.
int __sceSasSetSimpleADSR(SceSasCore *core, int voice, u32 envelope1, u32 envelope2)
Configures the entire voice ADSR envelope (rates & curves).
int __sceSasSetPause(SceSasCore *core, u32 voicebit, int pause)
Pauses/unpauses voice playback using a bitmask.
int __sceSasSetKeyOn(SceSasCore *core, int voice)
Plays the voice (starts Attack phase).
int __sceSasSetVoice(SceSasCore *core, int voice, void *vag, int size, int loop)
Sets PlayStation VAG data for a given sceSas voice.
int __sceSasGetPauseFlag(SceSasCore *core)
Get the pause status of every voice in a bitfield.
int __sceSasSetSL(SceSasCore *core, int voice, int level)
Sets the voice ADSR envelope sustain level height.
PspSasADSRFlags
ADSR envelope flags.
Definition pspsascore.h:136
int __sceSasConcatenateATRAC3(SceSasCore *core, int voice, void *data, int size)
int __sceSasSetGrain(SceSasCore *core, int grainsize)
Sets the grain size of the SceSasCore instance.
int __sceSasSetNoise(SceSasCore *core, int voice, int freq)
Configures the voice to play a noise waveform.
PspSasEffectTypes
Definition pspsascore.h:88
int __sceSasRevEVOL(SceSasCore *core, int leftvol, int rightvol)
Sets the effect volume of the SceSasCore instance.
PspSasADSRCurveModes
ADSR envelope curve modes.
Definition pspsascore.h:102
int __sceSasInit(SceSasCore *core, int grainsize, int maxvoices, PspSasOutputModes outputmode, int samplerate)
Initializes a SceSasCore instance.
int __sceSasSetOutputmode(SceSasCore *core, PspSasOutputModes outputmode)
Sets the current output mode of the SceSasCore instance.
int __sceSasRevParam(SceSasCore *core, int delay, int feedback)
Sets the effect delay and feedback parameters of the SceSasCore instance.
PspSasErrorCodes
Error codes used as return values by sceSasCore.
Definition pspsascore.h:115
int __sceSasGetGrain(SceSasCore *core)
Gets the grain size of the SceSasCore instance.
int __sceSasRevVON(SceSasCore *core, int dry, int wet)
Toggles dry and wet audio signals of the SceSasCore instance.
int __sceSasCore(SceSasCore *core, void *dst)
Runs a sceSas cycle iteration and outputs samples onto destination buffer.
int __sceSasSetADSRmode(SceSasCore *core, int voice, u32 mask, PspSasADSRCurveModes attackcurve, PspSasADSRCurveModes decaycurve, PspSasADSRCurveModes sustaincurve, PspSasADSRCurveModes releasecurve)
Sets the voice ADSR envelope curves.
int __sceSasUnsetATRAC3(SceSasCore *core, int voice)
int __sceSasSetKeyOff(SceSasCore *core, int voice)
Stops the voice (starts Release phase).
@ PSP_SAS_OUTPUTMODE_MULTICHANNEL
4 separate output buffers: L, R, Send-L, Send-R (each planar, not interleaved).
Definition pspsascore.h:85
@ PSP_SAS_OUTPUTMODE_STEREO
Interleaved stereo output (L/R), with dry + send already mixed together.
Definition pspsascore.h:83
@ PSP_SAS_ADSR_SUSTAIN
Definition pspsascore.h:139
@ PSP_SAS_ADSR_RELEASE
Definition pspsascore.h:140
@ PSP_SAS_ADSR_DECAY
Definition pspsascore.h:138
@ PSP_SAS_ADSR_ATTACK
Definition pspsascore.h:137
@ PSP_SAS_EFFECT_TYPE_OFF
Definition pspsascore.h:89
@ PSP_SAS_EFFECT_TYPE_PIPE
Definition pspsascore.h:98
@ PSP_SAS_EFFECT_TYPE_LARGE
Definition pspsascore.h:93
@ PSP_SAS_EFFECT_TYPE_ROOM
Definition pspsascore.h:90
@ PSP_SAS_EFFECT_TYPE_DELAY
Definition pspsascore.h:97
@ PSP_SAS_EFFECT_TYPE_MEDIUM
Definition pspsascore.h:92
@ PSP_SAS_EFFECT_TYPE_ECHO
Definition pspsascore.h:96
@ PSP_SAS_EFFECT_TYPE_SPACE
Definition pspsascore.h:95
@ PSP_SAS_EFFECT_TYPE_HALL
Definition pspsascore.h:94
@ PSP_SAS_EFFECT_TYPE_SMALL
Definition pspsascore.h:91
@ PSP_SAS_ADSR_CURVE_MODE_DIRECT
Equivalent to height = rate
Definition pspsascore.h:111
@ PSP_SAS_ADSR_CURVE_MODE_LINEAR_INCREASE
Equivalent to height += rate
Definition pspsascore.h:104
@ PSP_SAS_ADSR_CURVE_MODE_LINEAR_BENT
Definition pspsascore.h:107
@ PSP_SAS_ADSR_CURVE_MODE_EXPONENT_REV
Definition pspsascore.h:108
@ PSP_SAS_ADSR_CURVE_MODE_EXPONENT
Definition pspsascore.h:109
@ PSP_SAS_ADSR_CURVE_MODE_LINEAR_DECREASE
Equivalent to height -= rate
Definition pspsascore.h:106
@ PSP_SAS_ERROR_FX_TYPE
Definition pspsascore.h:126
@ PSP_SAS_ERROR_ALRDYINIT
Definition pspsascore.h:132
@ PSP_SAS_ERROR_PITCH_VAL
Definition pspsascore.h:119
@ PSP_SAS_ERROR_VOLUME_VAL
Definition pspsascore.h:124
@ PSP_SAS_ERROR_NOISE_CLOCK
Definition pspsascore.h:118
@ PSP_SAS_ERROR_NOTINIT
Definition pspsascore.h:131
@ PSP_SAS_ERROR_ADSR_VAL
Definition pspsascore.h:125
@ PSP_SAS_ERROR_ADSR_MODE
Definition pspsascore.h:120
@ PSP_SAS_ERROR_FX_DELAY
Definition pspsascore.h:128
@ PSP_SAS_ERROR_ADDRESS
Definition pspsascore.h:116
@ PSP_SAS_ERROR_VOICE_INDEX
Definition pspsascore.h:117
@ PSP_SAS_ERROR_INVALID_STATE
Definition pspsascore.h:123
@ PSP_SAS_ERROR_FX_VOLUME_VAL
Definition pspsascore.h:129
@ PSP_SAS_ERROR_FX_FEEDBACK
Definition pspsascore.h:127
@ PSP_SAS_ERROR_ADPCM_SIZE
Definition pspsascore.h:121
@ PSP_SAS_ERROR_BUSY
Definition pspsascore.h:130
@ PSP_SAS_ERROR_LOOP_MODE
Definition pspsascore.h:122
uint8_t u8
Definition psptypes.h:38
uint32_t u32
Definition psptypes.h:41
Contains all data related to a sceSasCore state.
Definition pspsascore.h:151