Index: mainwindow.h =================================================================== RCS file: /var/cvs/linuxsampler/gigedit/src/gigedit/mainwindow.h,v retrieving revision 1.30 diff -u -r1.30 mainwindow.h --- mainwindow.h 3 Feb 2008 00:19:54 -0000 1.30 +++ mainwindow.h 3 Feb 2008 16:47:42 -0000 @@ -336,6 +336,7 @@ void on_action_sample_properties(); void on_action_add_group(); void on_action_add_sample(); + void on_action_replace_all_samples_in_all_groups(); void on_action_remove_sample(); void on_action_add_instrument(); Index: mainwindow.cpp =================================================================== RCS file: /var/cvs/linuxsampler/gigedit/src/gigedit/mainwindow.cpp,v retrieving revision 1.43 diff -u -r1.43 mainwindow.cpp --- mainwindow.cpp 3 Feb 2008 14:10:47 -0000 1.43 +++ mainwindow.cpp 3 Feb 2008 16:47:42 -0000 @@ -209,6 +209,11 @@ sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) ); + actionGroup->add( + Gtk::Action::create("ReplaceAllSamplesInAllGroups", _("Replace All Samples In All Groups")), + sigc::mem_fun(*this, &MainWindow::on_action_replace_all_samples_in_all_groups) + ); + uiManager = Gtk::UIManager::create(); uiManager->insert_action_group(actionGroup); add_accel_group(uiManager->get_accel_group()); @@ -248,6 +253,7 @@ " " " " " " + " " " " " " " " @@ -1493,6 +1499,61 @@ } } +void MainWindow::on_action_replace_all_samples_in_all_groups() +{ + if (!file) return; + Gtk::FileChooserDialog dialog(*this, _("Select Folder"), + Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER); + dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + dialog.add_button(_("Select"), Gtk::RESPONSE_OK); + dialog.set_select_multiple(false); + if (dialog.run() == Gtk::RESPONSE_OK) + { + Glib::ustring error_files; + Glib::ustring folder = dialog.get_filename(); + for (gig::Sample* sample = file->GetFirstSample(); + sample; sample = file->GetNextSample()) + { + std::string filename = folder + "/" + sample->pInfo->Name + ".wav"; + SF_INFO info; + info.format = 0; + SNDFILE* hFile = sf_open(filename.c_str(), SFM_READ, &info); + try + { + if (!hFile) throw std::string("could not open file"); + int bitdepth; + switch (info.format & 0xff) { + case SF_FORMAT_PCM_S8: + case SF_FORMAT_PCM_16: + case SF_FORMAT_PCM_U8: + bitdepth = 16; + break; + case SF_FORMAT_PCM_24: + case SF_FORMAT_PCM_32: + case SF_FORMAT_FLOAT: + case SF_FORMAT_DOUBLE: + bitdepth = 24; + break; + default: + sf_close(hFile); + throw std::string("format not supported"); + } + SampleImportItem sched_item; + sched_item.gig_sample = sample; + sched_item.sample_path = filename; + m_SampleImportQueue.push_back(sched_item); + sf_close(hFile); + file_changed(); + } + catch (std::string what) + { + if (error_files.size()) error_files += "\n"; + error_files += filename += " (" + what + ")"; + } + } + } +} + void MainWindow::on_action_remove_sample() { if (!file) return; Glib::RefPtr sel = m_TreeViewSamples.get_selection();