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.

Bank.h 3.1KB

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