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

// 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); } #647

Closed
Stauley opened this issue Nov 24, 2024 · 2 comments

Comments

@Stauley
Copy link

Stauley 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);

}

@failedev17
Copy link

What's this?

@sezero
Copy link
Contributor

sezero commented Nov 24, 2024

Duplicate of #646

@sezero sezero marked this as a duplicate of #646 Nov 24, 2024
@sezero sezero closed this as completed Nov 24, 2024
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

3 participants