1 /*************************************************************************/ 2 /* cp_sample.h */ 3 /*************************************************************************/ 4 /* This file is part of: */ 5 /* GODOT ENGINE */ 6 /* https://godotengine.org */ 7 /*************************************************************************/ 8 /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ 9 /* Copyright (c) 2014-2019 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 CPSAMPLE_H 31 #define CPSAMPLE_H 32 33 #include "cp_config.h" 34 #include "cp_sample_manager.h" 35 class CPSample { 36 37 public: 38 enum VibratoType { 39 VIBRATO_SINE, 40 VIBRATO_SAW, 41 VIBRATO_SQUARE, 42 VIBRATO_RANDOM 43 44 }; 45 46 private: 47 enum { NAME_MAX_LEN = 26 }; 48 49 char name[NAME_MAX_LEN]; 50 51 uint8_t default_volume; /* 0.. 64 */ 52 uint8_t global_volume; /* 0.. 64 */ 53 54 bool pan_enabled; 55 uint8_t pan; /* 0.. 64 */ 56 57 VibratoType vibrato_type; 58 uint8_t vibrato_speed; /* 0.. 64 */ 59 uint8_t vibrato_depth; /* 0.. 64 */ 60 uint8_t vibrato_rate; /* 0.. 64 */ 61 62 CPSample_ID id; 63 64 void copy_from(const CPSample &p_sample); 65 66 public: 67 void operator=(const CPSample &p_sample); 68 69 const char *get_name() const; 70 void set_name(const char *p_name); 71 72 void set_default_volume(uint8_t p_vol); 73 uint8_t get_default_volume() const; 74 75 void set_global_volume(uint8_t p_vol); 76 uint8_t get_global_volume() const; 77 78 void set_pan_enabled(bool p_vol); 79 bool is_pan_enabled() const; 80 81 void set_pan(uint8_t p_pan); 82 uint8_t get_pan() const; 83 84 void set_vibrato_type(VibratoType p_vibrato_type); 85 VibratoType get_vibrato_type() const; 86 87 void set_vibrato_speed(uint8_t p_vibrato_speed); 88 uint8_t get_vibrato_speed() const; 89 90 void set_vibrato_depth(uint8_t p_vibrato_depth); 91 uint8_t get_vibrato_depth() const; 92 93 void set_vibrato_rate(uint8_t p_vibrato_rate); 94 uint8_t get_vibrato_rate() const; 95 96 void set_sample_data(CPSample_ID); 97 CPSample_ID get_sample_data() const; 98 99 void reset(); 100 101 CPSample(const CPSample &p_from); 102 CPSample(); 103 ~CPSample(); 104 }; 105 106 #endif 107