sceAudioSetFrequency -- what can i do to get it to work?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Viper8896
Posts: 110
Joined: Thu Jan 26, 2006 6:20 pm

sceAudioSetFrequency -- what can i do to get it to work?

Post by Viper8896 »

im trying to play a 48000hz file by calling a function which i have in a kernel mode prx. the problem is that it still plays at 44100hz which just makes the music go all slow and deep voice.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Cooleyes already did something like that for PPA. From the latest source code, his prx is:

main.c

Code: Select all

#include <pspsdk.h>
#include <pspkernel.h>
#include <string.h>
#include <pspaudio_kernel.h>


#define VERS 1
#define REVS 0


PSP_MODULE_INFO&#40;"cooleyesAudio", 0x1006, VERS, REVS&#41;;
PSP_MAIN_THREAD_ATTR&#40;0&#41;;

int pspAudioSetFrequency&#40;int frequency&#41; &#123;
	return sceAudioSetFrequency&#40;frequency&#41;;
&#125;

int module_start&#40;SceSize args, void *argp&#41;&#123;
	return 0;
&#125;

int module_stop&#40;&#41;&#123;
	return 0;
&#125;
makefile

Code: Select all

TARGET = cooleyesAudio
OBJS = main.o

INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;

BUILD_PRX = 1
PRX_EXPORTS = cooleyesAudio.exp

USE_KERNEL_LIBC=1
USE_KERNEL_LIBS=1

LIBDIR =
LDFLAGS = -mno-crt0 -nostartfiles
LIBS = -lpspkernel -lpspaudio_driver


PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build.mak
cooleyesAudio.exp

Code: Select all

# Define the exports for the prx
PSP_BEGIN_EXPORTS

# These four lines are mandatory &#40;although you can add other functions like module_stop&#41;
# syslib is a psynonym for the single mandatory export.
PSP_EXPORT_START&#40;syslib, 0, 0x8000&#41;
PSP_EXPORT_FUNC_HASH&#40;module_start&#41;
PSP_EXPORT_VAR_HASH&#40;module_info&#41;
PSP_EXPORT_END

PSP_EXPORT_START&#40;cooleyesAudio, 0, 0x4001&#41;
PSP_EXPORT_FUNC&#40;pspAudioSetFrequency&#41;
PSP_EXPORT_END

PSP_END_EXPORTS
Viper8896
Posts: 110
Joined: Thu Jan 26, 2006 6:20 pm

Post by Viper8896 »

ive been trying that very similar all the time. has sony done something to change it since 3.5 http://silverspring.lan.st/3.5x/kd/audio.html cos this is what prxtool gives me. no 0xA2BEAA6C.

Code: Select all

