1 |
/* |
/* |
2 |
* Copyright (C) 2006-2012 Andreas Persson |
* Copyright (C) 2006-2013 Andreas Persson |
3 |
* |
* |
4 |
* This program is free software; you can redistribute it and/or |
* This program is free software; you can redistribute it and/or |
5 |
* modify it under the terms of the GNU General Public License as |
* modify it under the terms of the GNU General Public License as |
179 |
sigc::mem_fun(*this, &MainWindow::on_action_add_instrument) |
sigc::mem_fun(*this, &MainWindow::on_action_add_instrument) |
180 |
); |
); |
181 |
actionGroup->add( |
actionGroup->add( |
182 |
|
Gtk::Action::create("DupInstrument", _("_Duplicate Instrument")), |
183 |
|
sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
184 |
|
); |
185 |
|
actionGroup->add( |
186 |
Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE), |
Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE), |
187 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
188 |
); |
); |
240 |
" <popup name='PopupMenu'>" |
" <popup name='PopupMenu'>" |
241 |
" <menuitem action='InstrProperties'/>" |
" <menuitem action='InstrProperties'/>" |
242 |
" <menuitem action='AddInstrument'/>" |
" <menuitem action='AddInstrument'/>" |
243 |
|
" <menuitem action='DupInstrument'/>" |
244 |
" <separator/>" |
" <separator/>" |
245 |
" <menuitem action='RemoveInstrument'/>" |
" <menuitem action='RemoveInstrument'/>" |
246 |
" </popup>" |
" </popup>" |
834 |
SF_INFO info; |
SF_INFO info; |
835 |
info.format = 0; |
info.format = 0; |
836 |
SNDFILE* hFile = sf_open((*iter).sample_path.c_str(), SFM_READ, &info); |
SNDFILE* hFile = sf_open((*iter).sample_path.c_str(), SFM_READ, &info); |
837 |
|
sf_command(hFile, SFC_SET_SCALE_FLOAT_INT_READ, 0, SF_TRUE); |
838 |
try { |
try { |
839 |
if (!hFile) throw std::string(_("could not open file")); |
if (!hFile) throw std::string(_("could not open file")); |
840 |
// determine sample's bit depth |
// determine sample's bit depth |
932 |
dialog.set_name("Gigedit"); |
dialog.set_name("Gigedit"); |
933 |
#endif |
#endif |
934 |
dialog.set_version(VERSION); |
dialog.set_version(VERSION); |
935 |
dialog.set_copyright("Copyright (C) 2006-2012 Andreas Persson"); |
dialog.set_copyright("Copyright (C) 2006-2013 Andreas Persson"); |
936 |
dialog.set_comments(_( |
dialog.set_comments(_( |
937 |
"Released under the GNU General Public License.\n" |
"Released under the GNU General Public License.\n" |
938 |
"\n" |
"\n" |
1334 |
file_changed(); |
file_changed(); |
1335 |
} |
} |
1336 |
|
|
1337 |
|
void MainWindow::on_action_duplicate_instrument() { |
1338 |
|
if (!file) return; |
1339 |
|
|
1340 |
|
// retrieve the currently selected instrument |
1341 |
|
// (being the original instrument to be duplicated) |
1342 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
1343 |
|
Gtk::TreeModel::iterator itSelection = sel->get_selected(); |
1344 |
|
if (!itSelection) return; |
1345 |
|
Gtk::TreeModel::Row row = *itSelection; |
1346 |
|
gig::Instrument* instrOrig = row[m_Columns.m_col_instr]; |
1347 |
|
if (!instrOrig) return; |
1348 |
|
|
1349 |
|
// duplicate the orginal instrument |
1350 |
|
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
1351 |
|
instrNew->pInfo->Name = |
1352 |
|
instrOrig->pInfo->Name + " (" + _("Copy") + ")"; |
1353 |
|
|
1354 |
|
// update instrument tree view |
1355 |
|
Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append(); |
1356 |
|
Gtk::TreeModel::Row rowInstr = *iterInstr; |
1357 |
|
rowInstr[m_Columns.m_col_name] = instrNew->pInfo->Name.c_str(); |
1358 |
|
rowInstr[m_Columns.m_col_instr] = instrNew; |
1359 |
|
file_changed(); |
1360 |
|
} |
1361 |
|
|
1362 |
void MainWindow::on_action_remove_instrument() { |
void MainWindow::on_action_remove_instrument() { |
1363 |
if (!file) return; |
if (!file) return; |
1364 |
if (file_is_shared) { |
if (file_is_shared) { |
1532 |
{ |
{ |
1533 |
sample->MIDIUnityNote = instrument.basenote; |
sample->MIDIUnityNote = instrument.basenote; |
1534 |
|
|
|
#if HAVE_SF_INSTRUMENT_LOOPS |
|
1535 |
if (instrument.loop_count && instrument.loops[0].mode != SF_LOOP_NONE) { |
if (instrument.loop_count && instrument.loops[0].mode != SF_LOOP_NONE) { |
1536 |
sample->Loops = 1; |
sample->Loops = 1; |
1537 |
|
|
1551 |
sample->LoopPlayCount = instrument.loops[0].count; |
sample->LoopPlayCount = instrument.loops[0].count; |
1552 |
sample->LoopSize = sample->LoopEnd - sample->LoopStart + 1; |
sample->LoopSize = sample->LoopEnd - sample->LoopStart + 1; |
1553 |
} |
} |
|
#endif |
|
1554 |
} |
} |
1555 |
|
|
1556 |
// schedule resizing the sample (which will be done |
// schedule resizing the sample (which will be done |