1 |
/* |
/* |
2 |
* Copyright (C) 2006-2013 Andreas Persson |
* Copyright (C) 2006-2014 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 |
42 |
#include <sndfile.h> |
#include <sndfile.h> |
43 |
|
|
44 |
#include "mainwindow.h" |
#include "mainwindow.h" |
45 |
|
#include "Settings.h" |
46 |
#include "../../gfx/status_attached.xpm" |
#include "../../gfx/status_attached.xpm" |
47 |
#include "../../gfx/status_detached.xpm" |
#include "../../gfx/status_detached.xpm" |
48 |
|
|
89 |
dimreg_vbox.pack_start(dimreg_hbox, Gtk::PACK_SHRINK); |
dimreg_vbox.pack_start(dimreg_hbox, Gtk::PACK_SHRINK); |
90 |
m_HPaned.add2(dimreg_vbox); |
m_HPaned.add2(dimreg_vbox); |
91 |
|
|
92 |
|
dimreg_label.set_tooltip_text(_("To automatically apply your changes above globally to the entire instrument, check all 3 check boxes on the right.")); |
93 |
|
dimreg_all_regions.set_tooltip_text(_("If checked: all changes you perform above will automatically be applied to all regions of this instrument as well.")); |
94 |
|
dimreg_all_dimregs.set_tooltip_text(_("If checked: all changes you perform above will automatically be applied as well to all dimension splits of the region selected below.")); |
95 |
|
dimreg_stereo.set_tooltip_text(_("If checked: all changes you perform above will automatically be applied to both audio channel splits (only if a \"stereo\" dimension is defined below).")); |
96 |
|
|
97 |
m_TreeViewNotebook.append_page(m_ScrolledWindowSamples, _("Samples")); |
m_TreeViewNotebook.append_page(m_ScrolledWindowSamples, _("Samples")); |
98 |
m_TreeViewNotebook.append_page(m_ScrolledWindow, _("Instruments")); |
m_TreeViewNotebook.append_page(m_ScrolledWindow, _("Instruments")); |
127 |
Gtk::Stock::PROPERTIES), |
Gtk::Stock::PROPERTIES), |
128 |
sigc::mem_fun( |
sigc::mem_fun( |
129 |
*this, &MainWindow::show_instr_props)); |
*this, &MainWindow::show_instr_props)); |
130 |
|
actionGroup->add(Gtk::Action::create("MidiRules", |
131 |
|
_("_Midi Rules")), |
132 |
|
sigc::mem_fun( |
133 |
|
*this, &MainWindow::show_midi_rules)); |
134 |
actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT), |
actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT), |
135 |
sigc::mem_fun( |
sigc::mem_fun( |
136 |
*this, &MainWindow::on_action_quit)); |
*this, &MainWindow::on_action_quit)); |
137 |
actionGroup->add(Gtk::Action::create("MenuInstrument", _("_Instrument"))); |
actionGroup->add(Gtk::Action::create("MenuInstrument", _("_Instrument"))); |
138 |
|
|
139 |
actionGroup->add(Gtk::Action::create("MenuView", _("_View"))); |
|
140 |
|
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
141 |
|
|
142 |
Glib::RefPtr<Gtk::ToggleAction> toggle_action = |
Glib::RefPtr<Gtk::ToggleAction> toggle_action = |
143 |
|
Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note")); |
144 |
|
toggle_action->set_active(true); |
145 |
|
actionGroup->add(toggle_action); |
146 |
|
|
147 |
|
toggle_action = |
148 |
|
Gtk::ToggleAction::create("CopySampleTune", _("Copy Sample's _Fine Tune")); |
149 |
|
toggle_action->set_active(true); |
150 |
|
actionGroup->add(toggle_action); |
151 |
|
|
152 |
|
toggle_action = |
153 |
|
Gtk::ToggleAction::create("CopySampleLoop", _("Copy Sample's _Loop Points")); |
154 |
|
toggle_action->set_active(true); |
155 |
|
actionGroup->add(toggle_action); |
156 |
|
|
157 |
|
|
158 |
|
actionGroup->add(Gtk::Action::create("MenuView", _("_View"))); |
159 |
|
toggle_action = |
160 |
Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); |
Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); |
161 |
toggle_action->set_active(true); |
toggle_action->set_active(true); |
162 |
actionGroup->add(toggle_action, |
actionGroup->add(toggle_action, |
182 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
183 |
); |
); |
184 |
|
|
185 |
|
|
186 |
|
actionGroup->add(Gtk::Action::create("MenuSettings", _("_Settings"))); |
187 |
|
|
188 |
|
toggle_action = |
189 |
|
Gtk::ToggleAction::create("WarnUserOnExtensions", _("Show warning on format _extensions")); |
190 |
|
toggle_action->set_active(Settings::singleton()->warnUserOnExtensions); |
191 |
|
actionGroup->add( |
192 |
|
toggle_action, |
193 |
|
sigc::mem_fun(*this, &MainWindow::on_action_warn_user_on_extensions) |
194 |
|
); |
195 |
|
|
196 |
|
|
197 |
// sample right-click popup actions |
// sample right-click popup actions |
198 |
actionGroup->add( |
actionGroup->add( |
199 |
Gtk::Action::create("SampleProperties", Gtk::Stock::PROPERTIES), |
Gtk::Action::create("SampleProperties", Gtk::Stock::PROPERTIES), |
235 |
" <separator/>" |
" <separator/>" |
236 |
" <menuitem action='Quit'/>" |
" <menuitem action='Quit'/>" |
237 |
" </menu>" |
" </menu>" |
238 |
|
" <menu action='MenuEdit'>" |
239 |
|
" <menuitem action='CopySampleUnity'/>" |
240 |
|
" <menuitem action='CopySampleTune'/>" |
241 |
|
" <menuitem action='CopySampleLoop'/>" |
242 |
|
" </menu>" |
243 |
" <menu action='MenuInstrument'>" |
" <menu action='MenuInstrument'>" |
244 |
" </menu>" |
" </menu>" |
245 |
" <menu action='MenuView'>" |
" <menu action='MenuView'>" |
246 |
" <menuitem action='Statusbar'/>" |
" <menuitem action='Statusbar'/>" |
247 |
" </menu>" |
" </menu>" |
248 |
|
" <menu action='MenuSettings'>" |
249 |
|
" <menuitem action='WarnUserOnExtensions'/>" |
250 |
|
" </menu>" |
251 |
" <menu action='MenuHelp'>" |
" <menu action='MenuHelp'>" |
252 |
" <menuitem action='About'/>" |
" <menuitem action='About'/>" |
253 |
" </menu>" |
" </menu>" |
254 |
" </menubar>" |
" </menubar>" |
255 |
" <popup name='PopupMenu'>" |
" <popup name='PopupMenu'>" |
256 |
" <menuitem action='InstrProperties'/>" |
" <menuitem action='InstrProperties'/>" |
257 |
|
" <menuitem action='MidiRules'/>" |
258 |
" <menuitem action='AddInstrument'/>" |
" <menuitem action='AddInstrument'/>" |
259 |
" <menuitem action='DupInstrument'/>" |
" <menuitem action='DupInstrument'/>" |
260 |
" <separator/>" |
" <separator/>" |
272 |
uiManager->add_ui_from_string(ui_info); |
uiManager->add_ui_from_string(ui_info); |
273 |
|
|
274 |
popup_menu = dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/PopupMenu")); |
popup_menu = dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/PopupMenu")); |
275 |
|
|
276 |
|
// Set tooltips for menu items (for some reason, setting a tooltip on the |
277 |
|
// respective Gtk::Action objects above will simply be ignored, no matter |
278 |
|
// if using Gtk::Action::set_tooltip() or passing the tooltip string on |
279 |
|
// Gtk::Action::create()). |
280 |
|
{ |
281 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
282 |
|
uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity")); |
283 |
|
item->set_tooltip_text(_("Used when dragging a sample to a region's sample reference field. You may disable this for example if you want to replace an existing sample in a region with a new sample, but don't want that the region's current unity note setting will be altered by this action.")); |
284 |
|
} |
285 |
|
{ |
286 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
287 |
|
uiManager->get_widget("/MenuBar/MenuEdit/CopySampleTune")); |
288 |
|
item->set_tooltip_text(_("Used when dragging a sample to a region's sample reference field. You may disable this for example if you want to replace an existing sample in a region with a new sample, but don't want that the region's current sample playback tuning will be altered by this action.")); |
289 |
|
} |
290 |
|
{ |
291 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
292 |
|
uiManager->get_widget("/MenuBar/MenuEdit/CopySampleLoop")); |
293 |
|
item->set_tooltip_text(_("Used when dragging a sample to a region's sample reference field. You may disable this for example if you want to replace an existing sample in a region with a new sample, but don't want that the region's current loop informations to be altered by this action.")); |
294 |
|
} |
295 |
|
{ |
296 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
297 |
|
uiManager->get_widget("/MenuBar/MenuSettings/WarnUserOnExtensions")); |
298 |
|
item->set_tooltip_text(_("If checked, a warning will be shown whenever you try to use a feature which is based on a LinuxSampler extension ontop of the original gig format, which would not work with the Gigasampler/GigaStudio application.")); |
299 |
|
} |
300 |
|
|
301 |
instrument_menu = static_cast<Gtk::MenuItem*>( |
instrument_menu = static_cast<Gtk::MenuItem*>( |
302 |
uiManager->get_widget("/MenuBar/MenuInstrument"))->get_submenu(); |
uiManager->get_widget("/MenuBar/MenuInstrument"))->get_submenu(); |
325 |
// Create the Tree model: |
// Create the Tree model: |
326 |
m_refTreeModel = Gtk::ListStore::create(m_Columns); |
m_refTreeModel = Gtk::ListStore::create(m_Columns); |
327 |
m_TreeView.set_model(m_refTreeModel); |
m_TreeView.set_model(m_refTreeModel); |
328 |
|
m_TreeView.set_tooltip_text(_("Right click here for actions on instruments & MIDI Rules.")); |
329 |
instrument_name_connection = m_refTreeModel->signal_row_changed().connect( |
instrument_name_connection = m_refTreeModel->signal_row_changed().connect( |
330 |
sigc::mem_fun(*this, &MainWindow::instrument_name_changed) |
sigc::mem_fun(*this, &MainWindow::instrument_name_changed) |
331 |
); |
); |
337 |
// create samples treeview (including its data model) |
// create samples treeview (including its data model) |
338 |
m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel); |
m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel); |
339 |
m_TreeViewSamples.set_model(m_refSamplesTreeModel); |
m_TreeViewSamples.set_model(m_refSamplesTreeModel); |
340 |
|
m_TreeViewSamples.set_tooltip_text(_("To actually use a sample, drag it from this list view to \"Sample\" -> \"Sample:\" on the region's settings pane on the right.\n\nRight click here for more actions on samples.")); |
341 |
// m_TreeViewSamples.set_reorderable(); |
// m_TreeViewSamples.set_reorderable(); |
342 |
m_TreeViewSamples.append_column_editable("Samples", m_SamplesModel.m_col_name); |
m_TreeViewSamples.append_column_editable("Samples", m_SamplesModel.m_col_name); |
343 |
m_TreeViewSamples.set_headers_visible(false); |
m_TreeViewSamples.set_headers_visible(false); |
372 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
373 |
propDialog.signal_changed().connect( |
propDialog.signal_changed().connect( |
374 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
375 |
|
midiRules.signal_changed().connect( |
376 |
|
sigc::mem_fun(*this, &MainWindow::file_changed)); |
377 |
|
|
378 |
dimreg_edit.signal_dimreg_to_be_changed().connect( |
dimreg_edit.signal_dimreg_to_be_changed().connect( |
379 |
dimreg_to_be_changed_signal.make_slot()); |
dimreg_to_be_changed_signal.make_slot()); |
622 |
gig::File* pFile = new gig::File; |
gig::File* pFile = new gig::File; |
623 |
// already add one new instrument by default |
// already add one new instrument by default |
624 |
gig::Instrument* pInstrument = pFile->AddInstrument(); |
gig::Instrument* pInstrument = pFile->AddInstrument(); |
625 |
pInstrument->pInfo->Name = _("Unnamed Instrument"); |
pInstrument->pInfo->Name = gig_from_utf8(_("Unnamed Instrument")); |
626 |
// update GUI with that new gig::File |
// update GUI with that new gig::File |
627 |
load_gig(pFile, 0 /*no file name yet*/); |
load_gig(pFile, 0 /*no file name yet*/); |
628 |
} |
} |
974 |
propDialog.deiconify(); |
propDialog.deiconify(); |
975 |
} |
} |
976 |
|
|
977 |
|
void MainWindow::on_action_warn_user_on_extensions() { |
978 |
|
Settings::singleton()->warnUserOnExtensions = |
979 |
|
!Settings::singleton()->warnUserOnExtensions; |
980 |
|
} |
981 |
|
|
982 |
void MainWindow::on_action_help_about() |
void MainWindow::on_action_help_about() |
983 |
{ |
{ |
984 |
Gtk::AboutDialog dialog; |
Gtk::AboutDialog dialog; |
988 |
dialog.set_name("Gigedit"); |
dialog.set_name("Gigedit"); |
989 |
#endif |
#endif |
990 |
dialog.set_version(VERSION); |
dialog.set_version(VERSION); |
991 |
dialog.set_copyright("Copyright (C) 2006-2013 Andreas Persson"); |
dialog.set_copyright("Copyright (C) 2006-2014 Andreas Persson"); |
992 |
dialog.set_comments(_( |
const std::string sComment = |
993 |
"Released under the GNU General Public License.\n" |
_("Built " __DATE__ "\nUsing ") + |
994 |
"\n" |
::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" + |
995 |
"Please notice that this is still a very young instrument editor. " |
_( |
996 |
"So better backup your Gigasampler files before editing them with " |
"Gigedit is released under the GNU General Public License.\n" |
997 |
"this application.\n" |
"\n" |
998 |
"\n" |
"Please notice that this is still a very young instrument editor. " |
999 |
"Please report bugs to: http://bugs.linuxsampler.org") |
"So better backup your Gigasampler files before editing them with " |
1000 |
); |
"this application.\n" |
1001 |
|
"\n" |
1002 |
|
"Please report bugs to: http://bugs.linuxsampler.org" |
1003 |
|
); |
1004 |
|
dialog.set_comments(sComment.c_str()); |
1005 |
dialog.set_website("http://www.linuxsampler.org"); |
dialog.set_website("http://www.linuxsampler.org"); |
1006 |
dialog.set_website_label("http://www.linuxsampler.org"); |
dialog.set_website_label("http://www.linuxsampler.org"); |
1007 |
dialog.run(); |
dialog.run(); |
1229 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
1230 |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
1231 |
instrument = gig->GetNextInstrument()) { |
instrument = gig->GetNextInstrument()) { |
1232 |
Glib::ustring name(instrument->pInfo->Name); |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
1233 |
|
|
1234 |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
1235 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
1245 |
if (group->Name != "") { |
if (group->Name != "") { |
1246 |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
1247 |
Gtk::TreeModel::Row rowGroup = *iterGroup; |
Gtk::TreeModel::Row rowGroup = *iterGroup; |
1248 |
rowGroup[m_SamplesModel.m_col_name] = group->Name.c_str(); |
rowGroup[m_SamplesModel.m_col_name] = gig_to_utf8(group->Name); |
1249 |
rowGroup[m_SamplesModel.m_col_group] = group; |
rowGroup[m_SamplesModel.m_col_group] = group; |
1250 |
rowGroup[m_SamplesModel.m_col_sample] = NULL; |
rowGroup[m_SamplesModel.m_col_sample] = NULL; |
1251 |
for (gig::Sample* sample = group->GetFirstSample(); |
for (gig::Sample* sample = group->GetFirstSample(); |
1253 |
Gtk::TreeModel::iterator iterSample = |
Gtk::TreeModel::iterator iterSample = |
1254 |
m_refSamplesTreeModel->append(rowGroup.children()); |
m_refSamplesTreeModel->append(rowGroup.children()); |
1255 |
Gtk::TreeModel::Row rowSample = *iterSample; |
Gtk::TreeModel::Row rowSample = *iterSample; |
1256 |
rowSample[m_SamplesModel.m_col_name] = sample->pInfo->Name.c_str(); |
rowSample[m_SamplesModel.m_col_name] = |
1257 |
|
gig_to_utf8(sample->pInfo->Name); |
1258 |
rowSample[m_SamplesModel.m_col_sample] = sample; |
rowSample[m_SamplesModel.m_col_sample] = sample; |
1259 |
rowSample[m_SamplesModel.m_col_group] = NULL; |
rowSample[m_SamplesModel.m_col_group] = NULL; |
1260 |
} |
} |
1267 |
m_TreeView.get_selection()->select(Gtk::TreePath("0")); |
m_TreeView.get_selection()->select(Gtk::TreePath("0")); |
1268 |
|
|
1269 |
instr_props_set_instrument(); |
instr_props_set_instrument(); |
1270 |
|
gig::Instrument* instrument = get_instrument(); |
1271 |
|
if (instrument) { |
1272 |
|
midiRules.set_instrument(instrument); |
1273 |
|
} |
1274 |
} |
} |
1275 |
|
|
1276 |
bool MainWindow::instr_props_set_instrument() |
bool MainWindow::instr_props_set_instrument() |
1312 |
Glib::ustring name = row[m_Columns.m_col_name]; |
Glib::ustring name = row[m_Columns.m_col_name]; |
1313 |
|
|
1314 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
1315 |
if (instrument->pInfo->Name != name) { |
Glib::ustring gigname(gig_to_utf8(instrument->pInfo->Name)); |
1316 |
row[m_Columns.m_col_name] = instrument->pInfo->Name; |
if (gigname != name) { |
1317 |
|
row[m_Columns.m_col_name] = gigname; |
1318 |
|
} |
1319 |
|
} |
1320 |
|
|
1321 |
|
void MainWindow::show_midi_rules() |
1322 |
|
{ |
1323 |
|
if (gig::Instrument* instrument = get_instrument()) |
1324 |
|
{ |
1325 |
|
midiRules.set_instrument(instrument); |
1326 |
|
midiRules.show(); |
1327 |
|
midiRules.deiconify(); |
1328 |
} |
} |
1329 |
} |
} |
1330 |
|
|
1339 |
else m_StatusBar.hide(); |
else m_StatusBar.hide(); |
1340 |
} |
} |
1341 |
|
|
1342 |
|
bool MainWindow::is_copy_samples_unity_note_enabled() const { |
1343 |
|
Gtk::CheckMenuItem* item = |
1344 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity")); |
1345 |
|
if (!item) { |
1346 |
|
std::cerr << "/MenuBar/MenuEdit/CopySampleUnity == NULL\n"; |
1347 |
|
return true; |
1348 |
|
} |
1349 |
|
return item->get_active(); |
1350 |
|
} |
1351 |
|
|
1352 |
|
bool MainWindow::is_copy_samples_fine_tune_enabled() const { |
1353 |
|
Gtk::CheckMenuItem* item = |
1354 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleTune")); |
1355 |
|
if (!item) { |
1356 |
|
std::cerr << "/MenuBar/MenuEdit/CopySampleTune == NULL\n"; |
1357 |
|
return true; |
1358 |
|
} |
1359 |
|
return item->get_active(); |
1360 |
|
} |
1361 |
|
|
1362 |
|
bool MainWindow::is_copy_samples_loop_enabled() const { |
1363 |
|
Gtk::CheckMenuItem* item = |
1364 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleLoop")); |
1365 |
|
if (!item) { |
1366 |
|
std::cerr << "/MenuBar/MenuEdit/CopySampleLoop == NULL\n"; |
1367 |
|
return true; |
1368 |
|
} |
1369 |
|
return item->get_active(); |
1370 |
|
} |
1371 |
|
|
1372 |
void MainWindow::on_button_release(GdkEventButton* button) |
void MainWindow::on_button_release(GdkEventButton* button) |
1373 |
{ |
{ |
1374 |
if (button->type == GDK_2BUTTON_PRESS) { |
if (button->type == GDK_2BUTTON_PRESS) { |
1375 |
show_instr_props(); |
show_instr_props(); |
1376 |
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
1377 |
|
// gig v2 files have no midi rules |
1378 |
|
static_cast<Gtk::MenuItem*>( |
1379 |
|
uiManager->get_widget("/PopupMenu/MidiRules"))->set_sensitive( |
1380 |
|
!(file->pVersion && file->pVersion->major == 2)); |
1381 |
popup_menu->popup(button->button, button->time); |
popup_menu->popup(button->button, button->time); |
1382 |
} |
} |
1383 |
} |
} |
1458 |
} |
} |
1459 |
|
|
1460 |
void MainWindow::add_instrument(gig::Instrument* instrument) { |
void MainWindow::add_instrument(gig::Instrument* instrument) { |
1461 |
const char* name = instrument->pInfo->Name.c_str(); |
const Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
1462 |
|
|
1463 |
// update instrument tree view |
// update instrument tree view |
1464 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
1480 |
if (!file) return; |
if (!file) return; |
1481 |
gig::Instrument* instrument = file->AddInstrument(); |
gig::Instrument* instrument = file->AddInstrument(); |
1482 |
__instrument_indexer++; |
__instrument_indexer++; |
1483 |
instrument->pInfo->Name = |
instrument->pInfo->Name = gig_from_utf8(_("Unnamed Instrument ") + |
1484 |
_("Unnamed Instrument ") + ToString(__instrument_indexer); |
ToString(__instrument_indexer)); |
1485 |
|
|
1486 |
add_instrument(instrument); |
add_instrument(instrument); |
1487 |
} |
} |
1501 |
// duplicate the orginal instrument |
// duplicate the orginal instrument |
1502 |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
1503 |
instrNew->pInfo->Name = |
instrNew->pInfo->Name = |
1504 |
instrOrig->pInfo->Name + " (" + _("Copy") + ")"; |
instrOrig->pInfo->Name + |
1505 |
|
gig_from_utf8(Glib::ustring(" (") + _("Copy") + ")"); |
1506 |
|
|
1507 |
add_instrument(instrNew); |
add_instrument(instrNew); |
1508 |
} |
} |
1550 |
} |
} |
1551 |
#endif |
#endif |
1552 |
instr_props_set_instrument(); |
instr_props_set_instrument(); |
1553 |
|
instr = get_instrument(); |
1554 |
|
if (instr) { |
1555 |
|
midiRules.set_instrument(instr); |
1556 |
|
} else { |
1557 |
|
midiRules.hide(); |
1558 |
|
} |
1559 |
} catch (RIFF::Exception e) { |
} catch (RIFF::Exception e) { |
1560 |
Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR); |
1561 |
msg.run(); |
msg.run(); |
1575 |
static int __sample_indexer = 0; |
static int __sample_indexer = 0; |
1576 |
if (!file) return; |
if (!file) return; |
1577 |
gig::Group* group = file->AddGroup(); |
gig::Group* group = file->AddGroup(); |
1578 |
group->Name = _("Unnamed Group"); |
group->Name = gig_from_utf8(_("Unnamed Group")); |
1579 |
if (__sample_indexer) group->Name += " " + ToString(__sample_indexer); |
if (__sample_indexer) group->Name += " " + ToString(__sample_indexer); |
1580 |
__sample_indexer++; |
__sample_indexer++; |
1581 |
// update sample tree view |
// update sample tree view |
1582 |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
1583 |
Gtk::TreeModel::Row rowGroup = *iterGroup; |
Gtk::TreeModel::Row rowGroup = *iterGroup; |
1584 |
rowGroup[m_SamplesModel.m_col_name] = group->Name.c_str(); |
rowGroup[m_SamplesModel.m_col_name] = gig_to_utf8(group->Name); |
1585 |
rowGroup[m_SamplesModel.m_col_sample] = NULL; |
rowGroup[m_SamplesModel.m_col_sample] = NULL; |
1586 |
rowGroup[m_SamplesModel.m_col_group] = group; |
rowGroup[m_SamplesModel.m_col_group] = group; |
1587 |
file_changed(); |
file_changed(); |
1690 |
break; |
break; |
1691 |
} |
} |
1692 |
} |
} |
1693 |
sample->pInfo->Name = filename; |
sample->pInfo->Name = gig_from_utf8(filename); |
1694 |
sample->Channels = info.channels; |
sample->Channels = info.channels; |
1695 |
sample->BitDepth = bitdepth; |
sample->BitDepth = bitdepth; |
1696 |
sample->FrameSize = bitdepth / 8/*1 byte are 8 bits*/ * info.channels; |
sample->FrameSize = bitdepth / 8/*1 byte are 8 bits*/ * info.channels; |
1704 |
&instrument, sizeof(instrument)) != SF_FALSE) |
&instrument, sizeof(instrument)) != SF_FALSE) |
1705 |
{ |
{ |
1706 |
sample->MIDIUnityNote = instrument.basenote; |
sample->MIDIUnityNote = instrument.basenote; |
1707 |
|
sample->FineTune = instrument.detune; |
1708 |
|
|
1709 |
if (instrument.loop_count && instrument.loops[0].mode != SF_LOOP_NONE) { |
if (instrument.loop_count && instrument.loops[0].mode != SF_LOOP_NONE) { |
1710 |
sample->Loops = 1; |
sample->Loops = 1; |
1742 |
Gtk::TreeModel::iterator iterSample = |
Gtk::TreeModel::iterator iterSample = |
1743 |
m_refSamplesTreeModel->append(row.children()); |
m_refSamplesTreeModel->append(row.children()); |
1744 |
Gtk::TreeModel::Row rowSample = *iterSample; |
Gtk::TreeModel::Row rowSample = *iterSample; |
1745 |
rowSample[m_SamplesModel.m_col_name] = filename; |
rowSample[m_SamplesModel.m_col_name] = |
1746 |
|
gig_to_utf8(sample->pInfo->Name); |
1747 |
rowSample[m_SamplesModel.m_col_sample] = sample; |
rowSample[m_SamplesModel.m_col_sample] = sample; |
1748 |
rowSample[m_SamplesModel.m_col_group] = NULL; |
rowSample[m_SamplesModel.m_col_group] = NULL; |
1749 |
// close sound file |
// close sound file |
1814 |
sample; sample = file->GetNextSample()) |
sample; sample = file->GetNextSample()) |
1815 |
{ |
{ |
1816 |
std::string filename = |
std::string filename = |
1817 |
folder + G_DIR_SEPARATOR_S + sample->pInfo->Name + |
folder + G_DIR_SEPARATOR_S + |
1818 |
postfixEntryBox.get_text().raw(); |
Glib::filename_from_utf8(gig_to_utf8(sample->pInfo->Name) + |
1819 |
|
postfixEntryBox.get_text()); |
1820 |
SF_INFO info; |
SF_INFO info; |
1821 |
info.format = 0; |
info.format = 0; |
1822 |
SNDFILE* hFile = sf_open(filename.c_str(), SFM_READ, &info); |
SNDFILE* hFile = sf_open(filename.c_str(), SFM_READ, &info); |
1850 |
catch (std::string what) |
catch (std::string what) |
1851 |
{ |
{ |
1852 |
if (!error_files.empty()) error_files += "\n"; |
if (!error_files.empty()) error_files += "\n"; |
1853 |
error_files += filename += " (" + what + ")"; |
error_files += Glib::filename_to_utf8(filename) + |
1854 |
|
" (" + what + ")"; |
1855 |
} |
} |
1856 |
} |
} |
1857 |
// show error message box when some file(s) could not be opened / added |
// show error message box when some file(s) could not be opened / added |
1876 |
try { |
try { |
1877 |
// remove group or sample from the gig file |
// remove group or sample from the gig file |
1878 |
if (group) { |
if (group) { |
1879 |
// temporarily remember the samples that bolong to |
// temporarily remember the samples that belong to |
1880 |
// that group (we need that to clean the queue) |
// that group (we need that to clean the queue) |
1881 |
std::list<gig::Sample*> members; |
std::list<gig::Sample*> members; |
1882 |
for (gig::Sample* pSample = group->GetFirstSample(); |
for (gig::Sample* pSample = group->GetFirstSample(); |
2002 |
channels_changed = true; |
channels_changed = true; |
2003 |
region_changed(); |
region_changed(); |
2004 |
} |
} |
2005 |
dimreg_edit.set_sample(sample); |
dimreg_edit.set_sample( |
2006 |
|
sample, |
2007 |
|
is_copy_samples_unity_note_enabled(), |
2008 |
|
is_copy_samples_fine_tune_enabled(), |
2009 |
|
is_copy_samples_loop_enabled() |
2010 |
|
); |
2011 |
|
|
2012 |
if (sample->Channels == 2 && !stereo_dimension) { |
if (sample->Channels == 2 && !stereo_dimension) { |
2013 |
// add samplechannel dimension |
// add samplechannel dimension |
2050 |
Glib::ustring name = row[m_SamplesModel.m_col_name]; |
Glib::ustring name = row[m_SamplesModel.m_col_name]; |
2051 |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
2052 |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
2053 |
|
gig::String gigname(gig_from_utf8(name)); |
2054 |
if (group) { |
if (group) { |
2055 |
if (group->Name != name) { |
if (group->Name != gigname) { |
2056 |
group->Name = name; |
group->Name = gigname; |
2057 |
printf("group name changed\n"); |
printf("group name changed\n"); |
2058 |
file_changed(); |
file_changed(); |
2059 |
} |
} |
2060 |
} else if (sample) { |
} else if (sample) { |
2061 |
if (sample->pInfo->Name != name.raw()) { |
if (sample->pInfo->Name != gigname) { |
2062 |
sample->pInfo->Name = name.raw(); |
sample->pInfo->Name = gigname; |
2063 |
printf("sample name changed\n"); |
printf("sample name changed\n"); |
2064 |
file_changed(); |
file_changed(); |
2065 |
} |
} |
2087 |
|
|
2088 |
// change name in gig |
// change name in gig |
2089 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
2090 |
if (instrument && instrument->pInfo->Name != name.raw()) { |
gig::String gigname(gig_from_utf8(name)); |
2091 |
instrument->pInfo->Name = name.raw(); |
if (instrument && instrument->pInfo->Name != gigname) { |
2092 |
|
instrument->pInfo->Name = gigname; |
2093 |
|
|
2094 |
// change name in the instrument properties window |
// change name in the instrument properties window |
2095 |
if (instrumentProps.get_instrument() == instrument) { |
if (instrumentProps.get_instrument() == instrument) { |