Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PresetsArray.cpp 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. PresetsArray.cpp - PresetsArray and Clipboard management
  4. Copyright (C) 2002-2005 Nasca Octavian Paul
  5. Author: Nasca Octavian Paul
  6. This program is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or (at your option) any later version.
  10. */
  11. #include "PresetsStore.h"
  12. #include "PresetsArray.h"
  13. #include <string.h>
  14. namespace zyncarla {
  15. PresetsArray::PresetsArray()
  16. {
  17. type[0] = 0;
  18. }
  19. PresetsArray::~PresetsArray()
  20. {}
  21. void PresetsArray::setpresettype(const char *type)
  22. {
  23. strcpy(this->type, type);
  24. }
  25. void PresetsArray::copy(PresetsStore &ps, const char *name)
  26. {
  27. copy(ps, -1, name);
  28. }
  29. void PresetsArray::copy(PresetsStore &ps, int nelement, const char *name)
  30. {
  31. XMLwrapper xml;
  32. //used only for the clipboard
  33. if(name == NULL)
  34. xml.minimal = false;
  35. char type[MAX_PRESETTYPE_SIZE];
  36. strcpy(type, this->type);
  37. if(nelement != -1)
  38. strcat(type, "n");
  39. if(name == NULL)
  40. if(strstr(type, "Plfo") != NULL)
  41. strcpy(type, "Plfo");
  42. xml.beginbranch(type);
  43. if(nelement == -1)
  44. add2XML(xml);
  45. else
  46. add2XMLsection(xml, nelement);
  47. xml.endbranch();
  48. if(name == NULL)
  49. ps.copyclipboard(xml, type);
  50. else
  51. ps.copypreset(xml, type, name);
  52. }
  53. #if 0
  54. void PresetsArray::paste(PresetsStore &ps, int npreset)
  55. {
  56. char type[MAX_PRESETTYPE_SIZE];
  57. strcpy(type, this->type);
  58. if(nelement != -1)
  59. strcat(type, "n");
  60. if(npreset == 0)
  61. if(strstr(type, "Plfo") != NULL)
  62. strcpy(type, "Plfo");
  63. XMLwrapper xml;
  64. if(npreset == 0) {
  65. if(!checkclipboardtype(ps)) {
  66. nelement = -1;
  67. return;
  68. }
  69. if(!ps.pasteclipboard(xml)) {
  70. nelement = -1;
  71. return;
  72. }
  73. } else if(!ps.pastepreset(xml, npreset)) {
  74. nelement = -1;
  75. return;
  76. }
  77. if(xml.enterbranch(type) == 0) {
  78. nelement = -1;
  79. return;
  80. }
  81. if(nelement == -1) {
  82. defaults();
  83. getfromXML(&xml);
  84. } else {
  85. defaults(nelement);
  86. getfromXMLsection(&xml, nelement);
  87. }
  88. xml.exitbranch();
  89. nelement = -1;
  90. }
  91. bool PresetsArray::checkclipboardtype(PresetsStore &ps)
  92. {
  93. char type[MAX_PRESETTYPE_SIZE];
  94. strcpy(type, this->type);
  95. if(nelement != -1)
  96. strcat(type, "n");
  97. return ps.checkclipboardtype(type);
  98. }
  99. #endif
  100. //void PresetsArray::rescanforpresets()
  101. //{
  102. // char type[MAX_PRESETTYPE_SIZE];
  103. // strcpy(type, this->type);
  104. // if(nelement != -1)
  105. // strcat(type, "n");
  106. //
  107. // presetsstore.rescanforpresets(type);
  108. //}
  109. }