1 |
/* |
/* |
2 |
* Copyright (C) 2006-2010 Andreas Persson |
* Copyright (C) 2006-2013 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 |
20 |
#include "dimregionedit.h" |
#include "dimregionedit.h" |
21 |
|
|
22 |
#include "global.h" |
#include "global.h" |
23 |
|
#include "compat.h" |
24 |
|
|
25 |
|
VelocityCurve::VelocityCurve(double (gig::DimensionRegion::*getter)(uint8_t)) : |
26 |
|
getter(getter), dimreg(0) { |
27 |
|
set_size_request(80, 80); |
28 |
|
} |
29 |
|
|
30 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
31 |
|
bool VelocityCurve::on_expose_event(GdkEventExpose* e) { |
32 |
|
const Cairo::RefPtr<Cairo::Context>& cr = |
33 |
|
get_window()->create_cairo_context(); |
34 |
|
#if 0 |
35 |
|
} |
36 |
|
#endif |
37 |
|
#else |
38 |
|
bool VelocityCurve::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) { |
39 |
|
#endif |
40 |
|
if (dimreg) { |
41 |
|
int w = get_width(); |
42 |
|
int h = get_height(); |
43 |
|
|
44 |
|
for (int pass = 0 ; pass < 2 ; pass++) { |
45 |
|
for (double x = 0 ; x <= w ; x++) { |
46 |
|
int vel = int(x * (127 - 1e-10) / w + 1); |
47 |
|
double y = (1 - (dimreg->*getter)(vel)) * (h - 3) + 1.5; |
48 |
|
|
49 |
|
if (x < 1e-10) { |
50 |
|
cr->move_to(x, y); |
51 |
|
} else { |
52 |
|
cr->line_to(x, y); |
53 |
|
} |
54 |
|
} |
55 |
|
if (pass == 0) { |
56 |
|
cr->line_to(w, h); |
57 |
|
cr->line_to(0, h); |
58 |
|
cr->set_source_rgba(0.5, 0.44, 1.0, is_sensitive() ? 0.2 : 0.1); |
59 |
|
cr->fill(); |
60 |
|
} else { |
61 |
|
cr->set_line_width(3); |
62 |
|
cr->set_source_rgba(0.5, 0.44, 1.0, is_sensitive() ? 1.0 : 0.3); |
63 |
|
cr->stroke(); |
64 |
|
} |
65 |
|
} |
66 |
|
} |
67 |
|
return true; |
68 |
|
} |
69 |
|
|
70 |
|
|
71 |
|
CrossfadeCurve::CrossfadeCurve() : dimreg(0) { |
72 |
|
set_size_request(280, 80); |
73 |
|
} |
74 |
|
|
75 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
76 |
|
bool CrossfadeCurve::on_expose_event(GdkEventExpose* e) { |
77 |
|
const Cairo::RefPtr<Cairo::Context>& cr = |
78 |
|
get_window()->create_cairo_context(); |
79 |
|
#if 0 |
80 |
|
} |
81 |
|
#endif |
82 |
|
#else |
83 |
|
bool CrossfadeCurve::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) { |
84 |
|
#endif |
85 |
|
if (dimreg) { |
86 |
|
cr->translate(1.5, 0); |
87 |
|
|
88 |
|
// first, draw curves for the other layers |
89 |
|
gig::Region* region = dimreg->GetParent(); |
90 |
|
int dimregno; |
91 |
|
for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) { |
92 |
|
if (region->pDimensionRegions[dimregno] == dimreg) { |
93 |
|
break; |
94 |
|
} |
95 |
|
} |
96 |
|
int bitcount = 0; |
97 |
|
int layer_bit = 0; |
98 |
|
for (int dim = 0 ; dim < region->Dimensions ; dim++) { |
99 |
|
if (region->pDimensionDefinitions[dim].dimension == |
100 |
|
gig::dimension_layer) { |
101 |
|
layer_bit = 1 << bitcount; |
102 |
|
|
103 |
|
int mask = |
104 |
|
~(((1 << region->pDimensionDefinitions[dim].bits) - 1) << |
105 |
|
bitcount); |
106 |
|
int c = dimregno & mask; // mask away the layer dimension |
107 |
|
|
108 |
|
for (int i = 0 ; i < region->pDimensionDefinitions[dim].zones ; |
109 |
|
i++) { |
110 |
|
gig::DimensionRegion* d = |
111 |
|
region->pDimensionRegions[c + (i << bitcount)]; |
112 |
|
if (d != dimreg) { |
113 |
|
draw_one_curve(cr, d, false); |
114 |
|
} |
115 |
|
} |
116 |
|
break; |
117 |
|
} |
118 |
|
bitcount += region->pDimensionDefinitions[dim].bits; |
119 |
|
} |
120 |
|
|
121 |
|
// then, draw the currently selected layer |
122 |
|
draw_one_curve(cr, dimreg, is_sensitive()); |
123 |
|
} |
124 |
|
return true; |
125 |
|
} |
126 |
|
|
127 |
|
void CrossfadeCurve::draw_one_curve(const Cairo::RefPtr<Cairo::Context>& cr, |
128 |
|
const gig::DimensionRegion* d, |
129 |
|
bool sensitive) { |
130 |
|
int w = get_width(); |
131 |
|
int h = get_height(); |
132 |
|
|
133 |
|
if (d->Crossfade.out_end) { |
134 |
|
for (int pass = 0 ; pass < 2 ; pass++) { |
135 |
|
cr->move_to(d->Crossfade.in_start / 127.0 * (w - 3), h); |
136 |
|
cr->line_to(d->Crossfade.in_end / 127.0 * (w - 3), 1.5); |
137 |
|
cr->line_to(d->Crossfade.out_start / 127.0 * (w - 3), 1.5); |
138 |
|
cr->line_to(d->Crossfade.out_end / 127.0 * (w - 3), h); |
139 |
|
|
140 |
|
if (pass == 0) { |
141 |
|
cr->set_source_rgba(0.5, 0.44, 1.0, sensitive ? 0.2 : 0.1); |
142 |
|
cr->fill(); |
143 |
|
} else { |
144 |
|
cr->set_line_width(3); |
145 |
|
cr->set_source_rgba(0.5, 0.44, 1.0, sensitive ? 1.0 : 0.3); |
146 |
|
cr->stroke(); |
147 |
|
} |
148 |
|
} |
149 |
|
} |
150 |
|
} |
151 |
|
|
152 |
|
|
153 |
DimRegionEdit::DimRegionEdit() : |
DimRegionEdit::DimRegionEdit() : |
154 |
|
velocity_curve(&gig::DimensionRegion::GetVelocityAttenuation), |
155 |
|
release_curve(&gig::DimensionRegion::GetVelocityRelease), |
156 |
|
cutoff_curve(&gig::DimensionRegion::GetVelocityCutoff), |
157 |
eEG1PreAttack(_("Pre-attack"), 0, 100, 2), |
eEG1PreAttack(_("Pre-attack"), 0, 100, 2), |
158 |
eEG1Attack(_("Attack"), 0, 60, 3), |
eEG1Attack(_("Attack"), 0, 60, 3), |
159 |
eEG1Decay1(_("Decay 1"), 0.005, 60, 3), |
eEG1Decay1(_("Decay 1"), 0.005, 60, 3), |
476 |
addProp(eCrossfade_out_start); |
addProp(eCrossfade_out_start); |
477 |
addProp(eCrossfade_out_end); |
addProp(eCrossfade_out_end); |
478 |
|
|
479 |
|
Gtk::Frame* frame = new Gtk::Frame; |
480 |
|
frame->add(crossfade_curve); |
481 |
|
table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1, |
482 |
|
Gtk::SHRINK, Gtk::SHRINK); |
483 |
|
rowno++; |
484 |
|
|
485 |
|
eCrossfade_in_start.signal_value_changed().connect( |
486 |
|
sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw)); |
487 |
|
eCrossfade_in_end.signal_value_changed().connect( |
488 |
|
sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw)); |
489 |
|
eCrossfade_out_start.signal_value_changed().connect( |
490 |
|
sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw)); |
491 |
|
eCrossfade_out_end.signal_value_changed().connect( |
492 |
|
sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw)); |
493 |
|
|
494 |
nextPage(); |
nextPage(); |
495 |
|
|
496 |
addHeader(_("General Filter Settings")); |
addHeader(_("General Filter Settings")); |
541 |
addProp(eVCFVelocityCurve); |
addProp(eVCFVelocityCurve); |
542 |
addProp(eVCFVelocityScale); |
addProp(eVCFVelocityScale); |
543 |
addProp(eVCFVelocityDynamicRange); |
addProp(eVCFVelocityDynamicRange); |
544 |
|
|
545 |
|
eVCFCutoffController.signal_value_changed().connect( |
546 |
|
sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw)); |
547 |
|
eVCFVelocityCurve.signal_value_changed().connect( |
548 |
|
sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw)); |
549 |
|
eVCFVelocityScale.signal_value_changed().connect( |
550 |
|
sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw)); |
551 |
|
eVCFVelocityDynamicRange.signal_value_changed().connect( |
552 |
|
sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw)); |
553 |
|
|
554 |
|
frame = new Gtk::Frame; |
555 |
|
frame->add(cutoff_curve); |
556 |
|
table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1, |
557 |
|
Gtk::SHRINK, Gtk::SHRINK); |
558 |
|
rowno++; |
559 |
|
|
560 |
addProp(eVCFResonance); |
addProp(eVCFResonance); |
561 |
addProp(eVCFResonanceDynamic); |
addProp(eVCFResonanceDynamic); |
562 |
{ |
{ |
639 |
|
|
640 |
nextPage(); |
nextPage(); |
641 |
|
|
642 |
|
addHeader(_("Velocity Reponse")); |
643 |
eVelocityResponseCurve.set_choices(curve_type_texts, curve_type_values); |
eVelocityResponseCurve.set_choices(curve_type_texts, curve_type_values); |
644 |
addProp(eVelocityResponseCurve); |
addProp(eVelocityResponseCurve); |
645 |
addProp(eVelocityResponseDepth); |
addProp(eVelocityResponseDepth); |
646 |
addProp(eVelocityResponseCurveScaling); |
addProp(eVelocityResponseCurveScaling); |
647 |
|
|
648 |
|
eVelocityResponseCurve.signal_value_changed().connect( |
649 |
|
sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw)); |
650 |
|
eVelocityResponseDepth.signal_value_changed().connect( |
651 |
|
sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw)); |
652 |
|
eVelocityResponseCurveScaling.signal_value_changed().connect( |
653 |
|
sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw)); |
654 |
|
|
655 |
|
frame = new Gtk::Frame; |
656 |
|
frame->add(velocity_curve); |
657 |
|
table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1, |
658 |
|
Gtk::SHRINK, Gtk::SHRINK); |
659 |
|
rowno++; |
660 |
|
|
661 |
|
addHeader(_("Release Velocity Reponse")); |
662 |
eReleaseVelocityResponseCurve.set_choices(curve_type_texts, |
eReleaseVelocityResponseCurve.set_choices(curve_type_texts, |
663 |
curve_type_values); |
curve_type_values); |
664 |
addProp(eReleaseVelocityResponseCurve); |
addProp(eReleaseVelocityResponseCurve); |
665 |
addProp(eReleaseVelocityResponseDepth); |
addProp(eReleaseVelocityResponseDepth); |
666 |
|
|
667 |
|
eReleaseVelocityResponseCurve.signal_value_changed().connect( |
668 |
|
sigc::mem_fun(release_curve, &VelocityCurve::queue_draw)); |
669 |
|
eReleaseVelocityResponseDepth.signal_value_changed().connect( |
670 |
|
sigc::mem_fun(release_curve, &VelocityCurve::queue_draw)); |
671 |
|
frame = new Gtk::Frame; |
672 |
|
frame->add(release_curve); |
673 |
|
table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1, |
674 |
|
Gtk::SHRINK, Gtk::SHRINK); |
675 |
|
rowno++; |
676 |
|
|
677 |
addProp(eReleaseTriggerDecay); |
addProp(eReleaseTriggerDecay); |
678 |
{ |
{ |
679 |
const char* choices[] = { _("none"), _("effect4depth"), _("effect5depth"), 0 }; |
const char* choices[] = { _("none"), _("effect4depth"), _("effect5depth"), 0 }; |
750 |
Gtk::Entry*& widget) |
Gtk::Entry*& widget) |
751 |
{ |
{ |
752 |
label = new Gtk::Label(Glib::ustring(labelText) + ":"); |
label = new Gtk::Label(Glib::ustring(labelText) + ":"); |
753 |
label->set_alignment(Gtk::ALIGN_LEFT); |
label->set_alignment(Gtk::ALIGN_START); |
754 |
|
|
755 |
table[pageno]->attach(*label, 1, 2, rowno, rowno + 1, |
table[pageno]->attach(*label, 1, 2, rowno, rowno + 1, |
756 |
Gtk::FILL, Gtk::SHRINK); |
Gtk::FILL, Gtk::SHRINK); |
776 |
str += "</b>"; |
str += "</b>"; |
777 |
Gtk::Label* label = new Gtk::Label(str); |
Gtk::Label* label = new Gtk::Label(str); |
778 |
label->set_use_markup(); |
label->set_use_markup(); |
779 |
label->set_alignment(Gtk::ALIGN_LEFT); |
label->set_alignment(Gtk::ALIGN_START); |
780 |
table[pageno]->attach(*label, 0, 3, rowno, rowno + 1, |
table[pageno]->attach(*label, 0, 3, rowno, rowno + 1, |
781 |
Gtk::FILL, Gtk::SHRINK); |
Gtk::FILL, Gtk::SHRINK); |
782 |
rowno++; |
rowno++; |
824 |
void DimRegionEdit::set_dim_region(gig::DimensionRegion* d) |
void DimRegionEdit::set_dim_region(gig::DimensionRegion* d) |
825 |
{ |
{ |
826 |
dimregion = d; |
dimregion = d; |
827 |
|
velocity_curve.set_dim_region(d); |
828 |
|
release_curve.set_dim_region(d); |
829 |
|
cutoff_curve.set_dim_region(d); |
830 |
|
crossfade_curve.set_dim_region(d); |
831 |
|
|
832 |
set_sensitive(d); |
set_sensitive(d); |
833 |
if (!d) return; |
if (!d) return; |
943 |
eVCFVelocityCurve.set_sensitive(sensitive); |
eVCFVelocityCurve.set_sensitive(sensitive); |
944 |
eVCFVelocityScale.set_sensitive(sensitive); |
eVCFVelocityScale.set_sensitive(sensitive); |
945 |
eVCFVelocityDynamicRange.set_sensitive(sensitive); |
eVCFVelocityDynamicRange.set_sensitive(sensitive); |
946 |
|
cutoff_curve.set_sensitive(sensitive); |
947 |
eVCFResonance.set_sensitive(sensitive); |
eVCFResonance.set_sensitive(sensitive); |
948 |
eVCFResonanceController.set_sensitive(sensitive); |
eVCFResonanceController.set_sensitive(sensitive); |
949 |
eVCFKeyboardTracking.set_sensitive(sensitive); |
eVCFKeyboardTracking.set_sensitive(sensitive); |
1036 |
eCrossfade_in_end.set_sensitive(hasController); |
eCrossfade_in_end.set_sensitive(hasController); |
1037 |
eCrossfade_out_start.set_sensitive(hasController); |
eCrossfade_out_start.set_sensitive(hasController); |
1038 |
eCrossfade_out_end.set_sensitive(hasController); |
eCrossfade_out_end.set_sensitive(hasController); |
1039 |
|
crossfade_curve.set_sensitive(hasController); |
1040 |
} |
} |
1041 |
|
|
1042 |
void DimRegionEdit::LFO1Controller_changed() |
void DimRegionEdit::LFO1Controller_changed() |