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.

112 lines
3.2KB

  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. Bank.h - Instrument Bank
  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. #ifndef BANK_H
  18. #define BANK_H
  19. #include <string>
  20. #include <vector>
  21. #include "../globals.h"
  22. #include "Config.h"
  23. //entries in a bank
  24. #define BANK_SIZE 160
  25. /**The instrument Bank*/
  26. class Bank
  27. {
  28. public:
  29. /**Constructor*/
  30. Bank(Config* config);
  31. ~Bank();
  32. std::string getname(unsigned int ninstrument);
  33. std::string getnamenumbered(unsigned int ninstrument);
  34. //if newslot==-1 then this is ignored, else it will be put on that slot
  35. int setname(unsigned int ninstrument,
  36. const std::string &newname,
  37. int newslot);
  38. /**returns true when slot is empty*/
  39. bool emptyslot(unsigned int ninstrument);
  40. /**Empties out the selected slot*/
  41. int clearslot(unsigned int ninstrument);
  42. /**Saves the given Part to slot*/
  43. int savetoslot(unsigned int ninstrument, class Part * part);
  44. /**Loads the given slot into a Part*/
  45. int loadfromslot(unsigned int ninstrument, class Part * part);
  46. /**Swaps Slots*/
  47. int swapslot(unsigned int n1, unsigned int n2);
  48. int loadbank(std::string bankdirname) NONREALTIME;
  49. int newbank(std::string newbankdirname) NONREALTIME;
  50. std::string bankfiletitle; //this is shown on the UI of the bank (the title of the window)
  51. int locked();
  52. void rescanforbanks();
  53. void setMsb(uint8_t msb);
  54. void setLsb(uint8_t lsb);
  55. struct bankstruct {
  56. bool operator<(const bankstruct &b) const;
  57. std::string dir;
  58. std::string name;
  59. };
  60. std::vector<bankstruct> banks;
  61. int bankpos;
  62. struct ins_t {
  63. ins_t(void);
  64. std::string name;
  65. //All valid instruments must have a non-empty filename
  66. std::string filename;
  67. } ins[BANK_SIZE];
  68. private:
  69. //it adds a filename to the bank
  70. //if pos is -1 it try to find a position
  71. //returns -1 if the bank is full, or 0 if the instrument was added
  72. int addtobank(int pos, std::string filename, std::string name);
  73. void deletefrombank(int pos);
  74. void clearbank();
  75. std::string defaultinsname;
  76. std::string dirname;
  77. void scanrootdir(std::string rootdir); //scans a root dir for banks
  78. Config* const config;
  79. public:
  80. uint8_t bank_msb;
  81. uint8_t bank_lsb;
  82. };
  83. #endif