mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-04-27 13:13:16 +00:00
reverb:: load audio from all formats supported by SDL_Mixer
This commit is contained in:
parent
d5d6fd0f28
commit
522ab46051
@ -260,12 +260,33 @@ auto hchook = addHook(hooks_drawcell, 100, draw_bird)
|
|||||||
else if(argis("-reverb")) {
|
else if(argis("-reverb")) {
|
||||||
shift();
|
shift();
|
||||||
string fname = args();
|
string fname = args();
|
||||||
FILE *f = fopen(fname.c_str(), "rb");
|
|
||||||
fseek(f, 0, SEEK_END);
|
if(fname.substr(isize(fname) - 4) == ".raw") {
|
||||||
orig.resize(ftell(f)/sizeof(sample));
|
FILE *f = fopen(fname.c_str(), "rb");
|
||||||
fseek(f, 0, SEEK_SET);
|
if(!f) {
|
||||||
fread(&orig[0], 4, orig.size(), f);
|
printf("failed to load\n");
|
||||||
fclose(f);
|
return 1;
|
||||||
|
}
|
||||||
|
fseek(f, 0, SEEK_END);
|
||||||
|
orig.resize(ftell(f)/sizeof(sample));
|
||||||
|
fseek(f, 0, SEEK_SET);
|
||||||
|
fread(&orig[0], 4, orig.size(), f);
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
Mix_CloseAudio();
|
||||||
|
Mix_OpenAudio(freq, AUDIO_S16LSB, 2, 4096);
|
||||||
|
auto chunk = Mix_LoadWAV(fname.c_str());
|
||||||
|
if(!chunk) {
|
||||||
|
printf("failed to load\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
orig.resize(chunk->alen / 4);
|
||||||
|
memcpy(&orig[0], chunk->abuf, chunk->alen);
|
||||||
|
Mix_FreeChunk(chunk);
|
||||||
|
}
|
||||||
|
|
||||||
println(hlog, "original size = ", isize(orig));
|
println(hlog, "original size = ", isize(orig));
|
||||||
|
|
||||||
for(auto& o: orig) {
|
for(auto& o: orig) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user