expose all audio formats supported by sndfile

This commit is contained in:
tildearrow 2024-06-14 18:53:33 -05:00
parent 3949821ae2
commit 3305a2b697
2 changed files with 47 additions and 2 deletions

View file

@ -67,6 +67,10 @@
#include "actionUtil.h"
#ifdef HAVE_SNDFILE
#include <sndfile.h>
#endif
bool Particle::update(float frameTime) {
pos.x+=speed.x*frameTime;
pos.y+=speed.y*frameTime;
@ -1835,8 +1839,7 @@ void FurnaceGUI::openFileDialog(FurnaceGUIFileDialogs type) {
if (!dirExists(workingDirSample)) workingDirSample=getHomeDir();
hasOpened=fileDialog->openLoad(
_("Load Sample"),
{_("compatible files"), "*.wav *.dmc *.brr",
_("all files"), "*"},
audioLoadFormats,
workingDirSample,
dpiScale,
NULL, // TODO
@ -7202,6 +7205,46 @@ bool FurnaceGUI::init() {
}
#endif
// initialize audio formats
String compatFormats;
audioLoadFormats.push_back(_("compatible files"));
audioLoadFormats.push_back("");
#ifdef HAVE_SNDFILE
int value=0;
sf_command(NULL,SFC_GET_FORMAT_MAJOR_COUNT,&value,sizeof(int));
logV("simple formats: %d",value);
for (int i=0; i<value; i++) {
SF_FORMAT_INFO f;
f.format=i;
if (sf_command(NULL,SFC_GET_FORMAT_MAJOR,&f,sizeof(SF_FORMAT_INFO))!=0) continue;
logV("format %d: %s (%s)\n",i,f.name,f.extension);
// these two are/will be handled somewhere else
if (strcmp(f.extension,"raw")==0) continue;
if (strcmp(f.extension,"xi")==0) continue;
// just in case
if (strcmp(f.extension,"dmc")==0) continue;
if (strcmp(f.extension,"brr")==0) continue;
audioLoadFormats.push_back(f.name);
audioLoadFormats.push_back(fmt::sprintf("*.%s",f.extension));
compatFormats+=fmt::sprintf("*.%s ",f.extension);
}
#endif
compatFormats+="*.dmc ";
compatFormats+="*.brr";
audioLoadFormats[1]=compatFormats;
audioLoadFormats.push_back(_("NES DPCM data"));
audioLoadFormats.push_back("*.dmc");
audioLoadFormats.push_back(_("SNES Bit Rate Reduction"));
audioLoadFormats.push_back("*.brr");
audioLoadFormats.push_back(_("all files"));
audioLoadFormats.push_back("*");
logI("done!");
return true;

View file

@ -2357,6 +2357,8 @@ class FurnaceGUI {
std::vector<FurnaceGUISysCategory> sysCategories;
std::vector<String> audioLoadFormats;
bool wavePreviewOn;
SDL_Scancode wavePreviewKey;
int wavePreviewNote;