Files
PS2Recomp/ps2xRuntime/include/ps2_audio.h
T
Aslan Hud c1e98c9398 Add IOP, audio, pad, fio changes, VAG handling, and call-stack logger (#76)
- Add IOP with RPC handling (handleRPC, LibSd SID) and init/reset using RDRAM
- Add IOP audio layer for LibSd RPC (handleLibSdRpc)
- Add PS2AudioBackend with VAG decode, onVagTransfer/onSoundCommand, raylib playback
- Add PSPadBackend with readState and raylib input
- Add IOP RAM mapping in Memory (getIOPRAM) for EE↔IOP access
- Add fio syscalls: fioOpen, fioRead, fioWrite, fioClose, fioLseek, fioMkdir
- Add VAG accumulation for fio reads (multi-chunk VagAccumEntry)
- Add ps2_log.h call-stack logger (tab-indented, Debug only, ps2_log.txt next to exe)
- Code generator: emit ps2_log include and PS_LOG_ENTRY for full functions
- Recompiler: emit ps2_log include and PS_LOG_ENTRY for stubs
- Runtime: print "[PS2 LOG] Logs saved at <path>" on exit (Debug only)
2026-02-24 11:45:52 -03:00

49 lines
1.4 KiB
C++

#ifndef PS2_AUDIO_H
#define PS2_AUDIO_H
#include <cstdint>
#include <memory>
#include <mutex>
#include <unordered_map>
#include <vector>
class PS2AudioBackend
{
public:
PS2AudioBackend();
~PS2AudioBackend();
void onVagTransfer(const uint8_t *rdram, uint32_t srcAddr, uint32_t sizeBytes);
void onVagTransferFromBuffer(const uint8_t *data, uint32_t sizeBytes, uint32_t keyAddr);
void onSoundCommand(uint32_t sid, uint32_t rpcNum,
const uint8_t *sendBuf, uint32_t sendSize,
uint8_t *recvBuf, uint32_t recvSize);
void play(uint32_t sampleAddr, float pitch = 1.0f, float volume = 1.0f,
uint32_t voiceIndex = 0xFFFFFFFFu);
void stop(uint32_t voiceId);
void stopAll();
void setAudioReady(bool ready) { m_audioReady = ready; }
private:
struct DecodedSample
{
std::vector<int16_t> pcm;
uint32_t sampleRate = 44100;
};
struct Impl;
std::unique_ptr<Impl> m_impl;
bool m_audioReady = false;
uint32_t m_mostRecentSampleKey = 0;
std::vector<DecodedSample> m_loadOrderSamples;
std::unordered_map<uint32_t, DecodedSample> m_sampleBank;
std::mutex m_mutex;
void playDecodedSample(uint32_t sampleKey, DecodedSample &sample, float pitch, float volume,
bool isBgm = false);
void pruneFinishedSounds();
};
#endif