Export 1, Name sceAudio_driver, Functions 27, Variables 0, flags 00010011
Functions&#58;
0x035C14C6 &#91;0x00000578&#93; - sceAudio_driver_035C14C6
0x138A70F1 &#91;0x00002074&#93; - sceAudio_driver_138A70F1
0x1A223275 &#91;0x00002684&#93; - sceAudio_driver_1A223275
0x3D4B75F7 &#91;0x000028F4&#93; - sceAudio_driver_3D4B75F7
0x43645E69 &#91;0x0000210C&#93; - sceAudio_driver_43645E69
0x442588EB &#91;0x00001434&#93; - sceAudio_driver_442588EB
0x47D06FE6 &#91;0x000007F8&#93; - sceAudio_driver_47D06FE6
0x5140D94F &#91;0x000008F4&#93; - sceAudio_driver_5140D94F
0x63BBD850 &#91;0x000027E4&#93; - sceAudio_driver_63BBD850
0x669D93E4 &#91;0x00001E08&#93; - sceAudio_driver_669D93E4
0x7222BC76 &#91;0x00002910&#93; - sceAudio_driver_7222BC76
0x798FB2A3 &#91;0x00000660&#93; - sceAudio_driver_798FB2A3
0x8BCD60A5 &#91;0x000028A8&#93; - sceAudio_driver_8BCD60A5
0xA17F55D7 &#91;0x00000F70&#93; - sceAudio_driver_A17F55D7
0xB282F4B2 &#91;0x00000F20&#93; - sceAudio_driver_B282F4B2
0xBED111E5 &#91;0x000015F4&#93; - sceAudio_driver_BED111E5
0xC2031226 &#91;0x00000E68&#93; - sceAudio_driver_C2031226
0xCC966C3A &#91;0x00002750&#93; - sceAudio_driver_CC966C3A
0xD6620E8E &#91;0x00000C4C&#93; - sceAudio_driver_D6620E8E
0xD81BCF3F &#91;0x00001314&#93; - sceAudio_driver_D81BCF3F
0xDDB4EFE9 &#91;0x00001960&#93; - sceAudio_driver_DDB4EFE9
0xE4A9D621 &#91;0x00000AD8&#93; - sceAudio_driver_E4A9D621
0xE73CE6EE &#91;0x00001110&#93; - sceAudio_driver_E73CE6EE
0xF42AAEFB &#91;0x00002938&#93; - sceAudio_driver_F42AAEFB
0xF9504CA4 &#91;0x0000105C&#93; - sceAudio_driver_F9504CA4
0xFC67A110 &#91;0x000018C4&#93; - sceAudio_driver_FC67A110
0xFC7AA255 &#91;0x0000151C&#93; - sceAudio_driver_FC7AA255
Export 2, Name sceAudio, Functions 27, Variables 0, flags 40010011
Functions&#58;
0x01562BA3 &#91;0x00001354&#93; - sceAudio_01562BA3
0x086E5895 &#91;0x000028A8&#93; - sceAudio_086E5895
0x136CAF51 &#91;0x00000660&#93; - sceAudio_136CAF51
0x13F592BC &#91;0x000008F4&#93; - sceAudio_13F592BC
0x2D53F36E &#91;0x00001374&#93; - sceAudio_2D53F36E
0x38553111 &#91;0x00001E08&#93; - sceAudio_38553111
0x41EFADE7 &#91;0x00000C4C&#93; - sceAudio_41EFADE7
0x43196845 &#91;0x00001390&#93; - sceAudio_43196845
0x5C37C0AE &#91;0x00002074&#93; - sceAudio_5C37C0AE
0x5EC81C55 &#91;0x00000AD8&#93; - sceAudio_5EC81C55
0x63F2889C &#91;0x00001254&#93; - sceAudio_63F2889C
0x647CEF33 &#91;0x000012C4&#93; - sceAudio_647CEF33
0x6D4BEC68 &#91;0x000028F4&#93; - sceAudio_6D4BEC68
0x6FC46853 &#91;0x00000E68&#93; - sceAudio_6FC46853
0x7DE61688 &#91;0x00002750&#93; - sceAudio_7DE61688
0x87B2E651 &#91;0x00002684&#93; - sceAudio_87B2E651
0x8C1009B2 &#91;0x00000578&#93; - sceAudio_8C1009B2
0x95FD0C2D &#91;0x00001110&#93; - sceAudio_95FD0C2D
0xA633048E &#91;0x00002938&#93; - sceAudio_A633048E
0xA708C6A6 &#91;0x00002910&#93; - sceAudio_A708C6A6
0xB011922F &#91;0x00000F20&#93; - sceAudio_B011922F
0xB7E1D8E7 &#91;0x0000105C&#93; - sceAudio_B7E1D8E7
0xCB2E439E &#91;0x00000F70&#93; - sceAudio_CB2E439E
0xE0727056 &#91;0x0000210C&#93; - sceAudio_E0727056
0xE2D56B2D &#91;0x000007F8&#93; - sceAudio_E2D56B2D
0xE926D3FB &#91;0x000027E4&#93; - sceAudio_E926D3FB
0xE9D97901 &#91;0x00001314&#93; - sceAudio_E9D97901
or do i just not no how to use prxtool
cooleyes
Posts: 123
Joined: Thu May 18, 2006 3:30 pm

