--- gigedit/trunk/src/gigedit/mainwindow.cpp 2012/04/29 16:15:45 2344
+++ gigedit/trunk/src/gigedit/mainwindow.cpp 2013/02/24 15:19:39 2423
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2012 Andreas Persson
+ * Copyright (C) 2006-2013 Andreas Persson
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -53,30 +53,6 @@
return ss.str();
}
-Table::Table(int x, int y) : Gtk::Table(x, y), rowno(0) { }
-
-void Table::add(BoolEntry& boolentry)
-{
- attach(boolentry.widget, 0, 2, rowno, rowno + 1,
- Gtk::FILL, Gtk::SHRINK);
- rowno++;
-}
-
-void Table::add(BoolEntryPlus6& boolentry)
-{
- attach(boolentry.widget, 0, 2, rowno, rowno + 1,
- Gtk::FILL, Gtk::SHRINK);
- rowno++;
-}
-
-void Table::add(LabelWidget& prop)
-{
- attach(prop.label, 1, 2, rowno, rowno + 1,
- Gtk::FILL, Gtk::SHRINK);
- attach(prop.widget, 2, 3, rowno, rowno + 1,
- Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
- rowno++;
-}
MainWindow::MainWindow() :
dimreg_label(_("Changes apply to:")),
@@ -179,6 +155,10 @@
sigc::mem_fun(*this, &MainWindow::on_action_add_instrument)
);
actionGroup->add(
+ Gtk::Action::create("DupInstrument", _("_Duplicate Instrument")),
+ sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument)
+ );
+ actionGroup->add(
Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE),
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument)
);
@@ -236,6 +216,7 @@
" "
" "
" "
+ " "
" "
" "
" "
@@ -317,9 +298,9 @@
sigc::mem_fun(*this, &MainWindow::file_changed));
m_DimRegionChooser.signal_region_changed().connect(
sigc::mem_fun(*this, &MainWindow::file_changed));
- instrumentProps.signal_instrument_changed().connect(
+ instrumentProps.signal_changed().connect(
sigc::mem_fun(*this, &MainWindow::file_changed));
- propDialog.signal_info_changed().connect(
+ propDialog.signal_changed().connect(
sigc::mem_fun(*this, &MainWindow::file_changed));
dimreg_edit.signal_dimreg_to_be_changed().connect(
@@ -829,6 +810,7 @@
SF_INFO info;
info.format = 0;
SNDFILE* hFile = sf_open((*iter).sample_path.c_str(), SFM_READ, &info);
+ sf_command(hFile, SFC_SET_SCALE_FLOAT_INT_READ, 0, SF_TRUE);
try {
if (!hFile) throw std::string(_("could not open file"));
// determine sample's bit depth
@@ -926,7 +908,7 @@
dialog.set_name("Gigedit");
#endif
dialog.set_version(VERSION);
- dialog.set_copyright("Copyright (C) 2006-2012 Andreas Persson");
+ dialog.set_copyright("Copyright (C) 2006-2013 Andreas Persson");
dialog.set_comments(_(
"Released under the GNU General Public License.\n"
"\n"
@@ -959,8 +941,7 @@
eCommissioned(_("Commissioned")),
eSubject(_("Subject")),
quitButton(Gtk::Stock::CLOSE),
- table(2, 1),
- update_model(0)
+ table(2, 1)
{
set_title(_("File Properties"));
eName.set_width_chars(50);
@@ -1020,79 +1001,40 @@
void PropDialog::set_info(DLS::Info* info)
{
- this->info = info;
- update_model++;
- eName.set_value(info->Name);
- eCreationDate.set_value(info->CreationDate);
- eComments.set_value(info->Comments);
- eProduct.set_value(info->Product);
- eCopyright.set_value(info->Copyright);
- eArtists.set_value(info->Artists);
- eGenre.set_value(info->Genre);
- eKeywords.set_value(info->Keywords);
- eEngineer.set_value(info->Engineer);
- eTechnician.set_value(info->Technician);
- eSoftware.set_value(info->Software);
- eMedium.set_value(info->Medium);
- eSource.set_value(info->Source);
- eSourceForm.set_value(info->SourceForm);
- eCommissioned.set_value(info->Commissioned);
- eSubject.set_value(info->Subject);
- update_model--;
+ update(info);
}
-sigc::signal& PropDialog::signal_info_changed()
-{
- return info_changed;
-}
void InstrumentProps::set_IsDrum(bool value)
{
- instrument->IsDrum = value;
+ m->IsDrum = value;
}
void InstrumentProps::set_MIDIBank(uint16_t value)
{
- instrument->MIDIBank = value;
+ m->MIDIBank = value;
}
void InstrumentProps::set_MIDIProgram(uint32_t value)
{
- instrument->MIDIProgram = value;
-}
-
-void InstrumentProps::set_DimensionKeyRange_low(uint8_t value)
-{
- instrument->DimensionKeyRange.low = value;
- if (value > instrument->DimensionKeyRange.high) {
- eDimensionKeyRangeHigh.set_value(value);
- }
+ m->MIDIProgram = value;
}
-void InstrumentProps::set_DimensionKeyRange_high(uint8_t value)
-{
- instrument->DimensionKeyRange.high = value;
- if (value < instrument->DimensionKeyRange.low) {
- eDimensionKeyRangeLow.set_value(value);
- }
-}
-
-InstrumentProps::InstrumentProps()
- : update_model(0),
- quitButton(Gtk::Stock::CLOSE),
- table(2,1),
- eName(_("Name")),
- eIsDrum(_("Is drum")),
- eMIDIBank(_("MIDI bank"), 0, 16383),
- eMIDIProgram(_("MIDI program")),
- eAttenuation(_("Attenuation"), 0, 96, 0, 1),
- eGainPlus6(_("Gain +6dB"), eAttenuation, -6),
- eEffectSend(_("Effect send"), 0, 65535),
- eFineTune(_("Fine tune"), -8400, 8400),
- ePitchbendRange(_("Pitchbend range"), 0, 12),
- ePianoReleaseMode(_("Piano release mode")),
- eDimensionKeyRangeLow(_("Keyswitching range low")),
- eDimensionKeyRangeHigh(_("Keyswitching range high"))
+InstrumentProps::InstrumentProps() :
+ quitButton(Gtk::Stock::CLOSE),
+ table(2,1),
+ eName(_("Name")),
+ eIsDrum(_("Is drum")),
+ eMIDIBank(_("MIDI bank"), 0, 16383),
+ eMIDIProgram(_("MIDI program")),
+ eAttenuation(_("Attenuation"), 0, 96, 0, 1),
+ eGainPlus6(_("Gain +6dB"), eAttenuation, -6),
+ eEffectSend(_("Effect send"), 0, 65535),
+ eFineTune(_("Fine tune"), -8400, 8400),
+ ePitchbendRange(_("Pitchbend range"), 0, 12),
+ ePianoReleaseMode(_("Piano release mode")),
+ eDimensionKeyRangeLow(_("Keyswitching range low")),
+ eDimensionKeyRangeHigh(_("Keyswitching range high"))
{
set_title(_("Instrument Properties"));
@@ -1114,10 +1056,8 @@
connect(eFineTune, &gig::Instrument::FineTune);
connect(ePitchbendRange, &gig::Instrument::PitchbendRange);
connect(ePianoReleaseMode, &gig::Instrument::PianoReleaseMode);
- connect(eDimensionKeyRangeLow,
- &InstrumentProps::set_DimensionKeyRange_low);
- connect(eDimensionKeyRangeHigh,
- &InstrumentProps::set_DimensionKeyRange_high);
+ connect(eDimensionKeyRangeLow, eDimensionKeyRangeHigh,
+ &gig::Instrument::DimensionKeyRange);
table.set_col_spacings(5);
@@ -1156,28 +1096,15 @@
void InstrumentProps::set_instrument(gig::Instrument* instrument)
{
- this->instrument = instrument;
+ update(instrument);
update_model++;
- eName.set_value(instrument->pInfo->Name);
eIsDrum.set_value(instrument->IsDrum);
eMIDIBank.set_value(instrument->MIDIBank);
eMIDIProgram.set_value(instrument->MIDIProgram);
- eAttenuation.set_value(instrument->Attenuation);
- eGainPlus6.set_value(instrument->Attenuation);
- eEffectSend.set_value(instrument->EffectSend);
- eFineTune.set_value(instrument->FineTune);
- ePitchbendRange.set_value(instrument->PitchbendRange);
- ePianoReleaseMode.set_value(instrument->PianoReleaseMode);
- eDimensionKeyRangeLow.set_value(instrument->DimensionKeyRange.low);
- eDimensionKeyRangeHigh.set_value(instrument->DimensionKeyRange.high);
update_model--;
}
-sigc::signal& InstrumentProps::signal_instrument_changed()
-{
- return instrument_changed;
-}
void MainWindow::file_changed()
{
@@ -1249,6 +1176,11 @@
// select the first instrument
Glib::RefPtr tree_sel_ref = m_TreeView.get_selection();
tree_sel_ref->select(Gtk::TreePath("0"));
+
+ gig::Instrument* instrument = get_instrument();
+ if (instrument) {
+ instrumentProps.set_instrument(instrument);
+ }
}
void MainWindow::show_instr_props()
@@ -1328,6 +1260,31 @@
file_changed();
}
+void MainWindow::on_action_duplicate_instrument() {
+ if (!file) return;
+
+ // retrieve the currently selected instrument
+ // (being the original instrument to be duplicated)
+ Glib::RefPtr sel = m_TreeView.get_selection();
+ Gtk::TreeModel::iterator itSelection = sel->get_selected();
+ if (!itSelection) return;
+ Gtk::TreeModel::Row row = *itSelection;
+ gig::Instrument* instrOrig = row[m_Columns.m_col_instr];
+ if (!instrOrig) return;
+
+ // duplicate the orginal instrument
+ gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig);
+ instrNew->pInfo->Name =
+ instrOrig->pInfo->Name + " (" + _("Copy") + ")";
+
+ // update instrument tree view
+ Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append();
+ Gtk::TreeModel::Row rowInstr = *iterInstr;
+ rowInstr[m_Columns.m_col_name] = instrNew->pInfo->Name.c_str();
+ rowInstr[m_Columns.m_col_instr] = instrNew;
+ file_changed();
+}
+
void MainWindow::on_action_remove_instrument() {
if (!file) return;
if (file_is_shared) {
@@ -1352,6 +1309,13 @@
// remove respective row from instruments tree view
m_refTreeModel->erase(it);
file_changed();
+
+ instr = get_instrument();
+ if (instr) {
+ instrumentProps.set_instrument(instr);
+ } else {
+ instrumentProps.hide();
+ }
} catch (RIFF::Exception e) {
Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR);
msg.run();
@@ -1501,7 +1465,6 @@
{
sample->MIDIUnityNote = instrument.basenote;
-#if HAVE_SF_INSTRUMENT_LOOPS
if (instrument.loop_count && instrument.loops[0].mode != SF_LOOP_NONE) {
sample->Loops = 1;
@@ -1521,7 +1484,6 @@
sample->LoopPlayCount = instrument.loops[0].count;
sample->LoopSize = sample->LoopEnd - sample->LoopStart + 1;
}
-#endif
}
// schedule resizing the sample (which will be done