1 // samplv1_ui.cpp
2 //
3 /****************************************************************************
4    Copyright (C) 2012-2020, 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 #include "samplv1_ui.h"
23 
24 #include "samplv1_param.h"
25 
26 
27 //-------------------------------------------------------------------------
28 // samplv1_ui - decl.
29 //
30 
samplv1_ui(samplv1 * pSampl,bool bPlugin)31 samplv1_ui::samplv1_ui ( samplv1 *pSampl, bool bPlugin )
32 	: m_pSampl(pSampl), m_bPlugin(bPlugin)
33 {
34 }
35 
36 
instance(void) const37 samplv1 *samplv1_ui::instance (void) const
38 {
39 	return m_pSampl;
40 }
41 
42 
isPlugin(void) const43 bool samplv1_ui::isPlugin (void) const
44 {
45 	return m_bPlugin;
46 }
47 
48 
setSampleFile(const char * pszSampleFile,uint16_t iOctaves)49 void samplv1_ui::setSampleFile ( const char *pszSampleFile, uint16_t iOctaves )
50 {
51 	m_pSampl->setSampleFile(pszSampleFile, iOctaves, true);
52 }
53 
sampleFile(void) const54 const char *samplv1_ui::sampleFile (void) const
55 {
56 	return m_pSampl->sampleFile();
57 }
58 
octaves(void) const59 uint16_t samplv1_ui::octaves (void) const
60 {
61 	return m_pSampl->octaves();
62 }
63 
64 
sample(void) const65 samplv1_sample *samplv1_ui::sample (void) const
66 {
67 	return m_pSampl->sample();
68 }
69 
setReverse(bool bReverse)70 void samplv1_ui::setReverse ( bool bReverse )
71 {
72 	m_pSampl->setReverse(bReverse);
73 }
74 
isReverse(void) const75 bool samplv1_ui::isReverse (void) const
76 {
77 	return m_pSampl->isReverse();
78 }
79 
80 
setOffset(bool bOffset)81 void samplv1_ui::setOffset ( bool bOffset )
82 {
83 	m_pSampl->setOffset(bOffset);
84 }
85 
isOffset(void) const86 bool samplv1_ui::isOffset (void) const
87 {
88 	return m_pSampl->isOffset();
89 }
90 
91 
setOffsetRange(uint32_t iOffsetStart,uint32_t iOffsetEnd)92 void samplv1_ui::setOffsetRange ( uint32_t iOffsetStart, uint32_t iOffsetEnd )
93 {
94 	m_pSampl->setOffsetRange(iOffsetStart, iOffsetEnd, true);
95 }
96 
offsetStart(void) const97 uint32_t samplv1_ui::offsetStart (void) const
98 {
99 	return m_pSampl->offsetStart();
100 }
101 
offsetEnd(void) const102 uint32_t samplv1_ui::offsetEnd (void) const
103 {
104 	return m_pSampl->offsetEnd();
105 }
106 
107 
setLoop(bool bLoop)108 void samplv1_ui::setLoop ( bool bLoop )
109 {
110 	m_pSampl->setLoop(bLoop);
111 }
112 
isLoop(void) const113 bool samplv1_ui::isLoop (void) const
114 {
115 	return m_pSampl->isLoop();
116 }
117 
118 
setLoopRange(uint32_t iLoopStart,uint32_t iLoopEnd)119 void samplv1_ui::setLoopRange ( uint32_t iLoopStart, uint32_t iLoopEnd )
120 {
121 	m_pSampl->setLoopRange(iLoopStart, iLoopEnd, true);
122 }
123 
loopStart(void) const124 uint32_t samplv1_ui::loopStart (void) const
125 {
126 	return m_pSampl->loopStart();
127 }
128 
loopEnd(void) const129 uint32_t samplv1_ui::loopEnd (void) const
130 {
131 	return m_pSampl->loopEnd();
132 }
133 
134 
setLoopFade(uint32_t iLoopFade)135 void samplv1_ui::setLoopFade ( uint32_t iLoopFade )
136 {
137 	m_pSampl->setLoopFade(iLoopFade, true);
138 }
139 
loopFade(void) const140 uint32_t samplv1_ui::loopFade (void) const
141 {
142 	return m_pSampl->loopFade();
143 }
144 
145 
setLoopZero(bool bLoopZero)146 void samplv1_ui::setLoopZero ( bool bLoopZero )
147 {
148 	m_pSampl->setLoopZero(bLoopZero, true);
149 }
150 
isLoopZero(void) const151 bool samplv1_ui::isLoopZero (void) const
152 {
153 	return m_pSampl->isLoopZero();
154 }
155 
156 
loadPreset(const QString & sFilename)157 bool samplv1_ui::loadPreset ( const QString& sFilename )
158 {
159 	return samplv1_param::loadPreset(m_pSampl, sFilename);
160 }
161 
savePreset(const QString & sFilename)162 bool samplv1_ui::savePreset ( const QString& sFilename )
163 {
164 	return samplv1_param::savePreset(m_pSampl, sFilename);
165 }
166 
167 
setParamValue(samplv1::ParamIndex index,float fValue)168 void samplv1_ui::setParamValue ( samplv1::ParamIndex index, float fValue )
169 {
170 	m_pSampl->setParamValue(index, fValue);
171 }
172 
paramValue(samplv1::ParamIndex index) const173 float samplv1_ui::paramValue ( samplv1::ParamIndex index ) const
174 {
175 	return m_pSampl->paramValue(index);
176 }
177 
178 
controls(void) const179 samplv1_controls *samplv1_ui::controls (void) const
180 {
181 	return m_pSampl->controls();
182 }
183 
184 
programs(void) const185 samplv1_programs *samplv1_ui::programs (void) const
186 {
187 	return m_pSampl->programs();
188 }
189 
190 
reset(void)191 void samplv1_ui::reset (void)
192 {
193 	return m_pSampl->reset();
194 }
195 
196 
updatePreset(bool bDirty)197 void samplv1_ui::updatePreset ( bool bDirty )
198 {
199 	m_pSampl->updatePreset(bDirty);
200 }
201 
202 
midiInEnabled(bool bEnabled)203 void samplv1_ui::midiInEnabled ( bool bEnabled )
204 {
205 	m_pSampl->midiInEnabled(bEnabled);
206 }
207 
208 
midiInCount(void)209 uint32_t samplv1_ui::midiInCount (void)
210 {
211 	return m_pSampl->midiInCount();
212 }
213 
214 
directNoteOn(int note,int vel)215 void samplv1_ui::directNoteOn ( int note, int vel )
216 {
217 	m_pSampl->directNoteOn(note, vel);
218 }
219 
220 
setTuningEnabled(bool enabled)221 void samplv1_ui::setTuningEnabled ( bool enabled )
222 {
223 	m_pSampl->setTuningEnabled(enabled);
224 }
225 
isTuningEnabled(void) const226 bool samplv1_ui::isTuningEnabled (void) const
227 {
228 	return m_pSampl->isTuningEnabled();
229 }
230 
231 
setTuningRefPitch(float refPitch)232 void samplv1_ui::setTuningRefPitch ( float refPitch )
233 {
234 	m_pSampl->setTuningRefPitch(refPitch);
235 }
236 
tuningRefPitch(void) const237 float samplv1_ui::tuningRefPitch (void) const
238 {
239 	return m_pSampl->tuningRefPitch();
240 }
241 
242 
setTuningRefNote(int refNote)243 void samplv1_ui::setTuningRefNote ( int refNote )
244 {
245 	m_pSampl->setTuningRefNote(refNote);
246 }
247 
tuningRefNote(void) const248 int samplv1_ui::tuningRefNote (void) const
249 {
250 	return m_pSampl->tuningRefNote();
251 }
252 
253 
setTuningScaleFile(const char * pszScaleFile)254 void samplv1_ui::setTuningScaleFile ( const char *pszScaleFile )
255 {
256 	m_pSampl->setTuningScaleFile(pszScaleFile);
257 }
258 
tuningScaleFile(void) const259 const char *samplv1_ui::tuningScaleFile (void) const
260 {
261 	return m_pSampl->tuningScaleFile();
262 }
263 
264 
setTuningKeyMapFile(const char * pszKeyMapFile)265 void samplv1_ui::setTuningKeyMapFile ( const char *pszKeyMapFile )
266 {
267 	m_pSampl->setTuningKeyMapFile(pszKeyMapFile);
268 }
269 
tuningKeyMapFile(void) const270 const char *samplv1_ui::tuningKeyMapFile (void) const
271 {
272 	return m_pSampl->tuningKeyMapFile();
273 }
274 
275 
resetTuning(void)276 void samplv1_ui::resetTuning (void)
277 {
278 	m_pSampl->resetTuning();
279 }
280 
281 
282 // MIDI note/octave name helper (static).
noteName(int note)283 QString samplv1_ui::noteName ( int note )
284 {
285 	static const char *s_notes[] =
286 	{
287 		QT_TR_NOOP("C"),
288 		QT_TR_NOOP("C#/Db"),
289 		QT_TR_NOOP("D"),
290 		QT_TR_NOOP("D#/Eb"),
291 		QT_TR_NOOP("E"),
292 		QT_TR_NOOP("F"),
293 		QT_TR_NOOP("F#/Gb"),
294 		QT_TR_NOOP("G"),
295 		QT_TR_NOOP("G#/Ab"),
296 		QT_TR_NOOP("A"),
297 		QT_TR_NOOP("A#/Bb"),
298 		QT_TR_NOOP("B")
299 	};
300 
301 	return QString("%1 %2").arg(s_notes[note % 12]).arg((note / 12) - 1);
302 }
303 
304 
305 // end of samplv1_ui.cpp
306