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 questions ...

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



Joined: 13 Apr 2006
Posts: 12

PostPosted: Tue Apr 18, 2006 8:17 pm    Post subject: Mp3 questions ... Reply with quote

why does my mp3s have a clicking sound in the beginning (sometimes they have, sometimes not)

thats my code:
Code:

int Question(void)
{
   Color dimmedColor = RGB(100, 100, 100);
   Color shadowColorD = RGB(55, 55, 55 );

   Image* ourImage;
   SceCtrlData pad;

   char music[200];
   char title[200];
   char buffer[200];
   char filler[200];
   
   int ptr_balken = 1;
   int ptr_time = 30;
   int ptr_check = 1;
   int counter = 1;

   quick = 150;
   scann = (question * 3)-3;
   fseek(file, 1L, 0);
   fseek(file, -1L, 1);
   while (count < scann)
   {
      fscanf(file, "%s", &music);
      count++;
   }
   fscanf(file, "%s", &music);
   fscanf(file, "%s", &music);
   fscanf(file, "%d", &truebutton);

   sprintf(buffer, "gfx/questions/question%04d.png", question);
   ourImage = loadImage(buffer);
   blitAlphaImageToScreen(0 ,0 , 480, 272, ourImage, 0, 0);
   freeImage(ourImage);

   sprintf(buffer, "gfx/balken/balken00.png");
   ourImage = loadImage(buffer);
   blitAlphaImageToScreen(0 ,0 , 442, 21, ourImage, 19, 100);
   freeImage(ourImage);
   
   sprintf(filler, "%d", ptr_time);           
   printTextScreen(231, 107, filler, shadowColorD);
   printTextScreen(230, 107, filler, dimmedColor);   
   flipScreen();
   sprintf(buffer, "gfx/questions/question%04d.png", question);
   ourImage = loadImage(buffer);
   blitAlphaImageToScreen(0 ,0 , 480, 272, ourImage, 0, 0);
   freeImage(ourImage);

   sprintf(buffer, "gfx/balken/balken00.png");
   ourImage = loadImage(buffer);
   blitAlphaImageToScreen(0 ,0 , 442, 21, ourImage, 19, 100);
   freeImage(ourImage);
   
   sprintf(filler, "%d", ptr_time);           
   printTextScreen(231, 107, filler, shadowColorD);
   printTextScreen(230, 107, filler, dimmedColor);   
   flipScreen();
   ptr_time = ptr_time -1;

   sprintf(title, "music/%s.mp3", music);
   MP3_Init(1);
                MP3_Load(title);
                MP3_Play();
   CheckButtons();

   while (counter < 31)
   {
      sprintf(buffer, "gfx/balken/balken%02d.png", ptr_balken);
      ourImage = loadImage(buffer);
      blitAlphaImageToScreen(0 ,0 , 442, 21, ourImage, 19, 100);
   
      sprintf(filler, "%d", ptr_time);           
      printTextScreen(231, 107, filler, shadowColorD);
      printTextScreen(230, 107, filler, dimmedColor);
      flipScreen();
      freeImage(ourImage);
      CheckButtons();
      ptr_time = ptr_time -1;
      if (ptr_check == 2)
      {
         quick = quick - 10;
         if (ptr_balken < 13)
         {ptr_balken++;}
         ptr_check = 1;
      }
      else if (ptr_check == 1)
      {ptr_check++;}
      counter++;
   }

   MP3_Stop();
   MP3_FreeTune();

   sprintf(buffer, "gfx/questions/question%04d_w.png", question);
   ourImage = loadImage(buffer);
   blitAlphaImageToScreen(0 ,0 , 480, 272, ourImage, 0, 0);
   freeImage(ourImage);
         
   sprintf(buffer, "gfx/points/slow.png");
   ourImage = loadImage(buffer);
   blitAlphaImageToScreen(0 ,0 , 362, 30, ourImage, 59, 90);
   freeImage(ourImage);
   flipScreen();

   while(1)
   {
      sceCtrlReadBufferPositive(&pad, 1);
      if(pad.Buttons & PSP_CTRL_CROSS)
      {
         sceKernelDelayThread(250000);
         break;
      }
   }

   count = 0;
   ScoreBoardOne();
   return 1;
}


on button input, mp3 is stopped an unloaded
Code:

int CheckButtons(void)
{
   int starttime;
   Image* ourImage;

   SceCtrlData pad;

   char buffer[200];

   starttime = clock();
   while(clock() - starttime < 1000000)
   {
      sceCtrlReadBufferPositive(&pad, 1);
      if(pad.Buttons & PSP_CTRL_CROSS)
      {
         pressed = 1;
         MP3_Stop();
         MP3_FreeTune();

         if (truebutton == 1)
         {
            sprintf(buffer, "gfx/questions/question%04d_r.png", question);
            ourImage = loadImage(buffer);
            blitAlphaImageToScreen(0 ,0 , 480, 272, ourImage, 0, 0);
            freeImage(ourImage);
            sprintf(buffer, "gfx/points/points%03d.png", quick);
            ourImage = loadImage(buffer);
            blitAlphaImageToScreen(0 ,0 , 362, 30, ourImage, 59, 90);
            freeImage(ourImage);
         }
         else
         {
            sprintf(buffer, "gfx/questions/question%04d_w.png", question);
            ourImage = loadImage(buffer);
            blitAlphaImageToScreen(0 ,0 , 480, 272, ourImage, 0, 0);
            freeImage(ourImage);
            sprintf(buffer, "gfx/points/wrong.png");
            ourImage = loadImage(buffer);
            blitAlphaImageToScreen(0 ,0 , 362, 30, ourImage, 59, 90);
            freeImage(ourImage);
            quick = 0;
         }
         flipScreen();
         break;
      }

         }

   count = 0;
   if (pressed == 1)
   {
      pressed = 0;
      while(1)
      {
         sceCtrlReadBufferPositive(&pad, 1);
         if(pad.Buttons & PSP_CTRL_CROSS)
         {
            sceKernelDelayThread(250000);
            break;
         }
      }
      ScoreBoardOne();
   }
   return 1;      
}


loop restarts with new values ...

as i said, sometimes the mp3s starting with noise, sometimes they workking properly ...
(besides ive noticed , that small mp3s will be repeated, even if u terminate them imideatly, anyone knows why?)[/code]
Back to top
View user's profile Send private message
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Tue Apr 18, 2006 11:11 pm    Post subject: Reply with quote

Audio signals click because either the first or the last sample isn't 0 (or at the same level the last sample finished at). The click is the sharp transition from the old level to the new one.
Also, lots of mpg encoders I've used manage to add a click to a wav file that didn't exist in the first place!
Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
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