audsrv_set_volume(gSFXVolume);
if ((gSFXVolume != 0 && gSFXVolume <=4)){
audsrv_set_volume(0x0096);
}
if ((gSFXVolume >4 && gSFXVolume <=8)){
audsrv_set_volume(0x0190);
}
if ((gSFXVolume >8 && gSFXVolume <=12)){
audsrv_set_volume(0x0230);
}
Based on the source code, the lowest possible volume value is 0 while max value is:I dont have time to remove the not working volume setting at the time of uploading this, not sure why it didn't work...first thing i tried was setting an integer with user defined values of 0-100 with the callsince the arg is int vol i figured itd be that easy...didn't work so I did a big stupid inefficient volume function just to see if that would work heres a snippetCode:audsrv_set_volume(gSFXVolume);
Code:if ((gSFXVolume != 0 && gSFXVolume <=4)){ audsrv_set_volume(0x0096); } if ((gSFXVolume >4 && gSFXVolume <=8)){ audsrv_set_volume(0x0190); } if ((gSFXVolume >8 && gSFXVolume <=12)){ audsrv_set_volume(0x0230); }
didn't work either...really need to test individual shorts first to see if its an issue there or on my side but i'll do that later.
#define MAX_VOLUME 0x3fff
Try more extreme ranged values. When you day the same, the same as max volume?I tried 0x0096 and 0x3fff both sounded the same, max volume but it's a good suggestion anyway maybe I messed something up during the testing. I will try again when I get a chance.
audsrv_set_volume(0x1000);
What's the SPU2 cache? It doesn't have one... right?I "think" the issue is needing to clear the spu2 cache buffer flags etc .. I'll need to do research in order to try proceed.
I dont have time to remove the not working volume setting at the time of uploading this, not sure why it didn't work...first thing i tried was setting an integer with user defined values of 0-100 with the callsince the arg is int vol i figured itd be that easy...didn't work so I did a big stupid inefficient volume function just to see if that would work heres a snippetCode:audsrv_set_volume(gSFXVolume);
Code:if ((gSFXVolume != 0 && gSFXVolume <=4)){ audsrv_set_volume(0x0096); } if ((gSFXVolume >4 && gSFXVolume <=8)){ audsrv_set_volume(0x0190); } if ((gSFXVolume >8 && gSFXVolume <=12)){ audsrv_set_volume(0x0230); }
didn't work either...really need to test individual shorts first to see if its an issue there or on my side but i'll do that later.
I tried 0x0096 and 0x3fff both sounded the same, max volume but it's a good suggestion anyway maybe I messed something up during the testing. I will try again when I get a chance.
yea the same as max volume, good point though it is default to 100 (max_volume) in cfg so it could be an issue there or some where else related to the int itself.. got a few things to play with
EDIT: ok tested a few things, taking the int gSFXVolume out of the equation completely and just using a standard vol call(as well as a few other lower values) it all sounds exactly the same to me as MAX_VOLUME.. perhaps the volume function for audsrv does not work as intended? or adpcm can only be one volume? im not sure exactly but sfx volume seems like a no go. other people are welcome to test it out and give resultsCode:audsrv_set_volume(0x1000);![]()
you'd know better than me mateWhat's the SPU2 cache? It doesn't have one... right?
audsrv_adpcm_t sfx;
audsrv_load_adpcm(&sfx, snd1_buffer, snd1_size);
audsrv_play_adpcm(&sfx);
memset(&sfx, 0, sizeof(sfx));
audsrv_adpcm_t sfx = {0};
sfx.buffer = NULL;
sfx.size = 0;
struct audsrv_adpcm_t sfx;
struct audsrv_adpcm_t sfx2;
/** Initializes adpcm unit of audsrv
* @returns zero on success, negative value on error
*
* Frees up all memory taken by samples, and stops all voices from
* being played. This can be called multiple times
*/
int audsrv_adpcm_init();

