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

Specific sound won't play as OGG/Vorbis with device set to 48000hz #589

Open
rapha-s opened this issue Jan 29, 2024 · 2 comments
Open

Specific sound won't play as OGG/Vorbis with device set to 48000hz #589

rapha-s opened this issue Jan 29, 2024 · 2 comments

Comments

@rapha-s
Copy link

rapha-s commented Jan 29, 2024

I have this file
adv_zenhan.zip
Its an ogg/vorbis with sample rate of 96000hz.

The current facts (on Windows):

  • With a device set to 48000 hz, it won't play
  • With a device set to 96000 hz, it plays
  • With a device set to 48000 hz, if reencoded to wav with FFMPEG, still at 96000 hz sample rate, it plays
  • It plays regardless of the device settings if reencoded to ogg/vorbis and resampled to 48000hz
  • Other ogg files regardless of sample rate plays just fine
  • The specific file plays fine on any player that uses ffmpeg libraries as backend

I have a minimum reproducible example:
For wav simply reencoding with ffmpeg without any parameter suffice.
For the other ogg, anything that is known to work is enough.

#include <SDL2/SDL.h>
#include <SDL2/SDL_mixer.h>
#include <stdbool.h>

int main(int argc, char* argv[])
{
    SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO);
    Mix_Init(MIX_INIT_OGG);

    SDL_Window* window = SDL_CreateWindow("Audio Test",
        SDL_WINDOWPOS_UNDEFINED,
        SDL_WINDOWPOS_UNDEFINED,
        256,
        256,
        SDL_WINDOW_RESIZABLE);

    Mix_OpenAudio(48000, MIX_DEFAULT_FORMAT, 2, 4096);

    Mix_Music* ogg = Mix_LoadMUS("adv_zenhan.ogg");
    Mix_Music* wav = Mix_LoadMUS("adv_zenhan.wav");
    Mix_Music* works = Mix_LoadMUS("works for sure.ogg");
    Mix_PlayMusic(ogg,65535);

    SDL_Event Event;

    bool done = false;
    while (!done)
    {
        bool gotEvent = SDL_PollEvent(&Event);

        while (!done && gotEvent)
        {
            switch (Event.type)
            {
            case SDL_KEYDOWN:
                switch (Event.key.keysym.sym)
                {
                case 'o':
                    Mix_PlayMusic(ogg, 65535);
                    break;
                case 'w':
                    Mix_PlayMusic(wav, 65535);
                    break;
                case 'r':
                    Mix_PlayMusic(works, 65535);
                    break;
                default:
                    break;
                }
                break;

            case SDL_QUIT:
                done = true;
                break;

            default:
                break;
            }
            if (!done) gotEvent = SDL_PollEvent(&Event);
        }
        SDL_Delay(10);
    }
    Mix_FreeMusic(ogg);
    Mix_FreeMusic(wav);
    Mix_FreeMusic(works);

    Mix_CloseAudio();
    SDL_Quit();
    return 0;
}

I've no idea what's going on, it doesn't make sense and I couldn't figure out the cause, so I'm reporting.

@rapha-s
Copy link
Author

rapha-s commented Jan 29, 2024

Confirmed the same behaviour happens on openSUSE Tumbleweed.

@sezero
Copy link
Contributor

sezero commented Jan 30, 2024

With stb_vorbis backend, it plays.

With libvorbis backend: reproduced the issue: the playmus program
with an -r option anything smaller than 96000 just quits:

$ ./playmus -r 48000 ~/3/1/adv_zenhan.ogg
INFO: Opened audio at 48000 Hz 16 bit stereo 4096 bytes audio buffer
INFO: Detected music type: OGG Vorbis
INFO: Playing /home/ozzie/3/1/adv_zenhan.ogg, duration 73.846156

However -r 96000 or -r 192000 works.

Something in music_vorbis.c? @slouken?

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