/[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 2397 by persson, Wed Jan 9 20:59:29 2013 UTC revision 2566 by schoenebeck, Tue May 20 14:35:36 2014 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (C) 2006-2013 Andreas Persson   * Copyright (C) 2006-2014 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 55  bool VelocityCurve::on_draw(const Cairo: Line 55  bool VelocityCurve::on_draw(const Cairo:
55              if (pass == 0) {              if (pass == 0) {
56                  cr->line_to(w, h);                  cr->line_to(w, h);
57                  cr->line_to(0, h);                  cr->line_to(0, h);
58                  cr->set_source_rgba(0.5, 0.44, 1.0, 0.2);                  cr->set_source_rgba(0.5, 0.44, 1.0, is_sensitive() ? 0.2 : 0.1);
59                  cr->fill();                  cr->fill();
60              } else {              } else {
61                  cr->set_line_width(3);                  cr->set_line_width(3);
62                  cr->set_source_rgb(0.5, 0.44, 1.0);                  cr->set_source_rgba(0.5, 0.44, 1.0, is_sensitive() ? 1.0 : 0.3);
63                  cr->stroke();                  cr->stroke();
64              }              }
65          }          }
# Line 82  bool CrossfadeCurve::on_expose_event(Gdk Line 82  bool CrossfadeCurve::on_expose_event(Gdk
82  #else  #else
83  bool CrossfadeCurve::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {  bool CrossfadeCurve::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
84  #endif  #endif
85      if (dimreg && dimreg->Crossfade.out_end) {      if (dimreg) {
         int w = get_width();  
         int h = get_height();  
           
86          cr->translate(1.5, 0);          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            for (int dim = 0 ; dim < region->Dimensions ; dim++) {
98                if (region->pDimensionDefinitions[dim].dimension ==
99                    gig::dimension_layer) {
100                    int mask =
101                        ~(((1 << region->pDimensionDefinitions[dim].bits) - 1) <<
102                          bitcount);
103                    int c = dimregno & mask; // mask away the layer dimension
104    
105                    for (int i = 0 ; i < region->pDimensionDefinitions[dim].zones ;
106                         i++) {
107                        gig::DimensionRegion* d =
108                            region->pDimensionRegions[c + (i << bitcount)];
109                        if (d != dimreg) {
110                            draw_one_curve(cr, d, false);
111                        }
112                    }
113                    break;
114                }
115                bitcount += region->pDimensionDefinitions[dim].bits;
116            }
117    
118            // then, draw the currently selected layer
119            draw_one_curve(cr, dimreg, is_sensitive());
120        }
121        return true;
122    }
123    
124    void CrossfadeCurve::draw_one_curve(const Cairo::RefPtr<Cairo::Context>& cr,
125                                        const gig::DimensionRegion* d,
126                                        bool sensitive) {
127        int w = get_width();
128        int h = get_height();
129    
130        if (d->Crossfade.out_end) {
131          for (int pass = 0 ; pass < 2 ; pass++) {          for (int pass = 0 ; pass < 2 ; pass++) {
132              cr->move_to(dimreg->Crossfade.in_start / 127.0 * (w - 3), h);              cr->move_to(d->Crossfade.in_start / 127.0 * (w - 3), h);
133              cr->line_to(dimreg->Crossfade.in_end / 127.0 * (w - 3), 1.5);              cr->line_to(d->Crossfade.in_end / 127.0 * (w - 3), 1.5);
134              cr->line_to(dimreg->Crossfade.out_start / 127.0 * (w - 3), 1.5);              cr->line_to(d->Crossfade.out_start / 127.0 * (w - 3), 1.5);
135              cr->line_to(dimreg->Crossfade.out_end / 127.0 * (w - 3), h);              cr->line_to(d->Crossfade.out_end / 127.0 * (w - 3), h);
136    
137              if (pass == 0) {              if (pass == 0) {
138                  cr->set_source_rgba(0.5, 0.44, 1.0, 0.2);                  cr->set_source_rgba(0.5, 0.44, 1.0, sensitive ? 0.2 : 0.1);
139                  cr->fill();                  cr->fill();
140              } else {              } else {
141                  cr->set_line_width(3);                  cr->set_line_width(3);
142                  cr->set_source_rgb(0.5, 0.44, 1.0);                  cr->set_source_rgba(0.5, 0.44, 1.0, sensitive ? 1.0 : 0.3);
143                  cr->stroke();                  cr->stroke();
144              }              }
145          }          }
146      }      }
     return true;  
147  }  }
148    
149    
# Line 111  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 130  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 181  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(_("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(_("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      eFineTune(_("Fine tune"), -49, 50),      eFineTune(_("Fine tune"), -49, 50),
# Line 348  DimRegionEdit::DimRegionEdit() : Line 388  DimRegionEdit::DimRegionEdit() :
388            "Caution: this setting is stored on Sample side, thus is shared "            "Caution: this setting is stored on Sample side, thus is shared "
389            "among all dimension regions that use this sample!")            "among all dimension regions that use this sample!")
390      );      );
391        
392        eEG1PreAttack.set_tip(
393            "Very first level this EG starts with. It rises then in Attack Time "
394            "seconds from this initial level to 100%."
395        );
396        eEG1Attack.set_tip(
397            "Duration of the EG's Attack stage, which raises its level from "
398            "Pre-Attack Level to 100%."
399        );
400        eEG1Hold.set_tip(
401           "On looped sounds, enabling this will cause the Decay 1 stage not to "
402           "enter before the loop has been passed one time."
403        );
404        eAttenuationController.set_tip(_(
405            "If you are not using the 'Layer' dimension, then this controller "
406            "simply alters the volume. If you are using the 'Layer' dimension, "
407            "then this controller is controlling the crossfade between Layers in "
408            "real-time."
409        ));
410    
411        eLFO1Sync.set_tip(
412            "If not checked, every voice will use its own LFO instance, which "
413            "causes voices triggered at different points in time to have different "
414            "LFO levels. By enabling 'Sync' here the voices will instead use and "
415            "share one single LFO, causing all voices to have the same LFO level, "
416            "no matter when the individual notes have been triggered."
417        );
418        eLFO2Sync.set_tip(
419            "If not checked, every voice will use its own LFO instance, which "
420            "causes voices triggered at different points in time to have different "
421            "LFO levels. By enabling 'Sync' here the voices will instead use and "
422            "share one single LFO, causing all voices to have the same LFO level, "
423            "no matter when the individual notes have been triggered."
424        );
425        eLFO3Sync.set_tip(
426            "If not checked, every voice will use its own LFO instance, which "
427            "causes voices triggered at different points in time to have different "
428            "LFO levels. By enabling 'Sync' here the voices will instead use and "
429            "share one single LFO, causing all voices to have the same LFO level, "
430            "no matter when the individual notes have been triggered."
431        );
432        eLFO1FlipPhase.set_tip(
433           "Inverts the LFO's generated wave vertically."
434        );
435        eLFO2FlipPhase.set_tip(
436           "Inverts the LFO's generated wave vertically."
437        );
438    
439      pageno = 0;      pageno = 0;
440      rowno = 0;      rowno = 0;
# Line 357  DimRegionEdit::DimRegionEdit() : Line 444  DimRegionEdit::DimRegionEdit() :
444      addString(_("Sample"), lSample, wSample);      addString(_("Sample"), lSample, wSample);
445      //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);
446  #ifdef OLD_TOOLTIPS  #ifdef OLD_TOOLTIPS
447      tooltips.set_tip(*wSample, _("Drop a sample here"));      tooltips.set_tip(*wSample, _("Drag & drop a sample here"));
448  #else  #else
449      wSample->set_tooltip_text(_("Drop a sample here"));      wSample->set_tooltip_text(_("Drag & drop a sample here"));
450  #endif  #endif
451      addProp(eUnityNote);      addProp(eUnityNote);
452      addHeader(_("Optional Settings"));      addHeader(_("Optional Settings"));
# Line 391  DimRegionEdit::DimRegionEdit() : Line 478  DimRegionEdit::DimRegionEdit() :
478      addHeader(_("Amplitude Envelope (EG1)"));      addHeader(_("Amplitude Envelope (EG1)"));
479      addProp(eEG1PreAttack);      addProp(eEG1PreAttack);
480      addProp(eEG1Attack);      addProp(eEG1Attack);
481        addProp(eEG1Hold);
482      addProp(eEG1Decay1);      addProp(eEG1Decay1);
483      addProp(eEG1Decay2);      addProp(eEG1Decay2);
484      addProp(eEG1InfiniteSustain);      addProp(eEG1InfiniteSustain);
485      addProp(eEG1Sustain);      addProp(eEG1Sustain);
486      addProp(eEG1Release);      addProp(eEG1Release);
     addProp(eEG1Hold);  
