summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2025-01-04 18:42:35 +0100
committerRoland Reichwein <mail@reichwein.it>2025-01-04 18:42:35 +0100
commit0d603dc0d8f3a1fcc4d348114a6a0638608dad73 (patch)
tree0a59893471ad42e7eed1a8a2d90c723b4f632c42
parentdbe72ddb8eb215de6d38cd01ed201704ab315a4f (diff)
Output switch
-rw-r--r--MainLoop.cpp2
-rw-r--r--PCM.cpp26
2 files changed, 19 insertions, 9 deletions
diff --git a/MainLoop.cpp b/MainLoop.cpp
index 9db8c9a..32e8eb0 100644
--- a/MainLoop.cpp
+++ b/MainLoop.cpp
@@ -28,7 +28,7 @@ MainLoop::MainLoop():
m_clock_click{},
m_internal_click{m_config},
m_midi{},
- m_pcm{},
+ m_pcm{m_config},
m_ui{m_config}
{
}
diff --git a/PCM.cpp b/PCM.cpp
index 8c0e01f..5e90b97 100644
--- a/PCM.cpp
+++ b/PCM.cpp
@@ -1,6 +1,8 @@
#include "PCM.h"
-PCM::PCM(): m_phase(1000000)
+PCM::PCM(Config& config):
+ m_config(config),
+ m_phase(1000000)
{
// prepare the sample
std::string data_s = Reichwein::File::getFile("media/click.s16le");
@@ -80,16 +82,24 @@ void PCM::generate()
{
int i;
- for (i = 0; i < nframes; i++) {
- if (m_phase < 0 || m_phase >= m_data.size())
- {
+ if (m_config.get_output() == 0) {
+ for (i = 0; i < nframes; i++) {
buffer[i] = 0;
}
- else
- {
- buffer[i] = m_data[m_phase];
+ m_phase += nframes;
+ } else {
+
+ for (i = 0; i < nframes; i++) {
+ if (m_phase < 0 || m_phase >= m_data.size())
+ {
+ buffer[i] = 0;
+ }
+ else
+ {
+ buffer[i] = m_data[m_phase];
+ }
+ m_phase++;
}
- m_phase++;
}
}