forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

MP3 Playback is way too fast. What's next?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
^L^



Joined: 14 Jun 2008
Posts: 19

PostPosted: Sun Aug 10, 2008 3:17 pm    Post subject: MP3 Playback is way too fast. What's next? Reply with quote

My music plays way too fast whenever it's loaded and doesn't stop once it has ended. What do I do?
I isolated my code so I could find out what's been wrong.
Code:
#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <pspaudio.h>
#include <pspaudiolib.h>
#include <psppower.h>

#include "mp3player.h"

# ifdef PSPFW3X
PSP_MODULE_INFO("Program", 0x0, 1, 1);
PSP_HEAP_SIZE_KB(6*1024);
# else
PSP_MODULE_INFO("Program", 0x1000, 1, 1);
# endif
PSP_MAIN_THREAD_ATTR(0);
PSP_MAIN_THREAD_STACK_SIZE_KB(32);

#define printf pspDebugScreenPrintf

int var = 0;
int timer = 0;

int main() {
//scePowerSetClockFrequency(333, 333, 166);
SetupCallbacks();
pspDebugScreenInit();
pspAudioInit();
SceCtrlData pad;
while(1) {
sceCtrlReadBufferPositive(&pad, 1);
   if(timer>=1) {
          timer--;
   }
   if(timer<0) {
          timer=0;
   }
   if(var==0) {
      printf("X: Sound 1\n[]: Sound 2\n");
      var=1;
   }
   if(pad.Buttons & PSP_CTRL_SQUARE && (timer==0)) {
      MP3_End();
      MP3_Init(1);
      MP3_Load("SQU.mp3");
      MP3_Play();
      timer=20;
   }
   if(pad.Buttons & PSP_CTRL_CROSS && (timer==0)) {
      MP3_End();
      MP3_Init(1);
      MP3_Load("CRO.mp3");
      MP3_Play();
      timer=20;
   }

}
MP3_Stop();
MP3_FreeTune();
sceKernelSleepThread();
return 0;
}

I just can't find the reason. I kinda know what I need for stopping the music after it's played once but I'm not exactly sure and cannot get it to work :(


Last edited by ^L^ on Tue Aug 12, 2008 7:56 am; edited 1 time in total
Back to top
View user's profile Send private message
iceman755



Joined: 21 Jul 2008
Posts: 34

PostPosted: Sun Aug 10, 2008 5:09 pm    Post subject: Reply with quote

what I can see is:

-the variable timer is always equal to zero, so it has no efect in your code.

-the loop is lasting forever.

-you need to use a lastbutton check.

I hope this help you to figure out what is wrong.
_________________
"Libera eas de ore leonis, ne absorbeat eas tartarus, ne cadant in obscurum"
Back to top
View user's profile Send private message
psPea



Joined: 01 Sep 2007
Posts: 64

PostPosted: Tue Aug 12, 2008 5:48 am    Post subject: Reply with quote

It could be that the frequency of the mp3 you're using is < 44100 hz(the default on the PSP). this would be the care (maybe) if the mp3 is mpeg 2/2.5 (mp3pro if you use yahoo/musicmatch jukebox). Solutions(if this is the problem): re-encode mp3 to 44100 hz or change the PSP audio output frequency to match the mp3.
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
^L^



Joined: 14 Jun 2008
Posts: 19

PostPosted: Tue Aug 12, 2008 7:45 am    Post subject: Reply with quote

The MP3 files all have exactly 44kHz whenever I check their properties. Would that make much of a difference? And what would I do to change the PSP's output frequency?

And I felt sooooooo dumb whenever I saw the timer variable thing. I'm such an idiot. I think if I have this in, then I wouldn't need a lastbutton variable or anything. It should also take care of playing it looped.

I'm going to recompile the program and test it out! Thanks for the help! If there's another problem with it regarding the playback, I'll post again.
Back to top
View user's profile Send private message
^L^



Joined: 14 Jun 2008
Posts: 19

PostPosted: Tue Aug 12, 2008 7:55 am    Post subject: Reply with quote

Yeah, I know, it's a double post... but....
The timer thing had no effect at the stage of the development of the program.
I think right now I should figure out how to change the output frequency or look at other people's source codes to see how they did it.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group