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 |
123 |
Gtk::Stock::PROPERTIES), |
Gtk::Stock::PROPERTIES), |
124 |
sigc::mem_fun( |
sigc::mem_fun( |
125 |
*this, &MainWindow::show_instr_props)); |
*this, &MainWindow::show_instr_props)); |
126 |
|
actionGroup->add(Gtk::Action::create("MidiRules", |
127 |
|
_("_Midi Rules")), |
128 |
|
sigc::mem_fun( |
129 |
|
*this, &MainWindow::show_midi_rules)); |
130 |
actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT), |
actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT), |
131 |
sigc::mem_fun( |
sigc::mem_fun( |
132 |
*this, &MainWindow::on_action_quit)); |
*this, &MainWindow::on_action_quit)); |
133 |
actionGroup->add(Gtk::Action::create("MenuInstrument", _("_Instrument"))); |
actionGroup->add(Gtk::Action::create("MenuInstrument", _("_Instrument"))); |
134 |
|
|
135 |
actionGroup->add(Gtk::Action::create("MenuView", _("_View"))); |
|
136 |
|
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
137 |
|
|
138 |
Glib::RefPtr<Gtk::ToggleAction> toggle_action = |
Glib::RefPtr<Gtk::ToggleAction> toggle_action = |
139 |
|
Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note"), "ffaga"); |
140 |
|
toggle_action->set_active(true); |
141 |
|
//FIXME: doesn't work, why? |
142 |
|
toggle_action->set_tooltip(_("Used when dragging a sample to a region's sample reference field.")); |
143 |
|
actionGroup->add(toggle_action); |
144 |
|
|
145 |
|
toggle_action = |
146 |
|
Gtk::ToggleAction::create("CopySampleTune", _("Copy Sample's _Fine Tune")); |
147 |
|
toggle_action->set_active(true); |
148 |
|
//FIXME: doesn't work, why? |
149 |
|
toggle_action->set_tooltip(_("Used when dragging a sample to a region's sample reference field.")); |
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 |
|
//FIXME: doesn't work, why? |
156 |
|
toggle_action->set_tooltip(_("Used when dragging a sample to a region's sample reference field.")); |
157 |
|
actionGroup->add(toggle_action); |
158 |
|
|
159 |
|
|
160 |
|
actionGroup->add(Gtk::Action::create("MenuView", _("_View"))); |
161 |
|
toggle_action = |
162 |
Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); |
Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); |
163 |
toggle_action->set_active(true); |
toggle_action->set_active(true); |
164 |
actionGroup->add(toggle_action, |
actionGroup->add(toggle_action, |
225 |
" <separator/>" |
" <separator/>" |
226 |
" <menuitem action='Quit'/>" |
" <menuitem action='Quit'/>" |
227 |
" </menu>" |
" </menu>" |
228 |
|
" <menu action='MenuEdit'>" |
229 |
|
" <menuitem action='CopySampleUnity'/>" |
230 |
|
" <menuitem action='CopySampleTune'/>" |
231 |
|
" <menuitem action='CopySampleLoop'/>" |
232 |
|
" </menu>" |
233 |
" <menu action='MenuInstrument'>" |
" <menu action='MenuInstrument'>" |
234 |
" </menu>" |
" </menu>" |
235 |
" <menu action='MenuView'>" |
" <menu action='MenuView'>" |
241 |
" </menubar>" |
" </menubar>" |
242 |
" <popup name='PopupMenu'>" |
" <popup name='PopupMenu'>" |
243 |
" <menuitem action='InstrProperties'/>" |
" <menuitem action='InstrProperties'/>" |
244 |
|
" <menuitem action='MidiRules'/>" |
245 |
" <menuitem action='AddInstrument'/>" |
" <menuitem action='AddInstrument'/>" |
246 |
" <menuitem action='DupInstrument'/>" |
" <menuitem action='DupInstrument'/>" |
247 |
" <separator/>" |
" <separator/>" |
332 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
333 |
propDialog.signal_changed().connect( |
propDialog.signal_changed().connect( |
334 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
335 |
|
midiRules.signal_changed().connect( |
336 |
|
sigc::mem_fun(*this, &MainWindow::file_changed)); |
337 |
|
|
338 |
dimreg_edit.signal_dimreg_to_be_changed().connect( |
dimreg_edit.signal_dimreg_to_be_changed().connect( |
339 |
dimreg_to_be_changed_signal.make_slot()); |
dimreg_to_be_changed_signal.make_slot()); |
582 |
gig::File* pFile = new gig::File; |
gig::File* pFile = new gig::File; |
583 |
// already add one new instrument by default |
// already add one new instrument by default |
584 |
gig::Instrument* pInstrument = pFile->AddInstrument(); |
gig::Instrument* pInstrument = pFile->AddInstrument(); |
585 |
pInstrument->pInfo->Name = _("Unnamed Instrument"); |
pInstrument->pInfo->Name = gig_from_utf8(_("Unnamed Instrument")); |
586 |
// update GUI with that new gig::File |
// update GUI with that new gig::File |
587 |
load_gig(pFile, 0 /*no file name yet*/); |
load_gig(pFile, 0 /*no file name yet*/); |
588 |
} |
} |
943 |
dialog.set_name("Gigedit"); |
dialog.set_name("Gigedit"); |
944 |
#endif |
#endif |
945 |
dialog.set_version(VERSION); |
dialog.set_version(VERSION); |
946 |
dialog.set_copyright("Copyright (C) 2006-2013 Andreas Persson"); |
dialog.set_copyright("Copyright (C) 2006-2014 Andreas Persson"); |
947 |
dialog.set_comments(_( |
const std::string sComment = |
948 |
"Released under the GNU General Public License.\n" |
_("Built " __DATE__ "\nUsing ") + |
949 |
"\n" |
::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" + |
950 |
"Please notice that this is still a very young instrument editor. " |
_( |
951 |
"So better backup your Gigasampler files before editing them with " |
"Gigedit is released under the GNU General Public License.\n" |
952 |
"this application.\n" |
"\n" |
953 |
"\n" |
"Please notice that this is still a very young instrument editor. " |
954 |
"Please report bugs to: http://bugs.linuxsampler.org") |
"So better backup your Gigasampler files before editing them with " |
955 |
); |
"this application.\n" |
956 |
|
"\n" |
957 |
|
"Please report bugs to: http://bugs.linuxsampler.org" |
958 |
|
); |
959 |
|
dialog.set_comments(sComment.c_str()); |
960 |
dialog.set_website("http://www.linuxsampler.org"); |
dialog.set_website("http://www.linuxsampler.org"); |
961 |
dialog.set_website_label("http://www.linuxsampler.org"); |
dialog.set_website_label("http://www.linuxsampler.org"); |
962 |
dialog.run(); |
dialog.run(); |
1044 |
} |
} |
1045 |
|
|
1046 |
|
|
1047 |
|
void InstrumentProps::set_Name(const gig::String& name) |
1048 |
|
{ |
1049 |
|
m->pInfo->Name = name; |
1050 |
|
} |
1051 |
|
|
1052 |
|
void InstrumentProps::update_name() |
1053 |
|
{ |
1054 |
|
update_model++; |
1055 |
|
eName.set_value(m->pInfo->Name); |
1056 |
|
update_model--; |
1057 |
|
} |
1058 |
|
|
1059 |
void InstrumentProps::set_IsDrum(bool value) |
void InstrumentProps::set_IsDrum(bool value) |
1060 |
{ |
{ |
1061 |
m->IsDrum = value; |
m->IsDrum = value; |
1098 |
"\"keyswitching\" dimension") |
"\"keyswitching\" dimension") |
1099 |
); |
); |
1100 |
|
|
1101 |
|
connect(eName, &InstrumentProps::set_Name); |
1102 |
connect(eIsDrum, &InstrumentProps::set_IsDrum); |
connect(eIsDrum, &InstrumentProps::set_IsDrum); |
1103 |
connect(eMIDIBank, &InstrumentProps::set_MIDIBank); |
connect(eMIDIBank, &InstrumentProps::set_MIDIBank); |
1104 |
connect(eMIDIProgram, &InstrumentProps::set_MIDIProgram); |
connect(eMIDIProgram, &InstrumentProps::set_MIDIProgram); |
1111 |
connect(eDimensionKeyRangeLow, eDimensionKeyRangeHigh, |
connect(eDimensionKeyRangeLow, eDimensionKeyRangeHigh, |
1112 |
&gig::Instrument::DimensionKeyRange); |
&gig::Instrument::DimensionKeyRange); |
1113 |
|
|
1114 |
|
eName.signal_value_changed().connect(sig_name_changed.make_slot()); |
1115 |
|
|
1116 |
table.set_col_spacings(5); |
table.set_col_spacings(5); |
1117 |
|
|
1118 |
table.add(eName); |
table.add(eName); |
1153 |
update(instrument); |
update(instrument); |
1154 |
|
|
1155 |
update_model++; |
update_model++; |
1156 |
|
eName.set_value(instrument->pInfo->Name); |
1157 |
eIsDrum.set_value(instrument->IsDrum); |
eIsDrum.set_value(instrument->IsDrum); |
1158 |
eMIDIBank.set_value(instrument->MIDIBank); |
eMIDIBank.set_value(instrument->MIDIBank); |
1159 |
eMIDIProgram.set_value(instrument->MIDIProgram); |
eMIDIProgram.set_value(instrument->MIDIProgram); |
1184 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
1185 |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
1186 |
instrument = gig->GetNextInstrument()) { |
instrument = gig->GetNextInstrument()) { |
1187 |
Glib::ustring name(instrument->pInfo->Name); |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
1188 |
|
|
1189 |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
1190 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
1200 |
if (group->Name != "") { |
if (group->Name != "") { |
1201 |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
1202 |
Gtk::TreeModel::Row rowGroup = *iterGroup; |
Gtk::TreeModel::Row rowGroup = *iterGroup; |
1203 |
rowGroup[m_SamplesModel.m_col_name] = group->Name.c_str(); |
rowGroup[m_SamplesModel.m_col_name] = gig_to_utf8(group->Name); |
1204 |
rowGroup[m_SamplesModel.m_col_group] = group; |
rowGroup[m_SamplesModel.m_col_group] = group; |
1205 |
rowGroup[m_SamplesModel.m_col_sample] = NULL; |
rowGroup[m_SamplesModel.m_col_sample] = NULL; |
1206 |
for (gig::Sample* sample = group->GetFirstSample(); |
for (gig::Sample* sample = group->GetFirstSample(); |
1208 |
Gtk::TreeModel::iterator iterSample = |
Gtk::TreeModel::iterator iterSample = |
1209 |
m_refSamplesTreeModel->append(rowGroup.children()); |
m_refSamplesTreeModel->append(rowGroup.children()); |
1210 |
Gtk::TreeModel::Row rowSample = *iterSample; |
Gtk::TreeModel::Row rowSample = *iterSample; |
1211 |
rowSample[m_SamplesModel.m_col_name] = sample->pInfo->Name.c_str(); |
rowSample[m_SamplesModel.m_col_name] = |
1212 |
|
gig_to_utf8(sample->pInfo->Name); |
1213 |
rowSample[m_SamplesModel.m_col_sample] = sample; |
rowSample[m_SamplesModel.m_col_sample] = sample; |
1214 |
rowSample[m_SamplesModel.m_col_group] = NULL; |
rowSample[m_SamplesModel.m_col_group] = NULL; |
1215 |
} |
} |
1221 |
// select the first instrument |
// select the first instrument |
1222 |
m_TreeView.get_selection()->select(Gtk::TreePath("0")); |
m_TreeView.get_selection()->select(Gtk::TreePath("0")); |
1223 |
|
|
1224 |
|
instr_props_set_instrument(); |
1225 |
gig::Instrument* instrument = get_instrument(); |
gig::Instrument* instrument = get_instrument(); |
1226 |
if (instrument) { |
if (instrument) { |
1227 |
|
midiRules.set_instrument(instrument); |
1228 |
|
} |
1229 |
|
} |
1230 |
|
|
1231 |
|
bool MainWindow::instr_props_set_instrument() |
1232 |
|
{ |
1233 |
|
instrumentProps.signal_name_changed().clear(); |
1234 |
|
|
1235 |
|
Gtk::TreeModel::const_iterator it = |
1236 |
|
m_TreeView.get_selection()->get_selected(); |
1237 |
|
if (it) { |
1238 |
|
Gtk::TreeModel::Row row = *it; |
1239 |
|
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
1240 |
|
|
1241 |
instrumentProps.set_instrument(instrument); |
instrumentProps.set_instrument(instrument); |
1242 |
|
|
1243 |
|
// make sure instrument tree is updated when user changes the |
1244 |
|
// instrument name in instrument properties window |
1245 |
|
instrumentProps.signal_name_changed().connect( |
1246 |
|
sigc::bind( |
1247 |
|
sigc::mem_fun(*this, |
1248 |
|
&MainWindow::instr_name_changed_by_instr_props), |
1249 |
|
it)); |
1250 |
|
} else { |
1251 |
|
instrumentProps.hide(); |
1252 |
} |
} |
1253 |
|
return it; |
1254 |
} |
} |
1255 |
|
|
1256 |
void MainWindow::show_instr_props() |
void MainWindow::show_instr_props() |
1257 |
{ |
{ |
1258 |
gig::Instrument* instrument = get_instrument(); |
if (instr_props_set_instrument()) { |
|
if (instrument) |
|
|
{ |
|
|
instrumentProps.set_instrument(instrument); |
|
1259 |
instrumentProps.show(); |
instrumentProps.show(); |
1260 |
instrumentProps.deiconify(); |
instrumentProps.deiconify(); |
1261 |
} |
} |
1262 |
} |
} |
1263 |
|
|
1264 |
|
void MainWindow::instr_name_changed_by_instr_props(Gtk::TreeModel::iterator& it) |
1265 |
|
{ |
1266 |
|
Gtk::TreeModel::Row row = *it; |
1267 |
|
Glib::ustring name = row[m_Columns.m_col_name]; |
1268 |
|
|
1269 |
|
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
1270 |
|
Glib::ustring gigname(gig_to_utf8(instrument->pInfo->Name)); |
1271 |
|
if (gigname != name) { |
1272 |
|
row[m_Columns.m_col_name] = gigname; |
1273 |
|
} |
1274 |
|
} |
1275 |
|
|
1276 |
|
void MainWindow::show_midi_rules() |
1277 |
|
{ |
1278 |
|
if (gig::Instrument* instrument = get_instrument()) |
1279 |
|
{ |
1280 |
|
midiRules.set_instrument(instrument); |
1281 |
|
midiRules.show(); |
1282 |
|
midiRules.deiconify(); |
1283 |
|
} |
1284 |
|
} |
1285 |
|
|
1286 |
void MainWindow::on_action_view_status_bar() { |
void MainWindow::on_action_view_status_bar() { |
1287 |
Gtk::CheckMenuItem* item = |
Gtk::CheckMenuItem* item = |
1288 |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar")); |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar")); |
1294 |
else m_StatusBar.hide(); |
else m_StatusBar.hide(); |
1295 |
} |
} |
1296 |
|
|
1297 |
|
bool MainWindow::is_copy_samples_unity_note_enabled() const { |
1298 |
|
Gtk::CheckMenuItem* item = |
1299 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity")); |
1300 |
|
if (!item) { |
1301 |
|
std::cerr << "/MenuBar/MenuEdit/CopySampleUnity == NULL\n"; |
1302 |
|
return true; |
1303 |
|
} |
1304 |
|
return item->get_active(); |
1305 |
|
} |
1306 |
|
|
1307 |
|
bool MainWindow::is_copy_samples_fine_tune_enabled() const { |
1308 |
|
Gtk::CheckMenuItem* item = |
1309 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleTune")); |
1310 |
|
if (!item) { |
1311 |
|
std::cerr << "/MenuBar/MenuEdit/CopySampleTune == NULL\n"; |
1312 |
|
return true; |
1313 |
|
} |
1314 |
|
return item->get_active(); |
1315 |
|
} |
1316 |
|
|
1317 |
|
bool MainWindow::is_copy_samples_loop_enabled() const { |
1318 |
|
Gtk::CheckMenuItem* item = |
1319 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleLoop")); |
1320 |
|
if (!item) { |
1321 |
|
std::cerr << "/MenuBar/MenuEdit/CopySampleLoop == NULL\n"; |
1322 |
|
return true; |
1323 |
|
} |
1324 |
|
return item->get_active(); |
1325 |
|
} |
1326 |
|
|
1327 |
void MainWindow::on_button_release(GdkEventButton* button) |
void MainWindow::on_button_release(GdkEventButton* button) |
1328 |
{ |
{ |
1329 |
if (button->type == GDK_2BUTTON_PRESS) { |
if (button->type == GDK_2BUTTON_PRESS) { |
1330 |
show_instr_props(); |
show_instr_props(); |
1331 |
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
1332 |
|
// gig v2 files have no midi rules |
1333 |
|
static_cast<Gtk::MenuItem*>( |
1334 |
|
uiManager->get_widget("/PopupMenu/MidiRules"))->set_sensitive( |
1335 |
|
!(file->pVersion && file->pVersion->major == 2)); |
1336 |
popup_menu->popup(button->button, button->time); |
popup_menu->popup(button->button, button->time); |
1337 |
} |
} |
1338 |
} |
} |
1413 |
} |
} |
1414 |
|
|
1415 |
void MainWindow::add_instrument(gig::Instrument* instrument) { |
void MainWindow::add_instrument(gig::Instrument* instrument) { |
1416 |
const char* name = instrument->pInfo->Name.c_str(); |
const Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
1417 |
|
|
1418 |
// update instrument tree view |
// update instrument tree view |
1419 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
1435 |
if (!file) return; |
if (!file) return; |
1436 |
gig::Instrument* instrument = file->AddInstrument(); |
gig::Instrument* instrument = file->AddInstrument(); |
1437 |
__instrument_indexer++; |
__instrument_indexer++; |
1438 |
instrument->pInfo->Name = |
instrument->pInfo->Name = gig_from_utf8(_("Unnamed Instrument ") + |
1439 |
_("Unnamed Instrument ") + ToString(__instrument_indexer); |
ToString(__instrument_indexer)); |
1440 |
|
|
1441 |
add_instrument(instrument); |
add_instrument(instrument); |
1442 |
} |
} |
1456 |
// duplicate the orginal instrument |
// duplicate the orginal instrument |
1457 |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
1458 |
instrNew->pInfo->Name = |
instrNew->pInfo->Name = |
1459 |
instrOrig->pInfo->Name + " (" + _("Copy") + ")"; |
instrOrig->pInfo->Name + |
1460 |
|
gig_from_utf8(Glib::ustring(" (") + _("Copy") + ")"); |
1461 |
|
|
1462 |
add_instrument(instrNew); |
add_instrument(instrNew); |
1463 |
} |
} |
1504 |
Gtk::TreePath(ToString(index))); |
Gtk::TreePath(ToString(index))); |
1505 |
} |
} |
1506 |
#endif |
#endif |
1507 |
|
instr_props_set_instrument(); |
1508 |
instr = get_instrument(); |
instr = get_instrument(); |
1509 |
if (instr) { |
if (instr) { |
1510 |
instrumentProps.set_instrument(instr); |
midiRules.set_instrument(instr); |
1511 |
} else { |
} else { |
1512 |
instrumentProps.hide(); |
midiRules.hide(); |
1513 |
} |
} |
1514 |
} catch (RIFF::Exception e) { |
} catch (RIFF::Exception e) { |
1515 |
Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR); |
1530 |
static int __sample_indexer = 0; |
static int __sample_indexer = 0; |
1531 |
if (!file) return; |
if (!file) return; |
1532 |
gig::Group* group = file->AddGroup(); |
gig::Group* group = file->AddGroup(); |
1533 |
group->Name = _("Unnamed Group"); |
group->Name = gig_from_utf8(_("Unnamed Group")); |
1534 |
if (__sample_indexer) group->Name += " " + ToString(__sample_indexer); |
if (__sample_indexer) group->Name += " " + ToString(__sample_indexer); |
1535 |
__sample_indexer++; |
__sample_indexer++; |
1536 |
// update sample tree view |
// update sample tree view |
1537 |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
1538 |
Gtk::TreeModel::Row rowGroup = *iterGroup; |
Gtk::TreeModel::Row rowGroup = *iterGroup; |
1539 |
rowGroup[m_SamplesModel.m_col_name] = group->Name.c_str(); |
rowGroup[m_SamplesModel.m_col_name] = gig_to_utf8(group->Name); |
1540 |
rowGroup[m_SamplesModel.m_col_sample] = NULL; |
rowGroup[m_SamplesModel.m_col_sample] = NULL; |
1541 |
rowGroup[m_SamplesModel.m_col_group] = group; |
rowGroup[m_SamplesModel.m_col_group] = group; |
1542 |
file_changed(); |
file_changed(); |
1645 |
break; |
break; |
1646 |
} |
} |
1647 |
} |
} |
1648 |
sample->pInfo->Name = filename; |
sample->pInfo->Name = gig_from_utf8(filename); |
1649 |
sample->Channels = info.channels; |
sample->Channels = info.channels; |
1650 |
sample->BitDepth = bitdepth; |
sample->BitDepth = bitdepth; |
1651 |
sample->FrameSize = bitdepth / 8/*1 byte are 8 bits*/ * info.channels; |
sample->FrameSize = bitdepth / 8/*1 byte are 8 bits*/ * info.channels; |
1659 |
&instrument, sizeof(instrument)) != SF_FALSE) |
&instrument, sizeof(instrument)) != SF_FALSE) |
1660 |
{ |
{ |
1661 |
sample->MIDIUnityNote = instrument.basenote; |
sample->MIDIUnityNote = instrument.basenote; |
1662 |
|
sample->FineTune = instrument.detune; |
1663 |
|
|
1664 |
if (instrument.loop_count && instrument.loops[0].mode != SF_LOOP_NONE) { |
if (instrument.loop_count && instrument.loops[0].mode != SF_LOOP_NONE) { |
1665 |
sample->Loops = 1; |
sample->Loops = 1; |
1697 |
Gtk::TreeModel::iterator iterSample = |
Gtk::TreeModel::iterator iterSample = |
1698 |
m_refSamplesTreeModel->append(row.children()); |
m_refSamplesTreeModel->append(row.children()); |
1699 |
Gtk::TreeModel::Row rowSample = *iterSample; |
Gtk::TreeModel::Row rowSample = *iterSample; |
1700 |
rowSample[m_SamplesModel.m_col_name] = filename; |
rowSample[m_SamplesModel.m_col_name] = |
1701 |
|
gig_to_utf8(sample->pInfo->Name); |
1702 |
rowSample[m_SamplesModel.m_col_sample] = sample; |
rowSample[m_SamplesModel.m_col_sample] = sample; |
1703 |
rowSample[m_SamplesModel.m_col_group] = NULL; |
rowSample[m_SamplesModel.m_col_group] = NULL; |
1704 |
// close sound file |
// close sound file |
1769 |
sample; sample = file->GetNextSample()) |
sample; sample = file->GetNextSample()) |
1770 |
{ |
{ |
1771 |
std::string filename = |
std::string filename = |
1772 |
folder + G_DIR_SEPARATOR_S + sample->pInfo->Name + |
folder + G_DIR_SEPARATOR_S + |
1773 |
postfixEntryBox.get_text().raw(); |
Glib::filename_from_utf8(gig_to_utf8(sample->pInfo->Name) + |
1774 |
|
postfixEntryBox.get_text()); |
1775 |
SF_INFO info; |
SF_INFO info; |
1776 |
info.format = 0; |
info.format = 0; |
1777 |
SNDFILE* hFile = sf_open(filename.c_str(), SFM_READ, &info); |
SNDFILE* hFile = sf_open(filename.c_str(), SFM_READ, &info); |
1805 |
catch (std::string what) |
catch (std::string what) |
1806 |
{ |
{ |
1807 |
if (!error_files.empty()) error_files += "\n"; |
if (!error_files.empty()) error_files += "\n"; |
1808 |
error_files += filename += " (" + what + ")"; |
error_files += Glib::filename_to_utf8(filename) + |
1809 |
|
" (" + what + ")"; |
1810 |
} |
} |
1811 |
} |
} |
1812 |
// 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 |
1831 |
try { |
try { |
1832 |
// remove group or sample from the gig file |
// remove group or sample from the gig file |
1833 |
if (group) { |
if (group) { |
1834 |
// temporarily remember the samples that bolong to |
// temporarily remember the samples that belong to |
1835 |
// that group (we need that to clean the queue) |
// that group (we need that to clean the queue) |
1836 |
std::list<gig::Sample*> members; |
std::list<gig::Sample*> members; |
1837 |
for (gig::Sample* pSample = group->GetFirstSample(); |
for (gig::Sample* pSample = group->GetFirstSample(); |
1957 |
channels_changed = true; |
channels_changed = true; |
1958 |
region_changed(); |
region_changed(); |
1959 |
} |
} |
1960 |
dimreg_edit.set_sample(sample); |
dimreg_edit.set_sample( |
1961 |
|
sample, |
1962 |
|
is_copy_samples_unity_note_enabled(), |
1963 |
|
is_copy_samples_fine_tune_enabled(), |
1964 |
|
is_copy_samples_loop_enabled() |
1965 |
|
); |
1966 |
|
|
1967 |
if (sample->Channels == 2 && !stereo_dimension) { |
if (sample->Channels == 2 && !stereo_dimension) { |
1968 |
// add samplechannel dimension |
// add samplechannel dimension |
2005 |
Glib::ustring name = row[m_SamplesModel.m_col_name]; |
Glib::ustring name = row[m_SamplesModel.m_col_name]; |
2006 |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
2007 |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
2008 |
|
gig::String gigname(gig_from_utf8(name)); |
2009 |
if (group) { |
if (group) { |
2010 |
if (group->Name != name) { |
if (group->Name != gigname) { |
2011 |
group->Name = name; |
group->Name = gigname; |
2012 |
printf("group name changed\n"); |
printf("group name changed\n"); |
2013 |
file_changed(); |
file_changed(); |
2014 |
} |
} |
2015 |
} else if (sample) { |
} else if (sample) { |
2016 |
if (sample->pInfo->Name != name.raw()) { |
if (sample->pInfo->Name != gigname) { |
2017 |
sample->pInfo->Name = name.raw(); |
sample->pInfo->Name = gigname; |
2018 |
printf("sample name changed\n"); |
printf("sample name changed\n"); |
2019 |
file_changed(); |
file_changed(); |
2020 |
} |
} |
2042 |
|
|
2043 |
// change name in gig |
// change name in gig |
2044 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
2045 |
if (instrument && instrument->pInfo->Name != name.raw()) { |
gig::String gigname(gig_from_utf8(name)); |
2046 |
instrument->pInfo->Name = name.raw(); |
if (instrument && instrument->pInfo->Name != gigname) { |
2047 |
|
instrument->pInfo->Name = gigname; |
2048 |
|
|
2049 |
|
// change name in the instrument properties window |
2050 |
|
if (instrumentProps.get_instrument() == instrument) { |
2051 |
|
instrumentProps.update_name(); |
2052 |
|
} |
2053 |
|
|
2054 |
file_changed(); |
file_changed(); |
2055 |
} |
} |
2056 |
} |
} |