void gdBrowser::__cb_save_project() { if (strcmp(name->value(), "") == 0) { /// FIXME glue business gdAlert("Please choose a project name."); return; } /* check if name->value() contains ".gprj" */ char ext[6] = ".gprj"; if (strstr(name->value(), ".gprj") != NULL) ext[0] = '\0'; char fullpath[PATH_MAX]; #if defined(_WIN32) sprintf(fullpath, "%s\\%s%s", where->value(), name->value(), ext); #else sprintf(fullpath, "%s/%s%s", where->value(), name->value(), ext); #endif if (gIsProject(fullpath) && !gdConfirmWin("Warning", "Project exists: overwrite?")) return; if (glue_saveProject(fullpath, name->value())) do_callback(); else gdAlert("Unable to save the project!"); }
void gdBrowser::__cb_load_sample() { if (browser->text(browser->value()) == NULL) return; int res = glue_loadChannel((SampleChannel*) ch, browser->get_selected_item(), browser->path_obj->value()); if (res == SAMPLE_LOADED_OK) { do_callback(); mainWin->delSubWindow(WID_SAMPLE_EDITOR); // if editor is open } else if (res == SAMPLE_NOT_VALID) gdAlert("This is not a valid WAVE file."); else if (res == SAMPLE_MULTICHANNEL) gdAlert("Multichannel samples not supported."); else if (res == SAMPLE_WRONG_BIT) gdAlert("This sample has an\nunsupported bit-depth (> 32 bit)."); else if (res == SAMPLE_WRONG_ENDIAN) gdAlert("This sample has a wrong\nbyte order (not little-endian)."); else if (res == SAMPLE_WRONG_FORMAT) gdAlert("This sample is encoded in\nan unsupported audio format."); else if (res == SAMPLE_READ_ERROR) gdAlert("Unable to read this sample."); else if (res == SAMPLE_PATH_TOO_LONG) gdAlert("File path too long."); else gdAlert("Unknown error."); }
void gdMainWindow::__cb_inputRec() { if (G_Mixer.chanInput == -1) { if (!glue_startInputRec()) gdAlert("No more channels available."); } else glue_stopInputRec(); }
void gdBrowser::__cb_load_patch() { if (browser->text(browser->value()) == NULL) return; /* patchFile is the file to open. * For patches: browser->get_selected_item() * for projects: browser->get_selected_item() without extention + * patch name appended */ std::string patchFile = browser->get_selected_item();; bool isProject; if (gIsProject(browser->get_selected_item())) { std::string patchName = gGetProjectName(browser->get_selected_item()); #if defined(__linux__) || defined(__APPLE__) patchFile = patchFile+"/"+patchName+".gptc"; #elif defined(_WIN32) patchFile = patchFile+"\\"+patchName+".gptc"; #endif isProject = true; } else isProject = false; int res = glue_loadPatch(patchFile.c_str(), browser->path_obj->value(), status, isProject); if (res == PATCH_UNREADABLE) { status->hide(); if (isProject) gdAlert("This project is unreadable."); else gdAlert("This patch is unreadable."); } else if (res == PATCH_INVALID) { status->hide(); if (isProject) gdAlert("This project is not valid."); else gdAlert("This patch is not valid."); } else do_callback(); }
void gdBrowser::__cb_save_sample() { if (strcmp(name->value(), "") == 0) { /// FIXME glue business gdAlert("Please choose a file name."); return; } /* bruteforce check extension. */ std::string filename = gStripExt(name->value()); char fullpath[PATH_MAX]; sprintf(fullpath, "%s/%s.wav", where->value(), filename.c_str()); if (gFileExists(fullpath)) if (!gdConfirmWin("Warning", "File exists: overwrite?")) return; if (((SampleChannel*)ch)->save(fullpath)) do_callback(); else gdAlert("Unable to save this sample!"); }
void gdBrowser::__cb_save_patch() { if (strcmp(name->value(), "") == 0) { /// FIXME glue business gdAlert("Please choose a file name."); return; } /* if name->value() contains ".gptc" */ char ext[6] = ".gptc"; if (strstr(name->value(), ".gptc") != NULL) ext[0] = '\0'; char fullpath[PATH_MAX]; sprintf(fullpath, "%s/%s%s", where->value(), name->value(), ext); if (gFileExists(fullpath)) if (!gdConfirmWin("Warning", "File exists: overwrite?")) return; if (glue_savePatch(fullpath, name->value(), false)) // false == not a project do_callback(); else gdAlert("Unable to save the patch!"); }
void gdBrowser::__cb_loadPlugin() { if (browser->text(browser->value()) == NULL) return; int res = G_PluginHost.addPlugin(browser->get_selected_item(), stackType, ch); /* store the folder path inside G_Conf, in order to reuse it the * next time. */ G_Conf.setPath(G_Conf.pluginPath, where->value()); if (res) do_callback(); else gdAlert("Unable to load the selected plugin!"); }
void gKeyboard::printChannelMessage(int res) { if (res == SAMPLE_NOT_VALID) gdAlert("This is not a valid WAVE file."); else if (res == SAMPLE_MULTICHANNEL) gdAlert("Multichannel samples not supported."); else if (res == SAMPLE_WRONG_BIT) gdAlert("This sample has an\nunsupported bit-depth (> 32 bit)."); else if (res == SAMPLE_WRONG_ENDIAN) gdAlert("This sample has a wrong\nbyte order (not little-endian)."); else if (res == SAMPLE_WRONG_FORMAT) gdAlert("This sample is encoded in\nan unsupported audio format."); else if (res == SAMPLE_READ_ERROR) gdAlert("Unable to read this sample."); else if (res == SAMPLE_PATH_TOO_LONG) gdAlert("File path too long."); else gdAlert("Unknown error."); }
int glue_loadPatch(const char *fname, const char *fpath, gProgress *status) { /* update browser's status bar with % 0.1 */ status->show(); status->value(0.1f); //Fl::check(); Fl::wait(0); /* is it a valid patch? */ int res = G_Patch.open(fname); if (res != PATCH_OPEN_OK) return res; /* reset the system. False = don't update the gui right now */ glue_resetToInitState(false); status->value(0.2f); // progress status: % 0.2 //Fl::check(); Fl::wait(0); /* mixerHandler will update the samples inside Mixer */ mh_loadPatch(); /* take the patch name and update the main window's title */ G_Patch.getName(); gu_update_win_label(G_Patch.name); status->value(0.4f); // progress status: 0.4 //Fl::check(); Fl::wait(0); G_Patch.readRecs(); status->value(0.6f); // progress status: 0.6 //Fl::check(); Fl::wait(0); #ifdef WITH_VST int resPlugins = G_Patch.readPlugins(); status->value(0.8f); // progress status: 0.8 //Fl::check(); Fl::wait(0); #endif /* this one is vital: let recorder recompute the actions' positions if * the current samplerate != patch samplerate */ recorder::updateSamplerate(G_Conf.samplerate, G_Patch.samplerate); /* update gui */ gu_update_controls(); status->value(1.0f); // progress status: 1.0 (done) //Fl::check(); Fl::wait(0); /* save patchPath by taking the last dir of the broswer, in order to * reuse it the next time */ G_Conf.setPath(G_Conf.patchPath, fpath); printf("[glue] patch %s loaded\n", fname); #ifdef WITH_VST if (resPlugins != 1) gdAlert("Some VST files were not loaded successfully."); #endif /* lastly close all other windows */ if (res) gu_closeAllSubwindows(); return res; }