Post by cooleyes »

sceAudioSetFrequency is still in fw360, but change in fw371
so , the new code in ppa is this :

sceAudio_driver371.S

Code: Select all

	.set noreorder

#include "pspimport.s"

	IMPORT_START	"sceAudio_driver",0x00010000
	IMPORT_FUNC	"sceAudio_driver",0x442588EB,sceAudioSetFrequency371
main.c

Code: Select all

#include <pspsdk.h>
#include <pspkernel.h>
#include <string.h>
#include <pspaudio_kernel.h>


#define VERS 1
#define REVS 0


PSP_MODULE_INFO&#40;"cooleyesAudio", 0x1006, VERS, REVS&#41;;
PSP_MAIN_THREAD_ATTR&#40;0&#41;;

int sceAudioSetFrequency371&#40;int frequency&#41;;

int pspAudioSetFrequency&#40;int devkitVersion, int frequency&#41; &#123;
	if &#40;devkitVersion < 0x03070110&#41;
		return sceAudioSetFrequency&#40;frequency&#41;;
	else
		return sceAudioSetFrequency371&#40;frequency&#41;;
&#125;

int module_start&#40;SceSize args, void *argp&#41;&#123;
	return 0;
&#125;

int module_stop&#40;&#41;&#123;
	return 0;
&#125;
makefile

Code: Select all

TARGET = cooleyesAudio
OBJS = main.o sceAudio_driver371.o

INCDIR = 
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;

BUILD_PRX = 1
PRX_EXPORTS = cooleyesAudio.exp

USE_KERNEL_LIBC=1
USE_KERNEL_LIBS=1

PSP_FW_VERSION = 371

LIBDIR = 
LDFLAGS = -mno-crt0 -nostartfiles
LIBS = -lpspkernel -lpspaudio_driver 


PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build.mak
cooleyesAudio.exp

Code: Select all

# Define the exports for the prx
PSP_BEGIN_EXPORTS

# These four lines are mandatory &#40;although you can add other functions like module_stop&#41;
# syslib is a psynonym for the single mandatory export.
PSP_EXPORT_START&#40;syslib, 0, 0x8000&#41;
PSP_EXPORT_FUNC_HASH&#40;module_start&#41;
PSP_EXPORT_VAR_HASH&#40;module_info&#41;
PSP_EXPORT_END

PSP_EXPORT_START&#40;cooleyesAudio, 0, 0x4001&#41;
PSP_EXPORT_FUNC&#40;pspAudioSetFrequency&#41;
PSP_EXPORT_END

PSP_END_EXPORTS
cooleyesAudio.h

Code: Select all

#ifdef __cplusplus
extern "C" &#123;
#endif

/**
  * Set audio sampling frequency
  *
  * @param frequency - Sampling frequency to set audio output to - either 44100 or 48000.
  *
  * @returns 0 on success, an error if less than 0.
  */
int pspAudioSetFrequency&#40;int devkitVersion, int frequency&#41;;

/*@&#125;*/

#ifdef __cplusplus
&#125;
#endif
Viper8896
Posts: 110
Joined: Thu Jan 26, 2006 6:20 pm

Post by Viper8896 »

thanks for your quick response. do you know if this work the same as the old function or is there something different like allowing other frequencies other than 44100/48000 for example.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

cooleyes wrote:sceAudioSetFrequency is still in fw360, but change in fw371
Good info, cooleyes. I wonder how many other things Sony changed like that as well.
cooleyes
Posts: 123
Joined: Thu May 18, 2006 3:30 pm

Post by cooleyes »

J.F. wrote:
cooleyes wrote:sceAudioSetFrequency is still in fw360, but change in fw371
Good info, cooleyes. I wonder how many other things Sony changed like that as well.
hehe, I don't know. :P
SDK for 3.71 M33

