cp_pattern.h 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*************************************************************************/
  2. /* cp_pattern.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef CP_PATTERN_H
  31. #define CP_PATTERN_H
  32. #include "cp_note.h"
  33. class CPPattern {
  34. public:
  35. enum {
  36. WIDTH = 64,
  37. DEFAULT_LEN = 64,
  38. RESIZE_EVERY_BITS = 4,
  39. MIN_ROWS = 1, //otherwise clipboard wont work
  40. MAX_LEN = 256
  41. };
  42. private:
  43. struct Event {
  44. uint16_t pos; //column*WIDTH+row
  45. uint8_t note;
  46. uint8_t instrument;
  47. uint8_t volume;
  48. uint8_t command;
  49. uint8_t parameter;
  50. unsigned int script_source_sign;
  51. bool cloned;
  52. };
  53. uint16_t length;
  54. uint32_t event_count;
  55. Event *events;
  56. int32_t get_event_pos(uint16_t p_target_pos);
  57. bool erase_event_at_pos(uint16_t p_pos);
  58. bool resize_event_list_to(uint32_t p_events);
  59. void operator=(const CPPattern &p_pattern); //no operator=
  60. public:
  61. bool is_empty();
  62. void clear();
  63. bool set_note(uint8_t p_column, uint16_t p_row, const CPNote &p_note); //true if no more memory
  64. CPNote get_note(uint8_t p_column, uint16_t p_row);
  65. CPNote get_transformed_script_note(uint8_t p_column, uint16_t p_row);
  66. int get_scripted_note_target_channel(uint8_t p_column, uint16_t p_row);
  67. void scripted_clone(uint8_t p_column, uint16_t p_row);
  68. void scripted_clone_remove(uint8_t p_column, uint16_t p_row);
  69. void script_transform_note(CPNote &n, const CPNote &p_note);
  70. bool update_scripted_clones_sourcing_channel(int channel);
  71. //void copy_to(CPPattern *p_pattern) const;
  72. void set_length(uint16_t p_rows);
  73. uint16_t get_length();
  74. CPPattern();
  75. ~CPPattern();
  76. };
  77. #endif