545 |
gig::File* pFile = new gig::File; |
gig::File* pFile = new gig::File; |
546 |
// already add one new instrument by default |
// already add one new instrument by default |
547 |
gig::Instrument* pInstrument = pFile->AddInstrument(); |
gig::Instrument* pInstrument = pFile->AddInstrument(); |
548 |
pInstrument->pInfo->Name = _("Unnamed Instrument"); |
pInstrument->pInfo->Name = gig_from_utf8(_("Unnamed Instrument")); |
549 |
// update GUI with that new gig::File |
// update GUI with that new gig::File |
550 |
load_gig(pFile, 0 /*no file name yet*/); |
load_gig(pFile, 0 /*no file name yet*/); |
551 |
} |
} |
1003 |
} |
} |
1004 |
|
|
1005 |
|
|
1006 |
|
void InstrumentProps::set_Name(const gig::String& name) |
1007 |
|
{ |
1008 |
|
m->pInfo->Name = name; |
1009 |
|
} |
1010 |
|
|
1011 |
|
void InstrumentProps::update_name() |
1012 |
|
{ |
1013 |
|
update_model++; |
1014 |
|
eName.set_value(m->pInfo->Name); |
1015 |
|
update_model--; |
1016 |
|
} |
1017 |
|
|
1018 |
void InstrumentProps::set_IsDrum(bool value) |
void InstrumentProps::set_IsDrum(bool value) |
1019 |
{ |
{ |
1020 |
m->IsDrum = value; |
m->IsDrum = value; |
1057 |
"\"keyswitching\" dimension") |
"\"keyswitching\" dimension") |
1058 |
); |
); |
1059 |
|
|
1060 |
|
connect(eName, &InstrumentProps::set_Name); |
1061 |
connect(eIsDrum, &InstrumentProps::set_IsDrum); |
connect(eIsDrum, &InstrumentProps::set_IsDrum); |
1062 |
connect(eMIDIBank, &InstrumentProps::set_MIDIBank); |
connect(eMIDIBank, &InstrumentProps::set_MIDIBank); |
1063 |
connect(eMIDIProgram, &InstrumentProps::set_MIDIProgram); |
connect(eMIDIProgram, &InstrumentProps::set_MIDIProgram); |
1070 |
connect(eDimensionKeyRangeLow, eDimensionKeyRangeHigh, |
connect(eDimensionKeyRangeLow, eDimensionKeyRangeHigh, |
1071 |
&gig::Instrument::DimensionKeyRange); |
&gig::Instrument::DimensionKeyRange); |
1072 |
|
|
1073 |
|
eName.signal_value_changed().connect(sig_name_changed.make_slot()); |
1074 |
|
|
1075 |
table.set_col_spacings(5); |
table.set_col_spacings(5); |
1076 |
|
|
1077 |
table.add(eName); |
table.add(eName); |
1112 |
update(instrument); |
update(instrument); |
1113 |
|
|
1114 |
update_model++; |
update_model++; |
1115 |
|
eName.set_value(instrument->pInfo->Name); |
1116 |
eIsDrum.set_value(instrument->IsDrum); |
eIsDrum.set_value(instrument->IsDrum); |
1117 |
eMIDIBank.set_value(instrument->MIDIBank); |
eMIDIBank.set_value(instrument->MIDIBank); |
1118 |
eMIDIProgram.set_value(instrument->MIDIProgram); |
eMIDIProgram.set_value(instrument->MIDIProgram); |
1143 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
1144 |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
1145 |
instrument = gig->GetNextInstrument()) { |
instrument = gig->GetNextInstrument()) { |
1146 |
Glib::ustring name(instrument->pInfo->Name); |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
1147 |
|
|
1148 |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
1149 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
1159 |
if (group->Name != "") { |
if (group->Name != "") { |
1160 |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
1161 |
Gtk::TreeModel::Row rowGroup = *iterGroup; |
Gtk::TreeModel::Row rowGroup = *iterGroup; |
1162 |
rowGroup[m_SamplesModel.m_col_name] = group->Name.c_str(); |
rowGroup[m_SamplesModel.m_col_name] = gig_to_utf8(group->Name); |
1163 |
rowGroup[m_SamplesModel.m_col_group] = group; |
rowGroup[m_SamplesModel.m_col_group] = group; |
1164 |
rowGroup[m_SamplesModel.m_col_sample] = NULL; |
rowGroup[m_SamplesModel.m_col_sample] = NULL; |
1165 |
for (gig::Sample* sample = group->GetFirstSample(); |
for (gig::Sample* sample = group->GetFirstSample(); |
1167 |
Gtk::TreeModel::iterator iterSample = |
Gtk::TreeModel::iterator iterSample = |
1168 |
m_refSamplesTreeModel->append(rowGroup.children()); |
m_refSamplesTreeModel->append(rowGroup.children()); |
1169 |
Gtk::TreeModel::Row rowSample = *iterSample; |
Gtk::TreeModel::Row rowSample = *iterSample; |
1170 |
rowSample[m_SamplesModel.m_col_name] = sample->pInfo->Name.c_str(); |
rowSample[m_SamplesModel.m_col_name] = |
1171 |
|
gig_to_utf8(sample->pInfo->Name); |
1172 |
rowSample[m_SamplesModel.m_col_sample] = sample; |
rowSample[m_SamplesModel.m_col_sample] = sample; |
1173 |
rowSample[m_SamplesModel.m_col_group] = NULL; |
rowSample[m_SamplesModel.m_col_group] = NULL; |
1174 |
} |
} |
1180 |
// select the first instrument |
// select the first instrument |
1181 |
m_TreeView.get_selection()->select(Gtk::TreePath("0")); |
m_TreeView.get_selection()->select(Gtk::TreePath("0")); |
1182 |
|
|
1183 |
gig::Instrument* instrument = get_instrument(); |
instr_props_set_instrument(); |
1184 |
if (instrument) { |
} |
1185 |
|
|
1186 |
|
bool MainWindow::instr_props_set_instrument() |
1187 |
|
{ |
1188 |
|
instrumentProps.signal_name_changed().clear(); |
1189 |
|
|
1190 |
|
Gtk::TreeModel::const_iterator it = |
1191 |
|
m_TreeView.get_selection()->get_selected(); |
1192 |
|
if (it) { |
1193 |
|
Gtk::TreeModel::Row row = *it; |
1194 |
|
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
1195 |
|
|
1196 |
instrumentProps.set_instrument(instrument); |
instrumentProps.set_instrument(instrument); |
1197 |
|
|
1198 |
|
// make sure instrument tree is updated when user changes the |
1199 |
|
// instrument name in instrument properties window |
1200 |
|
instrumentProps.signal_name_changed().connect( |
1201 |
|
sigc::bind( |
1202 |
|
sigc::mem_fun(*this, |
1203 |
|
&MainWindow::instr_name_changed_by_instr_props), |
1204 |
|
it)); |
1205 |
|
} else { |
1206 |
|
instrumentProps.hide(); |
1207 |
} |
} |
1208 |
|
return it; |
1209 |
} |
} |
1210 |
|
|
1211 |
void MainWindow::show_instr_props() |
void MainWindow::show_instr_props() |
1212 |
{ |
{ |
1213 |
gig::Instrument* instrument = get_instrument(); |
if (instr_props_set_instrument()) { |
|
if (instrument) |
|
|
{ |
|
|
instrumentProps.set_instrument(instrument); |
|
1214 |
instrumentProps.show(); |
instrumentProps.show(); |
1215 |
instrumentProps.deiconify(); |
instrumentProps.deiconify(); |
1216 |
} |
} |
1217 |
} |
} |
1218 |
|
|
1219 |
|
void MainWindow::instr_name_changed_by_instr_props(Gtk::TreeModel::iterator& it) |
1220 |
|
{ |
1221 |
|
Gtk::TreeModel::Row row = *it; |
1222 |
|
Glib::ustring name = row[m_Columns.m_col_name]; |
1223 |
|
|
1224 |
|
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
1225 |
|
Glib::ustring gigname(gig_to_utf8(instrument->pInfo->Name)); |
1226 |
|
if (gigname != name) { |
1227 |
|
row[m_Columns.m_col_name] = gigname; |
1228 |
|
} |
1229 |
|
} |
1230 |
|
|
1231 |
void MainWindow::on_action_view_status_bar() { |
void MainWindow::on_action_view_status_bar() { |
1232 |
Gtk::CheckMenuItem* item = |
Gtk::CheckMenuItem* item = |
1233 |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar")); |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar")); |
1324 |
} |
} |
1325 |
|
|
1326 |
void MainWindow::add_instrument(gig::Instrument* instrument) { |
void MainWindow::add_instrument(gig::Instrument* instrument) { |
1327 |
const char* name = instrument->pInfo->Name.c_str(); |
const Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
1328 |
|
|
1329 |
// update instrument tree view |
// update instrument tree view |
1330 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
1346 |
if (!file) return; |
if (!file) return; |
1347 |
gig::Instrument* instrument = file->AddInstrument(); |
gig::Instrument* instrument = file->AddInstrument(); |
1348 |
__instrument_indexer++; |
__instrument_indexer++; |
1349 |
instrument->pInfo->Name = |
instrument->pInfo->Name = gig_from_utf8(_("Unnamed Instrument ") + |
1350 |
_("Unnamed Instrument ") + ToString(__instrument_indexer); |
ToString(__instrument_indexer)); |
1351 |
|
|
1352 |
add_instrument(instrument); |
add_instrument(instrument); |
1353 |
} |
} |
1367 |
// duplicate the orginal instrument |
// duplicate the orginal instrument |
1368 |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
1369 |
instrNew->pInfo->Name = |
instrNew->pInfo->Name = |
1370 |
instrOrig->pInfo->Name + " (" + _("Copy") + ")"; |
instrOrig->pInfo->Name + |
1371 |
|
gig_from_utf8(Glib::ustring(" (") + _("Copy") + ")"); |
1372 |
|
|
1373 |
add_instrument(instrNew); |
add_instrument(instrNew); |
1374 |
} |
} |
1415 |
Gtk::TreePath(ToString(index))); |
Gtk::TreePath(ToString(index))); |
1416 |
} |
} |
1417 |
#endif |
#endif |
1418 |
instr = get_instrument(); |
instr_props_set_instrument(); |
|
if (instr) { |
|
|
instrumentProps.set_instrument(instr); |
|
|
} else { |
|
|
instrumentProps.hide(); |
|
|
} |
|
1419 |
} catch (RIFF::Exception e) { |
} catch (RIFF::Exception e) { |
1420 |
Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR); |
1421 |
msg.run(); |
msg.run(); |
1435 |
static int __sample_indexer = 0; |
static int __sample_indexer = 0; |
1436 |
if (!file) return; |
if (!file) return; |
1437 |
gig::Group* group = file->AddGroup(); |
gig::Group* group = file->AddGroup(); |
1438 |
group->Name = _("Unnamed Group"); |
group->Name = gig_from_utf8(_("Unnamed Group")); |
1439 |
if (__sample_indexer) group->Name += " " + ToString(__sample_indexer); |
if (__sample_indexer) group->Name += " " + ToString(__sample_indexer); |
1440 |
__sample_indexer++; |
__sample_indexer++; |
1441 |
// update sample tree view |
// update sample tree view |
1442 |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
1443 |
Gtk::TreeModel::Row rowGroup = *iterGroup; |
Gtk::TreeModel::Row rowGroup = *iterGroup; |
1444 |
rowGroup[m_SamplesModel.m_col_name] = group->Name.c_str(); |
rowGroup[m_SamplesModel.m_col_name] = gig_to_utf8(group->Name); |
1445 |
rowGroup[m_SamplesModel.m_col_sample] = NULL; |
rowGroup[m_SamplesModel.m_col_sample] = NULL; |
1446 |
rowGroup[m_SamplesModel.m_col_group] = group; |
rowGroup[m_SamplesModel.m_col_group] = group; |
1447 |
file_changed(); |
file_changed(); |
1550 |
break; |
break; |
1551 |
} |
} |
1552 |
} |
} |
1553 |
sample->pInfo->Name = filename; |
sample->pInfo->Name = gig_from_utf8(filename); |
1554 |
sample->Channels = info.channels; |
sample->Channels = info.channels; |
1555 |
sample->BitDepth = bitdepth; |
sample->BitDepth = bitdepth; |
1556 |
sample->FrameSize = bitdepth / 8/*1 byte are 8 bits*/ * info.channels; |
sample->FrameSize = bitdepth / 8/*1 byte are 8 bits*/ * info.channels; |
1601 |
Gtk::TreeModel::iterator iterSample = |
Gtk::TreeModel::iterator iterSample = |
1602 |
m_refSamplesTreeModel->append(row.children()); |
m_refSamplesTreeModel->append(row.children()); |
1603 |
Gtk::TreeModel::Row rowSample = *iterSample; |
Gtk::TreeModel::Row rowSample = *iterSample; |
1604 |
rowSample[m_SamplesModel.m_col_name] = filename; |
rowSample[m_SamplesModel.m_col_name] = |
1605 |
|
gig_to_utf8(sample->pInfo->Name); |
1606 |
rowSample[m_SamplesModel.m_col_sample] = sample; |
rowSample[m_SamplesModel.m_col_sample] = sample; |
1607 |
rowSample[m_SamplesModel.m_col_group] = NULL; |
rowSample[m_SamplesModel.m_col_group] = NULL; |
1608 |
// close sound file |
// close sound file |
1673 |
sample; sample = file->GetNextSample()) |
sample; sample = file->GetNextSample()) |
1674 |
{ |
{ |
1675 |
std::string filename = |
std::string filename = |
1676 |
folder + G_DIR_SEPARATOR_S + sample->pInfo->Name + |
folder + G_DIR_SEPARATOR_S + |
1677 |
postfixEntryBox.get_text().raw(); |
Glib::filename_from_utf8(gig_to_utf8(sample->pInfo->Name) + |
1678 |
|
postfixEntryBox.get_text()); |
1679 |
SF_INFO info; |
SF_INFO info; |
1680 |
info.format = 0; |
info.format = 0; |
1681 |
SNDFILE* hFile = sf_open(filename.c_str(), SFM_READ, &info); |
SNDFILE* hFile = sf_open(filename.c_str(), SFM_READ, &info); |
1709 |
catch (std::string what) |
catch (std::string what) |
1710 |
{ |
{ |
1711 |
if (!error_files.empty()) error_files += "\n"; |
if (!error_files.empty()) error_files += "\n"; |
1712 |
error_files += filename += " (" + what + ")"; |
error_files += Glib::filename_to_utf8(filename) + |
1713 |
|
" (" + what + ")"; |
1714 |
} |
} |
1715 |
} |
} |
1716 |
// 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 |
1735 |
try { |
try { |
1736 |
// remove group or sample from the gig file |
// remove group or sample from the gig file |
1737 |
if (group) { |
if (group) { |
1738 |
// temporarily remember the samples that bolong to |
// temporarily remember the samples that belong to |
1739 |
// that group (we need that to clean the queue) |
// that group (we need that to clean the queue) |
1740 |
std::list<gig::Sample*> members; |
std::list<gig::Sample*> members; |
1741 |
for (gig::Sample* pSample = group->GetFirstSample(); |
for (gig::Sample* pSample = group->GetFirstSample(); |
1904 |
Glib::ustring name = row[m_SamplesModel.m_col_name]; |
Glib::ustring name = row[m_SamplesModel.m_col_name]; |
1905 |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
1906 |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
1907 |
|
gig::String gigname(gig_from_utf8(name)); |
1908 |
if (group) { |
if (group) { |
1909 |
if (group->Name != name) { |
if (group->Name != gigname) { |
1910 |
group->Name = name; |
group->Name = gigname; |
1911 |
printf("group name changed\n"); |
printf("group name changed\n"); |
1912 |
file_changed(); |
file_changed(); |
1913 |
} |
} |
1914 |
} else if (sample) { |
} else if (sample) { |
1915 |
if (sample->pInfo->Name != name.raw()) { |
if (sample->pInfo->Name != gigname) { |
1916 |
sample->pInfo->Name = name.raw(); |
sample->pInfo->Name = gigname; |
1917 |
printf("sample name changed\n"); |
printf("sample name changed\n"); |
1918 |
file_changed(); |
file_changed(); |
1919 |
} |
} |
1941 |
|
|
1942 |
// change name in gig |
// change name in gig |
1943 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
1944 |
if (instrument && instrument->pInfo->Name != name.raw()) { |
gig::String gigname(gig_from_utf8(name)); |
1945 |
instrument->pInfo->Name = name.raw(); |
if (instrument && instrument->pInfo->Name != gigname) { |
1946 |
|
instrument->pInfo->Name = gigname; |
1947 |
|
|
1948 |
|
// change name in the instrument properties window |
1949 |
|
if (instrumentProps.get_instrument() == instrument) { |
1950 |
|
instrumentProps.update_name(); |
1951 |
|
} |
1952 |
|
|
1953 |
file_changed(); |
file_changed(); |
1954 |
} |
} |
1955 |
} |
} |