Browse Source

Fix submodule broken by previous commit.

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
e693d9beef
5 changed files with 12 additions and 11 deletions
  1. +1
    -1
      dep/glfw
  2. +1
    -1
      dep/nanosvg
  3. +1
    -1
      dep/nanovg
  4. +1
    -1
      dep/rtaudio
  5. +8
    -7
      src/engine/Engine.cpp

+ 1
- 1
dep/glfw

@@ -1 +1 @@
Subproject commit 7ba23eb03854dfe6ce36cc6d61cb913f76cad774
Subproject commit d9ab59efc781c392128a449361a381fcc93cf6f3

+ 1
- 1
dep/nanosvg

@@ -1 +1 @@
Subproject commit c1f6e209c16b18b46aa9f45d7e619acf42c29726
Subproject commit 25241c5a8f8451d41ab1b02ab2d865b01600d949

+ 1
- 1
dep/nanovg

@@ -1 +1 @@
Subproject commit f4069e6a1ad5da430fb0a9c57476d5ddc2ff89b2
Subproject commit 1f9c8864fc556a1be4d4bf1d6bfe20cde25734b4

+ 1
- 1
dep/rtaudio

@@ -1 +1 @@
Subproject commit b9468aa6f82fdea1f3dc364f477e859b39f0bb2a
Subproject commit d27f257b4bc827e4152cdc4d69a2e22084204afd

+ 8
- 7
src/engine/Engine.cpp View File

@@ -233,7 +233,7 @@ static void Engine_stepModules(Engine *that, int threadId) {
// Step each module // Step each module
// for (int i = threadId; i < modulesLen; i += threadCount) { // for (int i = threadId; i < modulesLen; i += threadCount) {
while (true) { while (true) {
// Chose module
// Choose next module
int i = internal->workerModuleIndex++; int i = internal->workerModuleIndex++;
if (i >= modulesLen) if (i >= modulesLen)
break; break;
@@ -277,7 +277,7 @@ static void Engine_step(Engine *that) {
if (smoothModule) { if (smoothModule) {
Param *param = &smoothModule->params[smoothParamId]; Param *param = &smoothModule->params[smoothParamId];
float value = param->value; float value = param->value;
// decay rate is 1 graphics frame
// Decay rate is 1 graphics frame
const float smoothLambda = 60.f; const float smoothLambda = 60.f;
float newValue = value + (smoothValue - value) * smoothLambda * internal->sampleTime; float newValue = value + (smoothValue - value) * smoothLambda * internal->sampleTime;
if (value == newValue) { if (value == newValue) {
@@ -377,7 +377,7 @@ static void Engine_run(Engine *that) {
// Every time the that waits and locks a mutex, it steps this many frames // Every time the that waits and locks a mutex, it steps this many frames
const int mutexSteps = 128; const int mutexSteps = 128;
// Time in seconds that the that is rushing ahead of the estimated clock time // Time in seconds that the that is rushing ahead of the estimated clock time
double ahead = 0.0;
double aheadTime = 0.0;
auto lastTime = std::chrono::high_resolution_clock::now(); auto lastTime = std::chrono::high_resolution_clock::now();


while (internal->running) { while (internal->running) {
@@ -390,6 +390,7 @@ static void Engine_run(Engine *that) {
for (Module *module : internal->modules) { for (Module *module : internal->modules) {
module->onSampleRateChange(); module->onSampleRateChange();
} }
aheadTime = 0.0;
} }


// Launch workers // Launch workers
@@ -413,17 +414,17 @@ static void Engine_run(Engine *that) {
} }


double stepTime = mutexSteps * internal->sampleTime; double stepTime = mutexSteps * internal->sampleTime;
ahead += stepTime;
aheadTime += stepTime;
auto currTime = std::chrono::high_resolution_clock::now(); auto currTime = std::chrono::high_resolution_clock::now();
const double aheadFactor = 2.0; const double aheadFactor = 2.0;
ahead -= aheadFactor * std::chrono::duration<double>(currTime - lastTime).count();
aheadTime -= aheadFactor * std::chrono::duration<double>(currTime - lastTime).count();
lastTime = currTime; lastTime = currTime;
ahead = std::fmax(ahead, 0.0);
aheadTime = std::fmax(aheadTime, 0.0);


// Avoid pegging the CPU at 100% when there are no "blocking" modules like AudioInterface, but still step audio at a reasonable rate // Avoid pegging the CPU at 100% when there are no "blocking" modules like AudioInterface, but still step audio at a reasonable rate
// The number of steps to wait before possibly sleeping // The number of steps to wait before possibly sleeping
const double aheadMax = 1.0; // seconds const double aheadMax = 1.0; // seconds
if (ahead > aheadMax) {
if (aheadTime > aheadMax) {
std::this_thread::sleep_for(std::chrono::duration<double>(stepTime)); std::this_thread::sleep_for(std::chrono::duration<double>(stepTime));
} }
} }


Loading…
Cancel
Save