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.

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