487      addProp(eEG1Controller);      addProp(eEG1Controller);
488      addProp(eEG1ControllerInvert);      addProp(eEG1ControllerInvert);
489      addProp(eEG1ControllerAttackInfluence);      addProp(eEG1ControllerAttackInfluence);
# Line 596  DimRegionEdit::DimRegionEdit() : Line 683  DimRegionEdit::DimRegionEdit() :
683    
684      nextPage();      nextPage();
685    
686      addHeader(_("Velocity Reponse"));      addHeader(_("Velocity Response"));
687      eVelocityResponseCurve.set_choices(curve_type_texts, curve_type_values);      eVelocityResponseCurve.set_choices(curve_type_texts, curve_type_values);
688      addProp(eVelocityResponseCurve);      addProp(eVelocityResponseCurve);
689      addProp(eVelocityResponseDepth);      addProp(eVelocityResponseDepth);
# Line 615  DimRegionEdit::DimRegionEdit() : Line 702  DimRegionEdit::DimRegionEdit() :
702                            Gtk::SHRINK, Gtk::SHRINK);                            Gtk::SHRINK, Gtk::SHRINK);
703      rowno++;      rowno++;
704    
705      addHeader(_("Release Velocity Reponse"));      addHeader(_("Release Velocity Response"));
706      eReleaseVelocityResponseCurve.set_choices(curve_type_texts,      eReleaseVelocityResponseCurve.set_choices(curve_type_texts,
707                                                curve_type_values);                                                curve_type_values);
708      addProp(eReleaseVelocityResponseCurve);      addProp(eReleaseVelocityResponseCurve);
# Line 642  DimRegionEdit::DimRegionEdit() : Line 729  DimRegionEdit::DimRegionEdit() :
729          eDimensionBypass.set_choices(choices, values);          eDimensionBypass.set_choices(choices, values);
730      }      }
731      addProp(eDimensionBypass);      addProp(eDimensionBypass);
732        eSelfMask.widget.set_tooltip_text(_(
733            "If enabled: new notes with higher velocity value will stop older "
734            "notes with lower velocity values, that way you can save voices that "
735            "would barely be audible. This is also useful for certain drum sounds."
736        ));
737      addProp(eSelfMask);      addProp(eSelfMask);
738        eSustainDefeat.widget.set_tooltip_text(_(
739            "If enabled: sustain pedal will not hold a note. This way you can use "
740            "the sustain pedal for other purposes, for example to switch among "
741            "dimension regions."
742        ));
743      addProp(eSustainDefeat);      addProp(eSustainDefeat);
744        eMSDecode.widget.set_tooltip_text(_(
745            "Defines if Mid/Side Recordings should be decoded. Mid/Side Recordings "
746            "are an alternative way to record sounds in stereo. The sampler needs "
747            "to decode such samples to actually make use of them. Note: this "
748            "feature is currently not supported by LinuxSampler."
749        ));
750      addProp(eMSDecode);      addProp(eMSDecode);
751    
752      nextPage();      nextPage();
# Line 885  void DimRegionEdit::set_dim_region(gig:: Line 988  void DimRegionEdit::set_dim_region(gig::
988          d->pSample ? d->pSample->LoopPlayCount : 0);          d->pSample ? d->pSample->LoopPlayCount : 0);
989      update_model--;      update_model--;
990    
991      wSample->set_text(d->pSample ? d->pSample->pInfo->Name.c_str() : _("NULL"));      wSample->set_text(d->pSample ? gig_to_utf8(d->pSample->pInfo->Name) :
992                          _("NULL"));
993    
994      update_loop_elements();      update_loop_elements();
995      VCFEnabled_toggled();      VCFEnabled_toggled();
# Line 900  void DimRegionEdit::VCFEnabled_toggled() Line 1004  void DimRegionEdit::VCFEnabled_toggled()
1004      eVCFVelocityCurve.set_sensitive(sensitive);      eVCFVelocityCurve.set_sensitive(sensitive);
1005      eVCFVelocityScale.set_sensitive(sensitive);      eVCFVelocityScale.set_sensitive(sensitive);
1006      eVCFVelocityDynamicRange.set_sensitive(sensitive);      eVCFVelocityDynamicRange.set_sensitive(sensitive);
1007        cutoff_curve.set_sensitive(sensitive);
1008      eVCFResonance.set_sensitive(sensitive);      eVCFResonance.set_sensitive(sensitive);
1009      eVCFResonanceController.set_sensitive(sensitive);      eVCFResonanceController.set_sensitive(sensitive);
1010      eVCFKeyboardTracking.set_sensitive(sensitive);      eVCFKeyboardTracking.set_sensitive(sensitive);
# Line 992  void DimRegionEdit::AttenuationControlle Line 1097  void DimRegionEdit::AttenuationControlle
1097      eCrossfade_in_end.set_sensitive(hasController);      eCrossfade_in_end.set_sensitive(hasController);
1098      eCrossfade_out_start.set_sensitive(hasController);      eCrossfade_out_start.set_sensitive(hasController);
1099      eCrossfade_out_end.set_sensitive(hasController);      eCrossfade_out_end.set_sensitive(hasController);
1100        crossfade_curve.set_sensitive(hasController);
1101  }  }
1102    
1103  void DimRegionEdit::LFO1Controller_changed()  void DimRegionEdit::LFO1Controller_changed()
# Line 1105  void DimRegionEdit::loop_infinite_toggle Line 1211  void DimRegionEdit::loop_infinite_toggle
1211      update_model--;      update_model--;
1212  }  }
1213    
1214  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)
1215  {  {
1216      if (dimregion) {      if (dimregion) {
1217          //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
# Line 1149  bool DimRegionEdit::set_sample(gig::Samp Line 1255  bool DimRegionEdit::set_sample(gig::Samp
1255              d[i]->pSample = sample;              d[i]->pSample = sample;
1256    
1257              // copy sample information from Sample to DimensionRegion              // copy sample information from Sample to DimensionRegion
1258                if (copy_sample_unity)
1259              d[i]->UnityNote = sample->MIDIUnityNote;                  d[i]->UnityNote = sample->MIDIUnityNote;
1260              d[i]->FineTune = sample->FineTune;              if (copy_sample_tune)
1261                    d[i]->FineTune = sample->FineTune;
1262              int loops = sample->Loops ? 1 : 0;              if (copy_sample_loop) {
1263              while (d[i]->SampleLoops > loops) {                  int loops = sample->Loops ? 1 : 0;
1264                  d[i]->DeleteSampleLoop(&d[i]->pSampleLoops[0]);                  while (d[i]->SampleLoops > loops) {
1265              }                      d[i]->DeleteSampleLoop(&d[i]->pSampleLoops[0]);
1266              while (d[i]->SampleLoops < sample->Loops) {                  }
1267                  DLS::sample_loop_t loop;                  while (d[i]->SampleLoops < sample->Loops) {
1268                  d[i]->AddSampleLoop(&loop);                      DLS::sample_loop_t loop;
1269              }                      d[i]->AddSampleLoop(&loop);
1270              if (loops) {                  }
1271                  d[i]->pSampleLoops[0].Size = sizeof(DLS::sample_loop_t);                  if (loops) {
1272                  d[i]->pSampleLoops[0].LoopType = sample->LoopType;                      d[i]->pSampleLoops[0].Size = sizeof(DLS::sample_loop_t);
1273                  d[i]->pSampleLoops[0].LoopStart = sample->LoopStart;                      d[i]->pSampleLoops[0].LoopType = sample->LoopType;
1274                  d[i]->pSampleLoops[0].LoopLength = sample->LoopEnd - sample->LoopStart + 1;                      d[i]->pSampleLoops[0].LoopStart = sample->LoopStart;
1275                        d[i]->pSampleLoops[0].LoopLength = sample->LoopEnd - sample->LoopStart + 1;
1276                    }
1277              }              }
1278          }          }
1279    
1280          // update ui          // update ui
1281          update_model++;          update_model++;
1282          wSample->set_text(dimregion->pSample->pInfo->Name);          wSample->set_text(gig_to_utf8(dimregion->pSample->pInfo->Name));
1283          eUnityNote.set_value(dimregion->UnityNote);          eUnityNote.set_value(dimregion->UnityNote);
1284          eFineTune.set_value(dimregion->FineTune);          eFineTune.set_value(dimregion->FineTune);
1285          eSampleLoopEnabled.set_value(dimregion->SampleLoops);          eSampleLoopEnabled.set_value(dimregion->SampleLoops);

Legend:
Removed from v.2397  
changed lines
  Added in v.2566

  ViewVC Help
Powered by ViewVC