![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
This is a discussion on Problem with Program within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Hi, I am making a program called Guitar PSP, which, over time, will having various tools that guitarists will find ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
![]() ![]() Developer
|
Hi,
I am making a program called Guitar PSP, which, over time, will having various tools that guitarists will find useful, such as a tuner (just sounds, untill we get access to a mic), tab viewer and player, mp3 player and a chord bank. The first make will just have the tuner, cause i am new to c programming. I am stuck however, my code doesn't work. The code below basically plays 6 mp3s, well, it's meant to. When I run it on my 2.5, it doesn't play. Here is my main function. Code:
int main() {
pspDebugScreenInit();
SetupCallbacks();
pspAudioInit();
SceCtrlData pad;
int i;
int num = 0;
int prevNum = 0;
char note[10];
printf("Welcome to Guitar PSP!\n\n");
printf("Press [X] to tune the next note\n");
printf("Press [O] to tune the previous note\n!");
while(1) {
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_CROSS) {
num++;
} else if(pad.Buttons & PSP_CTRL_CIRCLE) {
num--;
}
if(num<1) {
num = 0;
} else if(num>6) {
num = 6;
}
if(prevNum!=num) {
prevNum=num;
MP3_Stop();
MP3_FreeTune();
MP3_Init(1);
switch(num) {
case 1:
MP3_Load("be.mp3");
case 2:
MP3_Load("a.mp3");
case 3:
MP3_Load("d.mp3");
case 4:
MP3_Load("g.mp3");
case 5:
MP3_Load("b.mp3");
case 6:
MP3_Load("b.mp3");
}
MP3_Play();
}
for(i=0; i<10; i++) {
sceDisplayWaitVblankStart();
}
}
sceKernelSleepThread();
return 0;
}
__________________
[mEo!] My Apps: Slider PSP | Slime Volleyball PSP | PSP TV Setup Helper Guides: Stream TV to your PSP Firmware: 2.5 - 1.5 :D - 1.5 Casual 3 - 2.0 (Thank god for recovery mode) - 1.5 - 1.5 Casual 3 - 2.71 SE-A (Wooohooo!) - 3.03 OE - 3.10 OE - 3.30 OE - 3.40 OE-A - 3.51 M33 UMD Games: GTA: Liberty City Stories, SSX On Tour, FIFA World Cup 2006, GTA: Vice City Stories UMD Movies: Speed Looking Forward To: Full Speed Daedalus, FF Tactics PSP |
|
|
|
|
|
#2 |
![]() ![]() Developer
|
Just wondering but have you read this lesson?
http://www.psp-programming.com/tutorials/c/lesson06.htm Thats about adding/playing sound. |
|
|
|
|
|
#3 |
![]() ![]() Developer
|
Yes, that is where I have been learning from. I don't see anything I missed in that tutorial
__________________
[mEo!] My Apps: Slider PSP | Slime Volleyball PSP | PSP TV Setup Helper Guides: Stream TV to your PSP Firmware: 2.5 - 1.5 :D - 1.5 Casual 3 - 2.0 (Thank god for recovery mode) - 1.5 - 1.5 Casual 3 - 2.71 SE-A (Wooohooo!) - 3.03 OE - 3.10 OE - 3.30 OE - 3.40 OE-A - 3.51 M33 UMD Games: GTA: Liberty City Stories, SSX On Tour, FIFA World Cup 2006, GTA: Vice City Stories UMD Movies: Speed Looking Forward To: Full Speed Daedalus, FF Tactics PSP |
|
|
|
|
|
#4 |
![]() ![]() PSP Coder
|
Code:
if(prevNum!=num) {
prevNum=num;
MP3_Stop();
MP3_FreeTune();
MP3_Init(1);
switch(num) {
case 1:
MP3_Load("be.mp3");
case 2:
MP3_Load("a.mp3");
case 3:
MP3_Load("d.mp3");
case 4:
MP3_Load("g.mp3");
case 5:
MP3_Load("b.mp3");
case 6:
MP3_Load("b.mp3");
}
MP3_Play();
}
Also with switch / case selection, you normally need a break; statement inside the 'cases'. ie: Code:
switch (num)
{
case 1:
{
MP3_Load("be.mp3");
break;
}
case 2:
.
.
.
} //end switch
|
|
|
|
|
|
#5 |
![]() ![]() Developer
|
I agree about the switch statement, thanks i'll add that and see what happens.
but the if statement, if you look above that, when [X] or [O] are pressed, num changes. prevnum is the previous number, number always is re-assigned. if the new number does not equal the old one, then a button must have been pressed. load the appropriate mp3.... etc. etc.
__________________
[mEo!] My Apps: Slider PSP | Slime Volleyball PSP | PSP TV Setup Helper Guides: Stream TV to your PSP Firmware: 2.5 - 1.5 :D - 1.5 Casual 3 - 2.0 (Thank god for recovery mode) - 1.5 - 1.5 Casual 3 - 2.71 SE-A (Wooohooo!) - 3.03 OE - 3.10 OE - 3.30 OE - 3.40 OE-A - 3.51 M33 UMD Games: GTA: Liberty City Stories, SSX On Tour, FIFA World Cup 2006, GTA: Vice City Stories UMD Movies: Speed Looking Forward To: Full Speed Daedalus, FF Tactics PSP |
|
|
|
|
|
#7 |
![]() ![]() Developer
|
Here you go mate, this has some issues, but I'll post what I have now as I have to leave for a while.
Code:
#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <pspaudio.h>
#include <pspaudiolib.h>
#include <psppower.h>
#include "mp3player.h"
#define printf pspDebugScreenPrintf
PSP_MODULE_INFO("GuitarPSP", 0, 1, 1);
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}
/* Callback thread */
int CallbackThread(SceSize args, void *argp) {
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
int i;
int num = 0;
int prevNum = 0;
char note[10];
void PlayMP3()
{
if(num < 1) {
num = 0;
} else if(num > 6) {
num = 6;
}
if(prevNum!=num) {
prevNum=num;
MP3_Stop();
MP3_FreeTune();
switch(num) {
case 1:
MP3_Load("be.mp3");
case 2:
MP3_Load("a.mp3");
case 3:
MP3_Load("d.mp3");
case 4:
MP3_Load("g.mp3");
case 5:
MP3_Load("b.mp3");
case 6:
MP3_Load("e.mp3");
}
MP3_Play();
}
}
int main() {
pspDebugScreenInit();
SetupCallbacks();
pspAudioInit();
MP3_Init(1);
SceCtrlData pad, lastpad;
printf("Welcome to Guitar PSP!\n\n");
printf("Press [X] to tune the next note\n");
printf("Press [O] to tune the previous note\n!");
sceCtrlReadBufferPositive(&lastpad, 1);
while(1) {
sceCtrlReadBufferPositive (&pad, 1);
if(pad.Buttons != lastpad.Buttons) {
lastpad = pad;
if(pad.Buttons & PSP_CTRL_CROSS) {
num++;
PlayMP3();
} else if(pad.Buttons & PSP_CTRL_CIRCLE) {
num--;
PlayMP3();
}
}
}
sceKernelSleepThread();
return 0;
}
Hope this helps get you started. Last edited by Insomniac197; 05-28-2006 at 06:36 AM.. |
|
|
|
|
|
#8 |
![]() ![]() Developer
|
I will try this in the afternoon, thanks a lot for your help
__________________
[mEo!] My Apps: Slider PSP | Slime Volleyball PSP | PSP TV Setup Helper Guides: Stream TV to your PSP Firmware: 2.5 - 1.5 :D - 1.5 Casual 3 - 2.0 (Thank god for recovery mode) - 1.5 - 1.5 Casual 3 - 2.71 SE-A (Wooohooo!) - 3.03 OE - 3.10 OE - 3.30 OE - 3.40 OE-A - 3.51 M33 UMD Games: GTA: Liberty City Stories, SSX On Tour, FIFA World Cup 2006, GTA: Vice City Stories UMD Movies: Speed Looking Forward To: Full Speed Daedalus, FF Tactics PSP |
|
|
|
|
|
#10 |
![]() ![]() Developer
|
i tried a direct example from that site (www.psp-programming.com), i literally cut and paste. it doesn't work, crashes if i let it go to long. anyone konw why?
__________________
[mEo!] My Apps: Slider PSP | Slime Volleyball PSP | PSP TV Setup Helper Guides: Stream TV to your PSP Firmware: 2.5 - 1.5 :D - 1.5 Casual 3 - 2.0 (Thank god for recovery mode) - 1.5 - 1.5 Casual 3 - 2.71 SE-A (Wooohooo!) - 3.03 OE - 3.10 OE - 3.30 OE - 3.40 OE-A - 3.51 M33 UMD Games: GTA: Liberty City Stories, SSX On Tour, FIFA World Cup 2006, GTA: Vice City Stories UMD Movies: Speed Looking Forward To: Full Speed Daedalus, FF Tactics PSP |
|
|
|
![]() |
| Tags |
| problem , program |
| Thread Tools | |
|
|