-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Audio support #2
Comments
This is great. I will take a look at this today. Thank you! |
I've just published Gamekid 0.4 with your work added. Thank you! |
I was messing around with the audio callback yesterday because I noticed sometimes enabling audio would create stutters in certain situations. Specifically I noticed them in the opening cutscene of Pokemon Blue, but I wasn't able to figure out how to fix it. One thing I found was that the left and right buffers are already initialized to zero, so there's no reason to memset them. And according to the docs you are supposed to return 0 if the audio cycle is empty. I'm not sure if this really matters since it seems to work fine always returning 1. Maybe it's a battery optimization or something. Anyways, here is a more "correct" version of the audio callback. int audio_callback_playdate(void *context, int16_t *left, int16_t *right, int len)
{
update_square(left, right, 0, len);
update_square(left, right, 1, len);
update_wave(left, right, len);
update_noise(left, right, len);
for(int i = 0; i < len; ++i) {
if(left[i] != 0 || right[i] != 0) return 1;
}
return 0;
} |
It seems like Gamekid doesn't have the stuttering problem like mine does, at least in Pokemon Blue. |
I'm going to reopen this issue as I am disabling sound in Gamekid for now. Looking at the 32bit sound emulation @deltabeard has in the works, I may wait until that is more fleshed out and use that. Also finding the noise emulation is very off. The lightning bolts at the start of Link's Awakening use it and they just don't sound right compared to, say: https://www.youtube.com/watch?v=E0ErE4l1EKM |
Audio works for me 100%, but it is about 70% of the speed expected. No pitch bending, just slower. Is this anticipated behavior for how far along audio support is currently? |
May I ask if you can save in the Pok é mon game? |
A few days ago I released my port of PeanutGB as well. I was able to get audio working using the SDL example as a guide. I could probably make a pull request, but it's easier to explain it since you are more familiar with your code base.
You will need minigb_apu from the Peanut-GB SDL example. The only changes you need to make to minigb_apu is the audio_callback and update_square, update_wave, and update_noise . If you reference main.c and Ctrl+F for "sound", you will see all of the necessary set up for the sound callback. Basically it's just using pd->sound->addSource() and audio_init() from minigb_apu. You also have to remove the source when closing the rom or it will create problems.
The text was updated successfully, but these errors were encountered: