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.

110 lines
3.0KB

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