1 |
/* |
/* |
2 |
* Copyright (C) 2006-2016 Andreas Persson |
* Copyright (C) 2006-2017 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 |
17 |
* 02110-1301 USA. |
* 02110-1301 USA. |
18 |
*/ |
*/ |
19 |
|
|
20 |
|
#include "global.h" |
21 |
#include "dimregionedit.h" |
#include "dimregionedit.h" |
22 |
|
|
|
#include "global.h" |
|
23 |
#include "compat.h" |
#include "compat.h" |
24 |
|
|
25 |
VelocityCurve::VelocityCurve(double (gig::DimensionRegion::*getter)(uint8_t)) : |
VelocityCurve::VelocityCurve(double (gig::DimensionRegion::*getter)(uint8_t)) : |
147 |
} |
} |
148 |
|
|
149 |
|
|
150 |
|
EGStateOptions::EGStateOptions() : HBox(), |
151 |
|
label(_("May be cancelled: ")), |
152 |
|
checkBoxAttack(_("Attack")), |
153 |
|
checkBoxAttackHold(_("Attack Hold")), |
154 |
|
checkBoxDecay1(_("Decay 1")), |
155 |
|
checkBoxDecay2(_("Decay 2")), |
156 |
|
checkBoxRelease(_("Release")) |
157 |
|
{ |
158 |
|
set_spacing(6); |
159 |
|
|
160 |
|
pack_start(label); |
161 |
|
pack_start(checkBoxAttack, Gtk::PACK_SHRINK); |
162 |
|
pack_start(checkBoxAttackHold, Gtk::PACK_SHRINK); |
163 |
|
pack_start(checkBoxDecay1, Gtk::PACK_SHRINK); |
164 |
|
pack_start(checkBoxDecay2, Gtk::PACK_SHRINK); |
165 |
|
pack_start(checkBoxRelease, Gtk::PACK_SHRINK); |
166 |
|
|
167 |
|
checkBoxAttack.set_tooltip_text(_( |
168 |
|
"If checked: a note-off aborts the 'attack' stage." |
169 |
|
)); |
170 |
|
checkBoxAttackHold.set_tooltip_text(_( |
171 |
|
"If checked: a note-off aborts the 'attack hold' stage." |
172 |
|
)); |
173 |
|
checkBoxDecay1.set_tooltip_text(_( |
174 |
|
"If checked: a note-off aborts the 'decay 1' stage." |
175 |
|
)); |
176 |
|
checkBoxDecay2.set_tooltip_text(_( |
177 |
|
"If checked: a note-off aborts the 'decay 2' stage." |
178 |
|
)); |
179 |
|
checkBoxRelease.set_tooltip_text(_( |
180 |
|
"If checked: a note-on reverts back from the 'release' stage." |
181 |
|
)); |
182 |
|
} |
183 |
|
|
184 |
|
|
185 |
DimRegionEdit::DimRegionEdit() : |
DimRegionEdit::DimRegionEdit() : |
186 |
velocity_curve(&gig::DimensionRegion::GetVelocityAttenuation), |
velocity_curve(&gig::DimensionRegion::GetVelocityAttenuation), |
187 |
release_curve(&gig::DimensionRegion::GetVelocityRelease), |
release_curve(&gig::DimensionRegion::GetVelocityRelease), |
265 |
eMSDecode(_("Decode Mid/Side Recordings")), |
eMSDecode(_("Decode Mid/Side Recordings")), |
266 |
eSampleStartOffset(_("Sample start offset"), 0, 2000), |
eSampleStartOffset(_("Sample start offset"), 0, 2000), |
267 |
eUnityNote(_("Unity note")), |
eUnityNote(_("Unity note")), |
268 |
|
eSampleGroup(_("Sample Group")), |
269 |
eSampleFormatInfo(_("Sample Format")), |
eSampleFormatInfo(_("Sample Format")), |
270 |
eSampleID("Sample ID"), |
eSampleID("Sample ID"), |
271 |
|
eChecksum("Wave Data CRC-32"), |
272 |
eFineTune(_("Fine tune"), -49, 50), |
eFineTune(_("Fine tune"), -49, 50), |
273 |
eGain(_("Gain"), -96, 0, 2, -655360), |
eGain(_("Gain"), -96, 0, 2, -655360), |
274 |
eGainPlus6(_("Gain +6dB"), eGain, 6 * -655360), |
eGainPlus6(_("Gain +6dB"), eGain, 6 * -655360), |
301 |
&gig::DimensionRegion::EG1ControllerDecayInfluence); |
&gig::DimensionRegion::EG1ControllerDecayInfluence); |
302 |
connect(eEG1ControllerReleaseInfluence, |
connect(eEG1ControllerReleaseInfluence, |
303 |
&gig::DimensionRegion::EG1ControllerReleaseInfluence); |
&gig::DimensionRegion::EG1ControllerReleaseInfluence); |
304 |
|
{ |
305 |
|
ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG1Options.AttackCancel)); |
306 |
|
connect(eEG1StateOptions.checkBoxAttack, mp.pmember); |
307 |
|
} |
308 |
|
{ |
309 |
|
ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG1Options.AttackHoldCancel)); |
310 |
|
connect(eEG1StateOptions.checkBoxAttackHold, mp.pmember); |
311 |
|
} |
312 |
|
{ |
313 |
|
ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG1Options.Decay1Cancel)); |
314 |
|
connect(eEG1StateOptions.checkBoxDecay1, mp.pmember); |
315 |
|
} |
316 |
|
{ |
317 |
|
ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG1Options.Decay2Cancel)); |
318 |
|
connect(eEG1StateOptions.checkBoxDecay2, mp.pmember); |
319 |
|
} |
320 |
|
{ |
321 |
|
ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG1Options.ReleaseCancel)); |
322 |
|
connect(eEG1StateOptions.checkBoxRelease, mp.pmember); |
323 |
|
} |
324 |
connect(eLFO1Frequency, &gig::DimensionRegion::LFO1Frequency); |
connect(eLFO1Frequency, &gig::DimensionRegion::LFO1Frequency); |
325 |
connect(eLFO1InternalDepth, &gig::DimensionRegion::LFO1InternalDepth); |
connect(eLFO1InternalDepth, &gig::DimensionRegion::LFO1InternalDepth); |
326 |
connect(eLFO1ControlDepth, &gig::DimensionRegion::LFO1ControlDepth); |
connect(eLFO1ControlDepth, &gig::DimensionRegion::LFO1ControlDepth); |
342 |
&gig::DimensionRegion::EG2ControllerDecayInfluence); |
&gig::DimensionRegion::EG2ControllerDecayInfluence); |
343 |
connect(eEG2ControllerReleaseInfluence, |
connect(eEG2ControllerReleaseInfluence, |
344 |
&gig::DimensionRegion::EG2ControllerReleaseInfluence); |
&gig::DimensionRegion::EG2ControllerReleaseInfluence); |
345 |
|
{ |
346 |
|
ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG2Options.AttackCancel)); |
347 |
|
connect(eEG2StateOptions.checkBoxAttack, mp.pmember); |
348 |
|
} |
349 |
|
{ |
350 |
|
ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG2Options.AttackHoldCancel)); |
351 |
|
connect(eEG2StateOptions.checkBoxAttackHold, mp.pmember); |
352 |
|
} |
353 |
|
{ |
354 |
|
ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG2Options.Decay1Cancel)); |
355 |
|
connect(eEG2StateOptions.checkBoxDecay1, mp.pmember); |
356 |
|
} |
357 |
|
{ |
358 |
|
ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG2Options.Decay2Cancel)); |
359 |
|
connect(eEG2StateOptions.checkBoxDecay2, mp.pmember); |
360 |
|
} |
361 |
|
{ |
362 |
|
ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG2Options.ReleaseCancel)); |
363 |
|
connect(eEG2StateOptions.checkBoxRelease, mp.pmember); |
364 |
|
} |
365 |
connect(eLFO2Frequency, &gig::DimensionRegion::LFO2Frequency); |
connect(eLFO2Frequency, &gig::DimensionRegion::LFO2Frequency); |
366 |
connect(eLFO2InternalDepth, &gig::DimensionRegion::LFO2InternalDepth); |
connect(eLFO2InternalDepth, &gig::DimensionRegion::LFO2InternalDepth); |
367 |
connect(eLFO2ControlDepth, &gig::DimensionRegion::LFO2ControlDepth); |
connect(eLFO2ControlDepth, &gig::DimensionRegion::LFO2ControlDepth); |
544 |
wSample->set_tooltip_text(_("Drag & drop a sample here")); |
wSample->set_tooltip_text(_("Drag & drop a sample here")); |
545 |
#endif |
#endif |
546 |
addProp(eUnityNote); |
addProp(eUnityNote); |
547 |
|
addProp(eSampleGroup); |
548 |
addProp(eSampleFormatInfo); |
addProp(eSampleFormatInfo); |
549 |
addProp(eSampleID); |
addProp(eSampleID); |
550 |
|
addProp(eChecksum); |
551 |
addRightHandSide(buttonSelectSample); |
addRightHandSide(buttonSelectSample); |
552 |
addHeader(_("Optional Settings")); |
addHeader(_("Optional Settings")); |
553 |
addProp(eSampleStartOffset); |
addProp(eSampleStartOffset); |
589 |
addProp(eEG1ControllerAttackInfluence); |
addProp(eEG1ControllerAttackInfluence); |
590 |
addProp(eEG1ControllerDecayInfluence); |
addProp(eEG1ControllerDecayInfluence); |
591 |
addProp(eEG1ControllerReleaseInfluence); |
addProp(eEG1ControllerReleaseInfluence); |
592 |
|
addLine(eEG1StateOptions); |
593 |
|
|
594 |
nextPage(); |
nextPage(); |
595 |
|
|
735 |
addProp(eEG2ControllerAttackInfluence); |
addProp(eEG2ControllerAttackInfluence); |
736 |
addProp(eEG2ControllerDecayInfluence); |
addProp(eEG2ControllerDecayInfluence); |
737 |
addProp(eEG2ControllerReleaseInfluence); |
addProp(eEG2ControllerReleaseInfluence); |
738 |
|
addLine(eEG2StateOptions); |
739 |
lLFO2 = addHeader(_("Filter Cutoff Oscillator (LFO2)")); |
lLFO2 = addHeader(_("Filter Cutoff Oscillator (LFO2)")); |
740 |
addProp(eLFO2Frequency); |
addProp(eLFO2Frequency); |
741 |
addProp(eLFO2InternalDepth); |
addProp(eLFO2InternalDepth); |
1004 |
rowno++; |
rowno++; |
1005 |
} |
} |
1006 |
|
|
1007 |
|
void DimRegionEdit::addLine(Gtk::HBox& line) |
1008 |
|
{ |
1009 |
|
table[pageno]->attach(line, 1, 3, rowno, rowno + 1, |
1010 |
|
Gtk::FILL, Gtk::SHRINK); |
1011 |
|
rowno++; |
1012 |
|
} |
1013 |
|
|
1014 |
void DimRegionEdit::addRightHandSide(Gtk::Widget& widget) |
void DimRegionEdit::addRightHandSide(Gtk::Widget& widget) |
1015 |
{ |
{ |
1016 |
table[pageno]->attach(widget, 2, 3, rowno, rowno + 1, |
table[pageno]->attach(widget, 2, 3, rowno, rowno + 1, |
1043 |
eEG1ControllerAttackInfluence.set_value(d->EG1ControllerAttackInfluence); |
eEG1ControllerAttackInfluence.set_value(d->EG1ControllerAttackInfluence); |
1044 |
eEG1ControllerDecayInfluence.set_value(d->EG1ControllerDecayInfluence); |
eEG1ControllerDecayInfluence.set_value(d->EG1ControllerDecayInfluence); |
1045 |
eEG1ControllerReleaseInfluence.set_value(d->EG1ControllerReleaseInfluence); |
eEG1ControllerReleaseInfluence.set_value(d->EG1ControllerReleaseInfluence); |
1046 |
|
eEG1StateOptions.checkBoxAttack.set_value(d->EG1Options.AttackCancel); |
1047 |
|
eEG1StateOptions.checkBoxAttackHold.set_value(d->EG1Options.AttackHoldCancel); |
1048 |
|
eEG1StateOptions.checkBoxDecay1.set_value(d->EG1Options.Decay1Cancel); |
1049 |
|
eEG1StateOptions.checkBoxDecay2.set_value(d->EG1Options.Decay2Cancel); |
1050 |
|
eEG1StateOptions.checkBoxRelease.set_value(d->EG1Options.ReleaseCancel); |
1051 |
eLFO1Frequency.set_value(d->LFO1Frequency); |
eLFO1Frequency.set_value(d->LFO1Frequency); |
1052 |
eLFO1InternalDepth.set_value(d->LFO1InternalDepth); |
eLFO1InternalDepth.set_value(d->LFO1InternalDepth); |
1053 |
eLFO1ControlDepth.set_value(d->LFO1ControlDepth); |
eLFO1ControlDepth.set_value(d->LFO1ControlDepth); |
1066 |
eEG2ControllerAttackInfluence.set_value(d->EG2ControllerAttackInfluence); |
eEG2ControllerAttackInfluence.set_value(d->EG2ControllerAttackInfluence); |
1067 |
eEG2ControllerDecayInfluence.set_value(d->EG2ControllerDecayInfluence); |
eEG2ControllerDecayInfluence.set_value(d->EG2ControllerDecayInfluence); |
1068 |
eEG2ControllerReleaseInfluence.set_value(d->EG2ControllerReleaseInfluence); |
eEG2ControllerReleaseInfluence.set_value(d->EG2ControllerReleaseInfluence); |
1069 |
|
eEG2StateOptions.checkBoxAttack.set_value(d->EG2Options.AttackCancel); |
1070 |
|
eEG2StateOptions.checkBoxAttackHold.set_value(d->EG2Options.AttackHoldCancel); |
1071 |
|
eEG2StateOptions.checkBoxDecay1.set_value(d->EG2Options.Decay1Cancel); |
1072 |
|
eEG2StateOptions.checkBoxDecay2.set_value(d->EG2Options.Decay2Cancel); |
1073 |
|
eEG2StateOptions.checkBoxRelease.set_value(d->EG2Options.ReleaseCancel); |
1074 |
eLFO2Frequency.set_value(d->LFO2Frequency); |
eLFO2Frequency.set_value(d->LFO2Frequency); |
1075 |
eLFO2InternalDepth.set_value(d->LFO2InternalDepth); |
eLFO2InternalDepth.set_value(d->LFO2InternalDepth); |
1076 |
eLFO2ControlDepth.set_value(d->LFO2ControlDepth); |
eLFO2ControlDepth.set_value(d->LFO2ControlDepth); |
1119 |
eMSDecode.set_value(d->MSDecode); |
eMSDecode.set_value(d->MSDecode); |
1120 |
eSampleStartOffset.set_value(d->SampleStartOffset); |
eSampleStartOffset.set_value(d->SampleStartOffset); |
1121 |
eUnityNote.set_value(d->UnityNote); |
eUnityNote.set_value(d->UnityNote); |
1122 |
|
// show sample group name |
1123 |
|
{ |
1124 |
|
Glib::ustring s = "---"; |
1125 |
|
if (d->pSample && d->pSample->GetGroup()) |
1126 |
|
s = d->pSample->GetGroup()->Name; |
1127 |
|
eSampleGroup.text.set_text(s); |
1128 |
|
} |
1129 |
// assemble sample format info string |
// assemble sample format info string |
1130 |
{ |
{ |
1131 |
Glib::ustring s; |
Glib::ustring s; |
1157 |
} |
} |
1158 |
eSampleID.text.set_text(s); |
eSampleID.text.set_text(s); |
1159 |
} |
} |
1160 |
|
// generate raw wave form data CRC-32 checksum string |
1161 |
|
{ |
1162 |
|
Glib::ustring s = "---"; |
1163 |
|
if (d->pSample) { |
1164 |
|
char buf[64] = {}; |
1165 |
|
snprintf(buf, sizeof(buf), "%x", d->pSample->GetWaveDataCRC32Checksum()); |
1166 |
|
s = buf; |
1167 |
|
} |
1168 |
|
eChecksum.text.set_text(s); |
1169 |
|
} |
1170 |
buttonSelectSample.set_sensitive(d && d->pSample); |
buttonSelectSample.set_sensitive(d && d->pSample); |
1171 |
eFineTune.set_value(d->FineTune); |
eFineTune.set_value(d->FineTune); |
1172 |
eGain.set_value(d->Gain); |
eGain.set_value(d->Gain); |
1216 |
eEG2ControllerAttackInfluence.set_sensitive(sensitive); |
eEG2ControllerAttackInfluence.set_sensitive(sensitive); |
1217 |
eEG2ControllerDecayInfluence.set_sensitive(sensitive); |
eEG2ControllerDecayInfluence.set_sensitive(sensitive); |
1218 |
eEG2ControllerReleaseInfluence.set_sensitive(sensitive); |
eEG2ControllerReleaseInfluence.set_sensitive(sensitive); |
1219 |
|
eEG2StateOptions.set_sensitive(sensitive); |
1220 |
lLFO2->set_sensitive(sensitive); |
lLFO2->set_sensitive(sensitive); |
1221 |
eLFO2Frequency.set_sensitive(sensitive); |
eLFO2Frequency.set_sensitive(sensitive); |
1222 |
eLFO2InternalDepth.set_sensitive(sensitive); |
eLFO2InternalDepth.set_sensitive(sensitive); |
1410 |
|
|
1411 |
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) |
1412 |
{ |
{ |
1413 |
|
bool result = false; |
1414 |
for (std::set<gig::DimensionRegion*>::iterator itDimReg = dimregs.begin(); |
for (std::set<gig::DimensionRegion*>::iterator itDimReg = dimregs.begin(); |
1415 |
itDimReg != dimregs.end(); ++itDimReg) |
itDimReg != dimregs.end(); ++itDimReg) |
1416 |
{ |
{ |
1417 |
set_sample(*itDimReg, sample, copy_sample_unity, copy_sample_tune, copy_sample_loop); |
result |= set_sample(*itDimReg, sample, copy_sample_unity, copy_sample_tune, copy_sample_loop); |
1418 |
} |
} |
1419 |
|
return result; |
1420 |
} |
} |
1421 |
|
|
1422 |
bool DimRegionEdit::set_sample(gig::DimensionRegion* dimreg, gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop) |
bool DimRegionEdit::set_sample(gig::DimensionRegion* dimreg, gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop) |
1425 |
//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 |
1426 |
|
|
1427 |
// currently commented because we're sending a similar signal in MainWindow::on_sample_label_drop_drag_data_received() |
// currently commented because we're sending a similar signal in MainWindow::on_sample_label_drop_drag_data_received() |
1428 |
//dimreg_to_be_changed_signal.emit(dimregion); |
//DimRegionChangeGuard(this, dimregion); |
1429 |
|
|
1430 |
// make sure stereo samples always are the same in both |
// make sure stereo samples always are the same in both |
1431 |
// dimregs in the samplechannel dimension |
// dimregs in the samplechannel dimension |
1495 |
update_model--; |
update_model--; |
1496 |
|
|
1497 |
sample_ref_changed_signal.emit(oldref, sample); |
sample_ref_changed_signal.emit(oldref, sample); |
|
// currently commented because we're sending a similar signal in MainWindow::on_sample_label_drop_drag_data_received() |
|
|
//dimreg_changed_signal.emit(dimreg); |
|
1498 |
return true; |
return true; |
1499 |
} |
} |
1500 |
return false; |
return false; |
1563 |
if (value) { |
if (value) { |
1564 |
// create a new sample loop in case there is none yet |
// create a new sample loop in case there is none yet |
1565 |
if (!d->SampleLoops) { |
if (!d->SampleLoops) { |
1566 |
|
DimRegionChangeGuard(this, d); |
1567 |
|
|
1568 |
DLS::sample_loop_t loop; |
DLS::sample_loop_t loop; |
1569 |
loop.LoopType = gig::loop_type_normal; |
loop.LoopType = gig::loop_type_normal; |
1570 |
// loop the whole sample by default |
// loop the whole sample by default |
1571 |
loop.LoopStart = 0; |
loop.LoopStart = 0; |
1572 |
loop.LoopLength = |
loop.LoopLength = |
1573 |
(d->pSample) ? d->pSample->SamplesTotal : 0; |
(d->pSample) ? d->pSample->SamplesTotal : 0; |
|
dimreg_to_be_changed_signal.emit(d); |
|
1574 |
d->AddSampleLoop(&loop); |
d->AddSampleLoop(&loop); |
|
dimreg_changed_signal.emit(d); |
|
1575 |
} |
} |
1576 |
} else { |
} else { |
1577 |
if (d->SampleLoops) { |
if (d->SampleLoops) { |
1578 |
dimreg_to_be_changed_signal.emit(d); |
DimRegionChangeGuard(this, d); |
1579 |
|
|
1580 |
// delete ALL existing sample loops |
// delete ALL existing sample loops |
1581 |
while (d->SampleLoops) { |
while (d->SampleLoops) { |
1582 |
d->DeleteSampleLoop(&d->pSampleLoops[0]); |
d->DeleteSampleLoop(&d->pSampleLoops[0]); |
1583 |
} |
} |
|
dimreg_changed_signal.emit(d); |
|
1584 |
} |
} |
1585 |
} |
} |
1586 |
} |
} |
1630 |
gig::Sample* oldref = dimregion->pSample; |
gig::Sample* oldref = dimregion->pSample; |
1631 |
if (!oldref) return; |
if (!oldref) return; |
1632 |
|
|
1633 |
dimreg_to_be_changed_signal.emit(dimregion); |
DimRegionChangeGuard(this, dimregion); |
1634 |
|
|
1635 |
// in case currently assigned sample is a stereo one, then remove both |
// in case currently assigned sample is a stereo one, then remove both |
1636 |
// references (expected to be due to a "stereo dimension") |
// references (expected to be due to a "stereo dimension") |
1668 |
set_dim_region(dimregion); |
set_dim_region(dimregion); |
1669 |
|
|
1670 |
sample_ref_changed_signal.emit(oldref, NULL); |
sample_ref_changed_signal.emit(oldref, NULL); |
|
dimreg_changed_signal.emit(dimregion); |
|
1671 |
} |
} |
1672 |
|
|
1673 |
void DimRegionEdit::onButtonSelectSamplePressed() { |
void DimRegionEdit::onButtonSelectSamplePressed() { |