1 // samplv1.h 2 // 3 /**************************************************************************** 4 Copyright (C) 2012-2021, rncbc aka Rui Nuno Capela. All rights reserved. 5 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 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License along 17 with this program; if not, write to the Free Software Foundation, Inc., 18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 20 *****************************************************************************/ 21 22 #ifndef __samplv1_h 23 #define __samplv1_h 24 25 #include "config.h" 26 27 #include <cstdint> 28 29 30 // forward declarations 31 class samplv1_impl; 32 class samplv1_port; 33 class samplv1_sample; 34 class samplv1_controls; 35 class samplv1_programs; 36 37 38 //------------------------------------------------------------------------- 39 // samplv1 - decl. 40 // 41 42 class samplv1 43 { 44 public: 45 46 samplv1(uint16_t nchannels = 2, float srate = 44100.0f); 47 48 virtual ~samplv1(); 49 50 void setChannels(uint16_t nchannels); 51 uint16_t channels() const; 52 53 void setSampleRate(float srate); 54 float sampleRate() const; 55 56 void setSampleFile(const char *pszSampleFile, uint16_t iOctaves, bool bSync = false); 57 const char *sampleFile() const; 58 uint16_t octaves() const; 59 60 samplv1_sample *sample() const; 61 62 void setReverse(bool bReverse, bool bSync = false); 63 bool isReverse() const; 64 65 void setOffset(bool bOffset, bool bSync = false); 66 bool isOffset() const; 67 68 void setOffsetRange(uint32_t iOffsetStart, uint32_t iOffsetEnd, bool bSync = false); 69 uint32_t offsetStart() const; 70 uint32_t offsetEnd() const; 71 72 void setLoop(bool bLoop, bool bSync = false); 73 bool isLoop() const; 74 75 void setLoopRange(uint32_t iLoopStart, uint32_t iLoopEnd, bool bSync = false); 76 uint32_t loopStart() const; 77 uint32_t loopEnd() const; 78 79 void setLoopFade(uint32_t iLoopFade, bool bSync = false); 80 uint32_t loopFade() const; 81 82 void setLoopZero(bool bLoopZero, bool bSync = false); 83 bool isLoopZero() const; 84 85 void setBufferSize(uint32_t nsize); 86 uint32_t bufferSize() const; 87 88 void setTempo(float bpm); 89 float tempo() const; 90 91 enum ParamIndex { 92 93 GEN1_SAMPLE = 0, 94 GEN1_REVERSE, 95 GEN1_OFFSET, 96 GEN1_OFFSET_1, 97 GEN1_OFFSET_2, 98 GEN1_LOOP, 99 GEN1_LOOP_1, 100 GEN1_LOOP_2, 101 GEN1_OCTAVE, 102 GEN1_TUNING, 103 GEN1_GLIDE, 104 GEN1_ENVTIME, 105 DCF1_ENABLED, 106 DCF1_CUTOFF, 107 DCF1_RESO, 108 DCF1_TYPE, 109 DCF1_SLOPE, 110 DCF1_ENVELOPE, 111 DCF1_ATTACK, 112 DCF1_DECAY, 113 DCF1_SUSTAIN, 114 DCF1_RELEASE, 115 LFO1_ENABLED, 116 LFO1_SHAPE, 117 LFO1_WIDTH, 118 LFO1_BPM, 119 LFO1_RATE, 120 LFO1_SYNC, 121 LFO1_SWEEP, 122 LFO1_PITCH, 123 LFO1_CUTOFF, 124 LFO1_RESO, 125 LFO1_PANNING, 126 LFO1_VOLUME, 127 LFO1_ATTACK, 128 LFO1_DECAY, 129 LFO1_SUSTAIN, 130 LFO1_RELEASE, 131 DCA1_ENABLED, 132 DCA1_VOLUME, 133 DCA1_ATTACK, 134 DCA1_DECAY, 135 DCA1_SUSTAIN, 136 DCA1_RELEASE, 137 OUT1_WIDTH, 138 OUT1_PANNING, 139 OUT1_FXSEND, 140 OUT1_VOLUME, 141 142 DEF1_PITCHBEND, 143 DEF1_MODWHEEL, 144 DEF1_PRESSURE, 145 DEF1_VELOCITY, 146 DEF1_CHANNEL, 147 DEF1_MONO, 148 149 CHO1_WET, 150 CHO1_DELAY, 151 CHO1_FEEDB, 152 CHO1_RATE, 153 CHO1_MOD, 154 FLA1_WET, 155 FLA1_DELAY, 156 FLA1_FEEDB, 157 FLA1_DAFT, 158 PHA1_WET, 159 PHA1_RATE, 160 PHA1_FEEDB, 161 PHA1_DEPTH, 162 PHA1_DAFT, 163 DEL1_WET, 164 DEL1_DELAY, 165 DEL1_FEEDB, 166 DEL1_BPM, 167 REV1_WET, 168 REV1_ROOM, 169 REV1_DAMP, 170 REV1_FEEDB, 171 REV1_WIDTH, 172 DYN1_COMPRESS, 173 DYN1_LIMITER, 174 175 KEY1_LOW, 176 KEY1_HIGH, 177 178 NUM_PARAMS 179 }; 180 181 void setParamPort(ParamIndex index, float *pfParam); 182 samplv1_port *paramPort(ParamIndex index) const; 183 184 void setParamValue(ParamIndex index, float fValue); 185 float paramValue(ParamIndex index) const; 186 187 bool running(bool on); 188 189 void stabilize(); 190 void reset(); 191 192 samplv1_controls *controls() const; 193 samplv1_programs *programs() const; 194 195 void process_midi(uint8_t *data, uint32_t size); 196 void process(float **ins, float **outs, uint32_t nframes); 197 198 void sampleOffsetLoopTest(); 199 200 virtual void updatePreset(bool bDirty) = 0; 201 virtual void updateParam(ParamIndex index) = 0; 202 virtual void updateParams() = 0; 203 204 virtual void updateSample() = 0; 205 206 virtual void updateOffsetRange() = 0; 207 virtual void updateLoopRange() = 0; 208 virtual void updateLoopFade() = 0; 209 virtual void updateLoopZero() = 0; 210 211 void midiInEnabled(bool on); 212 uint32_t midiInCount(); 213 214 void directNoteOn(int note, int vel); 215 216 void setTuningEnabled(bool enabled); 217 bool isTuningEnabled() const; 218 219 void setTuningRefPitch(float refPitch); 220 float tuningRefPitch() const; 221 222 void setTuningRefNote(int refNote); 223 int tuningRefNote() const; 224 225 void setTuningScaleFile(const char *pszScaleFile); 226 const char *tuningScaleFile() const; 227 228 void setTuningKeyMapFile(const char *pszKeyMapFile); 229 const char *tuningKeyMapFile() const; 230 231 void resetTuning(); 232 233 virtual void updateTuning() = 0; 234 235 private: 236 237 samplv1_impl *m_pImpl; 238 }; 239 240 241 #endif// __samplv1_h 242 243 // end of samplv1.h 244