Debian Codegraph @

plugin/drumgizmo_plugin.cc

raw
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /***************************************************************************
3 * drumgizmo_lv2.cc
4 *
5 * Wed Mar 2 17:31:32 CET 2016
6 * Copyright 2016 Bent Bisballe Nyeng
7 * [email protected]
8 ****************************************************************************/
9
10 /*
11 * This file is part of DrumGizmo.
12 *
13 * DrumGizmo is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU Lesser General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * DrumGizmo is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License for more details.
22 *
23 * You should have received a copy of the GNU Lesser General Public License
24 * along with DrumGizmo; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 */
27 #include "drumgizmo_plugin.h"
28
29 #include <config.h>
30
31 #include <cstring>
32 #include <algorithm>
33 #include <string>
34
35 #include <midievent.h>
36
37 #include <hugin.hpp>
38
39 #include "configparser.h"
40 #include "nolocale.h"
41
42 #ifdef LV2
43 // Entry point for lv2 plugin instantiation.
44 PG_EXPORT PluginLV2* createEffectInstance()
45 {
46 return new DrumGizmoPlugin();
47 }
48 #endif
49
50 #ifdef VST
51 // Entry point for vst plugin instantiation.
52 AudioEffect* createEffectInstance(audioMasterCallback audioMaster)
53 {
54 return new DrumGizmoPlugin(audioMaster);
55 }
56
57 DrumGizmoPlugin::DrumGizmoPlugin(audioMasterCallback audioMaster)
58 : PluginVST(audioMaster),
59 #else
60 DrumGizmoPlugin::DrumGizmoPlugin()
61 :
62 #endif
63 config_string_io(settings)
64 {
65 init();
66
67 drumgizmo = std::make_shared<DrumGizmo>(settings, output, input);
68 resizeWindow(GUI::MainWindow::main_width, GUI::MainWindow::main_height);
69 drumgizmo->setFreeWheel(true);
70 drumgizmo->setSamplerate(44100);
71 drumgizmo->setFrameSize(2048);
72 }
73
74 void DrumGizmoPlugin::onSamplerateChange(float samplerate)
75 {
76 drumgizmo->setSamplerate(samplerate);
77 }
78
79 void DrumGizmoPlugin::onFramesizeChange(size_t framesize)
80 {
81 drumgizmo->setFrameSize(framesize);
82 }
83
84 void DrumGizmoPlugin::onActiveChange(bool active)
85 {
86 }
87
88 std::string DrumGizmoPlugin::onStateSave()
89 {
90 return config_string_io.get();
91 }
92
93 void DrumGizmoPlugin::onStateRestore(const std::string& config)
94 {
95 config_string_io.set(config);
96 }
97
98 size_t DrumGizmoPlugin::getNumberOfMidiInputs()
99 {
100 return 1;
101 }
102
103 size_t DrumGizmoPlugin::getNumberOfMidiOutputs()
104 {
105 return 0;
106 }
107
108 size_t DrumGizmoPlugin::getNumberOfAudioInputs()
109 {
110 return 0;
111 }
112
113 size_t DrumGizmoPlugin::getNumberOfAudioOutputs()
114 {
115 return NUM_CHANNELS;
116 }
117
118 std::string DrumGizmoPlugin::getId()
119 {
120 return "DrumGizmo";
121 }
122
123 std::string DrumGizmoPlugin::getURI()
124 {
125 return "http://drumgizmo.org";
126 }
127
128 std::string DrumGizmoPlugin::getEffectName()
129 {
130 return "DrumGizmo";
131 }
132
133 std::string DrumGizmoPlugin::getVendorString()
134 {
135 return "DrumGizmo Team";
136 }
137
138 std::string DrumGizmoPlugin::getProductString()
139 {
140 return "DrumGizmo";
141 }
142
143 std::string DrumGizmoPlugin::getHomepage()
144 {
145 return "https://www.drumgizmo.org";
146 }
147
148 PluginCategory DrumGizmoPlugin::getPluginCategory()
149 {
150 return PluginCategory::Synth;
151 }
152
153 static float g_samples[NUM_CHANNELS * 4096];
154
155 void DrumGizmoPlugin::process(size_t pos,
156 const std::vector<MidiEvent>& input_events,
157 std::vector<MidiEvent>& output_events,
158 const std::vector<const float*>& input_samples,
159 const std::vector<float*>& output_samples,
160 size_t count)
161 {
162 setLatency(drumgizmo->getLatency());
163
164 this->input_events = &input_events;
165 this->output_samples = &output_samples;
166
167 drumgizmo->run(pos, g_samples, count);
168
169 this->input_events = nullptr;
170 this->output_samples = nullptr;
171 }
172
173 bool DrumGizmoPlugin::hasInlineGUI()
174 {
175 return true;
176 }
177
178 class InlinePixelBufferAlpha
179 : public dggui::PixelBufferAlpha
180 {
181 public:
182 InlinePixelBufferAlpha(Plugin::InlineDrawContext& context)
183 {
184 buf = context.data;
185 width = context.width;
186 height = context.height;
187 x = 0;
188 y = 0;
189 }
190 };
191
192 class InlineCanvas
193 : public dggui::Canvas
194 {
195 public:
196 InlineCanvas(Plugin::InlineDrawContext& context)
197 : pixbuf(context)
198 {
199 }
200
201 // From Canvas:
202 dggui::PixelBufferAlpha& getPixelBuffer() override
203 {
204 return pixbuf;
205 }
206
207 private:
208 InlinePixelBufferAlpha pixbuf;
209 };
210
211 void DrumGizmoPlugin::onInlineRedraw(std::size_t width,
212 std::size_t max_height,
213 InlineDrawContext& context)
214 {
215 std::size_t bar_height = bar_red.height();
216 std::size_t image_height = ((double)width / inline_display_image.width()) * inline_display_image.height();
217
218 bool show_bar{false};
219 bool show_image{false};
220 std::size_t height = 0;
221
222 if(bar_height <= max_height)
223 {
224 show_bar = true;
225 height += bar_height;
226 }
227 if(bar_height + image_height <= max_height)
228 {
229 show_image = true;
230 height += image_height;
231 }
232
233 // They have to be called seperately to avoid lazy evaluation
234 bool nof_changed = settingsGetter.number_of_files.hasChanged();
235 bool nofl_changed = settingsGetter.number_of_files_loaded.hasChanged();
236 bool dls_changed = settingsGetter.drumkit_load_status.hasChanged();
237
238 bool in_progress =
239 settingsGetter.number_of_files_loaded.getValue() <
240 settingsGetter.number_of_files.getValue();
241
242 bool context_needs_update =
243 !context.data || context.width != width || context.height != height;
244 bool bar_needs_update =
245 nof_changed || nofl_changed || dls_changed || context_needs_update |
246 in_progress; // Always update while loading to prevent flickering.
247 bool image_needs_update = inline_image_first_draw || context_needs_update;
248 // TODO: settingsGetter.inline_image_filename.hasChanged();
249 bool something_needs_update =
250 context_needs_update || bar_needs_update || image_needs_update;
251
252 if (something_needs_update)
253 {
254 context.width = width;
255 context.height = height;
256 assert(context.width * context.height <= sizeof(inlineDisplayBuffer));
257
258 context.data = (unsigned char*)inlineDisplayBuffer;
259 InlineCanvas canvas(context);
260 dggui::Painter painter(canvas);
261
262 double progress =
263 (double)settingsGetter.number_of_files_loaded.getValue() /
264 (double)settingsGetter.number_of_files.getValue();
265
266 if(show_bar && bar_needs_update)
267 {
268 box.setSize(context.width, bar_height);
269 painter.drawImage(0, height - bar_height, box);
270
271 int brd = 4;
272 int val = (width - (2 * brd)) * progress;
273
274 switch(settingsGetter.drumkit_load_status.getValue())
275 {
276 case LoadStatus::Error:
277 bar_red.setSize(val, bar_height);
278 painter.drawImage(brd, height - bar_height, bar_red);
279 break;
280 case LoadStatus::Done:
281 bar_green.setSize(val, bar_height);
282 painter.drawImage(brd, height - bar_height, bar_green);
283 break;
284 case LoadStatus::Parsing:
285 case LoadStatus::Loading:
286 case LoadStatus::Idle:
287 bar_blue.setSize(val, bar_height);
288 painter.drawImage(brd, height - bar_height, bar_blue);
289 break;
290 }
291 }
292
293 if(show_image && image_needs_update)
294 {
295 // TODO: load new image and remove the bool
296 inline_image_first_draw = false;
297
298 painter.setColour(.5);
299 painter.drawFilledRectangle(0, 0, width, image_height);
300 painter.drawImageStretched(0, 0, inline_display_image, width, image_height);
301 }
302
303 // Convert to correct pixel format
304 for(std::size_t i = 0; i < context.height * context.width; ++i)
305 {
306 std::uint32_t pixel = inlineDisplayBuffer[i];
307 unsigned char* p = (unsigned char*)&pixel;
308 inlineDisplayBuffer[i] = pgzRGBA(p[0], p[1], p[2], p[3]);
309 }
310 }
311 }
312
313 bool DrumGizmoPlugin::hasGUI()
314 {
315 return true;
316 }
317
318 void* DrumGizmoPlugin::createWindow(void* parent)
319 {
320 plugin_gui = std::make_shared<GUI::MainWindow>(settings, parent);
321 resizeWindow(GUI::MainWindow::main_width, GUI::MainWindow::main_height);
322 onShowWindow();
323
324 return plugin_gui->getNativeWindowHandle();
325 }
326
327 void DrumGizmoPlugin::onDestroyWindow()
328 {
329 plugin_gui = nullptr;
330 }
331
332 void DrumGizmoPlugin::onShowWindow()
333 {
334 plugin_gui->show();
335 }
336
337 void DrumGizmoPlugin::onHideWindow()
338 {
339 plugin_gui->hide();
340 }
341
342 void DrumGizmoPlugin::onIdle()
343 {
344 plugin_gui->processEvents();
345 }
346
347 void DrumGizmoPlugin::closeWindow()
348 {
349 }
350
351
352 //
353 // Input Engine
354 //
355
356 DrumGizmoPlugin::Input::Input(DrumGizmoPlugin& plugin)
357 : plugin(plugin)
358 {
359 }
360
361 bool DrumGizmoPlugin::Input::init(const Instruments &instruments)
362 {
363 this->instruments = &instruments;
364 return true;
365 }
366
367 void DrumGizmoPlugin::Input::setParm(const std::string& parm, const std::string& value)
368 {
369 }
370
371 bool DrumGizmoPlugin::Input::start()
372 {
373 return true;
374 }
375
376 void DrumGizmoPlugin::Input::stop()
377 {
378 }
379
380 void DrumGizmoPlugin::Input::pre()
381 {
382 }
383
384 void DrumGizmoPlugin::Input::run(size_t pos, size_t len, std::vector<event_t>& events)
385 {
386 assert(events.empty());
387 assert(plugin.input_events);
388
389 events.reserve(plugin.input_events->size());
390
391 for(auto& event : *plugin.input_events)
392 {
393 processNote((const std::uint8_t*)event.getData(), event.getSize(),
394 event.getTime(), events);
395 }
396 }
397
398 void DrumGizmoPlugin::Input::post()
399 {
400 }
401
402 bool DrumGizmoPlugin::Input::isFreewheeling() const
403 {
404 return plugin.getFreeWheel();
405 }
406
407 bool DrumGizmoPlugin::Input::loadMidiMap(const std::string& file,
408 const Instruments& i)
409 {
410 bool result = AudioInputEngineMidi::loadMidiMap(file, i);
411 std::vector<std::pair<int, std::string>> midnam;
412
413 const auto& midimap = mmap.getMap();
414 std::map<int, std::string> map;
415 for(const auto& entry : midimap)
416 {
417 // in case of multiple instruments mapped to one note, use '/' as separator
418 if(!map[entry.note_id].empty())
419 {
420 map[entry.note_id] += "/";
421 }
422 map[entry.note_id] += entry.instrument_name;
423 }
424
425 midnam.reserve(map.size());
426 for(const auto& m : map)
427 {
428 midnam.push_back(std::make_pair(m.first, m.second));
429 }
430
431 if(midnam.size() > 0)
432 {
433 plugin.setMidnamData(midnam);
434 }
435 return result;
436 }
437
438 //
439 // Output Engine
440 //
441
442 DrumGizmoPlugin::Output::Output(DrumGizmoPlugin& plugin)
443 : plugin(plugin)
444 {
445 }
446
447 bool DrumGizmoPlugin::Output::init(const Channels& channels)
448 {
449 return true;
450 }
451
452 void DrumGizmoPlugin::Output::setParm(const std::string& parm, const std::string& value)
453 {
454 }
455
456 bool DrumGizmoPlugin::Output::start()
457 {
458 return true;
459 }
460
461 void DrumGizmoPlugin::Output::stop()
462 {
463 }
464
465 void DrumGizmoPlugin::Output::pre(size_t nsamples)
466 {
467 // Clear all channels
468 for(auto& channel : *plugin.output_samples)
469 {
470 if(channel)
471 {
472 std::memset(channel, 0, nsamples * sizeof(sample_t));
473 }
474 }
475 }
476
477 void DrumGizmoPlugin::Output::run(int ch, sample_t* samples, size_t nsamples)
478 {
479 assert(plugin.output_samples);
480
481 assert(sizeof(float) == sizeof(sample_t));
482
483 if((std::size_t)ch >= plugin.output_samples->size())
484 {
485 return;
486 }
487
488 if((*plugin.output_samples)[ch] == nullptr)
489 {
490 // Port not connected.
491 return;
492 }
493
494 // We are not running directly on the internal buffer: do a copy.
495 if((*plugin.output_samples)[ch] != samples)
496 {
497 memcpy((*plugin.output_samples)[ch], samples, nsamples * sizeof(sample_t));
498 }
499 }
500
501 void DrumGizmoPlugin::Output::post(size_t nsamples)
502 {
503 }
504
505 sample_t* DrumGizmoPlugin::Output::getBuffer(int ch) const
506 {
507 assert(plugin.output_samples);
508
509 if((std::size_t)ch >= plugin.output_samples->size())
510 {
511 return nullptr;
512 }
513
514 return (*plugin.output_samples)[ch];
515 }
516
517 size_t DrumGizmoPlugin::Output::getBufferSize() const
518 {
519 return plugin.getFramesize();
520 }
521
522 std::size_t DrumGizmoPlugin::Output::getSamplerate() const
523 {
524 return plugin.drumgizmo->samplerate();
525 }
526
527 bool DrumGizmoPlugin::Output::isFreewheeling() const
528 {
529 return plugin.getFreeWheel();
530 }
531
532 //
533 // ConfigStringIO
534 //
535
536 // anonymous namespace for helper furnctions of ConfigStringIO
537 namespace
538 {
539
540 std::string float2str(float a)
541 {
542 char buf[256];
543 snprintf_nol(buf, sizeof(buf) - 1, "%f", a);
544 return buf;
545 }
546
547 std::string bool2str(bool a)
548 {
549 return a?"true":"false";
550 }
551
552 std::string int2str(int a)
553 {
554 char buf[256];
555 snprintf(buf, sizeof(buf) - 1, "%d", a);
556 return buf;
557 }
558
559 float str2float(std::string a)
560 {
561 if(a == "")
562 {
563 return 0.0;
564 }
565
566 return atof_nol(a.c_str());
567 }
568
569 int str2int(std::string a)
570 {
571 try
572 {
573 return std::stoi(a);
574 }
575 catch(...)
576 {
577 return 0;
578 }
579 }
580
581 long long str2ll(std::string a)
582 {
583 try
584 {
585 return std::stoll(a);
586 }
587 catch(...)
588 {
589 return 0;
590 }
591 }
592
593 } // end anonymous namespace
594
595 DrumGizmoPlugin::ConfigStringIO::ConfigStringIO(Settings& settings)
596 : settings(settings)
597 {
598
599 }
600
601 std::string DrumGizmoPlugin::ConfigStringIO::get()
602 {
603 return
604 "<config version=\"1.0\">\n"
605 " <value name=\"drumkitfile\">" + settings.drumkit_file.load() + "</value>\n"
606 " <value name=\"midimapfile\">" + settings.midimap_file.load() + "</value>\n"
607 " <value name=\"enable_velocity_modifier\">" +
608 bool2str(settings.enable_velocity_modifier.load()) + "</value>\n"
609 " <value name=\"velocity_modifier_falloff\">" +
610 float2str(settings.velocity_modifier_falloff.load()) + "</value>\n"
611 " <value name=\"velocity_modifier_weight\">" +
612 float2str(settings.velocity_modifier_weight.load()) + "</value>\n"
613 " <value name=\"velocity_stddev\">" +
614 float2str(settings.velocity_stddev.load()) + "</value>\n"
615 " <value name=\"sample_selection_f_close\">" +
616 float2str(settings.sample_selection_f_close.load()) + "</value>\n"
617 " <value name=\"sample_selection_f_diverse\">" +
618 float2str(settings.sample_selection_f_diverse.load()) + "</value>\n"
619 " <value name=\"sample_selection_f_random\">" +
620 float2str(settings.sample_selection_f_random.load()) + "</value>\n"
621 " <value name=\"enable_velocity_randomiser\">" +
622 bool2str(settings.enable_velocity_randomiser.load()) + "</value>\n"
623 " <value name=\"velocity_randomiser_weight\">" +
624 float2str(settings.velocity_randomiser_weight.load()) + "</value>\n"
625 " <value name=\"enable_resampling\">" +
626 bool2str(settings.enable_resampling.load()) + "</value>\n"
627 " <value name=\"resampling_quality\">" +
628 float2str(settings.resampling_quality.load()) + "</value>\n"
629 " <value name=\"disk_cache_upper_limit\">" +
630 int2str(settings.disk_cache_upper_limit.load()) + "</value>\n"
631 " <value name=\"disk_cache_chunk_size\">" +
632 int2str(settings.disk_cache_chunk_size.load()) + "</value>\n"
633 " <value name=\"disk_cache_enable\">" +
634 bool2str(settings.disk_cache_enable.load()) + "</value>\n"
635 " <value name=\"enable_bleed_control\">" +
636 bool2str(settings.enable_bleed_control.load()) + "</value>\n"
637 " <value name=\"master_bleed\">" +
638 float2str(settings.master_bleed.load()) + "</value>\n"
639 " <value name=\"enable_latency_modifier\">" +
640 bool2str(settings.enable_latency_modifier.load()) + "</value>\n"
641 // Do not store/reload this value
642 //" <value name=\"latency_max\">" +
643 //int2str(settings.latency_max.load()) + "</value>\n"
644 " <value name=\"latency_laid_back_ms\">" +
645 float2str(settings.latency_laid_back_ms.load()) + "</value>\n"
646 " <value name=\"latency_stddev\">" +
647 float2str(settings.latency_stddev.load()) + "</value>\n"
648 " <value name=\"latency_regain\">" +
649 float2str(settings.latency_regain.load()) + "</value>\n"
650 " <value name=\"enable_powermap\">" +
651 bool2str(settings.enable_powermap.load()) + "</value>\n"
652 " <value name=\"powermap_fixed0_x\">" +
653 float2str(settings.powermap_fixed0_x.load()) + "</value>\n"
654 " <value name=\"powermap_fixed0_y\">" +
655 float2str(settings.powermap_fixed0_y.load()) + "</value>\n"
656 " <value name=\"powermap_fixed1_x\">" +
657 float2str(settings.powermap_fixed1_x.load()) + "</value>\n"
658 " <value name=\"powermap_fixed1_y\">" +
659 float2str(settings.powermap_fixed1_y.load()) + "</value>\n"
660 " <value name=\"powermap_fixed2_x\">" +
661 float2str(settings.powermap_fixed2_x.load()) + "</value>\n"
662 " <value name=\"powermap_fixed2_y\">" +
663 float2str(settings.powermap_fixed2_y.load()) + "</value>\n"
664 " <value name=\"powermap_shelf\">" +
665 bool2str(settings.powermap_shelf.load()) + "</value>\n"
666 " <value name=\"enable_voice_limit\">" +
667 bool2str(settings.enable_voice_limit.load()) + "</value>\n"
668 " <value name=\"voice_limit_max\">" +
669 int2str(settings.voice_limit_max.load()) + "</value>\n"
670 " <value name=\"voice_limit_rampdown\">" +
671 float2str(settings.voice_limit_rampdown.load()) + "</value>\n"
672 "</config>";
673 }
674
675 bool DrumGizmoPlugin::ConfigStringIO::set(std::string config_string)
676 {
677 DEBUG(config, "Load config: %s\n", config_string.c_str());
678
679 ConfigParser p;
680 if(!p.parseString(config_string))
681 {
682 ERR(config, "Config parse error.\n");
683 return false;
684 }
685
686 if(p.value("enable_velocity_modifier") != "")
687 {
688 settings.enable_velocity_modifier.store(p.value("enable_velocity_modifier") == "true");
689 }
690
691 if(p.value("velocity_modifier_falloff") != "")
692 {
693 settings.velocity_modifier_falloff.store(str2float(p.value("velocity_modifier_falloff")));
694 }
695
696 if(p.value("velocity_modifier_weight") != "")
697 {
698 settings.velocity_modifier_weight.store(str2float(p.value("velocity_modifier_weight")));
699 }
700
701 if(p.value("velocity_stddev") != "")
702 {
703 settings.velocity_stddev.store(str2float(p.value("velocity_stddev")));
704 }
705
706 if(p.value("sample_selection_f_close") != "")
707 {
708 settings.sample_selection_f_close.store(str2float(p.value("sample_selection_f_close")));
709 }
710
711 if(p.value("sample_selection_f_diverse") != "")
712 {
713 settings.sample_selection_f_diverse.store(str2float(p.value("sample_selection_f_diverse")));
714 }
715
716 if(p.value("sample_selection_f_random") != "")
717 {
718 settings.sample_selection_f_random.store(str2float(p.value("sample_selection_f_random")));
719 }
720
721 if(p.value("enable_velocity_randomiser") != "")
722 {
723 settings.enable_velocity_randomiser.store(p.value("enable_velocity_randomiser") == "true");
724 }
725
726 if(p.value("velocity_randomiser_weight") != "")
727 {
728 settings.velocity_randomiser_weight.store(str2float(p.value("velocity_randomiser_weight")));
729 }
730
731 if(p.value("enable_resampling") != "")
732 {
733 settings.enable_resampling.store(p.value("enable_resampling") == "true");
734 }
735
736 if(p.value("resampling_quality") != "")
737 {
738 settings.resampling_quality.store(str2float(p.value("resampling_quality")));
739 }
740
741 if(p.value("disk_cache_upper_limit") != "")
742 {
743 settings.disk_cache_upper_limit.store(str2ll(p.value("disk_cache_upper_limit")));
744 }
745
746 if(p.value("disk_cache_chunk_size") != "")
747 {
748 settings.disk_cache_chunk_size.store(str2int(p.value("disk_cache_chunk_size")));
749 }
750
751 if(p.value("disk_cache_enable") != "")
752 {
753 settings.disk_cache_enable.store(p.value("disk_cache_enable") == "true");
754 }
755
756 if(p.value("enable_bleed_control") != "")
757 {
758 settings.enable_bleed_control.store(p.value("enable_bleed_control") == "true");
759 }
760
761 if(p.value("master_bleed") != "")
762 {
763 settings.master_bleed.store(str2float(p.value("master_bleed")));
764 }
765
766 if(p.value("enable_latency_modifier") != "")
767 {
768 settings.enable_latency_modifier.store(p.value("enable_latency_modifier") == "true");
769 }
770
771 // Do not store/reload this value
772 //if(p.value("latency_max") != "")
773 //{
774 // settings.latency_max.store(str2int(p.value("latency_max")));
775 //}
776
777 if(p.value("latency_laid_back_ms") != "")
778 {
779 settings.latency_laid_back_ms.store(str2float(p.value("latency_laid_back_ms")));
780 }
781
782 if(p.value("latency_stddev") != "")
783 {
784 settings.latency_stddev.store(str2float(p.value("latency_stddev")));
785 }
786
787 if(p.value("latency_regain") != "")
788 {
789 settings.latency_regain.store(str2float(p.value("latency_regain")));
790 }
791
792 if(p.value("enable_powermap") != "")
793 {
794 settings.enable_powermap.store(p.value("enable_powermap") == "true");
795 }
796
797 if(p.value("powermap_fixed0_x") != "")
798 {
799 settings.powermap_fixed0_x.store(str2float(p.value("powermap_fixed0_x")));
800 }
801
802 if(p.value("powermap_fixed0_y") != "")
803 {
804 settings.powermap_fixed0_y.store(str2float(p.value("powermap_fixed0_y")));
805 }
806
807 if(p.value("powermap_fixed1_x") != "")
808 {
809 settings.powermap_fixed1_x.store(str2float(p.value("powermap_fixed1_x")));
810 }
811
812 if(p.value("powermap_fixed1_y") != "")
813 {
814 settings.powermap_fixed1_y.store(str2float(p.value("powermap_fixed1_y")));
815 }
816
817 if(p.value("powermap_fixed2_x") != "")
818 {
819 settings.powermap_fixed2_x.store(str2float(p.value("powermap_fixed2_x")));
820 }
821
822 if(p.value("powermap_fixed2_y") != "")
823 {
824 settings.powermap_fixed2_y.store(str2float(p.value("powermap_fixed2_y")));
825 }
826
827 if(p.value("powermap_shelf") != "")
828 {
829 settings.powermap_shelf.store(p.value("powermap_shelf") == "true");
830 }
831
832 if(p.value("enable_voice_limit") != "")
833 {
834 settings.enable_voice_limit.store(p.value("enable_voice_limit") == "true");
835 }
836
837 if(p.value("voice_limit_max") != "")
838 {
839 settings.voice_limit_max.store(str2int(p.value("voice_limit_max")));
840 }
841
842 if(p.value("voice_limit_rampdown") != "")
843 {
844 settings.voice_limit_rampdown.store(str2float(p.value("voice_limit_rampdown")));
845 }
846
847 std::string newkit = p.value("drumkitfile");
848 if(newkit != "")
849 {
850 settings.drumkit_file.store(newkit);
851 }
852
853 std::string newmidimap = p.value("midimapfile");
854 if(newmidimap != "")
855 {
856 settings.midimap_file.store(newmidimap);
857 }
858
859 return true;
860 }