Skip to content

Commit

Permalink
input meter linked to LockFreeQueue.cpp
Browse files Browse the repository at this point in the history
works™
  • Loading branch information
Shaji Khan committed Mar 9, 2024
1 parent 95cf722 commit c46d847
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
5 changes: 5 additions & 0 deletions app/src/main/cpp/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ bool Engine::setEffectOn(bool isOn) {

if (mFullDuplexPass.inSamples != NULL)
free (static_cast<void *>(mFullDuplexPass.inSamples));

if (mFullDuplexPass.raw != NULL)
free (static_cast<void *>(mFullDuplexPass.raw));

mFullDuplexPass.inSamples = static_cast<float *>(malloc(mFullDuplexPass.mBufferSize));
mFullDuplexPass.raw = static_cast<float *>(malloc(mFullDuplexPass.mBufferSize));
fileWriter->setChannels(mOutputChannelCount);
/*
if (mFullDuplexPass.recordingActive) {
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/cpp/FullDuplexPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class FullDuplexPass : public FullDuplexStream {
int outputPorts [MAX_PLUGINS] ;
int outputPorts2 [MAX_PLUGINS] ;
int activePlugins = 0 ;
float * raw = NULL; // this will never be greater than this(TM)
bool recordingActive = false ;
bool triggerRecord = false ;
bool bypass = false ;
Expand Down Expand Up @@ -81,8 +82,7 @@ class FullDuplexPass : public FullDuplexStream {

// float inSamples [samplesToProcess];
for (int i = 0 ; i < samplesToProcess ; i ++) {
outputFloats [i] = inputFloats [i];
inSamples [i] = inputFloats [i] * inputVolume ;
raw [i] = inSamples [i] = inputFloats [i] * inputVolume ;
}

// if (meterEnabled) {
Expand All @@ -107,7 +107,7 @@ class FullDuplexPass : public FullDuplexStream {
// Meter::process (samplesToProcess, inSamples, false);
// }

lockFreeQueueManager->process(outputFloats, inSamples, samplesToProcess) ;
lockFreeQueueManager->process(raw, inSamples, samplesToProcess) ;

// for (int32_t i = 0; i < samplesToProcess; i++) {
// *outputFloats++ = *inputFloats++ * outputVolume; // do some arbitrary processing
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/cpp/LockFreeQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,13 @@ void LockFreeQueueManager::main () {
IN
AudioBuffer * buffer ;
while (ready) {
if (lockFreeQueue.pop (buffer)) {
while (lockFreeQueue.pop (buffer)) {
for (int i = 0; i < functions_count; i++) {
(functions[i])(buffer);
}
}

// std::this_thread::sleep_for(std::chrono::milliseconds (1));

std::this_thread::sleep_for(std::chrono::milliseconds (100));
}
OUT
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/cpp/LockFreeQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class LockFreeQueue {
};

#define LOCK_FREE_SIZE 4096
#define SPARE_BUFFERS 16
#define SPARE_BUFFERS 128

class LockFreeQueueManager {
static LockFreeQueue<AudioBuffer *, LOCK_FREE_SIZE> lockFreeQueue ;
Expand Down

0 comments on commit c46d847

Please sign in to comment.