File indexing completed on 2024-04-28 15:08:06

0001 /* miniSynth - A Simple Software Synthesizer
0002    SPDX-FileCopyrightText: 2015 Ville Räisänen <vsr at vsr.name>
0003 
0004    SPDX-License-Identifier: GPL-3.0-or-later
0005 */
0006 
0007 #ifndef ADSRENVELOPE_H
0008 #define ADSRENVELOPE_H
0009 
0010 #include <qmath.h>
0011 
0012 class ADSREnvelope {
0013 public:
0014     ADSREnvelope();
0015     ADSREnvelope(unsigned int _attackTime,
0016                  unsigned int _decayTime,
0017                  unsigned int _releaseTime,
0018                  qreal _initialAmpl,
0019                  qreal _peakAmpl,
0020                  qreal _sustainAmpl);
0021     ~ADSREnvelope() = default;
0022     enum {STATE_OFF, STATE_ATTACK, STATE_DECAY, STATE_RELEASE};
0023 
0024     qreal initialAmpl, peakAmpl, sustainAmpl;
0025     unsigned int attackTime, decayTime, releaseTime;
0026 
0027     qreal eval(qreal t, unsigned char state) const;
0028 private:
0029 };
0030 
0031 #endif // ADSRENVELOPE_H