diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 5 | ||||
-rw-r--r-- | src/audiofile.h | 2 | ||||
-rw-r--r-- | src/audioinputengine.h | 2 | ||||
-rw-r--r-- | src/drumgizmo.cc | 3 | ||||
-rw-r--r-- | src/engineevent.h (renamed from src/event.h) | 2 | ||||
-rw-r--r-- | src/events.h | 3 | ||||
-rw-r--r-- | src/inputfilter.h | 2 | ||||
-rw-r--r-- | src/inputprocessor.cc | 40 | ||||
-rw-r--r-- | src/inputprocessor.h | 17 | ||||
-rw-r--r-- | src/powerlist.cc | 1 |
10 files changed, 43 insertions, 34 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 85b10fa..ff02883 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -33,7 +33,8 @@ libdg_la_CPPFLAGS = \ $(DEBUG_FLAGS) \ -I$(top_srcdir)/hugin -I$(top_srcdir)/pugixml/src \ $(SSEFLAGS) -I$(top_srcdir)/zita-resampler/libs \ - $(SNDFILE_CFLAGS) $(PTHREAD_CFLAGS) + $(SNDFILE_CFLAGS) $(PTHREAD_CFLAGS) \ + -Wno-deprecated-declarations libdg_la_LIBADD = \ $(SNDFILE_LIBS) $(PTHREAD_LIBS) libzr.la libpugi.la @@ -106,7 +107,7 @@ EXTRA_DIST = \ drumgizmoconf.h \ drumkit.h \ drumkitloader.h \ - event.h \ + engineevent.h \ events.h \ events_ds.h \ grid.h \ diff --git a/src/audiofile.h b/src/audiofile.h index e20d91f..504d0ae 100644 --- a/src/audiofile.h +++ b/src/audiofile.h @@ -32,8 +32,6 @@ #include <limits> #include <mutex> -#include <sndfile.h> - #include "audio.h" #include "channel.h" #include "logger.h" diff --git a/src/audioinputengine.h b/src/audioinputengine.h index 71a86c2..55a06ae 100644 --- a/src/audioinputengine.h +++ b/src/audioinputengine.h @@ -29,7 +29,7 @@ #include <string> #include <vector> -#include <event.h> +#include "engineevent.h" #include "instrument.h" diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index abe57be..b67e91a 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -32,7 +32,6 @@ #include <cstring> #include <mutex> -#include <event.h> #include <audiotypes.h> #include <config.h> @@ -312,7 +311,7 @@ repeat: assert(t >= 0); assert(t < evt.buffer_size - evt.buffer_ptr); - if(evt.rampdownInProgress() && evt.rampdown_offset < (evt.t + t) && + if(evt.hasRampdown() && evt.rampdown_offset < (pos + t) && evt.rampdown_count > 0) { if(evt.ramp_length > 0) diff --git a/src/event.h b/src/engineevent.h index 737fb18..9c60a4a 100644 --- a/src/event.h +++ b/src/engineevent.h @@ -1,6 +1,6 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /*************************************************************************** - * event.h + * engineevent.h * * Fri Jun 3 12:10:50 CEST 2011 * Copyright 2011 Bent Bisballe Nyeng diff --git a/src/events.h b/src/events.h index 9e3cae1..538127b 100644 --- a/src/events.h +++ b/src/events.h @@ -84,11 +84,12 @@ public: { } - bool rampdownInProgress() const + bool hasRampdown() const { return rampdown_count != -1; } + cacheid_t cache_id; sample_t* buffer; std::size_t buffer_size; diff --git a/src/inputfilter.h b/src/inputfilter.h index 45dd01e..128dfb0 100644 --- a/src/inputfilter.h +++ b/src/inputfilter.h @@ -26,7 +26,7 @@ */ #pragma once -#include <event.h> +#include "engineevent.h" //! An abstract filter component for the InputProcessor class filter chain. class InputFilter diff --git a/src/inputprocessor.cc b/src/inputprocessor.cc index 7d12bdd..c0c0e92 100644 --- a/src/inputprocessor.cc +++ b/src/inputprocessor.cc @@ -139,20 +139,18 @@ std::size_t InputProcessor::getLatency() const return latency; } -//! Applies choke with rampdown time in ms to event starting at offset. -static void applyChoke(Settings& settings, SampleEvent& event, - double length_ms, timepos_t offset) +void InputProcessor::applyChoke(Settings& settings, SampleEvent& event, + double length_ms, timepos_t offset, std::size_t pos) { std::size_t ramp_length = (length_ms / 1000.) * settings.samplerate.load(); event.rampdown_count = ramp_length; - event.rampdown_offset = offset; + event.rampdown_offset = offset + pos; event.ramp_length = ramp_length; } -//! Applies choke group actions to active events based on the input event -static void applyChokeGroup(Settings& settings, DrumKit& kit, - Instrument& instr, event_t& event, - EventsDS& events_ds) +void InputProcessor::applyChokeGroup(Settings& settings, DrumKit& kit, + Instrument& instr, event_t& event, + EventsDS& events_ds, std::size_t pos) { std::size_t instrument_id = event.instrument; if(instr.getGroup() == "") @@ -175,16 +173,15 @@ static void applyChokeGroup(Settings& settings, DrumKit& kit, event_sample.rampdown_count == -1) // Only if not already ramping. { // Fixed group rampdown time of 68ms, independent of samplerate - applyChoke(settings, event_sample, 68, event.offset); + applyChoke(settings, event_sample, 68, event.offset, pos); } } } } -//! Applies directed choke actions to active events based on the input event -static void applyDirectedChoke(Settings& settings, DrumKit& kit, - Instrument& instr, event_t& event, - EventsDS& events_ds) +void InputProcessor::applyDirectedChoke(Settings& settings, DrumKit& kit, + Instrument& instr, event_t& event, + EventsDS& events_ds, std::size_t pos) { for(const auto& choke : instr.getChokes()) { @@ -202,7 +199,7 @@ static void applyDirectedChoke(Settings& settings, DrumKit& kit, event_sample.rampdown_count == -1) // Only if not already ramping. { // choke.choketime is in ms - applyChoke(settings, event_sample, choke.choketime, event.offset); + applyChoke(settings, event_sample, choke.choketime, event.offset, pos); } } } @@ -245,10 +242,10 @@ bool InputProcessor::processOnset(event_t& event, std::size_t pos, } // Mute other instruments in the same instrument/choke group - applyChokeGroup(settings, kit, *instr, event, events_ds); + applyChokeGroup(settings, kit, *instr, event, events_ds, pos); // Apply directed chokes to mute other instruments if needed - applyDirectedChoke(settings, kit, *instr, event, events_ds); + applyDirectedChoke(settings, kit, *instr, event, events_ds, pos); auto const power_max = instr->getMaxPower(); auto const power_min = instr->getMinPower(); @@ -266,7 +263,7 @@ bool InputProcessor::processOnset(event_t& event, std::size_t pos, { limitVoices(instrument_id, settings.voice_limit_max.load(), - settings.voice_limit_rampdown.load()); + settings.voice_limit_rampdown.load(), pos); } //Given that audio files could be invalid, maybe we must add the new @@ -356,7 +353,7 @@ bool InputProcessor::processChoke(event_t& event, event_sample.rampdown_count == -1) // Only if not already ramping. { // Fixed group rampdown time of 68ms, independent of samplerate - applyChoke(settings, event_sample, 450, event.offset); + applyChoke(settings, event_sample, 450, event.offset, pos); } } } @@ -397,7 +394,7 @@ bool InputProcessor::processStop(event_t& event) void InputProcessor::limitVoices(std::size_t instrument_id, std::size_t max_voices, - float rampdown_time) + float rampdown_time, std::size_t pos) { const auto& group_ids=events_ds.getSampleEventGroupIDsOf(instrument_id); @@ -418,7 +415,7 @@ void InputProcessor::limitVoices(std::size_t instrument_id, } const auto& sample=events_ds.get<SampleEvent>(event_ids[0]); - return !sample.rampdownInProgress(); + return !sample.hasRampdown(); }; EventGroupIDs non_ramping; @@ -432,7 +429,6 @@ void InputProcessor::limitVoices(std::size_t instrument_id, } //Let us get the eldest... - //TODO: where is the playhead? Should we add it to the offset? auto compare_event_offsets = [this](EventGroupID a, EventGroupID b) { @@ -456,6 +452,6 @@ void InputProcessor::limitVoices(std::size_t instrument_id, for(const auto& event_id : event_ids) { auto& sample=events_ds.get<SampleEvent>(event_id); - applyChoke(settings, sample, rampdown_time, sample.offset); + applyChoke(settings, sample, rampdown_time, sample.offset, pos); } } diff --git a/src/inputprocessor.h b/src/inputprocessor.h index 971cc85..a8dc45b 100644 --- a/src/inputprocessor.h +++ b/src/inputprocessor.h @@ -30,13 +30,13 @@ #include <list> #include <memory> -#include <event.h> #include "drumkit.h" #include "events.h" #include "events_ds.h" #include "id.h" #include "inputfilter.h" +#include "engineevent.h" struct Settings; class Random; @@ -64,10 +64,23 @@ private: bool processChoke(event_t& event, std::size_t pos, double resample_ratio); bool processStop(event_t& event); + //! Applies choke with rampdown time in ms to event starting at offset. + void applyChoke(Settings& settings, SampleEvent& event, + double length_ms, timepos_t offset, std::size_t pos); + + //! Applies choke group actions to active events based on the input event + void applyChokeGroup(Settings& settings, DrumKit& kit, + Instrument& instr, event_t& event, + EventsDS& events_ds, std::size_t pos); + //! Applies directed choke actions to active events based on the input event + void applyDirectedChoke(Settings& settings, DrumKit& kit, + Instrument& instr, event_t& event, + EventsDS& events_ds, std::size_t pos); + //! Ramps down samples from events_ds is there are more groups playing than //! max_voices for a given instrument. void limitVoices(std::size_t instrument_id, std::size_t max_voices, - float rampdown_time); + float rampdown_time, std::size_t pos); std::vector<std::unique_ptr<InputFilter>> filters; diff --git a/src/powerlist.cc b/src/powerlist.cc index 23d9795..8dd0b24 100644 --- a/src/powerlist.cc +++ b/src/powerlist.cc @@ -84,6 +84,7 @@ const Channel* PowerList::getMasterChannel() af->load(nullptr, LOAD_SIZE); float silence{0.f}; + (void)silence; std::size_t silence_length{4u}; for (auto s = af->size; s > 0 && s > af->size - silence_length; --s) { |