Some changes have been added in this sdk: sctrlHENSetOnApplyPspRelSectionEven has been replaced
by sctrlHENSetStartModuleHandler.

Sony has changed a lot of kernel nids: ctrl, power, syscon, sysreg, clockgen, umd modules, etc
If your prx doesn't load, dump your nids using prxtool, and compare them to the ones of 3.71.

Sony has also deleted the power speed functions from kernel usage. You can use the new function
sctrlHENSetSpeed to fix this issue.

Included is a sample that uses the 32 MB of extra ram of the psp slim.
this is a README in SDK for 3.71 M33
I try to use old sceAudioSetFrequency nid to call , but do not work.
so I disasm audio.prx(3.71) by use svn prxtool.exe,
and compare with audio.prx(1.50) , and find out the new nid
Viper8896
Posts: 110
Joined: Thu Jan 26, 2006 6:20 pm

Post by Viper8896 »

have you tested this. im trying to use it in a kernel mode prx which im starting kukernelloadmodule but it is still treating the stream as 44100. i had a thorough look at all my code and couldn't see any errors but i will look more when i get some time. do you have an example that plays 48000 on 3.71?
cooleyes
Posts: 123
Joined: Thu May 18, 2006 3:30 pm

Post by cooleyes »

Viper8896 wrote:have you tested this. im trying to use it in a kernel mode prx which im starting kukernelloadmodule but it is still treating the stream as 44100. i had a thorough look at all my code and couldn't see any errors but i will look more when i get some time. do you have an example that plays 48000 on 3.71?
you must call sceAudioSetFrequency before sceAudioChReserve
Viper8896
Posts: 110
Joined: Thu Jan 26, 2006 6:20 pm

Post by Viper8896 »

i forgot to actually start the module first time i was just loading it. now that ive done that it still doesn't work. i was originally calling it before the channel reserve anyway but i tried it after to see if that would make a difference.

edit:

ive just noticed that when i return to the xmb it is all slow and deep which stays in effect until i restart the psp.
cooleyes
Posts: 123
Joined: Thu May 18, 2006 3:30 pm

Post by cooleyes »

ok , I got it
we must call "pspSdkSetK1(0)" first;

main.c

Code: Select all

#include <pspsdk.h> 
#include <pspkernel.h> 
#include <string.h> 
#include <pspaudio_kernel.h> 


#define VERS 1 
#define REVS 0 


PSP_MODULE_INFO&#40;"cooleyesAudio", 0x1006, VERS, REVS&#41;; 
PSP_MAIN_THREAD_ATTR&#40;0&#41;; 

int sceAudioSetFrequency371&#40;int frequency&#41;; 

int pspAudioSetFrequency&#40;int devkitVersion, int frequency&#41; &#123; 
   u32 k1; 
   k1 = pspSdkSetK1&#40;0&#41;;
   int ret;
   if &#40;devkitVersion < 0x03070110&#41; 
      ret = sceAudioSetFrequency&#40;frequency&#41;; 
   else 
      ret = sceAudioSetFrequency371&#40;frequency&#41;;
   pspSdkSetK1&#40;k1&#41;;
   return ret; 
&#125; 

int module_start&#40;SceSize args, void *argp&#41;&#123; 
   return 0; 
&#125; 

int module_stop&#40;&#41;&#123; 
   return 0; 
&#125; 
PeterLeRoi
Posts: 31
Joined: Wed May 16, 2007 11:08 am

Post by PeterLeRoi »

Only the output frequency can be changed? I need to sample at 8000 Hz, and was thinking 48000 Hz would be great :)

How can I get it to work? I´m afraid i´m a noob programming for psp. Want some file .c to include in my main.c and then, at the beginning of the program change the frequency with sceAudioSetFrequency(48000). Is this possible?

Thanks ;)
Post Reply