I just compiled an old build of the source code I had on my pc with your updates to AUDSRV and can confirm working PCM audio (if I don't also use ADPCM)Was it ever working, after I made those changes on Sunday?
This does sound a bit complicated to me but I'll still try myself until you have free time, although using the code in my statement above with the working PCM code copied into the current build along side the working ADPCM code; PCM stalls the console.If this seems too complicated, I can help you with this soon.
But then again, aren't you planning to add a sounds menu? So there is no need to change the applyConfig function. You can call the sound initialization functions after it.
void guiShowAudioConfig(void)
{
const char *AudioPaths[] = {"<not set>", "MC 1", "MC 2", "HDD", "USB", NULL};
diaSetEnum(diaAudioConfig, CFG_AUDIOPATH, AudioPaths);
diaSetInt(diaAudioConfig, CFG_SFX, gEnableSFX);
diaSetInt(diaAudioConfig, CFG_BGM, gEnableBGM);
diaSetInt(diaAudioConfig, CFG_AUDIOPATH, gAudioPath);
diaSetInt(diaAudioConfig, CFG_SFX_VOLUME, gSFXVolume);
diaSetInt(diaAudioConfig, CFG_BGM_VOLUME, gBGMVolume);
int ret = diaExecuteDialog(diaAudioConfig, -1, 1, &guiUpdater);
if (ret) {
diaGetInt(diaAudioConfig, CFG_SFX, &gEnableSFX);
diaGetInt(diaAudioConfig, CFG_BGM, &gEnableBGM);
diaGetInt(diaAudioConfig, CFG_AUDIOPATH, &gAudioPath);
diaGetInt(diaAudioConfig, CFG_SFX_VOLUME, &gSFXVolume);
diaGetInt(diaAudioConfig, CFG_BGM_VOLUME, &gBGMVolume);
applyConfig(-1, -1);
setVolume();
}
}
From what I've tested your changes to the volume control in AUDSRV work perfectly, thanks for taking the time to do this.The volume functions on the EE always expected a volume parameter in the range of 0 to 100, but that was not how the EE-side MIN_VOLUME and MAX_VOLUME were defined.
I just compiled an old build of the source code I had on my pc with your updates to AUDSRV and can confirm working PCM audio (if I don't also use ADPCM)
Is this the call to applyConfig you mean? The one in the audio settings menu, if so adding a call to setVolume() works as intended allowing for runtime adjusting of the adpcm volume (probably pcm too but I cant test that yet)Code:void guiShowAudioConfig(void) { const char *AudioPaths[] = {"<not set>", "MC 1", "MC 2", "HDD", "USB", NULL}; diaSetEnum(diaAudioConfig, CFG_AUDIOPATH, AudioPaths); diaSetInt(diaAudioConfig, CFG_SFX, gEnableSFX); diaSetInt(diaAudioConfig, CFG_BGM, gEnableBGM); diaSetInt(diaAudioConfig, CFG_AUDIOPATH, gAudioPath); diaSetInt(diaAudioConfig, CFG_SFX_VOLUME, gSFXVolume); diaSetInt(diaAudioConfig, CFG_BGM_VOLUME, gBGMVolume); int ret = diaExecuteDialog(diaAudioConfig, -1, 1, &guiUpdater); if (ret) { diaGetInt(diaAudioConfig, CFG_SFX, &gEnableSFX); diaGetInt(diaAudioConfig, CFG_BGM, &gEnableBGM); diaGetInt(diaAudioConfig, CFG_AUDIOPATH, &gAudioPath); diaGetInt(diaAudioConfig, CFG_SFX_VOLUME, &gSFXVolume); diaGetInt(diaAudioConfig, CFG_BGM_VOLUME, &gBGMVolume); applyConfig(-1, -1); setVolume(); } }
but if I call sfxInit() again to reset pathing and re-read sfx files
or even just call audsrv_adpcm_init() to clear the spu2 buffer of samples; the console stalls.
Sure, no problem.From what I've tested your changes to the volume control in AUDSRV work perfectly, thanks for taking the time to do this.
PCM works if I remove all traces of ADPCM code, if I keep the ADPCM code in and add PCM code; ADPCM plays fine but when I trigger PCM the console freezes. (Even if ADPCM just initializes loads files into the buffer but never plays them if PCM is triggered the console stalls.)What exactly happens? So if you tried to play PCM, would this totally prevent any ADPCM samples from being played?
Or is it unable to play PCM audio at all, once you played ADPCM sounds?
What do you mean by "don't also use ADPCM"? Do you still initialize the ADPCM half of AUDSRV as usual, or did you remove all traces of ADPCM code?
Will do, Don't I need to call audsrv_adpcm_init again to clear the buffer? It's just audsrv_init that doesn't need to be called again right.If you want to get it to load new sound files, you might want to split off the logic for initializing AUDSRV itself from the logic that initializes the paths. Then it would not need to call the RPC-initialization functions, when it does not actually
Edit: Other functions do work, yea; setVolume() for example works so volume is now adjustable during runtime.But do other functions work? Did you stop playback of
(or simply avoid playing) all sounds first?
PCM works if I remove all traces of ADPCM code, if I keep the ADPCM code in and add PCM code; ADPCM plays fine but when I trigger PCM the console freezes. (Even if ADPCM just initializes loads files into the buffer but never plays them if PCM is triggered the console stalls.)
SifLoadModule("rom0:LIBSD", 0, NULL);
Will do, Don't I need to call audsrv_adpcm_init again to clear the buffer? It's just audsrv_init that doesn't need to be called again right.
Edit: Other functions do work, yea; setVolume() for example works so volume is now adjustable during runtime.
I didn't stop all playback but no sound was playing, I guess maybe it's because it's trying to play the confirm sound when clicking 'OK' at the same time as I'm trying to clear the buffer and reinit; never thought of that. Not sure of a way around that but I'll try think of something. (To test first I think I'll just remove the sound call for gSelectButton to make sure that's the problem) I'm not sure of any other way to stop playback other than audsrv_quit but then I'd have to reinit the whole lib

void pcm_test(void)
{
int ret;
int played;
int err;
char chunk[2048];
FILE *wav;
struct audsrv_fmt_t format;
format.bits = 16;
format.freq = 22050;
format.channels = 2;
err = audsrv_set_format(&format);
printf("set format returned %d\n", err);
printf("audsrv returned error string: %s\n", audsrv_get_error_string());
audsrv_set_volume(MAX_VOLUME);
wav = fopen("mass0:SND/up_down.wav", "rb");
if (wav == NULL)
{
printf("failed to open wav file\n");
audsrv_quit();
}
fseek(wav, 0x30, SEEK_SET);
printf("starting play loop\n");
played = 0;
while (1)
{
ret = fread(chunk, 1, sizeof(chunk), wav);
if (ret > 0)
{
audsrv_wait_audio(ret);
audsrv_play_audio(chunk, ret);
}
if (ret < sizeof(chunk))
{
/* no more data */
break;
}
played++;
if (played % 8 == 0)
{
printf(".");
}
if (played == 512) break;
}
fclose(wav);
printf("sample: stopping audsrv\n");
audsrv_quit();
printf("sample: ended\n");
}

This is great, its impressive you were able to fix things so quickly. Thanks again hahaNew changes to the PS2SDK, to fix existing issues:
- Changed libsd's SD_SWITCH_KEYDOWN and SD_SWITCH_KEYUP to SD_SWITCH_KEYON and SD_SWITCH_KEYOFF respectively
- Fixed AUDSRV clearing the block transfer handler with sceSdInit() whenever audsrv_adpcm_init() is called.
- audsrv_adpcm_init() will no longer call sceSdInit(), but will stop playing ADPCM sounds by setting SD_SWITCH_KEYOFF.
- audsrv_adpcm_init() will now initialize the volume for voice channel 0 as well.
- Standardized the DMA channel numbers throughout AUDSRV.
- audsrv_quit() will now call audsrv_adpcm_init() to stop voice playback and will terminate the playback thread before deinitializing the RPC client - to avoid a RPC call with an invalid RPC client.
static int bgmFormat(void)
{
int ret;
struct audsrv_fmt_t bgm_fmt;
bgm_fmt.bits = 16;
bgm_fmt.freq = 22050;
bgm_fmt.channels = 2;
ret = audsrv_set_format(&bgm_fmt);
if (ret != 0)
{
printf("Error setting audio format %d\n", ret);
}
return ret;
}