/[svn]/gigedit/trunk/src/gigedit/dimregionedit.cpp
ViewVC logotype

Diff of /gigedit/trunk/src/gigedit/dimregionedit.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2536 by schoenebeck, Mon Apr 21 17:49:17 2014 UTC revision 2926 by schoenebeck, Sun Jun 5 14:33:58 2016 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (C) 2006-2014 Andreas Persson   * Copyright (C) 2006-2016 Andreas Persson
3   *   *
4   * This program is free software; you can redistribute it and/or   * This program is free software; you can redistribute it and/or
5   * modify it under the terms of the GNU General Public License as   * modify it under the terms of the GNU General Public License as
# Line 151  DimRegionEdit::DimRegionEdit() : Line 151  DimRegionEdit::DimRegionEdit() :
151      velocity_curve(&gig::DimensionRegion::GetVelocityAttenuation),      velocity_curve(&gig::DimensionRegion::GetVelocityAttenuation),
152      release_curve(&gig::DimensionRegion::GetVelocityRelease),      release_curve(&gig::DimensionRegion::GetVelocityRelease),
153      cutoff_curve(&gig::DimensionRegion::GetVelocityCutoff),      cutoff_curve(&gig::DimensionRegion::GetVelocityCutoff),
154      eEG1PreAttack(_("Pre-attack"), 0, 100, 2),      eEG1PreAttack(_("Pre-attack Level (%)"), 0, 100, 2),
155      eEG1Attack(_("Attack"), 0, 60, 3),      eEG1Attack(_("Attack Time (seconds)"), 0, 60, 3),
156      eEG1Decay1(_("Decay 1"), 0.005, 60, 3),      eEG1Decay1(_("Decay 1 Time (seconds)"), 0.005, 60, 3),
157      eEG1Decay2(_("Decay 2"), 0, 60, 3),      eEG1Decay2(_("Decay 2 Time (seconds)"), 0, 60, 3),
158      eEG1InfiniteSustain(_("Infinite sustain")),      eEG1InfiniteSustain(_("Infinite sustain")),
159      eEG1Sustain(_("Sustain"), 0, 100, 2),      eEG1Sustain(_("Sustain Level (%)"), 0, 100, 2),
160      eEG1Release(_("Release"), 0, 60, 3),      eEG1Release(_("Release Time (seconds)"), 0, 60, 3),
161      eEG1Hold(_("Hold")),      eEG1Hold(_("Hold Attack Stage until Loop End")),
162      eEG1Controller(_("Controller")),      eEG1Controller(_("Controller")),
163      eEG1ControllerInvert(_("Controller invert")),      eEG1ControllerInvert(_("Controller invert")),
164      eEG1ControllerAttackInfluence(_("Controller attack influence"), 0, 3),      eEG1ControllerAttackInfluence(_("Controller attack influence"), 0, 3),
# Line 170  DimRegionEdit::DimRegionEdit() : Line 170  DimRegionEdit::DimRegionEdit() :
170      eLFO1Controller(_("Controller")),      eLFO1Controller(_("Controller")),
171      eLFO1FlipPhase(_("Flip phase")),      eLFO1FlipPhase(_("Flip phase")),
172      eLFO1Sync(_("Sync")),      eLFO1Sync(_("Sync")),
173      eEG2PreAttack(_("Pre-attack"), 0, 100, 2),      eEG2PreAttack(_("Pre-attack Level (%)"), 0, 100, 2),
174      eEG2Attack(_("Attack"), 0, 60, 3),      eEG2Attack(_("Attack Time (seconds)"), 0, 60, 3),
175      eEG2Decay1(_("Decay 1"), 0.005, 60, 3),      eEG2Decay1(_("Decay 1 Time (seconds)"), 0.005, 60, 3),
176      eEG2Decay2(_("Decay 2"), 0, 60, 3),      eEG2Decay2(_("Decay 2 Time (seconds)"), 0, 60, 3),
177      eEG2InfiniteSustain(_("Infinite sustain")),      eEG2InfiniteSustain(_("Infinite sustain")),
178      eEG2Sustain(_("Sustain"), 0, 100, 2),      eEG2Sustain(_("Sustain Level (%)"), 0, 100, 2),
179      eEG2Release(_("Release"), 0, 60, 3),      eEG2Release(_("Release Time (seconds)"), 0, 60, 3),
180      eEG2Controller(_("Controller")),      eEG2Controller(_("Controller")),
181      eEG2ControllerInvert(_("Controller invert")),      eEG2ControllerInvert(_("Controller invert")),
182      eEG2ControllerAttackInfluence(_("Controller attack influence"), 0, 3),      eEG2ControllerAttackInfluence(_("Controller attack influence"), 0, 3),
# Line 221  DimRegionEdit::DimRegionEdit() : Line 221  DimRegionEdit::DimRegionEdit() :
221      ePitchTrack(_("Pitch track")),      ePitchTrack(_("Pitch track")),
222      eDimensionBypass(_("Dimension bypass")),      eDimensionBypass(_("Dimension bypass")),
223      ePan(_("Pan"), -64, 63),      ePan(_("Pan"), -64, 63),
224      eSelfMask(_("One note/voice per key (a.k.a \"Self mask\")")),      eSelfMask(_("Kill lower velocity voices (a.k.a \"Self mask\")")),
225      eAttenuationController(_("Attenuation controller")),      eAttenuationController(_("Attenuation controller")),
226      eInvertAttenuationController(_("Invert attenuation controller")),      eInvertAttenuationController(_("Invert attenuation controller")),
227      eAttenuationControllerThreshold(_("Attenuation controller threshold")),      eAttenuationControllerThreshold(_("Attenuation controller threshold")),
228      eChannelOffset(_("Channel offset"), 0, 9),      eChannelOffset(_("Channel offset"), 0, 9),
229      eSustainDefeat(_("Ignore Hold Pedal (a.k.a. \"Sustain defeat\")")),      eSustainDefeat(_("Ignore Hold Pedal (a.k.a. \"Sustain defeat\")")),
230      eMSDecode(_("MS decode")),      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),
# Line 239  DimRegionEdit::DimRegionEdit() : Line 241  DimRegionEdit::DimRegionEdit() :
241      eSampleLoopType(_("Loop type")),      eSampleLoopType(_("Loop type")),
242      eSampleLoopInfinite(_("Infinite loop")),      eSampleLoopInfinite(_("Infinite loop")),
243      eSampleLoopPlayCount(_("Playback count"), 1),      eSampleLoopPlayCount(_("Playback count"), 1),
244        buttonSelectSample(UNICODE_LEFT_ARROW + "  " + _("Select Sample")),
245      update_model(0)      update_model(0)
246  {  {
247        // make synthesis parameter page tabs scrollable
248        // (workaround for GTK3: default theme uses huge tabs which breaks layout)
249        set_scrollable();
250    
251      connect(eEG1PreAttack, &gig::DimensionRegion::EG1PreAttack);      connect(eEG1PreAttack, &gig::DimensionRegion::EG1PreAttack);
252      connect(eEG1Attack, &gig::DimensionRegion::EG1Attack);      connect(eEG1Attack, &gig::DimensionRegion::EG1Attack);
253      connect(eEG1Decay1, &gig::DimensionRegion::EG1Decay1);      connect(eEG1Decay1, &gig::DimensionRegion::EG1Decay1);
# Line 348  DimRegionEdit::DimRegionEdit() : Line 355  DimRegionEdit::DimRegionEdit() :
355      connect(eSampleLoopLength, &DimRegionEdit::set_LoopLength);      connect(eSampleLoopLength, &DimRegionEdit::set_LoopLength);
356      connect(eSampleLoopInfinite, &DimRegionEdit::set_LoopInfinite);      connect(eSampleLoopInfinite, &DimRegionEdit::set_LoopInfinite);
357      connect(eSampleLoopPlayCount, &DimRegionEdit::set_LoopPlayCount);      connect(eSampleLoopPlayCount, &DimRegionEdit::set_LoopPlayCount);
358        buttonSelectSample.signal_clicked().connect(
359            sigc::mem_fun(*this, &DimRegionEdit::onButtonSelectSamplePressed)
360        );
361    
362      for (int i = 0 ; i < 7 ; i++) {      for (int i = 0 ; i < 7 ; i++) {
363          table[i] = new Gtk::Table(3, 1);          table[i] = new Gtk::Table(3, 1);
# Line 358  DimRegionEdit::DimRegionEdit() : Line 368  DimRegionEdit::DimRegionEdit() :
368      eUnityNote.set_tip(      eUnityNote.set_tip(
369          _("Note this sample is associated with (a.k.a. 'root note')")          _("Note this sample is associated with (a.k.a. 'root note')")
370      );      );
371        buttonSelectSample.set_tooltip_text(
372            _("Selects the sample of this dimension region on the left hand side's sample tree view.")
373        );
374      eSampleStartOffset.set_tip(_("Sample position at which playback should be started"));      eSampleStartOffset.set_tip(_("Sample position at which playback should be started"));
375      ePan.set_tip(_("Stereo balance (left/right)"));      ePan.set_tip(_("Stereo balance (left/right)"));
376      eChannelOffset.set_tip(      eChannelOffset.set_tip(
# Line 388  DimRegionEdit::DimRegionEdit() : Line 401  DimRegionEdit::DimRegionEdit() :
401            "Caution: this setting is stored on Sample side, thus is shared "            "Caution: this setting is stored on Sample side, thus is shared "
402            "among all dimension regions that use this sample!")            "among all dimension regions that use this sample!")
403      );      );
404        
405        eEG1PreAttack.set_tip(
406            "Very first level this EG starts with. It rises then in Attack Time "
407            "seconds from this initial level to 100%."
408        );
409        eEG1Attack.set_tip(
410            "Duration of the EG's Attack stage, which raises its level from "
411            "Pre-Attack Level to 100%."
412        );
413        eEG1Hold.set_tip(
414           "On looped sounds, enabling this will cause the Decay 1 stage not to "
415           "enter before the loop has been passed one time."
416        );
417        eAttenuationController.set_tip(_(
418            "If you are not using the 'Layer' dimension, then this controller "
419            "simply alters the volume. If you are using the 'Layer' dimension, "
420            "then this controller is controlling the crossfade between Layers in "
421            "real-time."
422        ));
423    
424        eLFO1Sync.set_tip(
425            "If not checked, every voice will use its own LFO instance, which "
426            "causes voices triggered at different points in time to have different "
427            "LFO levels. By enabling 'Sync' here the voices will instead use and "
428            "share one single LFO, causing all voices to have the same LFO level, "
429            "no matter when the individual notes have been triggered."
430        );
431        eLFO2Sync.set_tip(
432            "If not checked, every voice will use its own LFO instance, which "
433            "causes voices triggered at different points in time to have different "
434            "LFO levels. By enabling 'Sync' here the voices will instead use and "
435            "share one single LFO, causing all voices to have the same LFO level, "
436            "no matter when the individual notes have been triggered."
437        );
438        eLFO3Sync.set_tip(
439            "If not checked, every voice will use its own LFO instance, which "
440            "causes voices triggered at different points in time to have different "
441            "LFO levels. By enabling 'Sync' here the voices will instead use and "
442            "share one single LFO, causing all voices to have the same LFO level, "
443            "no matter when the individual notes have been triggered."
444        );
445        eLFO1FlipPhase.set_tip(
446           "Inverts the LFO's generated wave vertically."
447        );
448        eLFO2FlipPhase.set_tip(
449           "Inverts the LFO's generated wave vertically."
450        );
451    
452      pageno = 0;      pageno = 0;
453      rowno = 0;      rowno = 0;
454      firstRowInBlock = 0;      firstRowInBlock = 0;
455    
456      addHeader(_("Mandatory Settings"));      addHeader(_("Mandatory Settings"));
457      addString(_("Sample"), lSample, wSample);      addString(_("Sample"), lSample, wSample, buttonNullSampleReference);
458        buttonNullSampleReference->set_label("X");
459        buttonNullSampleReference->set_tooltip_text(_("Remove current sample reference (NULL reference). This can be used to define a \"silent\" case where no sample shall be played."));
460        buttonNullSampleReference->signal_clicked().connect(
461            sigc::mem_fun(*this, &DimRegionEdit::nullOutSampleReference)
462        );
463      //TODO: the following would break drag&drop:   wSample->property_editable().set_value(false);  or this:    wSample->set_editable(false);      //TODO: the following would break drag&drop:   wSample->property_editable().set_value(false);  or this:    wSample->set_editable(false);
464  #ifdef OLD_TOOLTIPS  #ifdef OLD_TOOLTIPS
465      tooltips.set_tip(*wSample, _("Drag & drop a sample here"));      tooltips.set_tip(*wSample, _("Drag & drop a sample here"));
# Line 402  DimRegionEdit::DimRegionEdit() : Line 467  DimRegionEdit::DimRegionEdit() :
467      wSample->set_tooltip_text(_("Drag & drop a sample here"));      wSample->set_tooltip_text(_("Drag & drop a sample here"));
468  #endif  #endif
469      addProp(eUnityNote);      addProp(eUnityNote);
470        addProp(eSampleFormatInfo);
471        addProp(eSampleID);
472        addRightHandSide(buttonSelectSample);
473      addHeader(_("Optional Settings"));      addHeader(_("Optional Settings"));
474      addProp(eSampleStartOffset);      addProp(eSampleStartOffset);
475      addProp(eChannelOffset);      addProp(eChannelOffset);
# Line 431  DimRegionEdit::DimRegionEdit() : Line 499  DimRegionEdit::DimRegionEdit() :
499      addHeader(_("Amplitude Envelope (EG1)"));      addHeader(_("Amplitude Envelope (EG1)"));
500      addProp(eEG1PreAttack);      addProp(eEG1PreAttack);
501      addProp(eEG1Attack);      addProp(eEG1Attack);
502        addProp(eEG1Hold);
503      addProp(eEG1Decay1);      addProp(eEG1Decay1);
504      addProp(eEG1Decay2);      addProp(eEG1Decay2);
505      addProp(eEG1InfiniteSustain);      addProp(eEG1InfiniteSustain);
506      addProp(eEG1Sustain);      addProp(eEG1Sustain);
507      addProp(eEG1Release);      addProp(eEG1Release);
     addProp(eEG1Hold);  
508      addProp(eEG1Controller);      addProp(eEG1Controller);
509      addProp(eEG1ControllerInvert);      addProp(eEG1ControllerInvert);
510      addProp(eEG1ControllerAttackInfluence);      addProp(eEG1ControllerAttackInfluence);
# Line 636  DimRegionEdit::DimRegionEdit() : Line 704  DimRegionEdit::DimRegionEdit() :
704    
705      nextPage();      nextPage();
706    
707      addHeader(_("Velocity Reponse"));      addHeader(_("Velocity Response"));
708      eVelocityResponseCurve.set_choices(curve_type_texts, curve_type_values);      eVelocityResponseCurve.set_choices(curve_type_texts, curve_type_values);
709      addProp(eVelocityResponseCurve);      addProp(eVelocityResponseCurve);
710      addProp(eVelocityResponseDepth);      addProp(eVelocityResponseDepth);
# Line 655  DimRegionEdit::DimRegionEdit() : Line 723  DimRegionEdit::DimRegionEdit() :
723                            Gtk::SHRINK, Gtk::SHRINK);                            Gtk::SHRINK, Gtk::SHRINK);
724      rowno++;      rowno++;
725    
726      addHeader(_("Release Velocity Reponse"));      addHeader(_("Release Velocity Response"));
727      eReleaseVelocityResponseCurve.set_choices(curve_type_texts,      eReleaseVelocityResponseCurve.set_choices(curve_type_texts,
728                                                curve_type_values);                                                curve_type_values);
729      addProp(eReleaseVelocityResponseCurve);      addProp(eReleaseVelocityResponseCurve);
# Line 682  DimRegionEdit::DimRegionEdit() : Line 750  DimRegionEdit::DimRegionEdit() :
750          eDimensionBypass.set_choices(choices, values);          eDimensionBypass.set_choices(choices, values);
751      }      }
752      addProp(eDimensionBypass);      addProp(eDimensionBypass);
753      eSelfMask.widget.set_tooltip_text(_("If enabled: high velocity notes will stop low velocity notes at the same note, that way you can save voices that wouldn't be audible anyway."));      eSelfMask.widget.set_tooltip_text(_(
754            "If enabled: new notes with higher velocity value will stop older "
755            "notes with lower velocity values, that way you can save voices that "
756            "would barely be audible. This is also useful for certain drum sounds."
757        ));
758      addProp(eSelfMask);      addProp(eSelfMask);
759      eSustainDefeat.widget.set_tooltip_text(_("If enabled: sustain pedal will not hold a note."));      eSustainDefeat.widget.set_tooltip_text(_(
760            "If enabled: sustain pedal will not hold a note. This way you can use "
761            "the sustain pedal for other purposes, for example to switch among "
762            "dimension regions."
763        ));
764      addProp(eSustainDefeat);      addProp(eSustainDefeat);
765      eMSDecode.widget.set_tooltip_text(_("Gigastudio specific flag: defines if Mid Side Recordings should be decoded."));      eMSDecode.widget.set_tooltip_text(_(
766            "Defines if Mid/Side Recordings should be decoded. Mid/Side Recordings "
767            "are an alternative way to record sounds in stereo. The sampler needs "
768            "to decode such samples to actually make use of them. Note: this "
769            "feature is currently not supported by LinuxSampler."
770        ));
771      addProp(eMSDecode);      addProp(eMSDecode);
772    
773      nextPage();      nextPage();
# Line 763  void DimRegionEdit::addString(const char Line 844  void DimRegionEdit::addString(const char
844      rowno++;      rowno++;
845  }  }
846    
847    void DimRegionEdit::addString(const char* labelText, Gtk::Label*& label,
848                                  Gtk::Entry*& widget, Gtk::Button*& button)
849    {
850        label = new Gtk::Label(Glib::ustring(labelText) + ":");
851        label->set_alignment(Gtk::ALIGN_START);
852    
853        table[pageno]->attach(*label, 1, 2, rowno, rowno + 1,
854                              Gtk::FILL, Gtk::SHRINK);
855    
856        widget = new Gtk::Entry();
857        button = new Gtk::Button();
858    
859        Gtk::HBox* hbox = new Gtk::HBox;
860        hbox->pack_start(*widget);
861        hbox->pack_start(*button, Gtk::PACK_SHRINK);
862    
863        table[pageno]->attach(*hbox, 2, 3, rowno, rowno + 1,
864                              Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
865    
866        rowno++;
867    }
868    
869  Gtk::Label* DimRegionEdit::addHeader(const char* text)  Gtk::Label* DimRegionEdit::addHeader(const char* text)
870  {  {
871      if (firstRowInBlock < rowno - 1)      if (firstRowInBlock < rowno - 1)
# Line 820  void DimRegionEdit::addProp(LabelWidget& Line 923  void DimRegionEdit::addProp(LabelWidget&
923      rowno++;      rowno++;
924  }  }
925    
926    void DimRegionEdit::addRightHandSide(Gtk::Widget& widget)
927    {
928        table[pageno]->attach(widget, 2, 3, rowno, rowno + 1,
929                              Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
930        rowno++;
931    }
932    
933  void DimRegionEdit::set_dim_region(gig::DimensionRegion* d)  void DimRegionEdit::set_dim_region(gig::DimensionRegion* d)
934  {  {
# Line 912  void DimRegionEdit::set_dim_region(gig:: Line 1021  void DimRegionEdit::set_dim_region(gig::
1021      eMSDecode.set_value(d->MSDecode);      eMSDecode.set_value(d->MSDecode);
1022      eSampleStartOffset.set_value(d->SampleStartOffset);      eSampleStartOffset.set_value(d->SampleStartOffset);
1023      eUnityNote.set_value(d->UnityNote);      eUnityNote.set_value(d->UnityNote);
1024        // assemble sample format info string
1025        {
1026            Glib::ustring s;
1027            if (d->pSample) {
1028                switch (d->pSample->Channels) {
1029                    case 1: s = _("Mono"); break;
1030                    case 2: s = _("Stereo"); break;
1031                    default:
1032                        s = ToString(d->pSample->Channels) + _(" audio channels");
1033                        break;
1034                }
1035                s += " " + ToString(d->pSample->BitDepth) + " Bits";
1036                s += " " + ToString(d->pSample->SamplesPerSecond/1000) + "."
1037                          + ToString((d->pSample->SamplesPerSecond%1000)/100) + " kHz";
1038            } else {
1039                s = _("No sample assigned to this dimension region.");
1040            }
1041            eSampleFormatInfo.text.set_text(s);
1042        }
1043        // generate sample's memory address pointer string
1044        {
1045            Glib::ustring s;
1046            if (d->pSample) {
1047                char buf[64] = {};
1048                snprintf(buf, sizeof(buf), "%p", d->pSample);
1049                s = buf;
1050            } else {
1051                s = "---";
1052            }
1053            eSampleID.text.set_text(s);
1054        }
1055        buttonSelectSample.set_sensitive(d && d->pSample);
1056      eFineTune.set_value(d->FineTune);      eFineTune.set_value(d->FineTune);
1057      eGain.set_value(d->Gain);      eGain.set_value(d->Gain);
1058      eGainPlus6.set_value(d->Gain);      eGainPlus6.set_value(d->Gain);
# Line 1153  void DimRegionEdit::loop_infinite_toggle Line 1294  void DimRegionEdit::loop_infinite_toggle
1294    
1295  bool DimRegionEdit::set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop)  bool DimRegionEdit::set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop)
1296  {  {
1297      if (dimregion) {      for (std::set<gig::DimensionRegion*>::iterator itDimReg = dimregs.begin();
1298             itDimReg != dimregs.end(); ++itDimReg)
1299        {
1300            set_sample(*itDimReg, sample, copy_sample_unity, copy_sample_tune, copy_sample_loop);
1301        }
1302    }
1303    
1304    bool DimRegionEdit::set_sample(gig::DimensionRegion* dimreg, gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop)
1305    {
1306        if (dimreg) {
1307          //TODO: we should better move the code from MainWindow::on_sample_label_drop_drag_data_received() here          //TODO: we should better move the code from MainWindow::on_sample_label_drop_drag_data_received() here
1308    
1309          // 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()
# Line 1162  bool DimRegionEdit::set_sample(gig::Samp Line 1312  bool DimRegionEdit::set_sample(gig::Samp
1312          // make sure stereo samples always are the same in both          // make sure stereo samples always are the same in both
1313          // dimregs in the samplechannel dimension          // dimregs in the samplechannel dimension
1314          int nbDimregs = 1;          int nbDimregs = 1;
1315          gig::DimensionRegion* d[2] = { dimregion, 0 };          gig::DimensionRegion* d[2] = { dimreg, 0 };
1316          if (sample->Channels == 2) {          if (sample->Channels == 2) {
1317              gig::Region* region = dimregion->GetParent();              gig::Region* region = dimreg->GetParent();
1318    
1319              int bitcount = 0;              int bitcount = 0;
1320              int stereo_bit = 0;              int stereo_bit = 0;
# Line 1179  bool DimRegionEdit::set_sample(gig::Samp Line 1329  bool DimRegionEdit::set_sample(gig::Samp
1329              if (stereo_bit) {              if (stereo_bit) {
1330                  int dimregno;                  int dimregno;
1331                  for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) {                  for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) {
1332                      if (region->pDimensionRegions[dimregno] == dimregion) {                      if (region->pDimensionRegions[dimregno] == dimreg) {
1333                          break;                          break;
1334                      }                      }
1335                  }                  }
# Line 1189  bool DimRegionEdit::set_sample(gig::Samp Line 1339  bool DimRegionEdit::set_sample(gig::Samp
1339              }              }
1340          }          }
1341    
1342          gig::Sample* oldref = dimregion->pSample;          gig::Sample* oldref = dimreg->pSample;
1343    
1344          for (int i = 0 ; i < nbDimregs ; i++) {          for (int i = 0 ; i < nbDimregs ; i++) {
1345              d[i]->pSample = sample;              d[i]->pSample = sample;
# Line 1219  bool DimRegionEdit::set_sample(gig::Samp Line 1369  bool DimRegionEdit::set_sample(gig::Samp
1369    
1370          // update ui          // update ui
1371          update_model++;          update_model++;
1372          wSample->set_text(gig_to_utf8(dimregion->pSample->pInfo->Name));          wSample->set_text(gig_to_utf8(dimreg->pSample->pInfo->Name));
1373          eUnityNote.set_value(dimregion->UnityNote);          eUnityNote.set_value(dimreg->UnityNote);
1374          eFineTune.set_value(dimregion->FineTune);          eFineTune.set_value(dimreg->FineTune);
1375          eSampleLoopEnabled.set_value(dimregion->SampleLoops);          eSampleLoopEnabled.set_value(dimreg->SampleLoops);
1376          update_loop_elements();          update_loop_elements();
1377          update_model--;          update_model--;
1378    
1379          sample_ref_changed_signal.emit(oldref, sample);          sample_ref_changed_signal.emit(oldref, sample);
1380          // 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()
1381          //dimreg_changed_signal.emit(dimregion);          //dimreg_changed_signal.emit(dimreg);
1382          return true;          return true;
1383      }      }
1384      return false;      return false;
# Line 1358  void DimRegionEdit::set_LoopPlayCount(gi Line 1508  void DimRegionEdit::set_LoopPlayCount(gi
1508  {  {
1509      if (d->pSample) d->pSample->LoopPlayCount = value;      if (d->pSample) d->pSample->LoopPlayCount = value;
1510  }  }
1511    
1512    void DimRegionEdit::nullOutSampleReference() {
1513        if (!dimregion) return;
1514        gig::Sample* oldref = dimregion->pSample;
1515        if (!oldref) return;
1516    
1517        dimreg_to_be_changed_signal.emit(dimregion);
1518    
1519        // in case currently assigned sample is a stereo one, then remove both
1520        // references (expected to be due to a "stereo dimension")
1521        gig::DimensionRegion* d[2] = { dimregion, NULL };
1522        if (oldref->Channels == 2) {
1523            gig::Region* region = dimregion->GetParent();
1524            {
1525                int stereo_bit = 0;
1526                int bitcount = 0;
1527                for (int dim = 0 ; dim < region->Dimensions ; dim++) {
1528                    if (region->pDimensionDefinitions[dim].dimension == gig::dimension_samplechannel) {
1529                        stereo_bit = 1 << bitcount;
1530                        break;
1531                    }
1532                    bitcount += region->pDimensionDefinitions[dim].bits;
1533                }
1534    
1535                if (stereo_bit) {
1536                    int dimregno;
1537                    for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) {
1538                        if (region->pDimensionRegions[dimregno] == dimregion) {
1539                            break;
1540                        }
1541                    }
1542                    d[0] = region->pDimensionRegions[dimregno & ~stereo_bit];
1543                    d[1] = region->pDimensionRegions[dimregno | stereo_bit];
1544                }
1545            }
1546        }
1547    
1548        if (d[0]) d[0]->pSample = NULL;
1549        if (d[1]) d[1]->pSample = NULL;
1550    
1551        // update UI elements
1552        set_dim_region(dimregion);
1553    
1554        sample_ref_changed_signal.emit(oldref, NULL);
1555        dimreg_changed_signal.emit(dimregion);
1556    }
1557    
1558    void DimRegionEdit::onButtonSelectSamplePressed() {
1559        if (!dimregion) return;
1560        if (!dimregion->pSample) return;
1561        select_sample_signal.emit(dimregion->pSample);
1562    }
1563    
1564    sigc::signal<void, gig::Sample*>& DimRegionEdit::signal_select_sample() {
1565        return select_sample_signal;
1566    }

Legend:
Removed from v.2536  
changed lines
  Added in v.2926

  ViewVC Help
Powered by ViewVC