Skip to content
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

PCM: Jo Engine Doesn't Set Sample Rate #36

Closed
slinga-homebrew opened this issue Aug 5, 2020 · 2 comments
Closed

PCM: Jo Engine Doesn't Set Sample Rate #36

slinga-homebrew opened this issue Aug 5, 2020 · 2 comments

Comments

@slinga-homebrew
Copy link
Contributor

Hi Johannes,

I don't expect you to change anything, just wanted to document. Jo Engine doesn't appear to support setting the sample rate for PCM files. As per your comments in "demo - audio\main.c" the Saturn can support both 8000 and 44100 sample rates. However there does not appear to be a place to change the sample rates anywhere.

jo_audio_load_pcm() does not take a sample rate, the jo_sound struct does not contain the sample rate, and jo_audio_play_sound_on_channel() takes an index into the PCM _jo_internal_pcm[JO_SOUND_MAX_CHANNEL] array. This structure contains the sample rate (via some computation in pitch, see Ponut's code: https://github.com/ponut64/68k/blob/47e56ede2ee5bb4979ce85dffc5446ec44f81dd7/jo_demo/pcmsys.c#L207). The pitch doesn't appear to ever be set.

So here are the issues that should be considered:

  1. What does a pitch of 0 mean? Since it isn't set, what sample rate it is?
  2. Since the user cannot specify the sample rate it doesn't make sense to list multiple supported sample rates.
  3. Maybe change the jo_audio_play_sound_on_channel() prototype to take a PCM* as an input. That way the user could specify everything.

Thanks as always.

@johannes-fetz
Copy link
Owner

johannes-fetz commented Jan 13, 2021

@slinga-homebrew For Flicks-Flock you just have to do this:

void loadPCMAssets(void)
{
jo_audio_load_pcm("DEATH.PCM", JoSoundMono8Bit, &g_Assets.deathPCM);
g_Assets.deathPCM.sample_rate = 27086;
jo_audio_load_pcm("GRAVITY.PCM", JoSoundMono8Bit, &g_Assets.reverseGravityPCM);
g_Assets.reverseGravityPCM.sample_rate = 27086;
jo_audio_load_pcm("LIGHT.PCM", JoSoundMono8Bit, &g_Assets.lightningPCM);
g_Assets.lightningPCM.sample_rate = 27086;
jo_audio_load_pcm("STONE.PCM", JoSoundMono8Bit, &g_Assets.stoneSneakersPCM);
g_Assets.stoneSneakersPCM.sample_rate = 27086;
}

then replace my_jo_audio_play_sound by jo_audio_play_sound

@slinga-homebrew
Copy link
Contributor Author

Thanks, fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants