From 84730760698833df09eb8b082a5473be5fc85c85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Nusser?= Date: Thu, 2 Aug 2018 10:49:39 +0200 Subject: Fix rampdown issue and clean up a bit while at it. --- src/events.h | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'src/events.h') diff --git a/src/events.h b/src/events.h index f953031..b78dd79 100644 --- a/src/events.h +++ b/src/events.h @@ -42,6 +42,11 @@ typedef unsigned int timepos_t; class Event { public: + Event(channel_t channel, timepos_t offset = 0) + : channel(channel), offset(offset) + { + } + virtual ~Event() { } @@ -57,22 +62,21 @@ public: timepos_t offset; //< Global position (ie. not relative to buffer) }; -#define NO_RAMPDOWN -1 class EventSample : public Event { public: EventSample(channel_t c, float g, AudioFile* af, const std::string& grp, void* instr) + : Event(c) + , cache_id(CACHE_NOID) + , gain(g) + , t(0) + , file(af) + , group(grp) + , instrument(instr) + , rampdown_count(-1) + , ramp_length(0) { - cache_id = CACHE_NOID; - channel = c; - gain = g; - t = 0; - file = af; - group = grp; - instrument = instr; - rampdown = NO_RAMPDOWN; - ramp_start = 0; } Event::type_t getType() const @@ -80,6 +84,11 @@ public: return Event::sample; } + bool rampdownInProgress() const + { + return rampdown_count != -1; + } + cacheid_t cache_id; sample_t* buffer; size_t buffer_size; @@ -89,8 +98,8 @@ public: AudioFile* file; std::string group; void* instrument; - int rampdown; - int ramp_start; + int rampdown_count; + int ramp_length; float scale{1.0f}; }; -- cgit v1.2.3