128 |
*this, &MainWindow::on_action_quit)); |
*this, &MainWindow::on_action_quit)); |
129 |
actionGroup->add(Gtk::Action::create("MenuInstrument", _("_Instrument"))); |
actionGroup->add(Gtk::Action::create("MenuInstrument", _("_Instrument"))); |
130 |
|
|
131 |
actionGroup->add(Gtk::Action::create("MenuView", _("_View"))); |
|
132 |
|
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
133 |
|
|
134 |
Glib::RefPtr<Gtk::ToggleAction> toggle_action = |
Glib::RefPtr<Gtk::ToggleAction> toggle_action = |
135 |
|
Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note"), "ffaga"); |
136 |
|
toggle_action->set_active(true); |
137 |
|
//FIXME: doesn't work, why? |
138 |
|
toggle_action->set_tooltip(_("Used when dragging a sample to a region's sample reference field.")); |
139 |
|
actionGroup->add(toggle_action); |
140 |
|
|
141 |
|
toggle_action = |
142 |
|
Gtk::ToggleAction::create("CopySampleTune", _("Copy Sample's _Fine Tune")); |
143 |
|
toggle_action->set_active(true); |
144 |
|
//FIXME: doesn't work, why? |
145 |
|
toggle_action->set_tooltip(_("Used when dragging a sample to a region's sample reference field.")); |
146 |
|
actionGroup->add(toggle_action); |
147 |
|
|
148 |
|
toggle_action = |
149 |
|
Gtk::ToggleAction::create("CopySampleLoop", _("Copy Sample's _Loop Points")); |
150 |
|
toggle_action->set_active(true); |
151 |
|
//FIXME: doesn't work, why? |
152 |
|
toggle_action->set_tooltip(_("Used when dragging a sample to a region's sample reference field.")); |
153 |
|
actionGroup->add(toggle_action); |
154 |
|
|
155 |
|
|
156 |
|
actionGroup->add(Gtk::Action::create("MenuView", _("_View"))); |
157 |
|
toggle_action = |
158 |
Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); |
Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); |
159 |
toggle_action->set_active(true); |
toggle_action->set_active(true); |
160 |
actionGroup->add(toggle_action, |
actionGroup->add(toggle_action, |
221 |
" <separator/>" |
" <separator/>" |
222 |
" <menuitem action='Quit'/>" |
" <menuitem action='Quit'/>" |
223 |
" </menu>" |
" </menu>" |
224 |
|
" <menu action='MenuEdit'>" |
225 |
|
" <menuitem action='CopySampleUnity'/>" |
226 |
|
" <menuitem action='CopySampleTune'/>" |
227 |
|
" <menuitem action='CopySampleLoop'/>" |
228 |
|
" </menu>" |
229 |
" <menu action='MenuInstrument'>" |
" <menu action='MenuInstrument'>" |
230 |
" </menu>" |
" </menu>" |
231 |
" <menu action='MenuView'>" |
" <menu action='MenuView'>" |
575 |
gig::File* pFile = new gig::File; |
gig::File* pFile = new gig::File; |
576 |
// already add one new instrument by default |
// already add one new instrument by default |
577 |
gig::Instrument* pInstrument = pFile->AddInstrument(); |
gig::Instrument* pInstrument = pFile->AddInstrument(); |
578 |
pInstrument->pInfo->Name = _("Unnamed Instrument"); |
pInstrument->pInfo->Name = gig_from_utf8(_("Unnamed Instrument")); |
579 |
// update GUI with that new gig::File |
// update GUI with that new gig::File |
580 |
load_gig(pFile, 0 /*no file name yet*/); |
load_gig(pFile, 0 /*no file name yet*/); |
581 |
} |
} |
937 |
#endif |
#endif |
938 |
dialog.set_version(VERSION); |
dialog.set_version(VERSION); |
939 |
dialog.set_copyright("Copyright (C) 2006-2013 Andreas Persson"); |
dialog.set_copyright("Copyright (C) 2006-2013 Andreas Persson"); |
940 |
dialog.set_comments(_( |
const std::string sComment = |
941 |
"Released under the GNU General Public License.\n" |
_("Built " __DATE__ "\nUsing ") + |
942 |
"\n" |
::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" + |
943 |
"Please notice that this is still a very young instrument editor. " |
_( |
944 |
"So better backup your Gigasampler files before editing them with " |
"Gigedit is released under the GNU General Public License.\n" |
945 |
"this application.\n" |
"\n" |
946 |
"\n" |
"Please notice that this is still a very young instrument editor. " |
947 |
"Please report bugs to: http://bugs.linuxsampler.org") |
"So better backup your Gigasampler files before editing them with " |
948 |
); |
"this application.\n" |
949 |
|
"\n" |
950 |
|
"Please report bugs to: http://bugs.linuxsampler.org" |
951 |
|
); |
952 |
|
dialog.set_comments(sComment.c_str()); |
953 |
dialog.set_website("http://www.linuxsampler.org"); |
dialog.set_website("http://www.linuxsampler.org"); |
954 |
dialog.set_website_label("http://www.linuxsampler.org"); |
dialog.set_website_label("http://www.linuxsampler.org"); |
955 |
dialog.run(); |
dialog.run(); |
1177 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
1178 |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
1179 |
instrument = gig->GetNextInstrument()) { |
instrument = gig->GetNextInstrument()) { |
1180 |
Glib::ustring name(instrument->pInfo->Name); |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
1181 |
|
|
1182 |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
1183 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
1193 |
if (group->Name != "") { |
if (group->Name != "") { |
1194 |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
1195 |
Gtk::TreeModel::Row rowGroup = *iterGroup; |
Gtk::TreeModel::Row rowGroup = *iterGroup; |
1196 |
rowGroup[m_SamplesModel.m_col_name] = group->Name.c_str(); |
rowGroup[m_SamplesModel.m_col_name] = gig_to_utf8(group->Name); |
1197 |
rowGroup[m_SamplesModel.m_col_group] = group; |
rowGroup[m_SamplesModel.m_col_group] = group; |
1198 |
rowGroup[m_SamplesModel.m_col_sample] = NULL; |
rowGroup[m_SamplesModel.m_col_sample] = NULL; |
1199 |
for (gig::Sample* sample = group->GetFirstSample(); |
for (gig::Sample* sample = group->GetFirstSample(); |
1201 |
Gtk::TreeModel::iterator iterSample = |
Gtk::TreeModel::iterator iterSample = |
1202 |
m_refSamplesTreeModel->append(rowGroup.children()); |
m_refSamplesTreeModel->append(rowGroup.children()); |
1203 |
Gtk::TreeModel::Row rowSample = *iterSample; |
Gtk::TreeModel::Row rowSample = *iterSample; |
1204 |
rowSample[m_SamplesModel.m_col_name] = sample->pInfo->Name.c_str(); |
rowSample[m_SamplesModel.m_col_name] = |
1205 |
|
gig_to_utf8(sample->pInfo->Name); |
1206 |
rowSample[m_SamplesModel.m_col_sample] = sample; |
rowSample[m_SamplesModel.m_col_sample] = sample; |
1207 |
rowSample[m_SamplesModel.m_col_group] = NULL; |
rowSample[m_SamplesModel.m_col_group] = NULL; |
1208 |
} |
} |
1256 |
Glib::ustring name = row[m_Columns.m_col_name]; |
Glib::ustring name = row[m_Columns.m_col_name]; |
1257 |
|
|
1258 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
1259 |
if (instrument->pInfo->Name != name) { |
Glib::ustring gigname(gig_to_utf8(instrument->pInfo->Name)); |
1260 |
row[m_Columns.m_col_name] = instrument->pInfo->Name; |
if (gigname != name) { |
1261 |
|
row[m_Columns.m_col_name] = gigname; |
1262 |
} |
} |
1263 |
} |
} |
1264 |
|
|
1273 |
else m_StatusBar.hide(); |
else m_StatusBar.hide(); |
1274 |
} |
} |
1275 |
|
|
1276 |
|
bool MainWindow::is_copy_samples_unity_note_enabled() const { |
1277 |
|
Gtk::CheckMenuItem* item = |
1278 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity")); |
1279 |
|
if (!item) { |
1280 |
|
std::cerr << "/MenuBar/MenuEdit/CopySampleUnity == NULL\n"; |
1281 |
|
return true; |
1282 |
|
} |
1283 |
|
return item->get_active(); |
1284 |
|
} |
1285 |
|
|
1286 |
|
bool MainWindow::is_copy_samples_fine_tune_enabled() const { |
1287 |
|
Gtk::CheckMenuItem* item = |
1288 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleTune")); |
1289 |
|
if (!item) { |
1290 |
|
std::cerr << "/MenuBar/MenuEdit/CopySampleTune == NULL\n"; |
1291 |
|
return true; |
1292 |
|
} |
1293 |
|
return item->get_active(); |
1294 |
|
} |
1295 |
|
|
1296 |
|
bool MainWindow::is_copy_samples_loop_enabled() const { |
1297 |
|
Gtk::CheckMenuItem* item = |
1298 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleLoop")); |
1299 |
|
if (!item) { |
1300 |
|
std::cerr << "/MenuBar/MenuEdit/CopySampleLoop == NULL\n"; |
1301 |
|
return true; |
1302 |
|
} |
1303 |
|
return item->get_active(); |
1304 |
|
} |
1305 |
|
|
1306 |
void MainWindow::on_button_release(GdkEventButton* button) |
void MainWindow::on_button_release(GdkEventButton* button) |
1307 |
{ |
{ |
1308 |
if (button->type == GDK_2BUTTON_PRESS) { |
if (button->type == GDK_2BUTTON_PRESS) { |
1388 |
} |
} |
1389 |
|
|
1390 |
void MainWindow::add_instrument(gig::Instrument* instrument) { |
void MainWindow::add_instrument(gig::Instrument* instrument) { |
1391 |
const char* name = instrument->pInfo->Name.c_str(); |
const Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
1392 |
|
|
1393 |
// update instrument tree view |
// update instrument tree view |
1394 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
1410 |
if (!file) return; |
if (!file) return; |
1411 |
gig::Instrument* instrument = file->AddInstrument(); |
gig::Instrument* instrument = file->AddInstrument(); |
1412 |
__instrument_indexer++; |
__instrument_indexer++; |
1413 |
instrument->pInfo->Name = |
instrument->pInfo->Name = gig_from_utf8(_("Unnamed Instrument ") + |
1414 |
_("Unnamed Instrument ") + ToString(__instrument_indexer); |
ToString(__instrument_indexer)); |
1415 |
|
|
1416 |
add_instrument(instrument); |
add_instrument(instrument); |
1417 |
} |
} |
1431 |
// duplicate the orginal instrument |
// duplicate the orginal instrument |
1432 |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
1433 |
instrNew->pInfo->Name = |
instrNew->pInfo->Name = |
1434 |
instrOrig->pInfo->Name + " (" + _("Copy") + ")"; |
instrOrig->pInfo->Name + |
1435 |
|
gig_from_utf8(Glib::ustring(" (") + _("Copy") + ")"); |
1436 |
|
|
1437 |
add_instrument(instrNew); |
add_instrument(instrNew); |
1438 |
} |
} |
1499 |
static int __sample_indexer = 0; |
static int __sample_indexer = 0; |
1500 |
if (!file) return; |
if (!file) return; |
1501 |
gig::Group* group = file->AddGroup(); |
gig::Group* group = file->AddGroup(); |
1502 |
group->Name = _("Unnamed Group"); |
group->Name = gig_from_utf8(_("Unnamed Group")); |
1503 |
if (__sample_indexer) group->Name += " " + ToString(__sample_indexer); |
if (__sample_indexer) group->Name += " " + ToString(__sample_indexer); |
1504 |
__sample_indexer++; |
__sample_indexer++; |
1505 |
// update sample tree view |
// update sample tree view |
1506 |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
1507 |
Gtk::TreeModel::Row rowGroup = *iterGroup; |
Gtk::TreeModel::Row rowGroup = *iterGroup; |
1508 |
rowGroup[m_SamplesModel.m_col_name] = group->Name.c_str(); |
rowGroup[m_SamplesModel.m_col_name] = gig_to_utf8(group->Name); |
1509 |
rowGroup[m_SamplesModel.m_col_sample] = NULL; |
rowGroup[m_SamplesModel.m_col_sample] = NULL; |
1510 |
rowGroup[m_SamplesModel.m_col_group] = group; |
rowGroup[m_SamplesModel.m_col_group] = group; |
1511 |
file_changed(); |
file_changed(); |
1614 |
break; |
break; |
1615 |
} |
} |
1616 |
} |
} |
1617 |
sample->pInfo->Name = filename; |
sample->pInfo->Name = gig_from_utf8(filename); |
1618 |
sample->Channels = info.channels; |
sample->Channels = info.channels; |
1619 |
sample->BitDepth = bitdepth; |
sample->BitDepth = bitdepth; |
1620 |
sample->FrameSize = bitdepth / 8/*1 byte are 8 bits*/ * info.channels; |
sample->FrameSize = bitdepth / 8/*1 byte are 8 bits*/ * info.channels; |
1628 |
&instrument, sizeof(instrument)) != SF_FALSE) |
&instrument, sizeof(instrument)) != SF_FALSE) |
1629 |
{ |
{ |
1630 |
sample->MIDIUnityNote = instrument.basenote; |
sample->MIDIUnityNote = instrument.basenote; |
1631 |
|
sample->FineTune = instrument.detune; |
1632 |
|
|
1633 |
if (instrument.loop_count && instrument.loops[0].mode != SF_LOOP_NONE) { |
if (instrument.loop_count && instrument.loops[0].mode != SF_LOOP_NONE) { |
1634 |
sample->Loops = 1; |
sample->Loops = 1; |
1666 |
Gtk::TreeModel::iterator iterSample = |
Gtk::TreeModel::iterator iterSample = |
1667 |
m_refSamplesTreeModel->append(row.children()); |
m_refSamplesTreeModel->append(row.children()); |
1668 |
Gtk::TreeModel::Row rowSample = *iterSample; |
Gtk::TreeModel::Row rowSample = *iterSample; |
1669 |
rowSample[m_SamplesModel.m_col_name] = filename; |
rowSample[m_SamplesModel.m_col_name] = |
1670 |
|
gig_to_utf8(sample->pInfo->Name); |
1671 |
rowSample[m_SamplesModel.m_col_sample] = sample; |
rowSample[m_SamplesModel.m_col_sample] = sample; |
1672 |
rowSample[m_SamplesModel.m_col_group] = NULL; |
rowSample[m_SamplesModel.m_col_group] = NULL; |
1673 |
// close sound file |
// close sound file |
1738 |
sample; sample = file->GetNextSample()) |
sample; sample = file->GetNextSample()) |
1739 |
{ |
{ |
1740 |
std::string filename = |
std::string filename = |
1741 |
folder + G_DIR_SEPARATOR_S + sample->pInfo->Name + |
folder + G_DIR_SEPARATOR_S + |
1742 |
postfixEntryBox.get_text().raw(); |
Glib::filename_from_utf8(gig_to_utf8(sample->pInfo->Name) + |
1743 |
|
postfixEntryBox.get_text()); |
1744 |
SF_INFO info; |
SF_INFO info; |
1745 |
info.format = 0; |
info.format = 0; |
1746 |
SNDFILE* hFile = sf_open(filename.c_str(), SFM_READ, &info); |
SNDFILE* hFile = sf_open(filename.c_str(), SFM_READ, &info); |
1774 |
catch (std::string what) |
catch (std::string what) |
1775 |
{ |
{ |
1776 |
if (!error_files.empty()) error_files += "\n"; |
if (!error_files.empty()) error_files += "\n"; |
1777 |
error_files += filename += " (" + what + ")"; |
error_files += Glib::filename_to_utf8(filename) + |
1778 |
|
" (" + what + ")"; |
1779 |
} |
} |
1780 |
} |
} |
1781 |
// 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 |
1800 |
try { |
try { |
1801 |
// remove group or sample from the gig file |
// remove group or sample from the gig file |
1802 |
if (group) { |
if (group) { |
1803 |
// temporarily remember the samples that bolong to |
// temporarily remember the samples that belong to |
1804 |
// that group (we need that to clean the queue) |
// that group (we need that to clean the queue) |
1805 |
std::list<gig::Sample*> members; |
std::list<gig::Sample*> members; |
1806 |
for (gig::Sample* pSample = group->GetFirstSample(); |
for (gig::Sample* pSample = group->GetFirstSample(); |
1926 |
channels_changed = true; |
channels_changed = true; |
1927 |
region_changed(); |
region_changed(); |
1928 |
} |
} |
1929 |
dimreg_edit.set_sample(sample); |
dimreg_edit.set_sample( |
1930 |
|
sample, |
1931 |
|
is_copy_samples_unity_note_enabled(), |
1932 |
|
is_copy_samples_fine_tune_enabled(), |
1933 |
|
is_copy_samples_loop_enabled() |
1934 |
|
); |
1935 |
|
|
1936 |
if (sample->Channels == 2 && !stereo_dimension) { |
if (sample->Channels == 2 && !stereo_dimension) { |
1937 |
// add samplechannel dimension |
// add samplechannel dimension |
1974 |
Glib::ustring name = row[m_SamplesModel.m_col_name]; |
Glib::ustring name = row[m_SamplesModel.m_col_name]; |
1975 |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
1976 |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
1977 |
|
gig::String gigname(gig_from_utf8(name)); |
1978 |
if (group) { |
if (group) { |
1979 |
if (group->Name != name) { |
if (group->Name != gigname) { |
1980 |
group->Name = name; |
group->Name = gigname; |
1981 |
printf("group name changed\n"); |
printf("group name changed\n"); |
1982 |
file_changed(); |
file_changed(); |
1983 |
} |
} |
1984 |
} else if (sample) { |
} else if (sample) { |
1985 |
if (sample->pInfo->Name != name.raw()) { |
if (sample->pInfo->Name != gigname) { |
1986 |
sample->pInfo->Name = name.raw(); |
sample->pInfo->Name = gigname; |
1987 |
printf("sample name changed\n"); |
printf("sample name changed\n"); |
1988 |
file_changed(); |
file_changed(); |
1989 |
} |
} |
2011 |
|
|
2012 |
// change name in gig |
// change name in gig |
2013 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
2014 |
if (instrument && instrument->pInfo->Name != name.raw()) { |
gig::String gigname(gig_from_utf8(name)); |
2015 |
instrument->pInfo->Name = name.raw(); |
if (instrument && instrument->pInfo->Name != gigname) { |
2016 |
|
instrument->pInfo->Name = gigname; |
2017 |
|
|
2018 |
// change name in the instrument properties window |
// change name in the instrument properties window |
2019 |
if (instrumentProps.get_instrument() == instrument) { |
if (instrumentProps.get_instrument() == instrument) { |