1 |
/* |
/* |
2 |
* Copyright (C) 2006-2014 Andreas Persson |
* Copyright (C) 2006-2016 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 |
230 |
eMSDecode(_("Decode Mid/Side Recordings")), |
eMSDecode(_("Decode Mid/Side Recordings")), |
231 |
eSampleStartOffset(_("Sample start offset"), 0, 2000), |
eSampleStartOffset(_("Sample start offset"), 0, 2000), |
232 |
eUnityNote(_("Unity note")), |
eUnityNote(_("Unity note")), |
233 |
|
eSampleFormatInfo(_("Sample Format")), |
234 |
|
eSampleID("Sample ID"), |
235 |
eFineTune(_("Fine tune"), -49, 50), |
eFineTune(_("Fine tune"), -49, 50), |
236 |
eGain(_("Gain"), -96, 0, 2, -655360), |
eGain(_("Gain"), -96, 0, 2, -655360), |
237 |
eGainPlus6(_("Gain +6dB"), eGain, 6 * -655360), |
eGainPlus6(_("Gain +6dB"), eGain, 6 * -655360), |
241 |
eSampleLoopType(_("Loop type")), |
eSampleLoopType(_("Loop type")), |
242 |
eSampleLoopInfinite(_("Infinite loop")), |
eSampleLoopInfinite(_("Infinite loop")), |
243 |
eSampleLoopPlayCount(_("Playback count"), 1), |
eSampleLoopPlayCount(_("Playback count"), 1), |
244 |
|
buttonSelectSample(UNICODE_LEFT_ARROW + " " + _("Select Sample")), |
245 |
update_model(0) |
update_model(0) |
246 |
{ |
{ |
247 |
|
// make synthesis parameter page tabs scrollable |
248 |
|
// (workaround for GTK3: default theme uses huge tabs which breaks layout) |
249 |
|
set_scrollable(); |
250 |
|
|
251 |
connect(eEG1PreAttack, &gig::DimensionRegion::EG1PreAttack); |
connect(eEG1PreAttack, &gig::DimensionRegion::EG1PreAttack); |
252 |
connect(eEG1Attack, &gig::DimensionRegion::EG1Attack); |
connect(eEG1Attack, &gig::DimensionRegion::EG1Attack); |
253 |
connect(eEG1Decay1, &gig::DimensionRegion::EG1Decay1); |
connect(eEG1Decay1, &gig::DimensionRegion::EG1Decay1); |
355 |
connect(eSampleLoopLength, &DimRegionEdit::set_LoopLength); |
connect(eSampleLoopLength, &DimRegionEdit::set_LoopLength); |
356 |
connect(eSampleLoopInfinite, &DimRegionEdit::set_LoopInfinite); |
connect(eSampleLoopInfinite, &DimRegionEdit::set_LoopInfinite); |
357 |
connect(eSampleLoopPlayCount, &DimRegionEdit::set_LoopPlayCount); |
connect(eSampleLoopPlayCount, &DimRegionEdit::set_LoopPlayCount); |
358 |
|
buttonSelectSample.signal_clicked().connect( |
359 |
|
sigc::mem_fun(*this, &DimRegionEdit::onButtonSelectSamplePressed) |
360 |
|
); |
361 |
|
|
362 |
for (int i = 0 ; i < 7 ; i++) { |
for (int i = 0 ; i < 7 ; i++) { |
363 |
table[i] = new Gtk::Table(3, 1); |
table[i] = new Gtk::Table(3, 1); |
368 |
eUnityNote.set_tip( |
eUnityNote.set_tip( |
369 |
_("Note this sample is associated with (a.k.a. 'root note')") |
_("Note this sample is associated with (a.k.a. 'root note')") |
370 |
); |
); |
371 |
|
buttonSelectSample.set_tooltip_text( |
372 |
|
_("Selects the sample of this dimension region on the left hand side's sample tree view.") |
373 |
|
); |
374 |
eSampleStartOffset.set_tip(_("Sample position at which playback should be started")); |
eSampleStartOffset.set_tip(_("Sample position at which playback should be started")); |
375 |
ePan.set_tip(_("Stereo balance (left/right)")); |
ePan.set_tip(_("Stereo balance (left/right)")); |
376 |
eChannelOffset.set_tip( |
eChannelOffset.set_tip( |
454 |
firstRowInBlock = 0; |
firstRowInBlock = 0; |
455 |
|
|
456 |
addHeader(_("Mandatory Settings")); |
addHeader(_("Mandatory Settings")); |
457 |
addString(_("Sample"), lSample, wSample); |
addString(_("Sample"), lSample, wSample, buttonNullSampleReference); |
458 |
|
buttonNullSampleReference->set_label("X"); |
459 |
|
buttonNullSampleReference->set_tooltip_text(_("Remove current sample reference (NULL reference). This can be used to define a \"silent\" case where no sample shall be played.")); |
460 |
|
buttonNullSampleReference->signal_clicked().connect( |
461 |
|
sigc::mem_fun(*this, &DimRegionEdit::nullOutSampleReference) |
462 |
|
); |
463 |
//TODO: the following would break drag&drop: wSample->property_editable().set_value(false); or this: wSample->set_editable(false); |
//TODO: the following would break drag&drop: wSample->property_editable().set_value(false); or this: wSample->set_editable(false); |
464 |
#ifdef OLD_TOOLTIPS |
#ifdef OLD_TOOLTIPS |
465 |
tooltips.set_tip(*wSample, _("Drag & drop a sample here")); |
tooltips.set_tip(*wSample, _("Drag & drop a sample here")); |
467 |
wSample->set_tooltip_text(_("Drag & drop a sample here")); |
wSample->set_tooltip_text(_("Drag & drop a sample here")); |
468 |
#endif |
#endif |
469 |
addProp(eUnityNote); |
addProp(eUnityNote); |
470 |
|
addProp(eSampleFormatInfo); |
471 |
|
addProp(eSampleID); |
472 |
|
addRightHandSide(buttonSelectSample); |
473 |
addHeader(_("Optional Settings")); |
addHeader(_("Optional Settings")); |
474 |
addProp(eSampleStartOffset); |
addProp(eSampleStartOffset); |
475 |
addProp(eChannelOffset); |
addProp(eChannelOffset); |
844 |
rowno++; |
rowno++; |
845 |
} |
} |
846 |
|
|
847 |
|
void DimRegionEdit::addString(const char* labelText, Gtk::Label*& label, |
848 |
|
Gtk::Entry*& widget, Gtk::Button*& button) |
849 |
|
{ |
850 |
|
label = new Gtk::Label(Glib::ustring(labelText) + ":"); |
851 |
|
label->set_alignment(Gtk::ALIGN_START); |
852 |
|
|
853 |
|
table[pageno]->attach(*label, 1, 2, rowno, rowno + 1, |
854 |
|
Gtk::FILL, Gtk::SHRINK); |
855 |
|
|
856 |
|
widget = new Gtk::Entry(); |
857 |
|
button = new Gtk::Button(); |
858 |
|
|
859 |
|
Gtk::HBox* hbox = new Gtk::HBox; |
860 |
|
hbox->pack_start(*widget); |
861 |
|
hbox->pack_start(*button, Gtk::PACK_SHRINK); |
862 |
|
|
863 |
|
table[pageno]->attach(*hbox, 2, 3, rowno, rowno + 1, |
864 |
|
Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK); |
865 |
|
|
866 |
|
rowno++; |
867 |
|
} |
868 |
|
|
869 |
Gtk::Label* DimRegionEdit::addHeader(const char* text) |
Gtk::Label* DimRegionEdit::addHeader(const char* text) |
870 |
{ |
{ |
871 |
if (firstRowInBlock < rowno - 1) |
if (firstRowInBlock < rowno - 1) |
923 |
rowno++; |
rowno++; |
924 |
} |
} |
925 |
|
|
926 |
|
void DimRegionEdit::addRightHandSide(Gtk::Widget& widget) |
927 |
|
{ |
928 |
|
table[pageno]->attach(widget, 2, 3, rowno, rowno + 1, |
929 |
|
Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK); |
930 |
|
rowno++; |
931 |
|
} |
932 |
|
|
933 |
void DimRegionEdit::set_dim_region(gig::DimensionRegion* d) |
void DimRegionEdit::set_dim_region(gig::DimensionRegion* d) |
934 |
{ |
{ |
1021 |
eMSDecode.set_value(d->MSDecode); |
eMSDecode.set_value(d->MSDecode); |
1022 |
eSampleStartOffset.set_value(d->SampleStartOffset); |
eSampleStartOffset.set_value(d->SampleStartOffset); |
1023 |
eUnityNote.set_value(d->UnityNote); |
eUnityNote.set_value(d->UnityNote); |
1024 |
|
// assemble sample format info string |
1025 |
|
{ |
1026 |
|
Glib::ustring s; |
1027 |
|
if (d->pSample) { |
1028 |
|
switch (d->pSample->Channels) { |
1029 |
|
case 1: s = _("Mono"); break; |
1030 |
|
case 2: s = _("Stereo"); break; |
1031 |
|
default: |
1032 |
|
s = ToString(d->pSample->Channels) + _(" audio channels"); |
1033 |
|
break; |
1034 |
|
} |
1035 |
|
s += " " + ToString(d->pSample->BitDepth) + " Bits"; |
1036 |
|
s += " " + ToString(d->pSample->SamplesPerSecond/1000) + "." |
1037 |
|
+ ToString((d->pSample->SamplesPerSecond%1000)/100) + " kHz"; |
1038 |
|
} else { |
1039 |
|
s = _("No sample assigned to this dimension region."); |
1040 |
|
} |
1041 |
|
eSampleFormatInfo.text.set_text(s); |
1042 |
|
} |
1043 |
|
// generate sample's memory address pointer string |
1044 |
|
{ |
1045 |
|
Glib::ustring s; |
1046 |
|
if (d->pSample) { |
1047 |
|
char buf[64] = {}; |
1048 |
|
snprintf(buf, sizeof(buf), "%p", d->pSample); |
1049 |
|
s = buf; |
1050 |
|
} else { |
1051 |
|
s = "---"; |
1052 |
|
} |
1053 |
|
eSampleID.text.set_text(s); |
1054 |
|
} |
1055 |
|
buttonSelectSample.set_sensitive(d && d->pSample); |
1056 |
eFineTune.set_value(d->FineTune); |
eFineTune.set_value(d->FineTune); |
1057 |
eGain.set_value(d->Gain); |
eGain.set_value(d->Gain); |
1058 |
eGainPlus6.set_value(d->Gain); |
eGainPlus6.set_value(d->Gain); |
1294 |
|
|
1295 |
bool DimRegionEdit::set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop) |
bool DimRegionEdit::set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop) |
1296 |
{ |
{ |
1297 |
|
for (std::set<gig::DimensionRegion*>::iterator itDimReg = dimregs.begin(); |
1298 |
|
itDimReg != dimregs.end(); ++itDimReg) |
1299 |
|
{ |
1300 |
|
set_sample(*itDimReg, sample, copy_sample_unity, copy_sample_tune, copy_sample_loop); |
1301 |
|
} |
1302 |
|
} |
1303 |
|
|
1304 |
|
bool DimRegionEdit::set_sample(gig::DimensionRegion* dimreg, gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop) |
1305 |
|
{ |
1306 |
if (dimregion) { |
if (dimregion) { |
1307 |
//TODO: we should better move the code from MainWindow::on_sample_label_drop_drag_data_received() here |
//TODO: we should better move the code from MainWindow::on_sample_label_drop_drag_data_received() here |
1308 |
|
|
1508 |
{ |
{ |
1509 |
if (d->pSample) d->pSample->LoopPlayCount = value; |
if (d->pSample) d->pSample->LoopPlayCount = value; |
1510 |
} |
} |
1511 |
|
|
1512 |
|
void DimRegionEdit::nullOutSampleReference() { |
1513 |
|
if (!dimregion) return; |
1514 |
|
gig::Sample* oldref = dimregion->pSample; |
1515 |
|
if (!oldref) return; |
1516 |
|
|
1517 |
|
dimreg_to_be_changed_signal.emit(dimregion); |
1518 |
|
|
1519 |
|
// in case currently assigned sample is a stereo one, then remove both |
1520 |
|
// references (expected to be due to a "stereo dimension") |
1521 |
|
gig::DimensionRegion* d[2] = { dimregion, NULL }; |
1522 |
|
if (oldref->Channels == 2) { |
1523 |
|
gig::Region* region = dimregion->GetParent(); |
1524 |
|
{ |
1525 |
|
int stereo_bit = 0; |
1526 |
|
int bitcount = 0; |
1527 |
|
for (int dim = 0 ; dim < region->Dimensions ; dim++) { |
1528 |
|
if (region->pDimensionDefinitions[dim].dimension == gig::dimension_samplechannel) { |
1529 |
|
stereo_bit = 1 << bitcount; |
1530 |
|
break; |
1531 |
|
} |
1532 |
|
bitcount += region->pDimensionDefinitions[dim].bits; |
1533 |
|
} |
1534 |
|
|
1535 |
|
if (stereo_bit) { |
1536 |
|
int dimregno; |
1537 |
|
for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) { |
1538 |
|
if (region->pDimensionRegions[dimregno] == dimregion) { |
1539 |
|
break; |
1540 |
|
} |
1541 |
|
} |
1542 |
|
d[0] = region->pDimensionRegions[dimregno & ~stereo_bit]; |
1543 |
|
d[1] = region->pDimensionRegions[dimregno | stereo_bit]; |
1544 |
|
} |
1545 |
|
} |
1546 |
|
} |
1547 |
|
|
1548 |
|
if (d[0]) d[0]->pSample = NULL; |
1549 |
|
if (d[1]) d[1]->pSample = NULL; |
1550 |
|
|
1551 |
|
// update UI elements |
1552 |
|
set_dim_region(dimregion); |
1553 |
|
|
1554 |
|
sample_ref_changed_signal.emit(oldref, NULL); |
1555 |
|
dimreg_changed_signal.emit(dimregion); |
1556 |
|
} |
1557 |
|
|
1558 |
|
void DimRegionEdit::onButtonSelectSamplePressed() { |
1559 |
|
if (!dimregion) return; |
1560 |
|
if (!dimregion->pSample) return; |
1561 |
|
select_sample_signal.emit(dimregion->pSample); |
1562 |
|
} |
1563 |
|
|
1564 |
|
sigc::signal<void, gig::Sample*>& DimRegionEdit::signal_select_sample() { |
1565 |
|
return select_sample_signal; |
1566 |
|
} |