| View previous topic :: View next topic |
| Author |
Message |
HexDump
Joined: 07 Jun 2005 Posts: 70
|
Posted: Tue Apr 18, 2006 8:06 am Post subject: pspAudio and my emulator. |
|
|
Hi,
I know this could be the wrong place to ask about this, but I didnīt find any better place, so here we are:
I have a little problem with my emulator and sound. Iīm using pspAudioLib to output the sound from my emulator. I have a callback that is called by the psp when he needs the channel to be feed with new samples, ok, here comes the problem, there are a lot of times, where the psp asks for a number of samples to be written but the emulator has not produced such quantity, so glitches are heard all along.
How do peopple avoid this problem?.
Thanks in advance,
HexDump. |
|
| Back to top |
|
 |
RCON
Joined: 03 Aug 2005 Posts: 16
|
Posted: Tue Apr 18, 2006 9:54 am Post subject: |
|
|
I am using a similar callback and I reset the audio buffer to 0 and then return if a sound is not playing. It looks something like this:
| Code: |
if (!soundplaying) {
for (i=0; i<length; ++i) {
buf[i * 2] = 0;
buf[i * 2 + 1] = 0;
}
return;
}
// Continue processing your audio if a sound is playing
|
I'm not sure how you fill your audio buffer but this method worked for me. |
|
| Back to top |
|
 |
HexDump
Joined: 07 Jun 2005 Posts: 70
|
Posted: Tue Apr 18, 2006 4:43 pm Post subject: |
|
|
Yes, I use the same method (Well, I donīt check if a sound is playing because I allways write into the buffer what emulator says, if no sound emulator outs 0's).
The problem is that a lot of times I canīt fill the psp audio buffer with "length" samples, because my emulator has produced less than that.
Example: pspAudio hsa a buffer of 1024 samples by default, so when the callback is called it asks for 1024 samples -> length=1024. Then problem is that my emulator only has produced for example 800, there are 124 missing.
Thanks in advance,
HexDump. |
|
| Back to top |
|
 |
Jim

Joined: 02 Jul 2005 Posts: 487 Location: Sydney
|
Posted: Tue Apr 18, 2006 11:04 pm Post subject: |
|
|
The problem is, the emulator's not running fast enough. It has to produce at least 1024 samples to fill that buffer. If it's done more than 1024 then the emulation is going too fast. There's not a lot you can do about that, except turn everything on its head - ie. inside the callback from the audio device, run the emulation until it produces 1024 samples. Depending on how long that takes it will give you more or less problems and better or worse clicking.
Jim _________________ http://www.dbfinteractive.com |
|
| Back to top |
|
 |
RCON
Joined: 03 Aug 2005 Posts: 16
|
Posted: Wed Apr 19, 2006 3:08 am Post subject: |
|
|
my program gets audio artifacts too when I try to do a lot of calculations and can't fill the buffer. I optimized a lot of my code using tips from this site and it helped a lot. I was doing a lot of calculations/loops when I didn't need to.
http://bdn.borland.com/article/0,1410,28278,00.html
make sure you optimize one part of your code and then test it, if you try to do too much at once you could break it and not know where the problem is. |
|
| Back to top |
|
 |
HexDump
Joined: 07 Jun 2005 Posts: 70
|
Posted: Thu Apr 20, 2006 7:31 pm Post subject: |
|
|
Thanks to everyone answering, the problem was that I did calculations by hand, and I was executing less cycles by frame than I should.
Sorry to waste your time mates, and thanks again.
HexDump. |
|
| Back to top |
|
 |
|