Guitarix
gx_preset.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009, 2010 Hermann Meyer, James Warden, Andreas Degert
3  * Copyright (C) 2011 Pete Shorthose
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  * --------------------------------------------------------------------------
19  */
20 
21 /* --------------------------------------------------------------------------
22 
23  This is the gx_head preset handling functions
24 
25  ---------------------------------------------------------------------------*/
26 
27 #include <sys/stat.h>
28 
29 #include "engine.h" // NOLINT
30 
31 namespace gx_preset {
32 
33 /****************************************************************
34  ** class PresetIO
35  */
36 
39  gx_engine::ParamMap& param_,
41  UnitRacks& rack_units_)
42  : gx_system::AbstractPresetIO(),
43  mctrl(mctrl_),
44  convolver(cvr_),
45  param(param_),
46  opt(opt_),
47  plist(),
48  m(0),
49  rack_units(rack_units_) {
50 }
51 
53  clear();
54 }
55 
56 void PresetIO::clear() {
57  plist.clear();
58  delete m;
59  m = 0;
60 }
61 
62 bool PresetIO::midi_in_preset() {
63  const char *i = "system.midi_in_preset";
64  if (param.hasId(i)) {
65  return param[i].getBool().get_value();
66  } else {
67  return false;
68  }
69 }
70 
72  clear();
73  for (gx_engine::ParamMap::iterator i = param.begin(); i != param.end(); ++i) {
74  if (i->second->isInPreset() && i->second->isSavable()) {
75  i->second->stdJSON_value();
76  plist.push_back(i->second);
77  }
78  }
79  read_intern(jp, 0, head);
80 }
81 
82 void PresetIO::fixup_parameters(const gx_system::SettingsFileHeader& head) {
83  assert(param.hasId("jconv.wet_dry"));
84  if (head.is_current()) {
85  return;
86  }
87  if (head.get_major() == 1 && head.get_minor() < 2) {
88  if (param.hasId("jconv.wet_dry")) {
89  gx_engine::Parameter& p = param["jconv.wet_dry"];
90  if (p.isFloat()) {
91  p.getFloat().convert_from_range(-1, 1);
92  }
93  }
94  }
95 }
96 
97 static std::string replaced_id(const std::string& s) {
98  const char *old_new[][2] = {
99  { "beat_detector.stepper", "midi_out.beat_detector.stepper" },
100  { "beat_detector.note_off", "midi_out.beat_detector.note_off" },
101  { "beat_detector.atack_gain", "midi_out.beat_detector.atack_gain" },
102  { "beat_detector.beat_gain", "midi_out.beat_detector.beat_gain" },
103  { "beat_detector.midi_gain", "midi_out.beat_detector.midi_gain" },
104  // begin ui.*
105  // ui.<name> -> ui.<id> (rack unit visible)
106  { "ui.3 Band EQ", "ui.tonemodul" },
107  { "ui.BiQuad Filter", "ui.biquad" },
108  { "ui.Cabinet", "ui.cab" },
109  { "ui.Preamp", "ui.pre" },
110  { "ui.Chorus", "ui.chorus" },
111  { "ui.Chorus Mono", "ui.chorus_mono" },
112  { "ui.Compressor", "ui.compressor" },
113  { "ui.Convolver", "ui.jconv" },
114  { "ui.Crybaby", "ui.crybaby" },
115  { "ui.Delay", "ui.delay" },
116  { "ui.Echo", "ui.echo" },
117  { "ui.Feedback", "ui.feedback" },
118  { "ui.Flanger", "ui.flanger" },
119  { "ui.Flanger Mono", "ui.flanger_mono" },
120  { "ui.Freeverb", "ui.freeverb" },
121  { "ui.ImpulseResponse", "ui.IR" },
122  { "ui.Midi Out", "ui.midi_out" },
123  { "ui.Moog Filter", "ui.moog" },
124  { "ui.Multi Band Distortion", "ui.gx_distortion" },
125  { "ui.Oscilloscope", "ui.oscilloscope" },
126  { "ui.Overdrive", "ui.overdrive" },
127  { "ui.Phaser", "ui.phaser" },
128  { "ui.Phaser Mono", "ui.phaser_mono" },
129  { "ui.Postamp", "ui.ampmodul" },
130  { "ui.Scaleable EQ", "ui.eqs" },
131  { "ui.Stereo Delay", "ui.stereodelay" },
132  { "ui.Stereo Echo", "ui.stereoecho" },
133  { "ui.Stereo Verb", "ui.stereoverb" },
134  { "ui.Tonestack", "ui.amp.tonestack" },
135  { "ui.Tremolo", "ui.tremolo" },
136  { "ui.Vibe", "ui.univibe" },
137  { "ui.Vibe Mono", "ui.univibe_mono" },
138  { "ui.Zita Rev1", "ui.zita_rev1" },
139  { "ui.abGate", "ui.abgate" },
140  { "ui.low high pass", "ui.low_highpass" },
141  { "Rev.Rocket.s_h", "rev_rocket.s_h"},
142  { "Rev.Rocket.position", "rev_rocket.position"},
143  { "Rev.Rocket.pp", "rev_rocket.pp"},
144  { "ui.Rev.Rocket", "ui.rev_rocket"},
145  {0}
146  };
147  for (const char *(*p)[2] = old_new; (*p)[0]; ++p) {
148  if (s == (*p)[0]) {
149  return (*p)[1];
150  }
151  }
152  return "";
153 }
154 
156 public:
157  std::string id;
158  int weight;
159  UnitPositionID(const string& id_, const UnitPosition& u);
160  bool operator<(const UnitPositionID& v) const { return weight < v.weight; }
161 };
162 
163 UnitPositionID::UnitPositionID(const string& id_, const UnitPosition& u)
164  : UnitPosition(u),
165  id(id_),
166  weight(position - 1000 * pp) {
167 }
168 
169 void UnitsCollector::get_list(std::vector<std::string>& l, bool stereo, gx_engine::ParamMap& param) {
170  std::vector<UnitPositionID> v;
171  for (std::map<std::string,UnitPosition>::iterator i = m.begin(); i != m.end(); ++i) {
172  if (i->first == "jconv" && i->second.position < 0) {
173  i->second.position = 99; // very old presets
175  jp.get_ostream() << i->second.position;
176  jp.start_parser();
177  param[i->first+".position"].readJSON_value(jp);
178  }
179  if (i->first == "cab") {
180  if (i->second.position < 0) {
181  i->second.position = 98; // very old presets
183  jp.get_ostream() << i->second.position;
184  jp.start_parser();
185  param[i->first+".position"].readJSON_value(jp);
186  }
187  if (i->second.pp < 0) {
188  i->second.pp = 0;
190  jp.get_ostream() << i->second.pp;
191  jp.start_parser();
192  param[i->first+".pp"].readJSON_value(jp);
193  }
194  }
195  if (i->second.position >= 0 && i->second.show) {
196  if ((stereo && i->second.pp < 0) || (!stereo && i->second.pp >= 0)) {
197  if (!i->second.visible) { // make sure ui.XX is set for old presets
198  i->second.visible = true;
200  jp.put('1');
201  jp.start_parser();
202  param["ui."+i->first].readJSON_value(jp);
203  }
204  v.push_back(UnitPositionID(i->first, i->second));
205  }
206  }
207  }
208  l.clear();
209  std::sort(v.begin(), v.end());
210  int pp = 1;
211  for (std::vector<UnitPositionID>::iterator j = v.begin(); j != v.end(); ++j) {
212  if (!stereo && j->pp != pp) {
213  pp = j->pp;
214  l.push_back("ampstack");
215  }
216  l.push_back(j->id);
217  }
218  if (!stereo && pp) {
219  l.push_back("ampstack");
220  }
221  /*
222  cerr << "SL";
223  for (std::vector<std::string>::iterator ii = l.begin(); ii != l.end(); ++ii) {
224  cerr << " '" << *ii << "'";
225  }
226  cerr << endl;
227  */
228 }
229 
230 bool PresetIO::convert_old(gx_system::JsonParser &jp) {
231  const std::string& s = jp.current_value();
232  if (s == "system.mainwin_x") {
234  opt.mainwin_x = jp.current_value_int();
235  return true;
236  }
237  if (s == "system.mainwin_y") {
239  opt.mainwin_y = jp.current_value_int();
240  return true;
241  }
242  if (s == "system.mainwin_height") {
244  opt.mainwin_height = jp.current_value_int();
245  return true;
246  }
247  if (s == "system.mainwin_rack_height") {
249  opt.window_height = jp.current_value_int();
250  return true;
251  }
252  if (s == "system.preset_window_height") {
254  opt.preset_window_height = jp.current_value_int();
255  return true;
256  }
257  if (s == "oscilloscope.bufferset") {
259  opt.mul_buffer = jp.current_value_int();
260  return true;
261  }
262  if (s == "ui.skin_name") {
264  opt.skin_name = jp.current_value();
265  return true;
266  }
267  if (s == "ui.latency_nowarn") {
269  opt.no_warn_latency = jp.current_value_int();
270  return true;
271  }
272  if (s == "system.order_rack_h") {
274  opt.system_order_rack_h = jp.current_value_int();
275  return true;
276  }
277  if (s == "system.show_value") {
279  opt.system_show_value = jp.current_value_int();
280  return true;
281  }
282  if (s == "system.show_tooltips") {
284  opt.system_show_tooltips = jp.current_value_int();
285  return true;
286  }
287  if (s == "system.animations") {
289  opt.system_animations = jp.current_value_int();
290  return true;
291  }
292  if (s == "system.show_presets") {
294  opt.system_show_presets = jp.current_value_int();
295  return true;
296  }
297  if (s == "system.show_toolbar") {
299  opt.system_show_toolbar = jp.current_value_int();
300  return true;
301  }
302  if (s == "system.show_rack") {
304  opt.system_show_rack = jp.current_value_int();
305  return true;
306  }
307 
308  return false;
309 }
310 
311 static inline bool endswith(const std::string& s, int n, const char *t) {
312  return s.compare(std::max<int>(0, s.size()-n), n, t) == 0;
313 }
314 
315 static inline bool startswith(const std::string& s, int n, const char *t) {
316  return s.compare(0, n, t) == 0;
317 }
318 
319 void PresetIO::collectRackOrder(gx_engine::Parameter *p, gx_system::JsonParser &jp, UnitsCollector& u) {
320  const std::string& s = p->id();
321  if (startswith(s, 3, "ui.")) {
322  if (jp.current_value_int()) {
323  std::string ss = s.substr(3);
324  u.set_visible(ss, true);
325  u.set_show(ss, true);
326  }
327  } else if (endswith(s, 7, ".on_off")) {
328  if (jp.current_value_int()) {
329  u.set_show(s.substr(0, s.size()-7), true);
330  }
331  } else if (endswith(s, 9, ".position")) {
332  u.set_position(s.substr(0, s.size()-9), jp.current_value_int());
333  } else if (endswith(s, 3, ".pp")) {
334  u.set_pp(s.substr(0, s.size()-3), (jp.current_value() == "pre" ? 1 : 0));
335  }
336 }
337 
338 void PresetIO::read_parameters(gx_system::JsonParser &jp, bool preset) {
339  UnitsCollector u;
341  do {
344  if (!param.hasId(jp.current_value())) {
345  if (convert_old(jp)) {
346  continue;
347  }
348  std::string s = replaced_id(jp.current_value());
349  if (s.empty()) {
351  _("recall settings"),
352  _("unknown parameter: ")+jp.current_value());
353  jp.skip_object();
354  continue;
355  }
356  p = &param[s];
357  } else {
358  p = &param[jp.current_value()];
359  }
360  if (!preset and p->isInPreset()) {
362  _("recall settings"),
363  _("preset-parameter ")+p->id()+_(" in settings"));
364  jp.skip_object();
365  continue;
366  } else if (preset and !p->isInPreset()) {
368  _("recall settings"),
369  _("non preset-parameter ")+p->id()+_(" in preset"));
370  jp.skip_object();
371  continue;
372  } else if (!p->isSavable()) {
374  _("recall settings"),
375  _("non saveable parameter ")+p->id()+_(" in settings"));
376  jp.skip_object();
377  continue;
378  }
379  p->readJSON_value(jp);
380  collectRackOrder(p, jp, u);
381  } while (jp.peek() == gx_system::JsonParser::value_key);
383  u.get_list(rack_units.mono, false, param);
384  u.get_list(rack_units.stereo, true, param);
385 }
386 
387 void PresetIO::write_parameters(gx_system::JsonWriter &w, bool preset) {
388  w.begin_object(true);
389 #if 0
390  int n = 0;
391  int pp = 1;
392  for (std::vector<std::string>::iterator j = mono_rack_units.begin(); j != mono_rack_units.end(); ++j) {
393  if (*j == "ampstack") {
394  n = 1;
395  pp = 0;
396  }
397  w.write_key("ui."+*j);
398  w.write(1);
399  w.write_key(*j+".pp");
400  w.write(pp);
401  w.write_key(*j+".position");
402  w.write(n);
403  n++;
404  }
405 #endif
406  for (gx_engine::ParamMap::iterator i = param.begin();
407  i != param.end(); ++i) {
408  gx_engine::Parameter *param = i->second;
409  if (!param->isSavable()) {
410  continue;
411  }
412  if ((preset and param->isInPreset()) or(!preset and !param->isInPreset())) {
413  param->writeJSON(w);
414  w.newline();
415  }
416  }
417  w.end_object(true);
418 }
419 
420 
422  std::string NAME_;
423  std::string FILE_;
424  std::string INFO_;
425  std::string AUTHOR_;
426  ifstream is(opt.get_online_config_filename().c_str());
427  ofstream os(opt.get_online_presets_filename().c_str());
428  if (!is.fail() && !os.fail()) {
429  gx_system::JsonParser jp(&is);
430  try {
432  do {
434  do {
436  if (jp.current_value() == "name") {
437  jp.read_kv("name", NAME_);
438  } else if (jp.current_value() == "description") {
439  jp.read_kv("description", INFO_);
440  } else if (jp.current_value() == "author") {
441  jp.read_kv("author", AUTHOR_);
442  } else if (jp.current_value() == "file") {
443  jp.read_kv("file", FILE_);
444  INFO_ += "Author : " + AUTHOR_;
445  // olp.push_back(std::tuple<std::string,std::string,std::string>(NAME_,FILE_,INFO_));
446  os << "\n<<NAME>> \n" << NAME_ << "\n<<FILE>> \n" << FILE_ << "\n<<INFO>> \n" << INFO_ << "\n<<END>> \n" << "\n";
447  } else {
448  //gx_print_warning("read_online", "unknown key: " + jp.current_value());
449  jp.skip_object();
450  }
451  } while (jp.peek() == gx_system::JsonParser::value_key);
453  } while (jp.peek() == gx_system::JsonParser::begin_object);
454  } catch (gx_system::JsonException e) {
455  cerr << "JsonException: " << e.what() << ": '" << jp.current_value() << "'" << endl;
456  assert(false);
457  }
458  is.close();
459  os.close();
460  } else {
461  gx_print_warning(_("load online"),_("fail to open: "));
462  }
463 }
464 
465 void PresetIO::read_intern(gx_system::JsonParser &jp, bool *has_midi, const gx_system::SettingsFileHeader& head) {
466  bool use_midi = (has_midi != 0) || midi_in_preset();
467  if (has_midi) {
468  *has_midi = false;
469  }
471  do {
473  if (jp.current_value() == "engine") {
474  read_parameters(jp, true);
475  } else if (jp.current_value() == "jconv") { // for backwards compatibility
476  dynamic_cast<gx_engine::JConvParameter*>(&param["jconv.convolver"])->readJSON_value(jp);
477  } else if (jp.current_value() == "seq") {
478  dynamic_cast<gx_engine::SeqParameter*>(&param["seq.sequencer"])->readJSON_value(jp);
479  fprintf(stderr,"seq.sequencer found\n");
480  } else if (jp.current_value() == "midi_controller") {
481  if (use_midi) {
482  m = new gx_engine::ControllerArray();
483  m->readJSON(jp, param);
484  if (has_midi) {
485  *has_midi = true;
486  }
487  } else {
488  jp.skip_object();
489  }
490  } else {
492  _("recall settings"),
493  _("unknown preset section: ") + jp.current_value());
494  jp.skip_object();
495  }
496  } while (jp.peek() == gx_system::JsonParser::value_key);
498  fixup_parameters(head);
499 }
500 
502  for (gx_engine::paramlist::iterator i = plist.begin(); i != plist.end(); ++i) {
503  (*i)->setJSON_value();
504  }
505  if (m) {
506  mctrl.set_controller_array(*m);
507  }
508  clear();
509  mctrl.update_from_controllers();
510 }
511 
512 void PresetIO::write_intern(gx_system::JsonWriter &w, bool write_midi) {
513  w.begin_object(true);
514  w.write_key("engine");
515  write_parameters(w, true);
516  if (write_midi) {
517  w.write_key("midi_controller");
518  mctrl.writeJSON(w);
519  }
520  w.newline();
521  w.end_object(true);
522 }
523 
525  write_intern(jw, midi_in_preset());
526 }
527 
529  gx_system::JsonWriter &jw) {
530  param.set_init_values();
531  bool has_midi;
532  clear();
533  read_intern(jp, &has_midi, head);
534  commit_preset();
535  write_intern(jw, has_midi);
536 }
537 
538 
539 /****************************************************************
540  ** class StateIO
541  */
542 
545  gx_jack::GxJack& jack_, gx_system::CmdlineOptions& opt_, UnitRacks& rack_units)
546  : PresetIO(mctrl, cvr, param, opt_, rack_units),
547  midi_std_control(mstdctr),
548  jack(jack_) {
549 }
550 
552 }
553 
555  clear();
556  for (gx_engine::ParamMap::iterator i = param.begin(); i != param.end(); ++i) {
557  if (i->second->isSavable()) {
558  i->second->stdJSON_value();
559  plist.push_back(i->second);
560  }
561  }
562  do {
564  if (jp.current_value() == "settings") {
565  read_parameters(jp, false);
566  } else if (jp.current_value() == "current_preset") {
567  read_intern(jp, 0, head);
568  } else if (jp.current_value() == "midi_controller") {
569  m = new gx_engine::ControllerArray();
570  m->readJSON(jp, param);
571  } else if (jp.current_value() == "midi_ctrl_names") {
572  midi_std_control.readJSON(jp);
573  } else if (jp.current_value() == "jack_connections") {
574  jack.read_connections(jp);
575  } else {
577  _("recall settings"),
578  _("unknown section: ") + jp.current_value());
579  jp.skip_object();
580  }
581  } while (jp.peek() == gx_system::JsonParser::value_string);
582 }
583 
585  commit_preset();
586 }
587 
588 void StateIO::write_state(gx_system::JsonWriter &jw, bool no_preset) {
589  jw.write("settings");
590  write_parameters(jw, false);
591 
592  jw.write("midi_controller");
593  mctrl.writeJSON(jw);
594 
595  jw.write("midi_ctrl_names");
596  midi_std_control.writeJSON(jw);
597 
598  if (!no_preset) {
599  jw.write("current_preset");
600  write_intern(jw, false);
601  }
602 
603  jw.write("jack_connections");
604  jack.write_connections(jw);
605 
606  jw.newline();
607 }
608 
609 
610 /****************************************************************
611  ** class PluginPresetList
612  */
613 
616  : filename(fname), pmap(pmap_), mctrl(mctrl_), is(), jp(&is) {
617 }
618 
620  is.close();
621  is.open(filename.c_str());
622  jp.set_streampos(0);
623  if (is.fail()) {
624  return false;
625  }
626  try {
629  if (jp.current_value() != "gx_plugin_version") {
630  throw gx_system::JsonException("invalid gx_plugin file header");
631  }
633  } catch (gx_system::JsonException& e) {
634  gx_print_error(filename.c_str(), _("parse error"));
635  return false;
636  }
637  return true;
638 }
639 
640 bool PluginPresetList::next(Glib::ustring& name, bool *is_set) {
641  try {
643  name = "";
644  if (is_set) {
645  *is_set = false;
646  }
647  return false;
648  }
650  name = jp.current_value();
651  if (is_set) {
653  *is_set = true;
654  while (jp.peek() != gx_system::JsonParser::end_object) {
656  if (!pmap.hasId(jp.current_value())) {
658  _("recall plugin settings"),
659  _("unknown parameter: ")+jp.current_value());
660  jp.skip_object();
661  continue;
662  }
663  gx_engine::Parameter& p = pmap[jp.current_value()];
664  p.readJSON_value(jp);
665  if (!p.compareJSON_value()) {
666  *is_set = false;
667  }
668  }
670  } else {
671  jp.skip_object();
672  }
673  } catch (gx_system::JsonException& e) {
674  gx_print_error(filename.c_str(), _("parse error"));
675  return false;
676  }
677  return true;
678 }
679 
680 bool PluginPresetList::set(const Glib::ustring& name) {
681  gx_engine::paramlist plist;
682  if (!start()) {
683  return false;
684  }
685  bool ret = false;
686  try {
687  while (jp.peek() != gx_system::JsonParser::end_array) {
689  if (jp.current_value() != name) {
690  jp.skip_object();
691  } else {
692  ret = true;
694  while (jp.peek() != gx_system::JsonParser::end_object) {
696  if (pmap.hasId(jp.current_value())) {
697  gx_engine::Parameter& p = pmap[jp.current_value()];
698  p.readJSON_value(jp);
699  plist.push_back(&p);
700  }
701  }
703  }
704  }
707  } catch (gx_system::JsonException& e) {
708  gx_print_error(filename.c_str(), _("parse error"));
709  return false;
710  }
711  mctrl.remove_controlled_parameters(plist, 0);
712  for (gx_engine::paramlist::iterator i = plist.begin(); i != plist.end(); ++i) {
713  (*i)->setJSON_value();
714  }
715  return ret;
716 }
717 
718 static const int GX_PLUGIN_VERSION = 1;
719 
720 static inline bool compare_groups(const std::string& id, const char **groups) { //FIXME (is copy from gx_paramtable.cpp
721  if (!groups) {
722  return false;
723  }
724  for (const char **g = groups; *g; g += 2) {
725  const char *p = *g;
726  if ((*p) != '.') {
727  continue;
728  }
729  p++;
730  int n = strlen(p);
731  if (strncmp(id.c_str(), p, n) == 0 && id[n] == '.') {
732  return true;
733  }
734  }
735  return false;
736 }
737 
738 void PluginPresetList::write_values(gx_system::JsonWriter& jw, std::string id, const char **groups) {
739  id += ".";
740  string on_off = id + "on_off";
741  string pp = id + "pp";
742  std::string position = id + "position";
743  jw.begin_object(true);
744  for (gx_engine::ParamMap::iterator i = pmap.begin(); i != pmap.end(); ++i) {
745  if (i->first.compare(0, id.size(), id) == 0 || compare_groups(i->first, groups)) {
746  if (i->second->isInPreset()) {
747  if (i->first != on_off && i->first != pp && i->first != position) {
748  i->second->writeJSON(jw);
749  jw.newline();
750  }
751  }
752  }
753  }
754  jw.end_object(true);
755 }
756 
757 void PluginPresetList::save(const Glib::ustring& name, const std::string& id, const char **groups) {
758  try {
759  std::string tmpfile(filename + "_tmp");
760  ofstream os(tmpfile.c_str());
761  gx_system::JsonWriter jw(&os);
762  jw.begin_array();
763  jw.write("gx_plugin_version");
764  jw.write(GX_PLUGIN_VERSION, true);
765  bool found = false;
766  if (start()) {
767  while (jp.peek() != gx_system::JsonParser::end_array) {
769  jw.write(jp.current_value());
770  if (jp.current_value() == name) {
771  found = true;
772  write_values(jw, id, groups);
773  jp.skip_object();
774  } else {
775  jp.copy_object(jw);
776  }
777  }
778  }
779  if (!found) {
780  jw.write(name);
781  write_values(jw, id, groups);
782  }
783  jw.end_array(true);
784  jw.close();
785  os.close();
786  if (!os.good()) {
787  gx_print_error(_("save plugin preset"),
788  boost::format(_("couldn't write %1%")) % tmpfile);
789  return;
790  }
791  int rc = rename(tmpfile.c_str(), filename.c_str());
792  if (rc != 0) {
793  gx_print_error(_("save plugin preset"),
794  boost::format(_("couldn't rename %1% to %2%"))
795  % tmpfile % filename);
796  }
797  } catch (gx_system::JsonException& e) {
798  gx_print_error(filename.c_str(), _("parse error"));
799  }
800 }
801 
802 bool PluginPresetList::remove(const Glib::ustring& name) {
803  bool ret = false;
804  if (start()) {
805  try {
806  std::string tmpfile(filename + "_tmp");
807  ofstream os(tmpfile.c_str());
808  gx_system::JsonWriter jw(&os);
809  jw.begin_array();
810  jw.write("gx_plugin_version");
811  jw.write(GX_PLUGIN_VERSION, true);
812  while (jp.peek() != gx_system::JsonParser::end_array) {
814  if (jp.current_value() == name) {
815  jp.skip_object();
816  ret = true;
817  } else {
818  jw.write(jp.current_value());
819  jp.copy_object(jw);
820  }
821  }
824  jw.end_array(true);
825  jw.close();
826  os.close();
827  if (!os.good()) {
828  gx_print_error(_("remove plugin preset"),
829  boost::format(_("couldn't write %1%")) % tmpfile);
830  return false;
831  }
832  int rc = rename(tmpfile.c_str(), filename.c_str());
833  if (rc != 0) {
834  gx_print_error(_("remove plugin preset"),
835  boost::format(_("couldn't rename %1% to %2%"))
836  % tmpfile % filename);
837  return false;
838  }
839  } catch (gx_system::JsonException& e) {
840  gx_print_error(filename.c_str(), _("parse error"));
841  }
842  return ret;
843  } else {
844  return false;
845  }
846 }
847 
848 
849 /****************************************************************
850  ** GxSettings
851  */
852 
853 static const char *scratchpad_name = N_("Scratchpad");
854 static const char *scratchpad_file = "scratchpad.gx";
855 static const char *statename_postfix = "_rc";
856 static const char *bank_list = "banklist.js";
857 
861  : sigc::trackable(),
862  GxSettingsBase(seq_),
863  param(seq_.get_param()),
864  preset_io(mctrl_, cvr, param, opt, rack_units),
865  state_io(mctrl_, cvr, param, mstdctr, jack_, opt, rack_units),
866  state_loaded(false),
867  no_autosave(false),
868  jack(jack_),
869  mctrl(mctrl_),
870  options(opt),
871  preset_parameter(*param.reg_string("system.current_preset", "?", &current_name, "")),
872  bank_parameter(*param.reg_string("system.current_bank", "?", &current_bank, "")) {
873  set_io(&state_io, &preset_io);
874  statefile.set_filename(make_default_state_filename());
875  banks.parse(opt.get_preset_filepath(bank_list), opt.get_preset_dir(), opt.get_factory_dir(),
876  scratchpad_name, scratchpad_file);
877  instance = this;
878  GxExit::get_instance().signal_exit().connect(
879  sigc::mem_fun(*this, &GxSettings::exit_handler));
880  jack.signal_client_change().connect(
881  sigc::mem_fun(*this, &GxSettings::jack_client_changed));
882 }
883 
884 GxSettings *GxSettings::instance = 0;
885 
887  instance = 0;
888  auto_save_state();
889 }
890 
892  if (state_loaded) {
893  if (setting_is_preset()) {
896  !pf->get_flags()) {
897  save(*pf, current_name);
898  }
899  }
900  if (!no_autosave) {
901  save_to_state();
902  }
903  }
904 }
905 
906 void GxSettings::exit_handler(bool otherthread) {
907  if (otherthread) {
908  return;
909  }
910  auto_save_state();
911 }
912 
913 void GxSettings::jack_client_changed() {
914  string fn = make_state_filename();
915  if (state_loaded && fn == statefile.get_filename()) {
917  return;
918  }
919  if (!state_loaded && access(fn.c_str(), R_OK|W_OK) != 0) {
920  string defname = make_default_state_filename();
921  if (access(defname.c_str(), R_OK) == 0) {
922  statefile.set_filename(defname);
923  loadsetting(0, "");
924  }
925  }
927  loadstate();
928 }
929 
930 string GxSettings::make_default_state_filename() {
931  if (!options.get_loadfile().empty()) {
932  return options.get_loadfile();
933  }
934  std::string s = options.get_jack_instancename();
935  if (!s.empty()) {
936  s = options.get_user_filepath(s + statename_postfix);
937  if (access(s.c_str(), R_OK|W_OK) == 0) {
938  return s;
939  }
940  }
941  return options.get_user_filepath(
942  jack.get_default_instancename() + statename_postfix);
943 }
944 
945 string GxSettings::make_state_filename() {
946  if (!options.get_loadfile().empty()) {
947  return options.get_loadfile();
948  }
949  return options.get_user_filepath(
950  jack.get_instancename() + statename_postfix);
951 }
952 
953 bool GxSettings::check_create_config_dir(const Glib::ustring& dir) {
954  if (access((Glib::build_filename(dir, ".")).c_str(), R_OK|W_OK|X_OK) != 0) {
955  if (errno != ENOENT) {
956  throw GxFatalError(
957  boost::format(_("no read/write access in guitarix config dir '%1%'"))
958  % dir);
959  }
960  if (mkdir(dir.c_str(), 0777) != 0) {
961  throw GxFatalError(
962  boost::format(_("can't create guitarix config dir '%1%'"))
963  % dir);
964  }
965  return true;
966  }
967  return false;
968 }
969 
971  save(*banks.get_file(scratchpad_name), "livebuffer1");
972 }
973 
974 static inline std::vector<std::string>::iterator find_unit(std::vector<std::string>& r, const std::string& unit) {
975  std::vector<std::string>::iterator i = r.begin();
976  for (; i != r.end(); ++i) {
977  if (unit == *i) {
978  break;
979  }
980  }
981  return i;
982 }
983 
984 bool GxSettings::remove_rack_unit(const std::string& unit, bool stereo) {
985  std::vector<std::string>& r = stereo ? rack_units.stereo : rack_units.mono;
986  std::vector<std::string>::iterator i = find_unit(r, unit);
987  if (i != r.end()) {
988  r.erase(i);
989  return true;
990  }
991  return false;
992 }
993 
994 void GxSettings::insert_rack_unit(const std::string& unit, const std::string& before, bool stereo) {
995  std::vector<std::string>& r = stereo ? rack_units.stereo : rack_units.mono;
996  remove_rack_unit(unit, stereo);
997  if (before.empty()) {
998  r.push_back(unit);
999  } else {
1000  r.insert(find_unit(r, before), unit);
1001  }
1002 }
1003 
1004 Glib::RefPtr<Gio::File> GxSettings::uri_to_name_filename(const Glib::ustring& uri, Glib::ustring& name, std::string& filename) {
1005  Glib::RefPtr<Gio::File> rem = Gio::File::create_for_uri(uri);
1006  filename = rem->get_basename();
1007  banks.strip_preset_postfix(filename);
1008  name = gx_system::decode_filename(filename);
1009  banks.make_valid_utf8(name);
1010  banks.make_bank_unique(name, &filename);
1011  return rem;
1012 }
1013 
1014 gx_system::PresetFile* GxSettings::bank_insert_uri(const Glib::ustring& uri, bool move) {
1015  Glib::ustring name;
1016  std::string filename;
1017  Glib::RefPtr<Gio::File> rem = uri_to_name_filename(uri, name, filename);
1018  Glib::RefPtr<Gio::File> dest = Gio::File::create_for_path(filename);
1019  try {
1020  rem->copy(dest);
1021  } catch (Gio::Error& e) {
1022  gx_print_error(e.what().c_str(), _("can't copy to config dir"));
1023  return 0;
1024  }
1026  if (f->open_file(name, filename, gx_system::PresetFile::PRESET_FILE, 0)) {
1027  banks.insert(f);
1028  } else {
1029  delete f;
1030  try {
1031  dest->remove();
1032  } catch (Gio::Error& e) {
1033  gx_print_error(e.what().c_str(), _("can't remove copied file!?"));
1034  }
1035  return 0;
1036  }
1037  if (move) {
1038  try {
1039  rem->remove();
1040  } catch (Gio::Error& e) {
1041  gx_print_error(e.what().c_str(), _("can't move; file has been copied"));
1042  }
1043  }
1044  return f;
1045 }
1046 
1047 gx_system::PresetFile* GxSettings::bank_insert_content(const Glib::ustring& uri, const std::string content) {
1048  Glib::ustring name;
1049  std::string filename;
1050  uri_to_name_filename(uri, name, filename);
1051  Glib::RefPtr<Gio::File> dest = Gio::File::create_for_path(filename);
1052  try {
1053  Glib::RefPtr<Gio::FileOutputStream> s = dest->create_file();
1054  s->write(content);
1055  s->close();
1056  } catch (Gio::Error& e) {
1057  gx_print_error(e.what().c_str(), _("can't bank"));
1058  return 0;
1059  }
1061  if (f->open_file(name, filename, gx_system::PresetFile::PRESET_FILE, 0)) {
1062  banks.insert(f);
1063  } else {
1064  delete f;
1065  try {
1066  dest->remove();
1067  } catch (Gio::Error& e) {
1068  gx_print_error(e.what().c_str(), _("can't remove copied file!?"));
1069  }
1070  return 0;
1071  }
1072  return f;
1073 }
1074 
1076  Glib::ustring newname = name;
1077  std::string newfile;
1078  banks.make_bank_unique(newname, &newfile);
1080  if (f->create_file(newname, newfile, gx_system::PresetFile::PRESET_FILE, 0)) {
1081  banks.insert(f);
1082  return f;
1083  } else {
1084  delete f;
1085  return 0;
1086  }
1087 }
1088 
1089 bool GxSettings::rename_bank(const Glib::ustring& oldname, Glib::ustring& newname) {
1090  std::string newfile;
1091  banks.make_bank_unique(newname, &newfile);
1092  return GxSettingsBase::rename_bank(oldname, newname, newfile);
1093 }
1094 
1095 //static
1097  bool copied_from_old = false;
1098  std::string oldpreset;
1099  *need_new_preset = false;
1100  if (check_create_config_dir(opt.get_user_dir())) {
1101  check_create_config_dir(opt.get_preset_dir());
1102  check_create_config_dir(opt.get_plugin_dir());
1103  check_create_config_dir(opt.get_pluginpreset_dir());
1104  check_create_config_dir(opt.get_lv2_preset_dir());
1105  check_create_config_dir(opt.get_loop_dir());
1106  check_create_config_dir(opt.get_user_IR_dir());
1107  check_create_config_dir(opt.get_temp_dir());
1108  std::string fname = gx_jack::GxJack::get_default_instancename() + statename_postfix;
1109  if (access(Glib::build_filename(opt.get_old_user_dir(), fname).c_str(), R_OK) == 0) {
1110  copied_from_old = true;
1111  Glib::RefPtr<Gio::File> f = Gio::File::create_for_path(
1112  Glib::build_filename(opt.get_old_user_dir(), fname));
1113  try {
1114  f->copy(Gio::File::create_for_path(opt.get_user_filepath(fname)));
1115  } catch (Gio::Error& e) {
1116  gx_print_error(e.what().c_str(), _("can't copy to new config dir"));
1117  }
1118  }
1119  fname = Glib::build_filename(
1120  opt.get_old_user_dir(),
1122  if (access(fname.c_str(), R_OK) == 0) {
1123  Glib::RefPtr<Gio::File> f = Gio::File::create_for_path(fname);
1124  oldpreset = opt.get_preset_filepath("oldpresets.gx");
1125  try {
1126  f->copy(Gio::File::create_for_path(oldpreset));
1127  } catch (Gio::Error& e) {
1128  gx_print_error(e.what().c_str(), _("can't copy to new config preset dir"));
1129  oldpreset = "";
1130  }
1131  }
1132  } else {
1133  check_create_config_dir(opt.get_preset_dir());
1134  check_create_config_dir(opt.get_plugin_dir());
1135  check_create_config_dir(opt.get_pluginpreset_dir());
1136  check_create_config_dir(opt.get_lv2_preset_dir());
1137  check_create_config_dir(opt.get_loop_dir());
1138  check_create_config_dir(opt.get_user_IR_dir());
1139  check_create_config_dir(opt.get_temp_dir());
1140  }
1141  std::string fname = opt.get_preset_filepath(scratchpad_file);
1142  if (access(fname.c_str(), R_OK) != 0) {
1144  throw GxFatalError(
1145  boost::format(_("can't create file in '%1%' !!??")) % opt.get_preset_dir());
1146  }
1147  *need_new_preset = true;
1148  }
1149  fname = opt.get_preset_filepath(bank_list);
1150  if (access(fname.c_str(), R_OK) != 0) {
1151  ofstream f(fname.c_str());
1152  if (!f.good()) {
1153  throw GxFatalError(
1154  boost::format(_("can't create '%1%' in directory '%2%'"))
1155  % bank_list % opt.get_preset_dir());
1156  }
1158  pre.open_file(scratchpad_name, opt.get_preset_filepath(scratchpad_file), gx_system::PresetFile::PRESET_SCRATCH, 0);
1159  gx_system::JsonWriter jw(&f);
1160  jw.begin_array(true);
1161  pre.writeJSON(jw);
1162  if (!oldpreset.empty() && pre.open_file("copied presets", oldpreset, gx_system::PresetFile::PRESET_FILE, 0)) {
1163  pre.writeJSON(jw);
1164  }
1165  jw.end_array(true);
1166  jw.close();
1167  f.close();
1168  }
1169  return copied_from_old;
1170 }
1171 
1173  GxSettingsBase::loadstate();
1174 #if 0
1175  /* This following code is commented out because
1176  **
1177  ** o its debatable which of state file or scratch preset should have
1178  ** priority in case both differ because 2 different instantiations
1179  ** accessed the same scratch preset but different statefiles.
1180  **
1181  ** o if the scratch preset has priority, the autosave function would
1182  ** have to save to statefile *and* scratch preset (in case of the
1183  ** current preset being a scratch preset).
1184  **
1185  ** As an aside: load_preset() would have to be changed to not save
1186  ** to the scratch preset before loading in the case that this code
1187  ** is activated.
1188  */
1189  if (setting_is_preset()) {
1191  if (pf && pf->get_type() == gx_system::PresetFile::PRESET_SCRATCH) {
1192  /* make sure we see the content of the scratchpad,
1193  ** not the state file (in case someone changed the
1194  ** scratchpad while working with a different state file)
1195  */
1197  }
1198  }
1199 #endif
1200  state_loaded = true;
1201 }
1202 
1203 void GxSettings::add_plugin_preset_list(gx_preset::PluginPresetList& l,
1204  UnitPresetList &presetnames) {
1205  if (l.start()) {
1206  Glib::ustring name;
1207  bool is_set;
1208  while (l.next(name, &is_set)) {
1209  presetnames.push_back(PluginPresetEntry(name, is_set));
1210  }
1211  }
1212 }
1213 
1215  PluginPresetList lv2sets(options.get_lv2_preset_filepath(pdef->id), param, mctrl);
1216  add_plugin_preset_list(lv2sets, presetnames);
1217  PluginPresetList user(options.get_pluginpreset_filepath(pdef->id, false), param, mctrl);
1218  add_plugin_preset_list(user, presetnames);
1219  presetnames.push_back(PluginPresetEntry("", false));
1220  PluginPresetList factory(options.get_pluginpreset_filepath(pdef->id, true), param, mctrl);
1221  add_plugin_preset_list(factory, presetnames);
1222 }
1223 
1224 void GxSettings::plugin_preset_list_set(const PluginDef *pdef, bool factory, const Glib::ustring& name) {
1225  if (!PluginPresetList(options.get_pluginpreset_filepath(pdef->id, factory), param, mctrl).set(name))
1226  PluginPresetList(options.get_lv2_preset_filepath(pdef->id), param, mctrl).set(name);
1227 }
1228 
1229 void GxSettings::plugin_preset_list_save(const PluginDef *pdef, const Glib::ustring& name) {
1230  PluginPresetList(options.get_pluginpreset_filepath(pdef->id, false), param, mctrl).save(name, pdef->id, pdef->groups);
1231 }
1232 
1233 void GxSettings::plugin_preset_list_remove(const PluginDef *pdef, const Glib::ustring& name) {
1234  // remove loop files when delete a plugin preset
1235  if(strcmp(pdef->id,"dubber")==0) {
1236  std::string pPath = options.get_loop_dir();
1237  pPath += name;
1238  std::remove((pPath + "1.wav").c_str());
1239  std::remove((pPath + "2.wav").c_str());
1240  std::remove((pPath + "3.wav").c_str());
1241  std::remove((pPath + "4.wav").c_str());
1242  }
1243  if (!PluginPresetList(options.get_pluginpreset_filepath(pdef->id, false), param, mctrl).remove(name))
1244  PluginPresetList(options.get_lv2_preset_filepath(pdef->id), param, mctrl).remove(name);
1245 }
1246 
1247 
1248 /* ----------------------------------------------------------------*/
1249 } /* end of gx_preset namespace */
void write_state(gx_system::JsonWriter &jw, bool preserve_preset)
Definition: gx_preset.cpp:588
void set_pp(const std::string &s, bool v)
Definition: gx_preset.h:60
gx_system::PresetFile * bank_insert_uri(const Glib::ustring &uri, bool move)
Definition: gx_preset.cpp:1014
void set_io(AbstractStateIO *st, AbstractPresetIO *pr)
Definition: gx_json.h:474
void begin_array(bool nl=false)
Definition: gx_json.cpp:184
Definition: gx_preset.h:128
void save(PresetFile &pf, const Glib::ustring &name)
Definition: gx_json.cpp:1891
PresetFile * get_current_bank_file()
Definition: gx_json.h:483
const std::string & get_preset_dir() const
Definition: gx_system.h:473
void set_show(const std::string &s, bool v)
Definition: gx_preset.h:57
void make_bank_unique(Glib::ustring &name, std::string *file=0)
Definition: gx_json.cpp:1458
bool remove_rack_unit(const std::string &unit, bool stereo)
Definition: gx_preset.cpp:984
std::ostream & get_ostream()
Definition: gx_json.h:208
std::string get_pluginpreset_filepath(const std::string &id, bool factory) const
Definition: gx_system.h:467
map< string, Parameter * >::const_iterator iterator
Definition: gx_parameter.h:532
list< Parameter * > paramlist
Definition: gx_parameter.h:220
void set_visible(const std::string &s, bool v)
Definition: gx_preset.h:58
void create_default_scratch_preset()
Definition: gx_preset.cpp:970
void insert(PresetFile *f)
Definition: gx_json.h:449
void end_array(bool nl=false)
Definition: gx_json.cpp:192
void set_streampos(streampos pos)
Definition: gx_json.cpp:571
const Glib::ustring & get_jack_instancename() const
Definition: gx_system.h:495
void read_connections(gx_system::JsonParser &jp)
Definition: gx_jack.cpp:158
void write_preset(gx_system::JsonWriter &jw)
Definition: gx_preset.cpp:524
void read_preset(gx_system::JsonParser &jp, const gx_system::SettingsFileHeader &)
Definition: gx_preset.cpp:71
std::vector< PluginPresetEntry > UnitPresetList
Definition: gx_preset.h:135
#define N_(String)
PresetIO(gx_engine::MidiControllerList &mctrl, gx_engine::ConvolverAdapter &cvr, gx_engine::ParamMap &param, gx_system::CmdlineOptions &opt, UnitRacks &rack_units)
Definition: gx_preset.cpp:37
sigc::signal< void > selection_changed
Definition: gx_json.h:469
virtual void readJSON_value(gx_system::JsonParser &jp)=0
PresetFile * get_file(const Glib::ustring &bank) const
Definition: gx_json.cpp:1623
void read_state(gx_system::JsonParser &jp, const gx_system::SettingsFileHeader &)
Definition: gx_preset.cpp:554
bool isSavable() const
Definition: gx_parameter.h:170
std::string get_lv2_preset_filepath(const std::string &id) const
Definition: gx_system.h:469
virtual void writeJSON(gx_system::JsonWriter &jw) const =0
bool rename_bank(const Glib::ustring &oldname, Glib::ustring &newname)
Definition: gx_preset.cpp:1089
std::vector< std::string > mono
Definition: gx_preset.h:38
iterator end() const
Definition: gx_parameter.h:534
int get_type() const
Definition: gx_json.h:361
const std::string & get_loop_dir() const
Definition: gx_system.h:476
void write_key(const char *p, bool nl=false)
Definition: gx_json.cpp:200
static bool check_settings_dir(gx_system::CmdlineOptions &opt, bool *need_new_preset)
Definition: gx_preset.cpp:1096
const char ** groups
Definition: gx_plugin.h:187
void save(const Glib::ustring &name, const std::string &id, const char **groups)
Definition: gx_preset.cpp:757
std::string decode_filename(const std::string &s)
Definition: gx_system.cpp:1036
virtual bool compareJSON_value()=0
void copy_preset(gx_system::JsonParser &jp, const gx_system::SettingsFileHeader &, gx_system::JsonWriter &jw)
Definition: gx_preset.cpp:528
bool open_file(const Glib::ustring &name, const std::string &path, int tp, int flags)
Definition: gx_json.cpp:980
void parse(const std::string &bank_path, const std::string &preset_dir, const std::string &factory_path, const char *scratchpad_name, const char *scratchpad_file)
Definition: gx_json.cpp:1424
void gx_print_error(const char *, const std::string &)
Definition: gx_logging.cpp:166
bool read_kv(const char *key, float &v)
Definition: gx_json.cpp:511
static string get_default_instancename()
Definition: gx_jack.cpp:46
static bool make_empty_settingsfile(const string &name)
Definition: gx_json.cpp:684
gx_system::PresetFile * bank_insert_new(const Glib::ustring &name)
Definition: gx_preset.cpp:1075
static bool strip_preset_postfix(std::string &name)
Definition: gx_json.cpp:1450
void plugin_preset_list_load(const PluginDef *pdef, UnitPresetList &presetnames)
Definition: gx_preset.cpp:1214
bool remove(const Glib::ustring &name)
Definition: gx_preset.cpp:802
StateIO(gx_engine::MidiControllerList &mctrl, gx_engine::ConvolverAdapter &cvr, gx_engine::ParamMap &param, gx_engine::MidiStandardControllers &mstdctr, gx_jack::GxJack &jack, gx_system::CmdlineOptions &opt, UnitRacks &rack_units)
Definition: gx_preset.cpp:543
const char * id
Definition: gx_plugin.h:185
bool isFloat() const
Definition: gx_parameter.h:162
bool hasId(const string &id) const
Definition: gx_parameter.h:535
void plugin_preset_list_save(const PluginDef *pdef, const Glib::ustring &name)
Definition: gx_preset.cpp:1229
void set_filename(const string &fn)
Definition: gx_json.cpp:746
virtual void close()
Definition: gx_json.cpp:68
void insert_rack_unit(const std::string &unit, const std::string &before, bool stereo)
Definition: gx_preset.cpp:994
void write_connections(gx_system::JsonWriter &w)
Definition: gx_jack.cpp:218
std::vector< std::string > stereo
Definition: gx_preset.h:39
void begin_object(bool nl=false)
Definition: gx_json.cpp:168
const std::string & get_pluginpreset_dir() const
Definition: gx_system.h:474
string get_filename() const
Definition: gx_json.h:268
bool next(Glib::ustring &name, bool *is_set=0)
Definition: gx_preset.cpp:640
static GxExit & get_instance()
Definition: gx_logging.cpp:205
bool isInPreset() const
Definition: gx_parameter.h:169
void load_preset(PresetFile *pf, const Glib::ustring &name)
Definition: gx_json.cpp:1770
void read_online(gx_system::JsonParser &jp)
Definition: gx_preset.cpp:421
void copy_object(JsonWriter &jw)
Definition: gx_json.cpp:580
virtual const char * what() const
Definition: gx_json.h:46
UnitPositionID(const string &id_, const UnitPosition &u)
Definition: gx_preset.cpp:163
const std::string & get_factory_dir() const
Definition: gx_system.h:478
FloatParameter & getFloat()
Definition: gx_parameter.h:452
void gx_print_warning(const char *, const std::string &)
Definition: gx_logging.cpp:161
void set_position(const std::string &s, int v)
Definition: gx_preset.h:59
const std::string & get_temp_dir() const
Definition: gx_system.h:477
const std::string & get_old_user_dir() const
Definition: gx_system.h:471
sigc::signal< void, bool > & signal_exit()
Definition: gx_logging.h:116
const string & get_instancename()
Definition: gx_jack.h:202
void writeJSON(gx_system::JsonWriter &jw) const
std::string get_user_filepath(const std::string &basename) const
Definition: gx_system.h:371
Glib::ustring current_name
Definition: gx_json.h:467
string current_value() const
Definition: gx_json.h:143
iterator begin() const
Definition: gx_parameter.h:533
sigc::signal< void > & signal_client_change()
Definition: gx_jack.h:211
bool set(const Glib::ustring &name)
Definition: gx_preset.cpp:680
void readJSON(gx_system::JsonParser &jp)
Glib::ustring current_bank
Definition: gx_json.h:466
const std::string & get_lv2_preset_dir() const
Definition: gx_system.h:475
void plugin_preset_list_remove(const PluginDef *pdef, const Glib::ustring &name)
Definition: gx_preset.cpp:1233
GxSettings(gx_system::CmdlineOptions &opt, gx_jack::GxJack &jack, gx_engine::ConvolverAdapter &cvr, gx_engine::MidiStandardControllers &mstdctr, gx_engine::MidiControllerList &mctrl, gx_engine::ModuleSequencer &seq)
Definition: gx_preset.cpp:858
int get_flags() const
Definition: gx_json.h:358
const std::string & get_loadfile() const
Definition: gx_system.h:494
std::string get_preset_filepath(const std::string &basename) const
Definition: gx_system.h:463
const std::string & get_user_dir() const
Definition: gx_system.h:374
token next(token expect=no_token)
Definition: gx_json.cpp:496
PluginPresetList(const std::string &fname, gx_engine::ParamMap &pmap, gx_engine::MidiControllerList &mctrl_)
Definition: gx_preset.cpp:614
void write(float v, bool nl=false)
Definition: gx_json.cpp:116
const string & id() const
Definition: gx_parameter.h:172
bool operator<(const UnitPositionID &v) const
Definition: gx_preset.cpp:160
static void make_valid_utf8(Glib::ustring &s)
Definition: gx_json.cpp:1435
void get_list(std::vector< std::string > &l, bool stereo, gx_engine::ParamMap &param)
Definition: gx_preset.cpp:169
Glib::RefPtr< Gio::File > uri_to_name_filename(const Glib::ustring &uri, Glib::ustring &name, std::string &filename)
Definition: gx_preset.cpp:1004
const std::string & get_plugin_dir() const
Definition: gx_system.h:472
bool create_file(const Glib::ustring &name, const std::string &path, int tp, int flags)
Definition: gx_json.cpp:994
bool loadsetting(PresetFile *p, const Glib::ustring &name)
Definition: gx_json.cpp:1719
gx_system::PresetFile * bank_insert_content(const Glib::ustring &uri, const std::string content)
Definition: gx_preset.cpp:1047
void convert_from_range(float low, float up)
void remove_controlled_parameters(paramlist &plist, const ControllerArray *m)
void end_object(bool nl=false)
Definition: gx_json.cpp:176
void save_to_state(bool preserve_preset=false)
Definition: gx_json.cpp:1830
void plugin_preset_list_set(const PluginDef *pdef, bool factory, const Glib::ustring &name)
Definition: gx_preset.cpp:1224
const std::string & get_user_IR_dir() const
Definition: gx_system.h:375