remove extension when loading ins from file

This commit is contained in:
tildearrow 2022-02-26 04:49:40 -05:00
parent 271b3fb0fe
commit 1a69794efe
1 changed files with 14 additions and 5 deletions

View File

@ -1156,10 +1156,19 @@ bool DivEngine::addInstrumentFromFile(const char *path) {
const char* pathRedux=strrchr(path,DIR_SEPARATOR); const char* pathRedux=strrchr(path,DIR_SEPARATOR);
if (pathRedux==NULL) { if (pathRedux==NULL) {
pathRedux="Instrument"; pathRedux=path;
} else { } else {
pathRedux++; pathRedux++;
} }
String stripPath;
const char* pathReduxEnd=strrchr(pathRedux,'.');
if (pathReduxEnd==NULL) {
stripPath=pathRedux;
} else {
for (const char* i=pathRedux; pathRedux!=pathReduxEnd && (*i); i++) {
stripPath+=*i;
}
}
FILE* f=ps_fopen(path,"rb"); FILE* f=ps_fopen(path,"rb");
if (f==NULL) { if (f==NULL) {
@ -1284,7 +1293,7 @@ bool DivEngine::addInstrumentFromFile(const char *path) {
return false; return false;
} }
ins->name=pathRedux; ins->name=stripPath;
if (version>=11) { // 1.0 if (version>=11) { // 1.0
try { try {
@ -1517,7 +1526,7 @@ bool DivEngine::addInstrumentFromFile(const char *path) {
reader.seek(0,SEEK_SET); reader.seek(0,SEEK_SET);
ins->type=DIV_INS_FM; ins->type=DIV_INS_FM;
ins->name=pathRedux; ins->name=stripPath;
ins->fm.alg=reader.readC(); ins->fm.alg=reader.readC();
ins->fm.fb=reader.readC(); ins->fm.fb=reader.readC();
@ -1549,7 +1558,7 @@ bool DivEngine::addInstrumentFromFile(const char *path) {
reader.seek(0,SEEK_SET); reader.seek(0,SEEK_SET);
ins->type=DIV_INS_FM; ins->type=DIV_INS_FM;
ins->name=pathRedux; ins->name=stripPath;
ins->fm.alg=reader.readC(); ins->fm.alg=reader.readC();
ins->fm.fb=reader.readC(); ins->fm.fb=reader.readC();