--- gigedit/trunk/src/gigedit/dimregionedit.cpp 2009/02/03 19:38:19 1831 +++ gigedit/trunk/src/gigedit/dimregionedit.cpp 2019/10/16 17:56:41 3632 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2009 Andreas Persson + * Copyright (C) 2006-2019 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 @@ -17,43 +17,363 @@ * 02110-1301 USA. */ +#include "global.h" #include "dimregionedit.h" -#include "global.h" +#include "compat.h" + +#if USE_GTKMM_GRID +# include +#else +# include +#endif + +#include "Settings.h" + +VelocityCurve::VelocityCurve(double (gig::DimensionRegion::*getter)(uint8_t)) : + getter(getter), dimreg(0) { + set_size_request(80, 80); +} + +#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 +bool VelocityCurve::on_expose_event(GdkEventExpose* e) { + const Cairo::RefPtr& cr = + get_window()->create_cairo_context(); +#else +bool VelocityCurve::on_draw(const Cairo::RefPtr& cr) { +#endif + if (dimreg) { + int w = get_width(); + int h = get_height(); + + for (int pass = 0 ; pass < 2 ; pass++) { + for (double x = 0 ; x <= w ; x++) { + int vel = int(x * (127 - 1e-10) / w + 1); + double y = (1 - (dimreg->*getter)(vel)) * (h - 3) + 1.5; + + if (x < 1e-10) { + cr->move_to(x, y); + } else { + cr->line_to(x, y); + } + } + if (pass == 0) { + cr->line_to(w, h); + cr->line_to(0, h); + cr->set_source_rgba(0.5, 0.44, 1.0, is_sensitive() ? 0.2 : 0.1); + cr->fill(); + } else { + cr->set_line_width(3); + cr->set_source_rgba(0.5, 0.44, 1.0, is_sensitive() ? 1.0 : 0.3); + cr->stroke(); + } + } + } + return true; +} + + +CrossfadeCurve::CrossfadeCurve() : dimreg(0) { + set_size_request(500, 100); +} + +#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 +bool CrossfadeCurve::on_expose_event(GdkEventExpose* e) { + const Cairo::RefPtr& cr = + get_window()->create_cairo_context(); +#else +bool CrossfadeCurve::on_draw(const Cairo::RefPtr& cr) { +#endif + if (dimreg) { + cr->translate(1.5, 0); + + // first, draw curves for the other layers + gig::Region* region = dimreg->GetParent(); + int dimregno; + for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) { + if (region->pDimensionRegions[dimregno] == dimreg) { + break; + } + } + int bitcount = 0; + for (int dim = 0 ; dim < region->Dimensions ; dim++) { + if (region->pDimensionDefinitions[dim].dimension == + gig::dimension_layer) { + int mask = + ~(((1 << region->pDimensionDefinitions[dim].bits) - 1) << + bitcount); + int c = dimregno & mask; // mask away the layer dimension + + for (int i = 0 ; i < region->pDimensionDefinitions[dim].zones ; + i++) { + gig::DimensionRegion* d = + region->pDimensionRegions[c + (i << bitcount)]; + if (d != dimreg) { + draw_one_curve(cr, d, false); + } + } + break; + } + bitcount += region->pDimensionDefinitions[dim].bits; + } + + // then, draw the currently selected layer + draw_one_curve(cr, dimreg, is_sensitive()); + } + return true; +} + +void CrossfadeCurve::draw_one_curve(const Cairo::RefPtr& cr, + const gig::DimensionRegion* d, + bool sensitive) { + int w = get_width(); + int h = get_height(); + + if (d->Crossfade.out_end) { + for (int pass = 0 ; pass < 2 ; pass++) { + cr->move_to(d->Crossfade.in_start / 127.0 * (w - 3), h); + cr->line_to(d->Crossfade.in_end / 127.0 * (w - 3), 1.5); + cr->line_to(d->Crossfade.out_start / 127.0 * (w - 3), 1.5); + cr->line_to(d->Crossfade.out_end / 127.0 * (w - 3), h); + + if (pass == 0) { + cr->set_source_rgba(0.5, 0.44, 1.0, sensitive ? 0.2 : 0.1); + cr->fill(); + } else { + cr->set_line_width(3); + cr->set_source_rgba(0.5, 0.44, 1.0, sensitive ? 1.0 : 0.3); + cr->stroke(); + } + } + } +} + + +LFOGraph::LFOGraph() : dimreg(0) { + set_size_request(500, 100); +} + +#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 +bool LFOGraph::on_expose_event(GdkEventExpose* e) { + const Cairo::RefPtr& cr = + get_window()->create_cairo_context(); +#else +bool LFOGraph::on_draw(const Cairo::RefPtr& cr) { +#endif + if (dimreg) { + const int w = get_width(); + const int h = get_height(); + const bool sensitive = is_sensitive(); + const bool signedRange = this->signedRange(); + const float visiblePeriods = 5.f; // such that minimum LFO frequency 0.1 Hz draws exactly a half period + + // short-hand functions for setting colors + auto setGrayColor = [&] { + cr->set_source_rgba(0.88, 0.88, 0.88, sensitive ? 1.0 : 0.3); + }; + auto setBlackColor = [&] { + cr->set_source_rgba(0, 0, 0, sensitive ? 1.0 : 0.3); + }; + auto setGreenColor = [&] { + cr->set_source_rgba(94/255.f, 219/255.f, 80/255.f, sensitive ? 1.0 : 0.3); + }; + auto setRedColor = [&] { + cr->set_source_rgba(255.f, 44/255.f, 44/255.f, sensitive ? 1.0 : 0.3); + }; + /*auto setBlueColor = [&] { + cr->set_source_rgba(53/255.f, 167/255.f, 255.f, sensitive ? 1.0 : 0.3); + };*/ + auto setOrangeColor = [&] { + cr->set_source_rgba(255.f, 177/255.f, 82/255.f, sensitive ? 1.0 : 0.3); + }; + auto setWhiteColor = [&] { + cr->set_source_rgba(255.f, 255.f, 255.f, sensitive ? 1.0 : 0.3); + }; + + // fill background white + cr->rectangle(0, 0, w, h); + setWhiteColor(); + cr->fill(); + + // draw horizontal center line (dashed gray) if LFO range is signed + if (signedRange) { + cr->move_to(0, h/2); + cr->line_to(w, h/2); + cr->set_line_width(2); + setGrayColor(); + cr->set_dash(std::vector{ 7, 5 }, 0 /*offset*/); + cr->stroke(); + } + + // draw a vertical line for each second + for (int period = 1; period < visiblePeriods; ++period) { + int x = float(w) / float(visiblePeriods) * period; + cr->move_to(x, 0); + cr->line_to(x, h); + cr->set_line_width(2); + setGrayColor(); + cr->set_dash(std::vector{ 5, 3 }, 0 /*offset*/); + cr->stroke(); + } + + // how many curves shall we draw, two or one? + const int runs = (hasControllerAssigned()) ? 2 : 1; + // only draw the two curves in dashed style if they're very close to each other + const bool dashedCurves = (runs == 2 && controllerDepth() < 63); + // draw the required amount of curves + for (int run = 0; run < runs; ++run) { + // setup the LFO generator with the relevant parameters + lfo.setup({ + .waveType = waveType(), + .rangeType = (signedRange) ? LinuxSampler::LFO::range_signed : LinuxSampler::LFO::range_unsigned, + .frequency = frequency(), + .phase = phase(), + .startLevel = startLevel(), + .internalDepth = internalDepth(), + .midiControllerDepth = controllerDepth(), + .flipPolarity = flipPolarity(), + .samplerate = w / visiblePeriods, + .maxValue = (signedRange) ? h/2 : h, + }); + // 1st curve reflects min. CC value, 2nd curve max. CC value + lfo.setMIDICtrlValue( (run == 0) ? 0 : 127 ); + + // the actual render/draw loop + for (int x = 0; x < w ; ++x) { + const float y = + (signedRange) ? + h/2 - lfo.render() : + h - lfo.render(); + if (x == 0) + cr->move_to(x, y); + else + cr->line_to(x, y); + } + cr->set_line_width( (frequency() <= 4.f) ? 2 : 1 ); + if (runs == 1) + setOrangeColor(); + else if (run == 0) + setGreenColor(); + else + setRedColor(); + if (dashedCurves) + cr->set_dash(std::vector{ 3, 3 }, (run == 0) ? 0 : 3 /*offset*/); + else + cr->set_dash(std::vector(), 0 /*offset*/); + cr->stroke(); + } + + // draw text legend + if (runs == 2) { + setRedColor(); + cr->move_to(2, 10); + cr->show_text("CC Max."); + + setGreenColor(); + cr->move_to(2, 23); + cr->show_text("CC Min."); + } else { // no controller assigned, internal depth only ... + setOrangeColor(); + cr->move_to(2, 10); + cr->show_text("Const. Depth"); + } + // draw text legend for each second ("1s", "2s", ...) + for (int period = 1; period < visiblePeriods; ++period) { + int x = float(w) / float(visiblePeriods) * period; + setBlackColor(); + cr->move_to(x - 13, h - 3); + cr->show_text(ToString(period) + "s"); + } + } + return true; +} + + +EGStateOptions::EGStateOptions() : HBox(), + label(_("May be cancelled: ")), + checkBoxAttack(_("Attack")), + checkBoxAttackHold(_("Attack Hold")), + checkBoxDecay1(_("Decay 1")), + checkBoxDecay2(_("Decay 2")), + checkBoxRelease(_("Release")) +{ + set_spacing(6); + + pack_start(label); + pack_start(checkBoxAttack, Gtk::PACK_SHRINK); + pack_start(checkBoxAttackHold, Gtk::PACK_SHRINK); + pack_start(checkBoxDecay1, Gtk::PACK_SHRINK); + pack_start(checkBoxDecay2, Gtk::PACK_SHRINK); + pack_start(checkBoxRelease, Gtk::PACK_SHRINK); + + checkBoxAttack.set_tooltip_text(_( + "If checked: a note-off aborts the 'attack' stage." + )); + checkBoxAttackHold.set_tooltip_text(_( + "If checked: a note-off aborts the 'attack hold' stage." + )); + checkBoxDecay1.set_tooltip_text(_( + "If checked: a note-off aborts the 'decay 1' stage." + )); + checkBoxDecay2.set_tooltip_text(_( + "If checked: a note-off aborts the 'decay 2' stage." + )); + checkBoxRelease.set_tooltip_text(_( + "If checked: a note-on reverts back from the 'release' stage." + )); +} + +void EGStateOptions::on_show_tooltips_changed() { + const bool b = Settings::singleton()->showTooltips; + + checkBoxAttack.set_has_tooltip(b); + checkBoxAttackHold.set_has_tooltip(b); + checkBoxDecay1.set_has_tooltip(b); + checkBoxDecay2.set_has_tooltip(b); + checkBoxRelease.set_has_tooltip(b); +} + DimRegionEdit::DimRegionEdit() : - eEG1PreAttack(_("Pre-attack"), 0, 100, 2), - eEG1Attack(_("Attack"), 0, 60, 3), - eEG1Decay1(_("Decay 1"), 0.005, 60, 3), - eEG1Decay2(_("Decay 2"), 0, 60, 3), + velocity_curve(&gig::DimensionRegion::GetVelocityAttenuation), + release_curve(&gig::DimensionRegion::GetVelocityRelease), + cutoff_curve(&gig::DimensionRegion::GetVelocityCutoff), + eEG1PreAttack(_("Pre-attack Level (%)"), 0, 100, 2), + eEG1Attack(_("Attack Time (seconds)"), 0, 60, 3), + eEG1Decay1(_("Decay 1 Time (seconds)"), 0.005, 60, 3), + eEG1Decay2(_("Decay 2 Time (seconds)"), 0, 60, 3), eEG1InfiniteSustain(_("Infinite sustain")), - eEG1Sustain(_("Sustain"), 0, 100, 2), - eEG1Release(_("Release"), 0, 60, 3), - eEG1Hold(_("Hold")), + eEG1Sustain(_("Sustain Level (%)"), 0, 100, 2), + eEG1Release(_("Release Time (seconds)"), 0, 60, 3), + eEG1Hold(_("Hold Attack Stage until Loop End")), eEG1Controller(_("Controller")), eEG1ControllerInvert(_("Controller invert")), eEG1ControllerAttackInfluence(_("Controller attack influence"), 0, 3), eEG1ControllerDecayInfluence(_("Controller decay influence"), 0, 3), eEG1ControllerReleaseInfluence(_("Controller release influence"), 0, 3), + eLFO1Wave(_("Wave Form")), eLFO1Frequency(_("Frequency"), 0.1, 10, 2), + eLFO1Phase(_("Phase"), 0.0, 360.0, 2), eLFO1InternalDepth(_("Internal depth"), 0, 1200), eLFO1ControlDepth(_("Control depth"), 0, 1200), eLFO1Controller(_("Controller")), eLFO1FlipPhase(_("Flip phase")), eLFO1Sync(_("Sync")), - eEG2PreAttack(_("Pre-attack"), 0, 100, 2), - eEG2Attack(_("Attack"), 0, 60, 3), - eEG2Decay1(_("Decay 1"), 0.005, 60, 3), - eEG2Decay2(_("Decay 2"), 0, 60, 3), + eEG2PreAttack(_("Pre-attack Level (%)"), 0, 100, 2), + eEG2Attack(_("Attack Time (seconds)"), 0, 60, 3), + eEG2Decay1(_("Decay 1 Time (seconds)"), 0.005, 60, 3), + eEG2Decay2(_("Decay 2 Time (seconds)"), 0, 60, 3), eEG2InfiniteSustain(_("Infinite sustain")), - eEG2Sustain(_("Sustain"), 0, 100, 2), - eEG2Release(_("Release"), 0, 60, 3), + eEG2Sustain(_("Sustain Level (%)"), 0, 100, 2), + eEG2Release(_("Release Time (seconds)"), 0, 60, 3), eEG2Controller(_("Controller")), eEG2ControllerInvert(_("Controller invert")), eEG2ControllerAttackInfluence(_("Controller attack influence"), 0, 3), eEG2ControllerDecayInfluence(_("Controller decay influence"), 0, 3), eEG2ControllerReleaseInfluence(_("Controller release influence"), 0, 3), + eLFO2Wave(_("Wave Form")), eLFO2Frequency(_("Frequency"), 0.1, 10, 2), + eLFO2Phase(_("Phase"), 0.0, 360.0, 2), eLFO2InternalDepth(_("Internal depth"), 0, 1200), eLFO2ControlDepth(_("Control depth"), 0, 1200), eLFO2Controller(_("Controller")), @@ -61,10 +381,13 @@ eLFO2Sync(_("Sync")), eEG3Attack(_("Attack"), 0, 10, 3), eEG3Depth(_("Depth"), -1200, 1200), + eLFO3Wave(_("Wave Form")), eLFO3Frequency(_("Frequency"), 0.1, 10, 2), + eLFO3Phase(_("Phase"), 0.0, 360.0, 2), eLFO3InternalDepth(_("Internal depth"), 0, 1200), eLFO3ControlDepth(_("Control depth"), 0, 1200), eLFO3Controller(_("Controller")), + eLFO3FlipPhase(_("Flip phase")), eLFO3Sync(_("Sync")), eVCFEnabled(_("Enabled")), eVCFType(_("Type")), @@ -90,28 +413,39 @@ eCrossfade_out_start(_("Crossfade-out start")), eCrossfade_out_end(_("Crossfade-out end")), ePitchTrack(_("Pitch track")), + eSustainReleaseTrigger(_("Sustain Release Trigger")), + eNoNoteOffReleaseTrigger(_("No note-off release trigger")), eDimensionBypass(_("Dimension bypass")), ePan(_("Pan"), -64, 63), - eSelfMask(_("Self mask")), + eSelfMask(_("Kill lower velocity voices (a.k.a \"Self mask\")")), eAttenuationController(_("Attenuation controller")), eInvertAttenuationController(_("Invert attenuation controller")), eAttenuationControllerThreshold(_("Attenuation controller threshold")), eChannelOffset(_("Channel offset"), 0, 9), - eSustainDefeat(_("Sustain defeat")), - eMSDecode(_("MS decode")), + eSustainDefeat(_("Ignore Hold Pedal (a.k.a. \"Sustain defeat\")")), + eMSDecode(_("Decode Mid/Side Recordings")), eSampleStartOffset(_("Sample start offset"), 0, 2000), eUnityNote(_("Unity note")), + eSampleGroup(_("Sample Group")), + eSampleFormatInfo(_("Sample Format")), + eSampleID("Sample ID"), + eChecksum("Wave Data CRC-32"), eFineTune(_("Fine tune"), -49, 50), eGain(_("Gain"), -96, 0, 2, -655360), eGainPlus6(_("Gain +6dB"), eGain, 6 * -655360), eSampleLoopEnabled(_("Enabled")), - eSampleLoopStart(_("Loop start positon")), + eSampleLoopStart(_("Loop start position")), eSampleLoopLength(_("Loop size")), eSampleLoopType(_("Loop type")), eSampleLoopInfinite(_("Infinite loop")), eSampleLoopPlayCount(_("Playback count"), 1), + buttonSelectSample(UNICODE_LEFT_ARROW + " " + _("Select Sample")), update_model(0) { + // make synthesis parameter page tabs scrollable + // (workaround for GTK3: default theme uses huge tabs which breaks layout) + set_scrollable(); + connect(eEG1PreAttack, &gig::DimensionRegion::EG1PreAttack); connect(eEG1Attack, &gig::DimensionRegion::EG1Attack); connect(eEG1Decay1, &gig::DimensionRegion::EG1Decay1); @@ -128,7 +462,19 @@ &gig::DimensionRegion::EG1ControllerDecayInfluence); connect(eEG1ControllerReleaseInfluence, &gig::DimensionRegion::EG1ControllerReleaseInfluence); + connect(eEG1StateOptions.checkBoxAttack, &gig::DimensionRegion::EG1Options, + &gig::eg_opt_t::AttackCancel); + connect(eEG1StateOptions.checkBoxAttackHold, &gig::DimensionRegion::EG1Options, + &gig::eg_opt_t::AttackHoldCancel); + connect(eEG1StateOptions.checkBoxDecay1, &gig::DimensionRegion::EG1Options, + &gig::eg_opt_t::Decay1Cancel); + connect(eEG1StateOptions.checkBoxDecay2, &gig::DimensionRegion::EG1Options, + &gig::eg_opt_t::Decay2Cancel); + connect(eEG1StateOptions.checkBoxRelease, &gig::DimensionRegion::EG1Options, + &gig::eg_opt_t::ReleaseCancel); + connect(eLFO1Wave, &gig::DimensionRegion::LFO1WaveForm); connect(eLFO1Frequency, &gig::DimensionRegion::LFO1Frequency); + connect(eLFO1Phase, &gig::DimensionRegion::LFO1Phase); connect(eLFO1InternalDepth, &gig::DimensionRegion::LFO1InternalDepth); connect(eLFO1ControlDepth, &gig::DimensionRegion::LFO1ControlDepth); connect(eLFO1Controller, &gig::DimensionRegion::LFO1Controller); @@ -149,7 +495,19 @@ &gig::DimensionRegion::EG2ControllerDecayInfluence); connect(eEG2ControllerReleaseInfluence, &gig::DimensionRegion::EG2ControllerReleaseInfluence); + connect(eEG2StateOptions.checkBoxAttack, &gig::DimensionRegion::EG2Options, + &gig::eg_opt_t::AttackCancel); + connect(eEG2StateOptions.checkBoxAttackHold, &gig::DimensionRegion::EG2Options, + &gig::eg_opt_t::AttackHoldCancel); + connect(eEG2StateOptions.checkBoxDecay1, &gig::DimensionRegion::EG2Options, + &gig::eg_opt_t::Decay1Cancel); + connect(eEG2StateOptions.checkBoxDecay2, &gig::DimensionRegion::EG2Options, + &gig::eg_opt_t::Decay2Cancel); + connect(eEG2StateOptions.checkBoxRelease, &gig::DimensionRegion::EG2Options, + &gig::eg_opt_t::ReleaseCancel); + connect(eLFO2Wave, &gig::DimensionRegion::LFO2WaveForm); connect(eLFO2Frequency, &gig::DimensionRegion::LFO2Frequency); + connect(eLFO2Phase, &gig::DimensionRegion::LFO2Phase); connect(eLFO2InternalDepth, &gig::DimensionRegion::LFO2InternalDepth); connect(eLFO2ControlDepth, &gig::DimensionRegion::LFO2ControlDepth); connect(eLFO2Controller, &gig::DimensionRegion::LFO2Controller); @@ -157,10 +515,13 @@ connect(eLFO2Sync, &gig::DimensionRegion::LFO2Sync); connect(eEG3Attack, &gig::DimensionRegion::EG3Attack); connect(eEG3Depth, &gig::DimensionRegion::EG3Depth); + connect(eLFO3Wave, &gig::DimensionRegion::LFO3WaveForm); connect(eLFO3Frequency, &gig::DimensionRegion::LFO3Frequency); + connect(eLFO3Phase, &gig::DimensionRegion::LFO3Phase); connect(eLFO3InternalDepth, &gig::DimensionRegion::LFO3InternalDepth); connect(eLFO3ControlDepth, &gig::DimensionRegion::LFO3ControlDepth); connect(eLFO3Controller, &gig::DimensionRegion::LFO3Controller); + connect(eLFO3FlipPhase, &gig::DimensionRegion::LFO3FlipPhase); connect(eLFO3Sync, &gig::DimensionRegion::LFO3Sync); connect(eVCFEnabled, &gig::DimensionRegion::VCFEnabled); connect(eVCFType, &gig::DimensionRegion::VCFType); @@ -196,6 +557,8 @@ connect(eCrossfade_out_start, &DimRegionEdit::set_Crossfade_out_start); connect(eCrossfade_out_end, &DimRegionEdit::set_Crossfade_out_end); connect(ePitchTrack, &gig::DimensionRegion::PitchTrack); + connect(eSustainReleaseTrigger, &gig::DimensionRegion::SustainReleaseTrigger); + connect(eNoNoteOffReleaseTrigger, &gig::DimensionRegion::NoNoteOffReleaseTrigger); connect(eDimensionBypass, &gig::DimensionRegion::DimensionBypass); connect(ePan, &gig::DimensionRegion::Pan); connect(eSelfMask, &gig::DimensionRegion::SelfMask); @@ -219,16 +582,38 @@ connect(eSampleLoopLength, &DimRegionEdit::set_LoopLength); connect(eSampleLoopInfinite, &DimRegionEdit::set_LoopInfinite); connect(eSampleLoopPlayCount, &DimRegionEdit::set_LoopPlayCount); + buttonSelectSample.signal_clicked().connect( + sigc::mem_fun(*this, &DimRegionEdit::onButtonSelectSamplePressed) + ); - for (int i = 0 ; i < 7 ; i++) { + for (int i = 0 ; i < 9 ; i++) { +#if USE_GTKMM_GRID + table[i] = new Gtk::Grid; + table[i]->set_column_spacing(7); +#else table[i] = new Gtk::Table(3, 1); table[i]->set_col_spacings(7); +#endif + +// on Gtk 3 there is absolutely no margin by default +#if GTKMM_MAJOR_VERSION >= 3 +# if GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION < 12 + table[i]->set_margin_left(12); + table[i]->set_margin_right(12); +# else + table[i]->set_margin_start(12); + table[i]->set_margin_end(12); +# endif +#endif } // set tooltips eUnityNote.set_tip( _("Note this sample is associated with (a.k.a. 'root note')") ); + buttonSelectSample.set_tooltip_text( + _("Selects the sample of this dimension region on the left hand side's sample tree view.") + ); eSampleStartOffset.set_tip(_("Sample position at which playback should be started")); ePan.set_tip(_("Stereo balance (left/right)")); eChannelOffset.set_tip( @@ -259,16 +644,80 @@ "Caution: this setting is stored on Sample side, thus is shared " "among all dimension regions that use this sample!") ); + + eEG1PreAttack.set_tip( + "Very first level this EG starts with. It rises then in Attack Time " + "seconds from this initial level to 100%." + ); + eEG1Attack.set_tip( + "Duration of the EG's Attack stage, which raises its level from " + "Pre-Attack Level to 100%." + ); + eEG1Hold.set_tip( + "On looped sounds, enabling this will cause the Decay 1 stage not to " + "enter before the loop has been passed one time." + ); + eAttenuationController.set_tip(_( + "If you are not using the 'Layer' dimension, then this controller " + "simply alters the volume. If you are using the 'Layer' dimension, " + "then this controller is controlling the crossfade between Layers in " + "real-time." + )); + + eLFO1Sync.set_tip( + "If not checked, every voice will use its own LFO instance, which " + "causes voices triggered at different points in time to have different " + "LFO levels. By enabling 'Sync' here the voices will instead use and " + "share one single LFO, causing all voices to have the same LFO level, " + "no matter when the individual notes have been triggered." + ); + eLFO2Sync.set_tip( + "If not checked, every voice will use its own LFO instance, which " + "causes voices triggered at different points in time to have different " + "LFO levels. By enabling 'Sync' here the voices will instead use and " + "share one single LFO, causing all voices to have the same LFO level, " + "no matter when the individual notes have been triggered." + ); + eLFO3Sync.set_tip( + "If not checked, every voice will use its own LFO instance, which " + "causes voices triggered at different points in time to have different " + "LFO levels. By enabling 'Sync' here the voices will instead use and " + "share one single LFO, causing all voices to have the same LFO level, " + "no matter when the individual notes have been triggered." + ); + eLFO1FlipPhase.set_tip( + "Inverts the LFO's generated wave vertically." + ); + eLFO2FlipPhase.set_tip( + "Inverts the LFO's generated wave vertically." + ); + eLFO3FlipPhase.set_tip( + "Inverts the LFO's generated wave vertically." + ); pageno = 0; rowno = 0; firstRowInBlock = 0; addHeader(_("Mandatory Settings")); - addString(_("Sample"), lSample, wSample); + addString(_("Sample"), lSample, wSample, buttonNullSampleReference); + buttonNullSampleReference->set_label("X"); + 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.")); + buttonNullSampleReference->signal_clicked().connect( + sigc::mem_fun(*this, &DimRegionEdit::nullOutSampleReference) + ); //TODO: the following would break drag&drop: wSample->property_editable().set_value(false); or this: wSample->set_editable(false); - tooltips.set_tip(*wSample, _("Drop a sample here")); +#ifdef OLD_TOOLTIPS + tooltips.set_tip(*wSample, _("Drag & drop a sample here")); +#else + wSample->set_tooltip_text(_("Drag & drop a sample here")); +#endif addProp(eUnityNote); + addProp(eSampleGroup); + addProp(eSampleFormatInfo); + addProp(eSampleID); + addProp(eChecksum); + addRightHandSide(buttonSelectSample); addHeader(_("Optional Settings")); addProp(eSampleStartOffset); addProp(eChannelOffset); @@ -298,22 +747,25 @@ addHeader(_("Amplitude Envelope (EG1)")); addProp(eEG1PreAttack); addProp(eEG1Attack); + addProp(eEG1Hold); addProp(eEG1Decay1); addProp(eEG1Decay2); addProp(eEG1InfiniteSustain); addProp(eEG1Sustain); addProp(eEG1Release); - addProp(eEG1Hold); addProp(eEG1Controller); addProp(eEG1ControllerInvert); addProp(eEG1ControllerAttackInfluence); addProp(eEG1ControllerDecayInfluence); addProp(eEG1ControllerReleaseInfluence); + addLine(eEG1StateOptions); nextPage(); addHeader(_("Amplitude Oscillator (LFO1)")); + addProp(eLFO1Wave); addProp(eLFO1Frequency); + addProp(eLFO1Phase); addProp(eLFO1InternalDepth); addProp(eLFO1ControlDepth); { @@ -331,6 +783,49 @@ addProp(eLFO1Controller); addProp(eLFO1FlipPhase); addProp(eLFO1Sync); + { + Gtk::Frame* frame = new Gtk::Frame; + frame->add(lfo1Graph); + // on Gtk 3 there is no margin at all by default +#if GTKMM_MAJOR_VERSION >= 3 + frame->set_margin_top(12); + frame->set_margin_bottom(12); +#endif +#if USE_GTKMM_GRID + table[pageno]->attach(*frame, 1, rowno, 2); +#else + table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1, + Gtk::SHRINK, Gtk::SHRINK); +#endif + rowno++; + } + eLFO1Wave.signal_value_changed().connect( + sigc::mem_fun(lfo1Graph, &LFOGraph::queue_draw) + ); + eLFO1Frequency.signal_value_changed().connect( + sigc::mem_fun(lfo1Graph, &LFOGraph::queue_draw) + ); + eLFO1Phase.signal_value_changed().connect( + sigc::mem_fun(lfo1Graph, &LFOGraph::queue_draw) + ); + eLFO1InternalDepth.signal_value_changed().connect( + sigc::mem_fun(lfo1Graph, &LFOGraph::queue_draw) + ); + eLFO1ControlDepth.signal_value_changed().connect( + sigc::mem_fun(lfo1Graph, &LFOGraph::queue_draw) + ); + eLFO1Controller.signal_value_changed().connect( + sigc::mem_fun(lfo1Graph, &LFOGraph::queue_draw) + ); + eLFO1FlipPhase.signal_value_changed().connect( + sigc::mem_fun(lfo1Graph, &LFOGraph::queue_draw) + ); + eLFO1Sync.signal_value_changed().connect( + sigc::mem_fun(lfo1Graph, &LFOGraph::queue_draw) + ); + + nextPage(); + addHeader(_("Crossfade")); addProp(eAttenuationController); addProp(eInvertAttenuationController); @@ -340,6 +835,30 @@ addProp(eCrossfade_out_start); addProp(eCrossfade_out_end); + Gtk::Frame* frame = new Gtk::Frame; + frame->add(crossfade_curve); + // on Gtk 3 there is no margin at all by default +#if GTKMM_MAJOR_VERSION >= 3 + frame->set_margin_top(12); + frame->set_margin_bottom(12); +#endif +#if USE_GTKMM_GRID + table[pageno]->attach(*frame, 1, rowno, 2); +#else + table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1, + Gtk::SHRINK, Gtk::SHRINK); +#endif + rowno++; + + eCrossfade_in_start.signal_value_changed().connect( + sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw)); + eCrossfade_in_end.signal_value_changed().connect( + sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw)); + eCrossfade_out_start.signal_value_changed().connect( + sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw)); + eCrossfade_out_end.signal_value_changed().connect( + sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw)); + nextPage(); addHeader(_("General Filter Settings")); @@ -390,6 +909,31 @@ addProp(eVCFVelocityCurve); addProp(eVCFVelocityScale); addProp(eVCFVelocityDynamicRange); + + eVCFCutoffController.signal_value_changed().connect( + sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw)); + eVCFVelocityCurve.signal_value_changed().connect( + sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw)); + eVCFVelocityScale.signal_value_changed().connect( + sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw)); + eVCFVelocityDynamicRange.signal_value_changed().connect( + sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw)); + + frame = new Gtk::Frame; + frame->add(cutoff_curve); + // on Gtk 3 there is no margin at all by default +#if GTKMM_MAJOR_VERSION >= 3 + frame->set_margin_top(12); + frame->set_margin_bottom(12); +#endif +#if USE_GTKMM_GRID + table[pageno]->attach(*frame, 1, rowno, 2); +#else + table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1, + Gtk::SHRINK, Gtk::SHRINK); +#endif + rowno++; + addProp(eVCFResonance); addProp(eVCFResonanceDynamic); { @@ -423,8 +967,14 @@ addProp(eEG2ControllerAttackInfluence); addProp(eEG2ControllerDecayInfluence); addProp(eEG2ControllerReleaseInfluence); + addLine(eEG2StateOptions); + + nextPage(); + lLFO2 = addHeader(_("Filter Cutoff Oscillator (LFO2)")); + addProp(eLFO2Wave); addProp(eLFO2Frequency); + addProp(eLFO2Phase); addProp(eLFO2InternalDepth); addProp(eLFO2ControlDepth); { @@ -442,6 +992,46 @@ addProp(eLFO2Controller); addProp(eLFO2FlipPhase); addProp(eLFO2Sync); + { + Gtk::Frame* frame = new Gtk::Frame; + frame->add(lfo2Graph); + // on Gtk 3 there is no margin at all by default +#if GTKMM_MAJOR_VERSION >= 3 + frame->set_margin_top(12); + frame->set_margin_bottom(12); +#endif +#if USE_GTKMM_GRID + table[pageno]->attach(*frame, 1, rowno, 2); +#else + table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1, + Gtk::SHRINK, Gtk::SHRINK); +#endif + rowno++; + } + eLFO2Wave.signal_value_changed().connect( + sigc::mem_fun(lfo2Graph, &LFOGraph::queue_draw) + ); + eLFO2Frequency.signal_value_changed().connect( + sigc::mem_fun(lfo2Graph, &LFOGraph::queue_draw) + ); + eLFO2Phase.signal_value_changed().connect( + sigc::mem_fun(lfo2Graph, &LFOGraph::queue_draw) + ); + eLFO2InternalDepth.signal_value_changed().connect( + sigc::mem_fun(lfo2Graph, &LFOGraph::queue_draw) + ); + eLFO2ControlDepth.signal_value_changed().connect( + sigc::mem_fun(lfo2Graph, &LFOGraph::queue_draw) + ); + eLFO2Controller.signal_value_changed().connect( + sigc::mem_fun(lfo2Graph, &LFOGraph::queue_draw) + ); + eLFO2FlipPhase.signal_value_changed().connect( + sigc::mem_fun(lfo2Graph, &LFOGraph::queue_draw) + ); + eLFO2Sync.signal_value_changed().connect( + sigc::mem_fun(lfo2Graph, &LFOGraph::queue_draw) + ); nextPage(); @@ -452,7 +1042,9 @@ addProp(eEG3Attack); addProp(eEG3Depth); addHeader(_("Pitch Oscillator (LFO3)")); + addProp(eLFO3Wave); addProp(eLFO3Frequency); + addProp(eLFO3Phase); addProp(eLFO3InternalDepth); addProp(eLFO3ControlDepth); { @@ -468,20 +1060,121 @@ eLFO3Controller.set_choices(choices, values); } addProp(eLFO3Controller); + addProp(eLFO3FlipPhase); addProp(eLFO3Sync); + { + Gtk::Frame* frame = new Gtk::Frame; + frame->add(lfo3Graph); + // on Gtk 3 there is no margin at all by default +#if GTKMM_MAJOR_VERSION >= 3 + frame->set_margin_top(12); + frame->set_margin_bottom(12); +#endif +#if USE_GTKMM_GRID + table[pageno]->attach(*frame, 1, rowno, 2); +#else + table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1, + Gtk::SHRINK, Gtk::SHRINK); +#endif + rowno++; + } + eLFO3Wave.signal_value_changed().connect( + sigc::mem_fun(lfo3Graph, &LFOGraph::queue_draw) + ); + eLFO3Frequency.signal_value_changed().connect( + sigc::mem_fun(lfo3Graph, &LFOGraph::queue_draw) + ); + eLFO3Phase.signal_value_changed().connect( + sigc::mem_fun(lfo3Graph, &LFOGraph::queue_draw) + ); + eLFO3InternalDepth.signal_value_changed().connect( + sigc::mem_fun(lfo3Graph, &LFOGraph::queue_draw) + ); + eLFO3ControlDepth.signal_value_changed().connect( + sigc::mem_fun(lfo3Graph, &LFOGraph::queue_draw) + ); + eLFO3Controller.signal_value_changed().connect( + sigc::mem_fun(lfo3Graph, &LFOGraph::queue_draw) + ); + eLFO3FlipPhase.signal_value_changed().connect( + sigc::mem_fun(lfo3Graph, &LFOGraph::queue_draw) + ); + eLFO3Sync.signal_value_changed().connect( + sigc::mem_fun(lfo3Graph, &LFOGraph::queue_draw) + ); nextPage(); + addHeader(_("Velocity Response")); eVelocityResponseCurve.set_choices(curve_type_texts, curve_type_values); addProp(eVelocityResponseCurve); addProp(eVelocityResponseDepth); addProp(eVelocityResponseCurveScaling); + + eVelocityResponseCurve.signal_value_changed().connect( + sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw)); + eVelocityResponseDepth.signal_value_changed().connect( + sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw)); + eVelocityResponseCurveScaling.signal_value_changed().connect( + sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw)); + + frame = new Gtk::Frame; + frame->add(velocity_curve); + // on Gtk 3 there is no margin at all by default +#if GTKMM_MAJOR_VERSION >= 3 + frame->set_margin_top(12); + frame->set_margin_bottom(12); +#endif +#if USE_GTKMM_GRID + table[pageno]->attach(*frame, 1, rowno, 2); +#else + table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1, + Gtk::SHRINK, Gtk::SHRINK); +#endif + rowno++; + + addHeader(_("Release Velocity Response")); eReleaseVelocityResponseCurve.set_choices(curve_type_texts, curve_type_values); addProp(eReleaseVelocityResponseCurve); addProp(eReleaseVelocityResponseDepth); + + eReleaseVelocityResponseCurve.signal_value_changed().connect( + sigc::mem_fun(release_curve, &VelocityCurve::queue_draw)); + eReleaseVelocityResponseDepth.signal_value_changed().connect( + sigc::mem_fun(release_curve, &VelocityCurve::queue_draw)); + frame = new Gtk::Frame; + frame->add(release_curve); + // on Gtk 3 there is no margin at all by default +#if GTKMM_MAJOR_VERSION >= 3 + frame->set_margin_top(12); + frame->set_margin_bottom(12); +#endif +#if USE_GTKMM_GRID + table[pageno]->attach(*frame, 1, rowno, 2); +#else + table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1, + Gtk::SHRINK, Gtk::SHRINK); +#endif + rowno++; + addProp(eReleaseTriggerDecay); { + const char* choices[] = { _("off"), _("on (max. velocity)"), _("on (key velocity)"), 0 }; + static const gig::sust_rel_trg_t values[] = { + gig::sust_rel_trg_none, + gig::sust_rel_trg_maxvelocity, + gig::sust_rel_trg_keyvelocity + }; + eSustainReleaseTrigger.set_choices(choices, values); + } + eSustainReleaseTrigger.set_tip(_( + "By default release trigger samples are played on note-off events only. " + "This option allows to play release trigger sample on sustain pedal up " + "events as well. NOTE: This is a format extension!" + )); + addProp(eSustainReleaseTrigger); + { const char* choices[] = { _("none"), _("effect4depth"), _("effect5depth"), 0 }; static const gig::dim_bypass_ctrl_t values[] = { gig::dim_bypass_ctrl_none, @@ -490,9 +1183,31 @@ }; eDimensionBypass.set_choices(choices, values); } + eNoNoteOffReleaseTrigger.set_tip(_( + "By default release trigger samples are played on note-off events only. " + "If this option is checked, then no release trigger sample is played " + "when releasing a note. NOTE: This is a format extension!" + )); + addProp(eNoNoteOffReleaseTrigger); addProp(eDimensionBypass); + eSelfMask.widget.set_tooltip_text(_( + "If enabled: new notes with higher velocity value will stop older " + "notes with lower velocity values, that way you can save voices that " + "would barely be audible. This is also useful for certain drum sounds." + )); addProp(eSelfMask); + eSustainDefeat.widget.set_tooltip_text(_( + "If enabled: sustain pedal will not hold a note. This way you can use " + "the sustain pedal for other purposes, for example to switch among " + "dimension regions." + )); addProp(eSustainDefeat); + eMSDecode.widget.set_tooltip_text(_( + "Defines if Mid/Side Recordings should be decoded. Mid/Side Recordings " + "are an alternative way to record sounds in stereo. The sampler needs " + "to decode such samples to actually make use of them. Note: this " + "feature is currently not supported by LinuxSampler." + )); addProp(eMSDecode); nextPage(); @@ -540,12 +1255,20 @@ sigc::mem_fun(*this, &DimRegionEdit::loop_infinite_toggled)); append_page(*table[0], _("Sample")); - append_page(*table[1], _("Amplitude (1)")); - append_page(*table[2], _("Amplitude (2)")); - append_page(*table[3], _("Filter (1)")); - append_page(*table[4], _("Filter (2)")); - append_page(*table[5], _("Pitch")); - append_page(*table[6], _("Misc")); + append_page(*table[1], _("Amp (1)")); + append_page(*table[2], _("Amp (2)")); + append_page(*table[3], _("Amp (3)")); + append_page(*table[4], _("Filter (1)")); + append_page(*table[5], _("Filter (2)")); + append_page(*table[6], _("Filter (3)")); + append_page(*table[7], _("Pitch")); + append_page(*table[8], _("Misc")); + + Settings::singleton()->showTooltips.get_proxy().signal_changed().connect( + sigc::mem_fun(*this, &DimRegionEdit::on_show_tooltips_changed) + ); + + on_show_tooltips_changed(); } DimRegionEdit::~DimRegionEdit() @@ -556,15 +1279,61 @@ Gtk::Entry*& widget) { label = new Gtk::Label(Glib::ustring(labelText) + ":"); - label->set_alignment(Gtk::ALIGN_LEFT); - +#if HAS_GTKMM_ALIGNMENT + label->set_alignment(Gtk::ALIGN_START); +#else + label->set_halign(Gtk::Align::START); +#endif + +#if USE_GTKMM_GRID + table[pageno]->attach(*label, 1, rowno); +#else table[pageno]->attach(*label, 1, 2, rowno, rowno + 1, Gtk::FILL, Gtk::SHRINK); +#endif widget = new Gtk::Entry(); +#if USE_GTKMM_GRID + table[pageno]->attach(*widget, 2, rowno); +#else table[pageno]->attach(*widget, 2, 3, rowno, rowno + 1, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK); +#endif + + rowno++; +} + +void DimRegionEdit::addString(const char* labelText, Gtk::Label*& label, + Gtk::Entry*& widget, Gtk::Button*& button) +{ + label = new Gtk::Label(Glib::ustring(labelText) + ":"); +#if HAS_GTKMM_ALIGNMENT + label->set_alignment(Gtk::ALIGN_START); +#else + label->set_halign(Gtk::Align::START); +#endif + +#if USE_GTKMM_GRID + table[pageno]->attach(*label, 1, rowno); +#else + table[pageno]->attach(*label, 1, 2, rowno, rowno + 1, + Gtk::FILL, Gtk::SHRINK); +#endif + + widget = new Gtk::Entry(); + button = new Gtk::Button(); + + HBox* hbox = new HBox; + hbox->pack_start(*widget); + hbox->pack_start(*button, Gtk::PACK_SHRINK); + +#if USE_GTKMM_GRID + table[pageno]->attach(*hbox, 2, rowno); +#else + table[pageno]->attach(*hbox, 2, 3, rowno, rowno + 1, + Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK); +#endif rowno++; } @@ -574,29 +1343,63 @@ if (firstRowInBlock < rowno - 1) { Gtk::Label* filler = new Gtk::Label(" "); +#if USE_GTKMM_GRID + table[pageno]->attach(*filler, 0, firstRowInBlock); +#else table[pageno]->attach(*filler, 0, 1, firstRowInBlock, rowno, Gtk::FILL, Gtk::SHRINK); +#endif } Glib::ustring str = ""; str += text; str += ""; Gtk::Label* label = new Gtk::Label(str); label->set_use_markup(); - label->set_alignment(Gtk::ALIGN_LEFT); +#if HAS_GTKMM_ALIGNMENT + label->set_alignment(Gtk::ALIGN_START); +#else + label->set_halign(Gtk::Align::START); +#endif + // on GTKMM 3 there is absolutely no margin by default +#if GTKMM_MAJOR_VERSION >= 3 + label->set_margin_top(18); + label->set_margin_bottom(13); +#endif +#if USE_GTKMM_GRID + table[pageno]->attach(*label, 0, rowno, 3); +#else table[pageno]->attach(*label, 0, 3, rowno, rowno + 1, Gtk::FILL, Gtk::SHRINK); +#endif rowno++; firstRowInBlock = rowno; return label; } +void DimRegionEdit::on_show_tooltips_changed() { + const bool b = Settings::singleton()->showTooltips; + + buttonSelectSample.set_has_tooltip(b); + buttonNullSampleReference->set_has_tooltip(b); + wSample->set_has_tooltip(b); + + eEG1StateOptions.on_show_tooltips_changed(); + eEG2StateOptions.on_show_tooltips_changed(); + + set_has_tooltip(b); +} + void DimRegionEdit::nextPage() { if (firstRowInBlock < rowno - 1) { Gtk::Label* filler = new Gtk::Label(" "); +#if USE_GTKMM_GRID + table[pageno]->attach(*filler, 0, firstRowInBlock); +#else table[pageno]->attach(*filler, 0, 1, firstRowInBlock, rowno, Gtk::FILL, Gtk::SHRINK); +#endif } pageno++; rowno = 0; @@ -605,31 +1408,72 @@ void DimRegionEdit::addProp(BoolEntry& boolentry) { +#if USE_GTKMM_GRID + table[pageno]->attach(boolentry.widget, 1, rowno, 2); +#else table[pageno]->attach(boolentry.widget, 1, 3, rowno, rowno + 1, Gtk::FILL, Gtk::SHRINK); +#endif rowno++; } void DimRegionEdit::addProp(BoolEntryPlus6& boolentry) { +#if USE_GTKMM_GRID + table[pageno]->attach(boolentry.widget, 1, rowno, 2); +#else table[pageno]->attach(boolentry.widget, 1, 3, rowno, rowno + 1, Gtk::FILL, Gtk::SHRINK); +#endif rowno++; } void DimRegionEdit::addProp(LabelWidget& prop) { +#if USE_GTKMM_GRID + table[pageno]->attach(prop.label, 1, rowno); + table[pageno]->attach(prop.widget, 2, rowno); +#else table[pageno]->attach(prop.label, 1, 2, rowno, rowno + 1, Gtk::FILL, Gtk::SHRINK); table[pageno]->attach(prop.widget, 2, 3, rowno, rowno + 1, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK); +#endif rowno++; } +void DimRegionEdit::addLine(HBox& line) +{ +#if USE_GTKMM_GRID + table[pageno]->attach(line, 1, rowno, 2); +#else + table[pageno]->attach(line, 1, 3, rowno, rowno + 1, + Gtk::FILL, Gtk::SHRINK); +#endif + rowno++; +} + +void DimRegionEdit::addRightHandSide(Gtk::Widget& widget) +{ +#if USE_GTKMM_GRID + table[pageno]->attach(widget, 2, rowno); +#else + table[pageno]->attach(widget, 2, 3, rowno, rowno + 1, + Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK); +#endif + rowno++; +} void DimRegionEdit::set_dim_region(gig::DimensionRegion* d) { dimregion = d; + velocity_curve.set_dim_region(d); + release_curve.set_dim_region(d); + cutoff_curve.set_dim_region(d); + crossfade_curve.set_dim_region(d); + lfo1Graph.set_dim_region(d); + lfo2Graph.set_dim_region(d); + lfo3Graph.set_dim_region(d); set_sensitive(d); if (!d) return; @@ -648,7 +1492,14 @@ eEG1ControllerAttackInfluence.set_value(d->EG1ControllerAttackInfluence); eEG1ControllerDecayInfluence.set_value(d->EG1ControllerDecayInfluence); eEG1ControllerReleaseInfluence.set_value(d->EG1ControllerReleaseInfluence); + eEG1StateOptions.checkBoxAttack.set_value(d->EG1Options.AttackCancel); + eEG1StateOptions.checkBoxAttackHold.set_value(d->EG1Options.AttackHoldCancel); + eEG1StateOptions.checkBoxDecay1.set_value(d->EG1Options.Decay1Cancel); + eEG1StateOptions.checkBoxDecay2.set_value(d->EG1Options.Decay2Cancel); + eEG1StateOptions.checkBoxRelease.set_value(d->EG1Options.ReleaseCancel); + eLFO1Wave.set_value(d->LFO1WaveForm); eLFO1Frequency.set_value(d->LFO1Frequency); + eLFO1Phase.set_value(d->LFO1Phase); eLFO1InternalDepth.set_value(d->LFO1InternalDepth); eLFO1ControlDepth.set_value(d->LFO1ControlDepth); eLFO1Controller.set_value(d->LFO1Controller); @@ -666,7 +1517,14 @@ eEG2ControllerAttackInfluence.set_value(d->EG2ControllerAttackInfluence); eEG2ControllerDecayInfluence.set_value(d->EG2ControllerDecayInfluence); eEG2ControllerReleaseInfluence.set_value(d->EG2ControllerReleaseInfluence); + eEG2StateOptions.checkBoxAttack.set_value(d->EG2Options.AttackCancel); + eEG2StateOptions.checkBoxAttackHold.set_value(d->EG2Options.AttackHoldCancel); + eEG2StateOptions.checkBoxDecay1.set_value(d->EG2Options.Decay1Cancel); + eEG2StateOptions.checkBoxDecay2.set_value(d->EG2Options.Decay2Cancel); + eEG2StateOptions.checkBoxRelease.set_value(d->EG2Options.ReleaseCancel); + eLFO2Wave.set_value(d->LFO2WaveForm); eLFO2Frequency.set_value(d->LFO2Frequency); + eLFO2Phase.set_value(d->LFO2Phase); eLFO2InternalDepth.set_value(d->LFO2InternalDepth); eLFO2ControlDepth.set_value(d->LFO2ControlDepth); eLFO2Controller.set_value(d->LFO2Controller); @@ -674,10 +1532,13 @@ eLFO2Sync.set_value(d->LFO2Sync); eEG3Attack.set_value(d->EG3Attack); eEG3Depth.set_value(d->EG3Depth); + eLFO3Wave.set_value(d->LFO3WaveForm); eLFO3Frequency.set_value(d->LFO3Frequency); + eLFO3Phase.set_value(d->LFO3Phase); eLFO3InternalDepth.set_value(d->LFO3InternalDepth); eLFO3ControlDepth.set_value(d->LFO3ControlDepth); eLFO3Controller.set_value(d->LFO3Controller); + eLFO3FlipPhase.set_value(d->LFO3FlipPhase); eLFO3Sync.set_value(d->LFO3Sync); eVCFEnabled.set_value(d->VCFEnabled); eVCFType.set_value(d->VCFType); @@ -703,6 +1564,8 @@ eCrossfade_out_start.set_value(d->Crossfade.out_start); eCrossfade_out_end.set_value(d->Crossfade.out_end); ePitchTrack.set_value(d->PitchTrack); + eSustainReleaseTrigger.set_value(d->SustainReleaseTrigger); + eNoNoteOffReleaseTrigger.set_value(d->NoNoteOffReleaseTrigger); eDimensionBypass.set_value(d->DimensionBypass); ePan.set_value(d->Pan); eSelfMask.set_value(d->SelfMask); @@ -714,6 +1577,55 @@ eMSDecode.set_value(d->MSDecode); eSampleStartOffset.set_value(d->SampleStartOffset); eUnityNote.set_value(d->UnityNote); + // show sample group name + { + Glib::ustring s = "---"; + if (d->pSample && d->pSample->GetGroup()) + s = d->pSample->GetGroup()->Name; + eSampleGroup.text.set_text(s); + } + // assemble sample format info string + { + Glib::ustring s; + if (d->pSample) { + switch (d->pSample->Channels) { + case 1: s = _("Mono"); break; + case 2: s = _("Stereo"); break; + default: + s = ToString(d->pSample->Channels) + _(" audio channels"); + break; + } + s += " " + ToString(d->pSample->BitDepth) + " Bits"; + s += " " + ToString(d->pSample->SamplesPerSecond/1000) + "." + + ToString((d->pSample->SamplesPerSecond%1000)/100) + " kHz"; + } else { + s = _("No sample assigned to this dimension region."); + } + eSampleFormatInfo.text.set_text(s); + } + // generate sample's memory address pointer string + { + Glib::ustring s; + if (d->pSample) { + char buf[64] = {}; + snprintf(buf, sizeof(buf), "%p", d->pSample); + s = buf; + } else { + s = "---"; + } + eSampleID.text.set_text(s); + } + // generate raw wave form data CRC-32 checksum string + { + Glib::ustring s = "---"; + if (d->pSample) { + char buf[64] = {}; + snprintf(buf, sizeof(buf), "%x", d->pSample->GetWaveDataCRC32Checksum()); + s = buf; + } + eChecksum.text.set_text(s); + } + buttonSelectSample.set_sensitive(d && d->pSample); eFineTune.set_value(d->FineTune); eGain.set_value(d->Gain); eGainPlus6.set_value(d->Gain); @@ -730,7 +1642,8 @@ d->pSample ? d->pSample->LoopPlayCount : 0); update_model--; - wSample->set_text(d->pSample ? d->pSample->pInfo->Name.c_str() : _("NULL")); + wSample->set_text(d->pSample ? gig_to_utf8(d->pSample->pInfo->Name) : + _("NULL")); update_loop_elements(); VCFEnabled_toggled(); @@ -745,6 +1658,7 @@ eVCFVelocityCurve.set_sensitive(sensitive); eVCFVelocityScale.set_sensitive(sensitive); eVCFVelocityDynamicRange.set_sensitive(sensitive); + cutoff_curve.set_sensitive(sensitive); eVCFResonance.set_sensitive(sensitive); eVCFResonanceController.set_sensitive(sensitive); eVCFKeyboardTracking.set_sensitive(sensitive); @@ -760,13 +1674,17 @@ eEG2ControllerAttackInfluence.set_sensitive(sensitive); eEG2ControllerDecayInfluence.set_sensitive(sensitive); eEG2ControllerReleaseInfluence.set_sensitive(sensitive); + eEG2StateOptions.set_sensitive(sensitive); lLFO2->set_sensitive(sensitive); + eLFO2Wave.set_sensitive(sensitive); eLFO2Frequency.set_sensitive(sensitive); + eLFO2Phase.set_sensitive(sensitive); eLFO2InternalDepth.set_sensitive(sensitive); eLFO2ControlDepth.set_sensitive(sensitive); eLFO2Controller.set_sensitive(sensitive); eLFO2FlipPhase.set_sensitive(sensitive); eLFO2Sync.set_sensitive(sensitive); + lfo2Graph.set_sensitive(sensitive); if (sensitive) { VCFCutoffController_changed(); VCFResonanceController_changed(); @@ -837,6 +1755,7 @@ eCrossfade_in_end.set_sensitive(hasController); eCrossfade_out_start.set_sensitive(hasController); eCrossfade_out_end.set_sensitive(hasController); + crossfade_curve.set_sensitive(hasController); } void DimRegionEdit::LFO1Controller_changed() @@ -950,20 +1869,31 @@ update_model--; } -bool DimRegionEdit::set_sample(gig::Sample* sample) +bool DimRegionEdit::set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop) +{ + bool result = false; + for (std::set::iterator itDimReg = dimregs.begin(); + itDimReg != dimregs.end(); ++itDimReg) + { + result |= set_sample(*itDimReg, sample, copy_sample_unity, copy_sample_tune, copy_sample_loop); + } + return result; +} + +bool DimRegionEdit::set_sample(gig::DimensionRegion* dimreg, gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop) { - if (dimregion) { + if (dimreg) { //TODO: we should better move the code from MainWindow::on_sample_label_drop_drag_data_received() here // currently commented because we're sending a similar signal in MainWindow::on_sample_label_drop_drag_data_received() - //dimreg_to_be_changed_signal.emit(dimregion); + //DimRegionChangeGuard(this, dimregion); // make sure stereo samples always are the same in both // dimregs in the samplechannel dimension int nbDimregs = 1; - gig::DimensionRegion* d[2] = { dimregion, 0 }; + gig::DimensionRegion* d[2] = { dimreg, 0 }; if (sample->Channels == 2) { - gig::Region* region = dimregion->GetParent(); + gig::Region* region = dimreg->GetParent(); int bitcount = 0; int stereo_bit = 0; @@ -978,7 +1908,7 @@ if (stereo_bit) { int dimregno; for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) { - if (region->pDimensionRegions[dimregno] == dimregion) { + if (region->pDimensionRegions[dimregno] == dimreg) { break; } } @@ -988,44 +1918,44 @@ } } - gig::Sample* oldref = dimregion->pSample; + gig::Sample* oldref = dimreg->pSample; for (int i = 0 ; i < nbDimregs ; i++) { d[i]->pSample = sample; // copy sample information from Sample to DimensionRegion - - d[i]->UnityNote = sample->MIDIUnityNote; - d[i]->FineTune = sample->FineTune; - - int loops = sample->Loops ? 1 : 0; - while (d[i]->SampleLoops > loops) { - d[i]->DeleteSampleLoop(&d[i]->pSampleLoops[0]); - } - while (d[i]->SampleLoops < sample->Loops) { - DLS::sample_loop_t loop; - d[i]->AddSampleLoop(&loop); - } - if (loops) { - d[i]->pSampleLoops[0].Size = sizeof(DLS::sample_loop_t); - d[i]->pSampleLoops[0].LoopType = sample->LoopType; - d[i]->pSampleLoops[0].LoopStart = sample->LoopStart; - d[i]->pSampleLoops[0].LoopLength = sample->LoopEnd - sample->LoopStart + 1; + if (copy_sample_unity) + d[i]->UnityNote = sample->MIDIUnityNote; + if (copy_sample_tune) + d[i]->FineTune = sample->FineTune; + if (copy_sample_loop) { + int loops = sample->Loops ? 1 : 0; + while (d[i]->SampleLoops > loops) { + d[i]->DeleteSampleLoop(&d[i]->pSampleLoops[0]); + } + while (d[i]->SampleLoops < sample->Loops) { + DLS::sample_loop_t loop; + d[i]->AddSampleLoop(&loop); + } + if (loops) { + d[i]->pSampleLoops[0].Size = sizeof(DLS::sample_loop_t); + d[i]->pSampleLoops[0].LoopType = sample->LoopType; + d[i]->pSampleLoops[0].LoopStart = sample->LoopStart; + d[i]->pSampleLoops[0].LoopLength = sample->LoopEnd - sample->LoopStart + 1; + } } } // update ui update_model++; - wSample->set_text(dimregion->pSample->pInfo->Name); - eUnityNote.set_value(dimregion->UnityNote); - eFineTune.set_value(dimregion->FineTune); - eSampleLoopEnabled.set_value(dimregion->SampleLoops); + wSample->set_text(gig_to_utf8(dimreg->pSample->pInfo->Name)); + eUnityNote.set_value(dimreg->UnityNote); + eFineTune.set_value(dimreg->FineTune); + eSampleLoopEnabled.set_value(dimreg->SampleLoops); update_loop_elements(); update_model--; 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(dimregion); return true; } return false; @@ -1044,114 +1974,169 @@ } -void DimRegionEdit::set_UnityNote(gig::DimensionRegion* d, uint8_t value) +void DimRegionEdit::set_UnityNote(gig::DimensionRegion& d, uint8_t value) { - d->UnityNote = value; + d.UnityNote = value; } -void DimRegionEdit::set_FineTune(gig::DimensionRegion* d, int16_t value) +void DimRegionEdit::set_FineTune(gig::DimensionRegion& d, int16_t value) { - d->FineTune = value; + d.FineTune = value; } -void DimRegionEdit::set_Crossfade_in_start(gig::DimensionRegion* d, +void DimRegionEdit::set_Crossfade_in_start(gig::DimensionRegion& d, uint8_t value) { - d->Crossfade.in_start = value; - if (d->Crossfade.in_end < value) set_Crossfade_in_end(d, value); + d.Crossfade.in_start = value; + if (d.Crossfade.in_end < value) set_Crossfade_in_end(d, value); } -void DimRegionEdit::set_Crossfade_in_end(gig::DimensionRegion* d, +void DimRegionEdit::set_Crossfade_in_end(gig::DimensionRegion& d, uint8_t value) { - d->Crossfade.in_end = value; - if (value < d->Crossfade.in_start) set_Crossfade_in_start(d, value); - if (value > d->Crossfade.out_start) set_Crossfade_out_start(d, value); + d.Crossfade.in_end = value; + if (value < d.Crossfade.in_start) set_Crossfade_in_start(d, value); + if (value > d.Crossfade.out_start) set_Crossfade_out_start(d, value); } -void DimRegionEdit::set_Crossfade_out_start(gig::DimensionRegion* d, +void DimRegionEdit::set_Crossfade_out_start(gig::DimensionRegion& d, uint8_t value) { - d->Crossfade.out_start = value; - if (value < d->Crossfade.in_end) set_Crossfade_in_end(d, value); - if (value > d->Crossfade.out_end) set_Crossfade_out_end(d, value); + d.Crossfade.out_start = value; + if (value < d.Crossfade.in_end) set_Crossfade_in_end(d, value); + if (value > d.Crossfade.out_end) set_Crossfade_out_end(d, value); } -void DimRegionEdit::set_Crossfade_out_end(gig::DimensionRegion* d, +void DimRegionEdit::set_Crossfade_out_end(gig::DimensionRegion& d, uint8_t value) { - d->Crossfade.out_end = value; - if (value < d->Crossfade.out_start) set_Crossfade_out_start(d, value); + d.Crossfade.out_end = value; + if (value < d.Crossfade.out_start) set_Crossfade_out_start(d, value); } -void DimRegionEdit::set_Gain(gig::DimensionRegion* d, int32_t value) +void DimRegionEdit::set_Gain(gig::DimensionRegion& d, int32_t value) { - d->SetGain(value); + d.SetGain(value); } -void DimRegionEdit::set_LoopEnabled(gig::DimensionRegion* d, bool value) +void DimRegionEdit::set_LoopEnabled(gig::DimensionRegion& d, bool value) { if (value) { // create a new sample loop in case there is none yet - if (!d->SampleLoops) { + if (!d.SampleLoops) { + DimRegionChangeGuard(this, &d); + DLS::sample_loop_t loop; loop.LoopType = gig::loop_type_normal; // loop the whole sample by default loop.LoopStart = 0; loop.LoopLength = - (d->pSample) ? d->pSample->SamplesTotal : 0; - dimreg_to_be_changed_signal.emit(d); - d->AddSampleLoop(&loop); - dimreg_changed_signal.emit(d); + (d.pSample) ? d.pSample->SamplesTotal : 0; + d.AddSampleLoop(&loop); } } else { - if (d->SampleLoops) { - dimreg_to_be_changed_signal.emit(d); + if (d.SampleLoops) { + DimRegionChangeGuard(this, &d); + // delete ALL existing sample loops - while (d->SampleLoops) { - d->DeleteSampleLoop(&d->pSampleLoops[0]); + while (d.SampleLoops) { + d.DeleteSampleLoop(&d.pSampleLoops[0]); } - dimreg_changed_signal.emit(d); } } } -void DimRegionEdit::set_LoopType(gig::DimensionRegion* d, uint32_t value) +void DimRegionEdit::set_LoopType(gig::DimensionRegion& d, uint32_t value) { - if (d->SampleLoops) d->pSampleLoops[0].LoopType = value; + if (d.SampleLoops) d.pSampleLoops[0].LoopType = value; } -void DimRegionEdit::set_LoopStart(gig::DimensionRegion* d, uint32_t value) +void DimRegionEdit::set_LoopStart(gig::DimensionRegion& d, uint32_t value) { - if (d->SampleLoops) { - d->pSampleLoops[0].LoopStart = - d->pSample ? - std::min(value, uint32_t(d->pSample->SamplesTotal - - d->pSampleLoops[0].LoopLength)) : + if (d.SampleLoops) { + d.pSampleLoops[0].LoopStart = + d.pSample ? + std::min(value, uint32_t(d.pSample->SamplesTotal - + d.pSampleLoops[0].LoopLength)) : 0; } } -void DimRegionEdit::set_LoopLength(gig::DimensionRegion* d, uint32_t value) +void DimRegionEdit::set_LoopLength(gig::DimensionRegion& d, uint32_t value) { - if (d->SampleLoops) { - d->pSampleLoops[0].LoopLength = - d->pSample ? - std::min(value, uint32_t(d->pSample->SamplesTotal - - d->pSampleLoops[0].LoopStart)) : + if (d.SampleLoops) { + d.pSampleLoops[0].LoopLength = + d.pSample ? + std::min(value, uint32_t(d.pSample->SamplesTotal - + d.pSampleLoops[0].LoopStart)) : 0; } } -void DimRegionEdit::set_LoopInfinite(gig::DimensionRegion* d, bool value) +void DimRegionEdit::set_LoopInfinite(gig::DimensionRegion& d, bool value) { - if (d->pSample) { - if (value) d->pSample->LoopPlayCount = 0; - else if (d->pSample->LoopPlayCount == 0) d->pSample->LoopPlayCount = 1; + if (d.pSample) { + if (value) d.pSample->LoopPlayCount = 0; + else if (d.pSample->LoopPlayCount == 0) d.pSample->LoopPlayCount = 1; } } -void DimRegionEdit::set_LoopPlayCount(gig::DimensionRegion* d, uint32_t value) +void DimRegionEdit::set_LoopPlayCount(gig::DimensionRegion& d, uint32_t value) { - if (d->pSample) d->pSample->LoopPlayCount = value; + if (d.pSample) d.pSample->LoopPlayCount = value; +} + +void DimRegionEdit::nullOutSampleReference() { + if (!dimregion) return; + gig::Sample* oldref = dimregion->pSample; + if (!oldref) return; + + DimRegionChangeGuard(this, dimregion); + + // in case currently assigned sample is a stereo one, then remove both + // references (expected to be due to a "stereo dimension") + gig::DimensionRegion* d[2] = { dimregion, NULL }; + if (oldref->Channels == 2) { + gig::Region* region = dimregion->GetParent(); + { + int stereo_bit = 0; + int bitcount = 0; + for (int dim = 0 ; dim < region->Dimensions ; dim++) { + if (region->pDimensionDefinitions[dim].dimension == gig::dimension_samplechannel) { + stereo_bit = 1 << bitcount; + break; + } + bitcount += region->pDimensionDefinitions[dim].bits; + } + + if (stereo_bit) { + int dimregno; + for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) { + if (region->pDimensionRegions[dimregno] == dimregion) { + break; + } + } + d[0] = region->pDimensionRegions[dimregno & ~stereo_bit]; + d[1] = region->pDimensionRegions[dimregno | stereo_bit]; + } + } + } + + if (d[0]) d[0]->pSample = NULL; + if (d[1]) d[1]->pSample = NULL; + + // update UI elements + set_dim_region(dimregion); + + sample_ref_changed_signal.emit(oldref, NULL); +} + +void DimRegionEdit::onButtonSelectSamplePressed() { + if (!dimregion) return; + if (!dimregion->pSample) return; + select_sample_signal.emit(dimregion->pSample); +} + +sigc::signal& DimRegionEdit::signal_select_sample() { + return select_sample_signal; }