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.

129 lines
2.7KB

  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. PresetsArray::PresetsArray()
  15. {
  16. type[0] = 0;
  17. }
  18. PresetsArray::~PresetsArray()
  19. {}
  20. void PresetsArray::setpresettype(const char *type)
  21. {
  22. strcpy(this->type, type);
  23. }
  24. void PresetsArray::copy(PresetsStore &ps, const char *name)
  25. {
  26. copy(ps, -1, name);
  27. }
  28. void PresetsArray::copy(PresetsStore &ps, int nelement, const char *name)
  29. {
  30. XMLwrapper xml;
  31. //used only for the clipboard
  32. if(name == NULL)
  33. xml.minimal = false;
  34. char type[MAX_PRESETTYPE_SIZE];
  35. strcpy(type, this->type);
  36. if(nelement != -1)
  37. strcat(type, "n");
  38. if(name == NULL)
  39. if(strstr(type, "Plfo") != NULL)
  40. strcpy(type, "Plfo");
  41. xml.beginbranch(type);
  42. if(nelement == -1)
  43. add2XML(xml);
  44. else
  45. add2XMLsection(xml, nelement);
  46. xml.endbranch();
  47. if(name == NULL)
  48. ps.copyclipboard(xml, type);
  49. else
  50. ps.copypreset(xml, type, name);
  51. }
  52. #if 0
  53. void PresetsArray::paste(PresetsStore &ps, int npreset)
  54. {
  55. char type[MAX_PRESETTYPE_SIZE];
  56. strcpy(type, this->type);
  57. if(nelement != -1)
  58. strcat(type, "n");
  59. if(npreset == 0)
  60. if(strstr(type, "Plfo") != NULL)
  61. strcpy(type, "Plfo");
  62. XMLwrapper xml;
  63. if(npreset == 0) {
  64. if(!checkclipboardtype(ps)) {
  65. nelement = -1;
  66. return;
  67. }
  68. if(!ps.pasteclipboard(xml)) {
  69. nelement = -1;
  70. return;
  71. }
  72. } else if(!ps.pastepreset(xml, npreset)) {
  73. nelement = -1;
  74. return;
  75. }
  76. if(xml.enterbranch(type) == 0) {
  77. nelement = -1;
  78. return;
  79. }
  80. if(nelement == -1) {
  81. defaults();
  82. getfromXML(&xml);
  83. } else {
  84. defaults(nelement);
  85. getfromXMLsection(&xml, nelement);
  86. }
  87. xml.exitbranch();
  88. nelement = -1;
  89. }
  90. bool PresetsArray::checkclipboardtype(PresetsStore &ps)
  91. {
  92. char type[MAX_PRESETTYPE_SIZE];
  93. strcpy(type, this->type);
  94. if(nelement != -1)
  95. strcat(type, "n");
  96. return ps.checkclipboardtype(type);
  97. }
  98. #endif
  99. //void PresetsArray::rescanforpresets()
  100. //{
  101. // char type[MAX_PRESETTYPE_SIZE];
  102. // strcpy(type, this->type);
  103. // if(nelement != -1)
  104. // strcat(type, "n");
  105. //
  106. // presetsstore.rescanforpresets(type);
  107. //}