summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/chresampler.cc14
-rw-r--r--src/chresampler.h7
-rw-r--r--src/drumgizmo.cc5
-rw-r--r--src/drumgizmo.h3
-rw-r--r--src/inputprocessor.cc13
-rw-r--r--src/inputprocessor.h7
6 files changed, 41 insertions, 8 deletions
diff --git a/src/chresampler.cc b/src/chresampler.cc
index c8323de..c3c19bf 100644
--- a/src/chresampler.cc
+++ b/src/chresampler.cc
@@ -139,6 +139,15 @@ void CHResampler::process()
#endif
}
+std::size_t CHResampler::getLatency() const
+{
+#if defined(USE_ZITA)
+ return prv->zita.inpdist();
+#elif defined(USE_SRC)
+ return 0; // TODO?
+#endif
+}
+
std::size_t CHResampler::getInputSampleCount() const
{
#if defined(USE_ZITA)
@@ -172,6 +181,11 @@ void CHResampler::setInputSamples(float*, std::size_t) {}
void CHResampler::setOutputSamples(float*, std::size_t) {}
void CHResampler::process() {}
+std::size_t CHResampler::getLatency() const
+{
+ return 0;
+}
+
std::size_t CHResampler::getInputSampleCount() const
{
return 0;
diff --git a/src/chresampler.h b/src/chresampler.h
index 4148aee..d21d1cb 100644
--- a/src/chresampler.h
+++ b/src/chresampler.h
@@ -48,6 +48,8 @@ public:
void process();
+ std::size_t getLatency() const;
+
std::size_t getInputSampleCount() const;
std::size_t getOutputSampleCount() const;
@@ -96,5 +98,10 @@ public:
return resamplers[0].getOutputSampleCount();
}
+ std::size_t getLatency() const
+ {
+ return resamplers[0].getLatency();
+ }
+
std::array<CHResampler, 64> resamplers;
};
diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc
index ef4d3b6..a1278a1 100644
--- a/src/drumgizmo.cc
+++ b/src/drumgizmo.cc
@@ -410,6 +410,11 @@ void DrumGizmo::stop()
// engine.stop();
}
+std::size_t DrumGizmo::getLatency() const
+{
+ return input_processor.getLatency() + resamplers.getLatency();
+}
+
int DrumGizmo::samplerate()
{
return settings.samplerate.load();
diff --git a/src/drumgizmo.h b/src/drumgizmo.h
index 3f2d17c..63c0fb6 100644
--- a/src/drumgizmo.h
+++ b/src/drumgizmo.h
@@ -64,6 +64,9 @@ public:
std::string configString();
bool setConfigString(std::string cfg);
+ //! Get the current engine latency in samples.
+ std::size_t getLatency() const;
+
int samplerate();
void setSamplerate(int samplerate);
diff --git a/src/inputprocessor.cc b/src/inputprocessor.cc
index 1676090..b83855f 100644
--- a/src/inputprocessor.cc
+++ b/src/inputprocessor.cc
@@ -61,13 +61,18 @@ bool InputProcessor::process(const std::vector<event_t>& events, size_t pos, dou
return true;
}
+std::size_t InputProcessor::getLatency() const
+{
+ return 0;
+}
+
bool InputProcessor::processOnset(const event_t& event, size_t pos, double resample_ratio)
{
if(!kit.isValid()) {
return false;
}
- size_t ev_instr = event.instrument;
+ size_t ev_instr = event.instrument;
Instrument* instr = nullptr;
if(ev_instr < kit.instruments.size())
@@ -115,12 +120,6 @@ bool InputProcessor::processOnset(const event_t& event, size_t pos, double resam
for(Channel& ch: kit.channels)
{
AudioFile* af = sample->getAudioFile(&ch);
- if(af != nullptr)
- {
- // LAZYLOAD:
- // DEBUG(inputprocessor, "Requesting preparing of audio file\n");
- // loader.prepare(af);
- }
if(af == nullptr || !af->isValid())
{
//DEBUG(inputprocessor, "Missing AudioFile.\n");
diff --git a/src/inputprocessor.h b/src/inputprocessor.h
index da370ec..83a4f5b 100644
--- a/src/inputprocessor.h
+++ b/src/inputprocessor.h
@@ -37,7 +37,12 @@ class InputProcessor
{
public:
InputProcessor(DrumKit& kit, std::list<Event*>* activeevents);
- bool process(const std::vector<event_t>& events, size_t pos, double resample_ratio);
+
+ bool process(const std::vector<event_t>& events, size_t pos,
+ double resample_ratio);
+
+ std::size_t getLatency() const;
+
private:
DrumKit& kit;
std::list<Event*>* activeevents;