mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-23 21:15:11 +00:00
allow loading .brr samples directly
This commit is contained in:
parent
d7c885774e
commit
cbdf23efa7
3 changed files with 45 additions and 8 deletions
|
@ -2649,7 +2649,7 @@ DivSample* DivEngine::sampleFromFile(const char* path) {
|
|||
}
|
||||
extS+=i;
|
||||
}
|
||||
if (extS==".dmc") { // read as .dmc
|
||||
if (extS==".dmc" || extS==".brr") { // read as .dmc or .brr
|
||||
size_t len=0;
|
||||
DivSample* sample=new DivSample;
|
||||
sample->name=stripPath;
|
||||
|
@ -2696,12 +2696,48 @@ DivSample* DivEngine::sampleFromFile(const char* path) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
sample->rate=33144;
|
||||
sample->centerRate=33144;
|
||||
sample->depth=DIV_SAMPLE_DEPTH_1BIT_DPCM;
|
||||
sample->init(len*8);
|
||||
if (extS==".dmc") {
|
||||
sample->rate=33144;
|
||||
sample->centerRate=33144;
|
||||
sample->depth=DIV_SAMPLE_DEPTH_1BIT_DPCM;
|
||||
sample->init(len*8);
|
||||
} else if (extS==".brr") {
|
||||
sample->rate=32000;
|
||||
sample->centerRate=32000;
|
||||
sample->depth=DIV_SAMPLE_DEPTH_BRR;
|
||||
sample->init(16*(len/9));
|
||||
} else {
|
||||
fclose(f);
|
||||
BUSY_END;
|
||||
lastError="wait... is that right? no I don't think so...";
|
||||
delete sample;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (fread(sample->dataDPCM,1,len,f)==0) {
|
||||
unsigned char* dataBuf=sample->dataDPCM;
|
||||
if (extS==".brr") {
|
||||
dataBuf=sample->dataBRR;
|
||||
if ((len%9)==2) {
|
||||
// ignore loop position
|
||||
fseek(f,2,SEEK_SET);
|
||||
len-=2;
|
||||
if (len==0) {
|
||||
fclose(f);
|
||||
BUSY_END;
|
||||
lastError="BRR sample is empty!";
|
||||
delete sample;
|
||||
return NULL;
|
||||
}
|
||||
} else if ((len%9)!=0) {
|
||||
fclose(f);
|
||||
BUSY_END;
|
||||
lastError="possibly corrupt BRR sample!";
|
||||
delete sample;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (fread(dataBuf,1,len,f)==0) {
|
||||
fclose(f);
|
||||
BUSY_END;
|
||||
lastError=fmt::sprintf("could not read file! (%s)",strerror(errno));
|
||||
|
|
|
@ -1556,9 +1556,9 @@ void FurnaceGUI::openFileDialog(FurnaceGUIFileDialogs type) {
|
|||
if (!dirExists(workingDirSample)) workingDirSample=getHomeDir();
|
||||
hasOpened=fileDialog->openLoad(
|
||||
"Load Sample",
|
||||
{"compatible files", "*.wav *.dmc",
|
||||
{"compatible files", "*.wav *.dmc *.brr",
|
||||
"all files", ".*"},
|
||||
"compatible files{.wav,.dmc},.*",
|
||||
"compatible files{.wav,.dmc,.brr},.*",
|
||||
workingDirSample,
|
||||
dpiScale
|
||||
);
|
||||
|
|
|
@ -3296,6 +3296,7 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
|
|||
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByExtension,".dmw",uiColors[GUI_COLOR_FILE_WAVE],ICON_FA_FILE);
|
||||
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByExtension,".wav",uiColors[GUI_COLOR_FILE_AUDIO],ICON_FA_FILE_AUDIO_O);
|
||||
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByExtension,".dmc",uiColors[GUI_COLOR_FILE_AUDIO],ICON_FA_FILE_AUDIO_O);
|
||||
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByExtension,".brr",uiColors[GUI_COLOR_FILE_AUDIO],ICON_FA_FILE_AUDIO_O);
|
||||
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByExtension,".vgm",uiColors[GUI_COLOR_FILE_VGM],ICON_FA_FILE_AUDIO_O);
|
||||
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByExtension,".zsm",uiColors[GUI_COLOR_FILE_ZSM],ICON_FA_FILE_AUDIO_O);
|
||||
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByExtension,".ttf",uiColors[GUI_COLOR_FILE_FONT],ICON_FA_FONT);
|
||||
|
|
Loading…
Reference in a new issue