1 |
/* |
/* |
2 |
* Copyright (C) 2006-2014 Andreas Persson |
* Copyright (C) 2006-2015 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 |
connect(eEG1PreAttack, &gig::DimensionRegion::EG1PreAttack); |
connect(eEG1PreAttack, &gig::DimensionRegion::EG1PreAttack); |
351 |
connect(eSampleLoopLength, &DimRegionEdit::set_LoopLength); |
connect(eSampleLoopLength, &DimRegionEdit::set_LoopLength); |
352 |
connect(eSampleLoopInfinite, &DimRegionEdit::set_LoopInfinite); |
connect(eSampleLoopInfinite, &DimRegionEdit::set_LoopInfinite); |
353 |
connect(eSampleLoopPlayCount, &DimRegionEdit::set_LoopPlayCount); |
connect(eSampleLoopPlayCount, &DimRegionEdit::set_LoopPlayCount); |
354 |
|
buttonSelectSample.signal_clicked().connect( |
355 |
|
sigc::mem_fun(*this, &DimRegionEdit::onButtonSelectSamplePressed) |
356 |
|
); |
357 |
|
|
358 |
for (int i = 0 ; i < 7 ; i++) { |
for (int i = 0 ; i < 7 ; i++) { |
359 |
table[i] = new Gtk::Table(3, 1); |
table[i] = new Gtk::Table(3, 1); |
364 |
eUnityNote.set_tip( |
eUnityNote.set_tip( |
365 |
_("Note this sample is associated with (a.k.a. 'root note')") |
_("Note this sample is associated with (a.k.a. 'root note')") |
366 |
); |
); |
367 |
|
buttonSelectSample.set_tooltip_text( |
368 |
|
_("Selects the sample of this dimension region on the left hand side's sample tree view.") |
369 |
|
); |
370 |
eSampleStartOffset.set_tip(_("Sample position at which playback should be started")); |
eSampleStartOffset.set_tip(_("Sample position at which playback should be started")); |
371 |
ePan.set_tip(_("Stereo balance (left/right)")); |
ePan.set_tip(_("Stereo balance (left/right)")); |
372 |
eChannelOffset.set_tip( |
eChannelOffset.set_tip( |
450 |
firstRowInBlock = 0; |
firstRowInBlock = 0; |
451 |
|
|
452 |
addHeader(_("Mandatory Settings")); |
addHeader(_("Mandatory Settings")); |
453 |
addString(_("Sample"), lSample, wSample); |
addString(_("Sample"), lSample, wSample, buttonNullSampleReference); |
454 |
|
buttonNullSampleReference->set_label("X"); |
455 |
|
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.")); |
456 |
|
buttonNullSampleReference->signal_clicked().connect( |
457 |
|
sigc::mem_fun(*this, &DimRegionEdit::nullOutSampleReference) |
458 |
|
); |
459 |
//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); |
460 |
#ifdef OLD_TOOLTIPS |
#ifdef OLD_TOOLTIPS |
461 |
tooltips.set_tip(*wSample, _("Drag & drop a sample here")); |
tooltips.set_tip(*wSample, _("Drag & drop a sample here")); |
463 |
wSample->set_tooltip_text(_("Drag & drop a sample here")); |
wSample->set_tooltip_text(_("Drag & drop a sample here")); |
464 |
#endif |
#endif |
465 |
addProp(eUnityNote); |
addProp(eUnityNote); |
466 |
|
addProp(eSampleFormatInfo); |
467 |
|
addProp(eSampleID); |
468 |
|
addRightHandSide(buttonSelectSample); |
469 |
addHeader(_("Optional Settings")); |
addHeader(_("Optional Settings")); |
470 |
addProp(eSampleStartOffset); |
addProp(eSampleStartOffset); |
471 |
addProp(eChannelOffset); |
addProp(eChannelOffset); |
840 |
rowno++; |
rowno++; |
841 |
} |
} |
842 |
|
|
843 |
|
void DimRegionEdit::addString(const char* labelText, Gtk::Label*& label, |
844 |
|
Gtk::Entry*& widget, Gtk::Button*& button) |
845 |
|
{ |
846 |
|
label = new Gtk::Label(Glib::ustring(labelText) + ":"); |
847 |
|
label->set_alignment(Gtk::ALIGN_START); |
848 |
|
|
849 |
|
table[pageno]->attach(*label, 1, 2, rowno, rowno + 1, |
850 |
|
Gtk::FILL, Gtk::SHRINK); |
851 |
|
|
852 |
|
widget = new Gtk::Entry(); |
853 |
|
button = new Gtk::Button(); |
854 |
|
|
855 |
|
Gtk::HBox* hbox = new Gtk::HBox; |
856 |
|
hbox->pack_start(*widget); |
857 |
|
hbox->pack_start(*button, Gtk::PACK_SHRINK); |
858 |
|
|
859 |
|
table[pageno]->attach(*hbox, 2, 3, rowno, rowno + 1, |
860 |
|
Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK); |
861 |
|
|
862 |
|
rowno++; |
863 |
|
} |
864 |
|
|
865 |
Gtk::Label* DimRegionEdit::addHeader(const char* text) |
Gtk::Label* DimRegionEdit::addHeader(const char* text) |
866 |
{ |
{ |
867 |
if (firstRowInBlock < rowno - 1) |
if (firstRowInBlock < rowno - 1) |
919 |
rowno++; |
rowno++; |
920 |
} |
} |
921 |
|
|
922 |
|
void DimRegionEdit::addRightHandSide(Gtk::Widget& widget) |
923 |
|
{ |
924 |
|
table[pageno]->attach(widget, 2, 3, rowno, rowno + 1, |
925 |
|
Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK); |
926 |
|
rowno++; |
927 |
|
} |
928 |
|
|
929 |
void DimRegionEdit::set_dim_region(gig::DimensionRegion* d) |
void DimRegionEdit::set_dim_region(gig::DimensionRegion* d) |
930 |
{ |
{ |
1017 |
eMSDecode.set_value(d->MSDecode); |
eMSDecode.set_value(d->MSDecode); |
1018 |
eSampleStartOffset.set_value(d->SampleStartOffset); |
eSampleStartOffset.set_value(d->SampleStartOffset); |
1019 |
eUnityNote.set_value(d->UnityNote); |
eUnityNote.set_value(d->UnityNote); |
1020 |
|
// assemble sample format info string |
1021 |
|
{ |
1022 |
|
Glib::ustring s; |
1023 |
|
if (d->pSample) { |
1024 |
|
switch (d->pSample->Channels) { |
1025 |
|
case 1: s = _("Mono"); break; |
1026 |
|
case 2: s = _("Stereo"); break; |
1027 |
|
default: |
1028 |
|
s = ToString(d->pSample->Channels) + _(" audio channels"); |
1029 |
|
break; |
1030 |
|
} |
1031 |
|
s += " " + ToString(d->pSample->BitDepth) + " Bits"; |
1032 |
|
s += " " + ToString(d->pSample->SamplesPerSecond/1000) + "." |
1033 |
|
+ ToString((d->pSample->SamplesPerSecond%1000)/100) + " kHz"; |
1034 |
|
} else { |
1035 |
|
s = _("No sample assigned to this dimension region."); |
1036 |
|
} |
1037 |
|
eSampleFormatInfo.text.set_text(s); |
1038 |
|
} |
1039 |
|
// generate sample's memory address pointer string |
1040 |
|
{ |
1041 |
|
Glib::ustring s; |
1042 |
|
if (d->pSample) { |
1043 |
|
char buf[64] = {}; |
1044 |
|
snprintf(buf, sizeof(buf), "%p", d->pSample); |
1045 |
|
s = buf; |
1046 |
|
} else { |
1047 |
|
s = "---"; |
1048 |
|
} |
1049 |
|
eSampleID.text.set_text(s); |
1050 |
|
} |
1051 |
|
buttonSelectSample.set_sensitive(d && d->pSample); |
1052 |
eFineTune.set_value(d->FineTune); |
eFineTune.set_value(d->FineTune); |
1053 |
eGain.set_value(d->Gain); |
eGain.set_value(d->Gain); |
1054 |
eGainPlus6.set_value(d->Gain); |
eGainPlus6.set_value(d->Gain); |
1495 |
{ |
{ |
1496 |
if (d->pSample) d->pSample->LoopPlayCount = value; |
if (d->pSample) d->pSample->LoopPlayCount = value; |
1497 |
} |
} |
1498 |
|
|
1499 |
|
void DimRegionEdit::nullOutSampleReference() { |
1500 |
|
if (!dimregion) return; |
1501 |
|
gig::Sample* oldref = dimregion->pSample; |
1502 |
|
if (!oldref) return; |
1503 |
|
|
1504 |
|
dimreg_to_be_changed_signal.emit(dimregion); |
1505 |
|
|
1506 |
|
// in case currently assigned sample is a stereo one, then remove both |
1507 |
|
// references (expected to be due to a "stereo dimension") |
1508 |
|
gig::DimensionRegion* d[2] = { dimregion, NULL }; |
1509 |
|
if (oldref->Channels == 2) { |
1510 |
|
gig::Region* region = dimregion->GetParent(); |
1511 |
|
int stereo_bit = 0; |
1512 |
|
{ |
1513 |
|
int bitcount = 0; |
1514 |
|
for (int dim = 0 ; dim < region->Dimensions ; dim++) { |
1515 |
|
if (region->pDimensionDefinitions[dim].dimension == gig::dimension_samplechannel) { |
1516 |
|
stereo_bit = 1 << bitcount; |
1517 |
|
break; |
1518 |
|
} |
1519 |
|
bitcount += region->pDimensionDefinitions[dim].bits; |
1520 |
|
} |
1521 |
|
|
1522 |
|
if (stereo_bit) { |
1523 |
|
int dimregno; |
1524 |
|
for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) { |
1525 |
|
if (region->pDimensionRegions[dimregno] == dimregion) { |
1526 |
|
break; |
1527 |
|
} |
1528 |
|
} |
1529 |
|
d[0] = region->pDimensionRegions[dimregno & ~stereo_bit]; |
1530 |
|
d[1] = region->pDimensionRegions[dimregno | stereo_bit]; |
1531 |
|
} |
1532 |
|
} |
1533 |
|
} |
1534 |
|
|
1535 |
|
if (d[0]) d[0]->pSample = NULL; |
1536 |
|
if (d[1]) d[1]->pSample = NULL; |
1537 |
|
|
1538 |
|
// update UI elements |
1539 |
|
set_dim_region(dimregion); |
1540 |
|
|
1541 |
|
sample_ref_changed_signal.emit(oldref, NULL); |
1542 |
|
dimreg_changed_signal.emit(dimregion); |
1543 |
|
} |
1544 |
|
|
1545 |
|
void DimRegionEdit::onButtonSelectSamplePressed() { |
1546 |
|
if (!dimregion) return; |
1547 |
|
if (!dimregion->pSample) return; |
1548 |
|
select_sample_signal.emit(dimregion->pSample); |
1549 |
|
} |
1550 |
|
|
1551 |
|
sigc::signal<void, gig::Sample*>& DimRegionEdit::signal_select_sample() { |
1552 |
|
return select_sample_signal; |
1553 |
|
} |