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

(SDL3) Mix_SetPosition ignores left speaker with angles over 180 degrees. #646

Open
failedev17 opened this issue Nov 24, 2024 · 0 comments

Comments

@failedev17
Copy link

failedev17 commented Nov 24, 2024

// minimal example

#include <SDL3/SDL.h>
#include <SDL3_mixer/SDL_mixer.h>
#include <stdio.h>

int main(){
    SDL_Init(SDL_INIT_AUDIO);

    if(Mix_Init(MIX_INIT_OGG) <= 0)
    {
        printf("fail to init : %s", SDL_GetError());
        return -1;
    }

    if(!Mix_OpenAudio(0, nullptr))
    {
        printf("fail to open");
        return -1;
    }

    Mix_AllocateChannels(100);

    Mix_Volume(-1, MIX_MAX_VOLUME);

	Mix_Chunk* chunk = Mix_LoadWAV("bounce.wav");
	if(!chunk){
		printf("failed to load chunk\n");
		return -1;
	}

	int channel = Mix_PlayChannel(-1, chunk, 0);
	Mix_SetPosition(channel, 0, 0);

	SDL_Delay(2000);

	channel = Mix_PlayChannel(-1, chunk, 0);
	Mix_SetPosition(channel, 90, 0);

	SDL_Delay(2000);

	channel = Mix_PlayChannel(-1, chunk, 0);
	Mix_SetPosition(channel, 180, 0);

	SDL_Delay(2000);

	channel = Mix_PlayChannel(-1, chunk, 0);
	Mix_SetPosition(channel, 270, 0); // plays at the right speaker

	SDL_Delay(2000);
}

Manually calculating the left/right panning values and using Mix_SetPanning works though.

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

1 participant