libsdl-org / SDL_mixer

An audio mixer that supports various file formats for Simple Directmedia Layer.
zlib License
421 stars 142 forks source link

How to change Mix_Chunk to Mix_Music in SDL2_Mixer #533

Closed ParkSeungwon closed 1 year ago

ParkSeungwon commented 1 year ago

I couldn't find any documentation about this. Can anyone help me?

if (SDL_Init(SDL_INIT_AUDIO) < 0) return -1;

if( Mix_OpenAudio( 48000, MIX_DEFAULT_FORMAT, 2, 4096 ) == -1 ) return -1; 
Mix_Chunk *wave = Mix_LoadWAV("a.wav");
auto *p = SDL_RWFromMem(wave->abuf, wave->alen);
if(!p || !wave) return -1;
Mix_Music *music = Mix_LoadMUSType_RW(p, MUS_WAV, 0);
if(!music) cout <<"load Mus error " << SDL_GetError() << endl;
Mix_PlayMusic(music, 2);
//Mix_PlayChannel(-1, wave, 1);
char c;
cin >> c;

Mix_FreeMusic(music);
Mix_FreeChunk(wave);
Mix_CloseAudio();

I want to manipulate some wave data and store it in Mix_Music format with SDL2_Mixer. Above code gives me "load Mus error unknown wave format" error.

commented Mix_PlayChannel function works fine.

How can I change this code to make Mix_PlayMusic function work?

slouken commented 1 year ago

This is a good question for the SDL discussion group: https://discourse.libsdl.org/c/sdl-development/6

ParkSeungwon commented 1 year ago

SDL discussion group does not allow posting. My post is temporarily on hold for 2 days.. Could you remove temporary hold?

slouken commented 1 year ago

Okay, you should be able to post now.

ParkSeungwon commented 1 year ago

When I tried to post my draft, it is On hold again..나의 iPad에서 보냄2023. 6. 30. 오후 12:13, Sam Lantinga @.***> 작성: Okay, you should be able to post now.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

slouken commented 1 year ago

You're being blocked because you're posting too fast. Try typing out the first part of your question and then pasting the rest?