mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-23 21:15:11 +00:00
GUI: proper sample errors
This commit is contained in:
parent
5a08e0d230
commit
6492eeff56
3 changed files with 12 additions and 7 deletions
|
@ -2142,18 +2142,20 @@ int DivEngine::addSample() {
|
|||
return sampleCount;
|
||||
}
|
||||
|
||||
bool DivEngine::addSampleFromFile(const char* path) {
|
||||
int DivEngine::addSampleFromFile(const char* path) {
|
||||
isBusy.lock();
|
||||
SF_INFO si;
|
||||
SNDFILE* f=sf_open(path,SFM_READ,&si);
|
||||
if (f==NULL) {
|
||||
isBusy.unlock();
|
||||
return false;
|
||||
lastError=fmt::sprintf("could not open file! (%s)",sf_error_number(sf_error(NULL)));
|
||||
return -1;
|
||||
}
|
||||
if (si.frames>1000000) {
|
||||
if (si.frames>16777215) {
|
||||
lastError="this sample is too big! max sample size is 16777215.";
|
||||
sf_close(f);
|
||||
isBusy.unlock();
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
short* buf=new short[si.channels*si.frames];
|
||||
if (sf_readf_short(f,buf,si.frames)!=si.frames) {
|
||||
|
|
|
@ -489,7 +489,7 @@ class DivEngine {
|
|||
int addSample();
|
||||
|
||||
// add sample from file
|
||||
bool addSampleFromFile(const char* path);
|
||||
int addSampleFromFile(const char* path);
|
||||
|
||||
// delete sample
|
||||
void delSample(int index);
|
||||
|
|
|
@ -2269,8 +2269,11 @@ bool FurnaceGUI::loop() {
|
|||
}
|
||||
break;
|
||||
case GUI_FILE_SAMPLE_OPEN:
|
||||
e->addSampleFromFile(copyOfName.c_str());
|
||||
MARK_MODIFIED;
|
||||
if (e->addSampleFromFile(copyOfName.c_str())==-1) {
|
||||
showError(e->getLastError());
|
||||
} else {
|
||||
MARK_MODIFIED;
|
||||
}
|
||||
break;
|
||||
case GUI_FILE_SAMPLE_SAVE:
|
||||
if (curSample>=0 && curSample<(int)e->song.sample.size()) {
|
||||
|
|
Loading…
Reference in a new issue