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.
pspAudio and my emulator.
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:
I'm not sure how you fill your audio buffer but this method worked for me.
Code: Select all
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
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.
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.
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
Jim
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.
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.