1 /* $Id: ADSR.h,v 1.1 2012/07/08 00:45:54 sarrazip Exp $ 2 3 flatzebra - SDL-based sound renderer 4 Copyright (C) 2011 Pierre Sarrazin <http://sarrazip.com/> 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 17 License along with this program; if not, write to the Free 18 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 Boston, MA 02110-1301, USA. 20 */ 21 22 #pragma once 23 24 25 namespace roundbeetle { 26 27 28 struct ADSR 29 { 30 float attackLevel; // 0..1 31 float sustainLevel; // 0..1 32 float attackTime; // seconds (>= 0) 33 float decayTime; // seconds (>= 0) 34 float sustainTime; // seconds (>= 0) 35 float releaseTime; // seconds (>= 0) 36 ADSRADSR37 ADSR(float _attackLevel, 38 float _sustainLevel, 39 float _attackTime, 40 float _decayTime, 41 float _sustainTime, 42 float _releaseTime) 43 : attackLevel(_attackLevel), 44 sustainLevel(_sustainLevel), 45 attackTime(_attackTime), 46 decayTime(_decayTime), 47 sustainTime(_sustainTime), 48 releaseTime(_releaseTime) 49 { 50 } 51 getTotalTimeADSR52 float getTotalTime() const 53 { 54 return attackTime + decayTime + sustainTime + releaseTime; 55 } 56 57 }; 58 59 60 } // namespace roundbeetle 61