Which libraries does sceAudioSetFrequency need?

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

Moderators: cheriff, TyRaNiD

Post Reply
PeterLeRoi
Posts: 31
Joined: Wed May 16, 2007 11:08 am

Which libraries does sceAudioSetFrequency need?

Post by PeterLeRoi »

I´m trying to program using sceAudioSetFrequency, but the compiler always says:

main.c:(.text+0x21c0): undefined reference to `sceAudioSetFrequency'
collect2: ld returned 1 exit status
make: *** [Audio_Mechanica.elf] Error 1

I´m including <pspaudiolib.h>, <pspaudio.h> and <pspaudio_kernel.h>. I´ve been reading http://psp.jim.sh/pspsdk-doc/ : files -> file list -> pspaudio_kernel.h, and I thought these libraries would be enough :(

Thanks for the help ;)
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

You need to link pspaudio_driver
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
PeterLeRoi
Posts: 31
Joined: Wed May 16, 2007 11:08 am

Post by PeterLeRoi »

Thanks for your help Raphael :)

I´ve seen in a post from cooleyes, there are many files:

sceAudio_driver371.S , main.c , makefile , cooleyesAudio.exp , cooleyesAudio.h

Do I need to compile it and launch the .prx from my program?
Don´t know what (and how) to link :(

Again, thanks :)
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

sceAudioSetFrequency is a kernel level call. If you are doing 1.50 homebrew, that's no big deal, but if you're trying to be 3.xx/Slim compatible, you cannot call it in your app. You have to do like cooleyes and put it in an external prx.
PeterLeRoi
Posts: 31
Joined: Wed May 16, 2007 11:08 am

Post by PeterLeRoi »

I´m working with 3.03 version... so, instead :

sceAudioSetFrequency(48000);

I should do something like:

sceKernelLoadExec(pathTo.PRX, NULL);

with the .prx compiled using cooleyes source code ?

Thanks ;)



Edit: I´ve tried loading .prx (that get compiling cooleyes´ code) with :

sceKernelLoadExec("./setfrequency/cooleyesAudio.prx", NULL);

and psp freezes when reach that line :(

I´ve never loaded any .prx so don´t know if doing the correct steps.

Any help, please?
PeterLeRoi
Posts: 31
Joined: Wed May 16, 2007 11:08 am

Post by PeterLeRoi »

Ok, I´ve linked the pspaudio_driver. Now the program compiles ok, but when I start it using psplink get 0x80020001 error, and if put the eboot on psp´s "Game150" and launch, psp crashes and turn off. I´m using version 3.02 OE - B

The error is something about "kernel error", so maybe if dowgrade to 1.5 it´ll work fine. Don´t know. But, my question, isn´t psp suppose to run the program on kernel mode if I put it on "Game150" directory?
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

PeterLeRoi wrote:Ok, I´ve linked the pspaudio_driver. Now the program compiles ok, but when I start it using psplink get 0x80020001 error, and if put the eboot on psp´s "Game150" and launch, psp crashes and turn off. I´m using version 3.02 OE - B

The error is something about "kernel error", so maybe if dowgrade to 1.5 it´ll work fine. Don´t know. But, my question, isn´t psp suppose to run the program on kernel mode if I put it on "Game150" directory?
Only if you've programmed it to be kernel mode app. If you write it to be a 3.xx user mode app, you need to put it in GAME3xx or GAME with the kernel mode set to 3xx in the recovery menu.

You don't seem to get what I meant in my first reply. Read this thread entirely:
http://forums.ps2dev.org/viewtopic.php?t=9022
PeterLeRoi
Posts: 31
Joined: Wed May 16, 2007 11:08 am

Post by PeterLeRoi »

Thanks for your help J.F.

I´ve changed the attributes on PSP_MODULE_INFO, now I run the program on kernel mode.

The program compiles, but when I´m running it everything is fine until it reachs

sceAudioSetFrequency(48000);

at this line, psp freezes and turns off.

This is the error:

Code: Select all


Opening connection to localhost port 10000

host0&#58;/> ./Audio_Mechanica.elf
Load/Start host0&#58;/Audio_Mechanica.elf UID&#58; 0x044C3C65 Name&#58; Virtual Tape Recorder

host0&#58;/> Exception - Bus error &#40;instr&#41;
Thread ID - 0x0448ED71
Th Name   - user_main
EPC       - 0x080C2764
Cause     - 0x10000018
BadVAddr  - 0x08001080
Status    - 0x20008613
zr&#58;0x00000000 at&#58;0x0008FF00 v0&#58;0x00000000 v1&#58;0x00000000
a0&#58;0x0000BB80 a1&#58;0x00000000 a2&#58;0x88224898 a3&#58;0x00000000
t0&#58;0x00000000 t1&#58;0x0000133F t2&#58;0x20008600 t3&#58;0x882FFA00
t4&#58;0x09FFEDF8 t5&#58;0x00000E00 t6&#58;0x08902218 t7&#58;0x00008600
s0&#58;0x00070000 s1&#58;0x08910000 s2&#58;0x00000001 s3&#58;0x00000100
s4&#58;0x08910000 s5&#58;0x08910000 s6&#58;0x09F20000 s7&#58;0x08910000
t8&#58;0x00000000 t9&#58;0x880BF5B0 k0&#58;0x09FFEF00 k1&#58;0x00000000
gp&#58;0x0891A950 sp&#58;0x09FFEDF8 fp&#58;0x09FFEEA0 ra&#58;0x08902220

I thought: "Ok, I´ll read again the doc about this instruction". And my surprise, if look at "user audio library" on

http://www.geardome.com/pspsdk-doc/

it doesn´t appear, but if look on

http://psp.jim.sh/pspsdk-doc/

then the function appears.

Why? (the error or the appearing/dissapearing fuction)

Thanks again :)
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

Regarding the error, it's not clear from the error where the problem lies; build your code with debugging symbols and run psp-addr2line on the EPC to find out which instruction is actually failing.

Regarding the docs, psp.jim.sh is updated daily, and the geardome.com site is just an old mirror of that.
PeterLeRoi
Posts: 31
Joined: Wed May 16, 2007 11:08 am

Post by PeterLeRoi »

Thanks for your help jimparis

About the error, I didn´t explain it before, the program works without this instruction, but I need to add it. So I wrote the program:

If press L trigger, then it´ll run sceAudioSetFrequency in order to change frequency to 48000.

If don´t press L trigger, program works fine, can record and play sounds at 44100 Hz. Everything´s correct. But when press L trigger psp freezes, I´m 100% sure it´s related to that function.
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

Yes, but knowing where the error is occuring is still important. From what you've said I don't think there's enough info to figure out the problem..
PeterLeRoi
Posts: 31
Joined: Wed May 16, 2007 11:08 am

Post by PeterLeRoi »

Thanks for your help :)

I´ve started programming psp recently and don´t have much time, so don´t want my program works for any version specifically, if it works only on 1.5 it´ll be enough.

This afternoon I´ll downgrade to 1.5 and check if then the program can run.

Edit: tried on 1.5 and the same result :(

Code: Select all

Opening connection to localhost port 10000

host0&#58;/> ./Audio_Mechanica.elf
Load/Start host0&#58;/Audio_Mechanica.elf UID&#58; 0x0449F847 Name&#58; Virtual Tape Recorde
r

host0&#58;/> Exception - Bus error &#40;instr&#41;
Thread ID - 0x04490D53
Th Name   - user_main
EPC       - 0x080C2764
Cause     - 0x00000018
BadVAddr  - 0x80010050
Status    - 0x20008613
zr&#58;0x00000000 at&#58;0x0008FF00 v0&#58;0x00000000 v1&#58;0x00000000
a0&#58;0x0000BB80 a1&#58;0x00000000 a2&#58;0x88224998 a3&#58;0x00000000
t0&#58;0x00000000 t1&#58;0x0001B9ED t2&#58;0x20008600 t3&#58;0x882FFA00
t4&#58;0x09FFEDF8 t5&#58;0x00000E00 t6&#58;0x08902218 t7&#58;0x00008600
s0&#58;0x00070000 s1&#58;0x08910000 s2&#58;0x00000001 s3&#58;0x00000100
s4&#58;0x08910000 s5&#58;0x08910000 s6&#58;0x09F20000 s7&#58;0x08910000
t8&#58;0x00000000 t9&#58;0x880107E0 k0&#58;0x09FFEF00 k1&#58;0x00000000
gp&#58;0x0891A950 sp&#58;0x09FFEDF8 fp&#58;0x09FFEEA0 ra&#58;0x08902220
reset
Resetting psplink

host0&#58;/>
Maybe I´m forgetting something:

Code: Select all

#include "pspaudio_kernel.h"
...
PSP_MODULE_INFO&#40;"Virtual Tape Recorder", PSP_MODULE_KERNEL, 1, 1&#41;;
...
int main&#40;int argc, char* argv&#91;&#93;&#41;&#123;
          ...
          sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
          ...
          case DETECTA_L&#58;
		printf&#40;"\nChanging frec"&#41;;
		sceAudioSetFrequency&#40;48000&#41;;
		printf&#40;"\nFreq changed OK"&#41;;
		sceKernelDelayThread&#40;500000&#41;;
		break;

....
and Makefile:

Code: Select all

TARGET = Audio_Mechanica
OBJS = logging.o psp_audio_ext.o file_browser.o main.o 

INCDIR                 &#58;= ./include 
CFLAGS = -O2 -G0 -Wall -g
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti

ASFLAGS = $&#40;CFLAGS&#41;

LIBDIR = 
LDFLAGS =
LIBS = -lpspaudiolib -lpspaudio -lpspaudio_driver

EXTRA_TARGETS = EBOOT.PBP kxploit
PSP_EBOOT_TITLE = Audio Mechanica
EXTRA_CLEAN            = clean_kxploit
PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;

include $&#40;PSPSDK&#41;/lib/build.mak

copy&#58;
	cp -r __SCE__$&#123;TARGET&#125; /media/psp/psp/GAME/
	cp -r %__SCE__$&#123;TARGET&#125; /media/psp/psp/GAME/

Don´t know how to make Makefiles well, so I´m using Audio Mechanica´s Makefile with some changes :(
Last edited by PeterLeRoi on Fri Nov 16, 2007 2:11 am, edited 1 time in total.
PeterLeRoi
Posts: 31
Joined: Wed May 16, 2007 11:08 am

Post by PeterLeRoi »

I´ve tried :

Peter@pete /cygdrive/e/Uni/PSP/Polemic Desarrolleision
$ psp-addr2line.exe -fe Audio_Mechanica.elf 0x080C2764
??
??:0

I´ve added -g to my makefile, but it uses other files that didn´t know how were compilated :(
PeterLeRoi
Posts: 31
Joined: Wed May 16, 2007 11:08 am

Post by PeterLeRoi »

Ok, as I can´t get sceAudioSetFrequency working on my program, I´ve taken a "hello world" (main.c and Makefile):

1. link pspaudio_driver, pspaudio and pspaudiolib
2. add -g to CFLAGS on makefile
3. add #include <pspaudio_kernel.h>, #include <pspaudio.h>, #include <pspaudiolib.h> to main.c
4. changed PSP_MODULE_INFO´s mode attribute to 0x1000
and 5. added just one instruction sceAudioSetFrequency(48000)

And the result:

Code: Select all

host0&#58;/> ./hello.elf
Load/Start host0&#58;/hello.elf UID&#58; 0x044C5635 Name&#58; Hello World

host0&#58;/> Exception - Bus error &#40;instr&#41;
Thread ID - 0x04492C41
Th Name   - user_main
EPC       - 0x080C2764
Cause     - 0x00000018
BadVAddr  - 0xA0144848
Status    - 0x20008613
zr&#58;0x00000000 at&#58;0x0008FF00 v0&#58;0x0000000B v1&#58;0x08910000
a0&#58;0x0000BB80 a1&#58;0x089103E7 a2&#58;0xFFFFFFFF a3&#58;0x44004118
t0&#58;0x00000008 t1&#58;0x00000001 t2&#58;0x00000000 t3&#58;0x44003918
t4&#58;0x09FFEE20 t5&#58;0x00000E00 t6&#58;0x08900384 t7&#58;0x00008600
s0&#58;0x00000011 s1&#58;0x09FFEE34 s2&#58;0x00000001 s3&#58;0x09FFEEE0
s4&#58;0x00000011 s5&#58;0x00000013 s6&#58;0xDEADBEEF s7&#58;0xDEADBEEF
t8&#58;0x00000000 t9&#58;0x88224888 k0&#58;0x09FFEF00 k1&#58;0x00000000
gp&#58;0x08919370 sp&#58;0x09FFEE28 fp&#58;0x09FFEEA0 ra&#58;0x089003C4
and if try:

Code: Select all

Peter@pete /cygdrive/e/Uni/PSP/Hola mundo de pruerba
$ psp-addr2line.exe -fe hello.elf 0x080C2764
??
??&#58;0
Don´t know more things to try :( The EPC is the same, it doesn´t matter if using Hello world or audio mechanica

Thanks for your infinite patience :D (and sorry for my bad English)
Post Reply