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.

138 lines
3.1KB

  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 modify
  7. it under the terms of version 2 of the GNU General Public License
  8. as published by the Free Software Foundation.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License (version 2 or later) for more details.
  13. You should have received a copy of the GNU General Public License (version 2)
  14. along with this program; if not, write to the Free Software Foundation,
  15. Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. */
  17. #include "PresetsStore.h"
  18. #include "PresetsArray.h"
  19. #include <string.h>
  20. PresetsArray::PresetsArray()
  21. {
  22. type[0] = 0;
  23. }
  24. PresetsArray::~PresetsArray()
  25. {}
  26. void PresetsArray::setpresettype(const char *type)
  27. {
  28. strcpy(this->type, type);
  29. }
  30. void PresetsArray::copy(PresetsStore &ps, const char *name)
  31. {
  32. copy(ps, -1, name);
  33. }
  34. void PresetsArray::copy(PresetsStore &ps, int nelement, const char *name)
  35. {
  36. XMLwrapper xml;
  37. //used only for the clipboard
  38. if(name == NULL)
  39. xml.minimal = false;
  40. char type[MAX_PRESETTYPE_SIZE];
  41. strcpy(type, this->type);
  42. if(nelement != -1)
  43. strcat(type, "n");
  44. if(name == NULL)
  45. if(strstr(type, "Plfo") != NULL)
  46. strcpy(type, "Plfo");
  47. xml.beginbranch(type);
  48. if(nelement == -1)
  49. add2XML(&xml);
  50. else
  51. add2XMLsection(&xml, nelement);
  52. xml.endbranch();
  53. if(name == NULL)
  54. ps.copyclipboard(xml, type);
  55. else
  56. ps.copypreset(xml, type, name);
  57. }
  58. #if 0
  59. void PresetsArray::paste(PresetsStore &ps, int npreset)
  60. {
  61. char type[MAX_PRESETTYPE_SIZE];
  62. strcpy(type, this->type);
  63. if(nelement != -1)
  64. strcat(type, "n");
  65. if(npreset == 0)
  66. if(strstr(type, "Plfo") != NULL)
  67. strcpy(type, "Plfo");
  68. XMLwrapper xml;
  69. if(npreset == 0) {
  70. if(!checkclipboardtype(ps)) {
  71. nelement = -1;
  72. return;
  73. }
  74. if(!ps.pasteclipboard(xml)) {
  75. nelement = -1;
  76. return;
  77. }
  78. } else if(!ps.pastepreset(xml, npreset)) {
  79. nelement = -1;
  80. return;
  81. }
  82. if(xml.enterbranch(type) == 0) {
  83. nelement = -1;
  84. return;
  85. }
  86. if(nelement == -1) {
  87. defaults();
  88. getfromXML(&xml);
  89. } else {
  90. defaults(nelement);
  91. getfromXMLsection(&xml, nelement);
  92. }
  93. xml.exitbranch();
  94. nelement = -1;
  95. }
  96. bool PresetsArray::checkclipboardtype(PresetsStore &ps)
  97. {
  98. char type[MAX_PRESETTYPE_SIZE];
  99. strcpy(type, this->type);
  100. if(nelement != -1)
  101. strcat(type, "n");
  102. return ps.checkclipboardtype(type);
  103. }
  104. #endif
  105. //void PresetsArray::rescanforpresets()
  106. //{
  107. // char type[MAX_PRESETTYPE_SIZE];
  108. // strcpy(type, this->type);
  109. // if(nelement != -1)
  110. // strcat(type, "n");
  111. //
  112. // presetsstore.rescanforpresets(type);
  113. //}