you'd know better than me matea few months ago i was reading about the pcsx2 emulated spu2, i could be confusing some info from that?
The issues im having areall the struct variables are related to sfx right? but i cant clear all variables after a sound callCode:audsrv_adpcm_t sfx;
while inefficient it works for the mean time but it can't be done forever, trying to audsrv_load_adpcm() more than 2 struct pointers causes the console to freeze, so im just assuming i need to clear the spu2 buffers etc to load more sounds but this is also why I said i would need to research because im just making assumptions based off nothing really but trial and error.Code:struct audsrv_adpcm_t sfx; struct audsrv_adpcm_t sfx2;
Reading this part of the header
I would think calling audsrv_adpcm_init() again would solve the issue, but it just freezes the console again. Maybe the lib needs to be deinit and reinit? Issue there is everytime i call audsrv_quit() it also freezes the console.Code:/** Initializes adpcm unit of audsrv * @returns zero on success, negative value on error * * Frees up all memory taken by samples, and stops all voices from * being played. This can be called multiple times */ int audsrv_adpcm_init();
@sp193 I dont want to hassle you every time i run into an issue as i know you are trying to wrap up your ps2 projects for the meantime, but thanks for all your help so far it is appreciated.
I'll do my best to try get something use-able here
struct audsrv_adpcm_t sfx;
struct audsrv_adpcm_t sfx2;
u8* snd_buffer;
int snd_size;
char device_path[128];
char snd1_path[256], snd2_path[256];
void getAudioDevice(void)
{
if ((gAudioPath == 0))
sprintf(device_path, "mc0:Sound/");
if ((gAudioPath == 1))
sprintf(device_path, "pfs0:Sound/");
if ((gAudioPath == 2))
sprintf(device_path, "mass0:Sound/");
}
void sfxInit(void)
{
int ret;
ret = audsrv_init();
if (ret != 0)
{
printf("sfx: failed to initialize audsrv\n");
printf("audsrv returned error string: %s\n", audsrv_get_error_string());
}
audsrv_adpcm_init();
audsrv_set_volume(MAX_VOLUME);
}
int prep_sfx(char *snd_path)
{
FILE* adpcm;
getAudioDevice();
sprintf(snd1_path, "%s/scrollV.adp", device_path);
sprintf(snd2_path, "%s/scrollH.adp", device_path);
adpcm = fopen(snd_path, "rb");
fseek(adpcm, 0, SEEK_END);
snd_size = ftell(adpcm);
fseek(adpcm, 0, SEEK_SET);
snd_buffer = malloc(snd_size);
fread(snd_buffer, 1, snd_size, adpcm);
fclose(adpcm);
return 0;
}
void sfxEnd(void)
{
audsrv_stop_audio(); // I think this only related to PCM audio? put it in anyway in case.
free(snd_buffer);
//memset(&sfx, 0, sizeof(sfx);
//memset(&sfx2, 0, sizeof(sfx2);
}
if (gEnableSFX){
prep_sfx(snd*_path); //snd1_path or snd2_path
audsrv_load_adpcm(&sfx*, snd_buffer, snd_size); //&sfx or &sfx2
audsrv_play_adpcm(&sfx*); //&sfx or &sfx2
sfxEnd();
When you are done with the sound, you should stop all playback and free() snd*_buffer. You may clear the sfx structures then.
It doesn't seem to have a function for changing the individual channel volume levels, after it is set once at initialization. The audsrv_set_volume() function adjusts the master volume level.
I would think calling audsrv_adpcm_init() again would solve the issueCode:/** Initializes adpcm unit of audsrv * @returns zero on success, negative value on error * * Frees up all memory taken by samples, and stops all voices from * being played. This can be called multiple times */ int audsrv_adpcm_init();
header
Code:struct audsrv_adpcm_t sfx; struct audsrv_adpcm_t sfx2; u8* snd_buffer; int snd_size; char device_path[128]; char snd1_path[256], snd2_path[256];
Code:int prep_sfx(char *snd_path) { FILE* adpcm; getAudioDevice(); sprintf(snd1_path, "%s/scrollV.adp", device_path); sprintf(snd2_path, "%s/scrollH.adp", device_path); adpcm = fopen(snd_path, "rb"); fseek(adpcm, 0, SEEK_END); snd_size = ftell(adpcm); fseek(adpcm, 0, SEEK_SET); snd_buffer = malloc(snd_size); fread(snd_buffer, 1, snd_size, adpcm); fclose(adpcm); return 0; }
Code:void sfxEnd(void) { audsrv_stop_audio(); // I think this only related to PCM audio? put it in anyway in case. free(snd_buffer); //memset(&sfx, 0, sizeof(sfx); //memset(&sfx2, 0, sizeof(sfx2); }
Code:if (gEnableSFX){ prep_sfx(snd*_path); //snd1_path or snd2_path audsrv_load_adpcm(&sfx*, snd_buffer, snd_size); //&sfx or &sfx2 audsrv_play_adpcm(&sfx*); //&sfx or &sfx2 sfxEnd();
I've used a struct per sfx, this may be inefficient? which is why i was trying to clear it at sfxEnd() so I can just use the same struct every time with different variables.
struct audsrv_adpcm_t sfx[6];
u8* snd_buffer[6];
int snd_size[6];
char snd_path[6][256];
char device_path[128];
void getAudioDevice(void)
{
if ((gAudioPath == 0))
sprintf(device_path, "mc0:Sound/");
if ((gAudioPath == 1))
sprintf(device_path, "pfs0:Sound/");
if ((gAudioPath == 2))
sprintf(device_path, "mass0:Sound/");
}
int sfxInit(void)
{
FILE* adpcm;
int ret, i;
ret = audsrv_init();
if (ret != 0)
{
printf("sfx: failed to initialize audsrv\n");
printf("audsrv returned error string: %s\n", audsrv_get_error_string());
}
getAudioDevice();
//sfx0
sfx[0].buffer = snd_buffer[0];
sfx[0].size = snd_size[0];
sprintf(snd_path[0], "%s/scrollV.adp", device_path);
//sfx1
sfx[1].buffer = snd_buffer[1];
sfx[1].size = snd_size[1];
sprintf(snd_path[1], "%s/scrollH.adp", device_path);
//sfx2
sfx[2].buffer = snd_buffer[2];
sfx[2].size = snd_size[2];
sprintf(snd_path[2], "%s/page.adp", device_path);
//sfx3
sfx[3].buffer = snd_buffer[3];
sfx[3].size = snd_size[3];
sprintf(snd_path[3], "%s/cancel.adp", device_path);
//sfx4
sfx[4].buffer = snd_buffer[4];
sfx[4].size = snd_size[4];
sprintf(snd_path[4], "%s/transition.adp", device_path);
//sfx5
sfx[5].buffer = snd_buffer[5];
sfx[5].size = snd_size[5];
sprintf(snd_path[5], "%s/alert.adp", device_path);
//sfx6
sfx[6].buffer = snd_buffer[6];
sfx[6].size = snd_size[6];
sprintf(snd_path[6], "%s/confirm.adp", device_path);
audsrv_adpcm_init();
audsrv_set_volume(MAX_VOLUME);
for(i=0; i<3; ++i) { //setting the loop higher than 3, freezes the console...?
adpcm = fopen(snd_path[i], "rb");
if (adpcm == NULL)
{
printf("failed to open adpcm file\n");
audsrv_quit();
break;
}
fseek(adpcm, 0, SEEK_END);
sfx[i].size = ftell(adpcm);
fseek(adpcm, 0, SEEK_SET);
sfx[i].buffer = malloc(sfx[i].size);
if (sfx[i].buffer == 0) //0 or NULL? I think 0 as its related to size
{
printf("memory allocation failed\n");
break;
}
fread(sfx[i].buffer, 1, sfx[i].size, adpcm);
fclose(adpcm);
audsrv_load_adpcm(&sfx[i], sfx[i].buffer, sfx[i].size);
free(sfx[i].buffer);
}
return i;
}