Browse Source

Merge branch 'master' of https://github.com/VCVRack/Rack into 2017-10-bontric-midiCC-fix

tags/v0.5.0
ben 7 years ago
parent
commit
f7fe29464d
2 changed files with 11 additions and 4 deletions
  1. +2
    -0
      include/engine.hpp
  2. +9
    -4
      src/engine.cpp

+ 2
- 0
include/engine.hpp View File

@@ -97,6 +97,8 @@ void engineSetParam(Module *module, int paramId, float value);
void engineSetParamSmooth(Module *module, int paramId, float value);
void engineSetSampleRate(float sampleRate);
float engineGetSampleRate();
/** Returns the inverse of the current sample rate */
float engineGetSampleTime();

extern bool gPaused;



+ 9
- 4
src/engine.cpp View File

@@ -14,7 +14,8 @@

namespace rack {

float sampleRate = 0.0;
float sampleRate;
float sampleTime;
bool gPaused = false;


@@ -38,7 +39,7 @@ float Light::getBrightness() {
}

void Light::setBrightnessSmooth(float brightness) {
value += (brightness * brightness - value) / sampleRate * 60.0;
value += (brightness * brightness - value) * sampleTime * 60.0;
}


@@ -70,7 +71,7 @@ static void engineStep() {
smoothModule = NULL;
}
else {
value += delta * lambda / sampleRate;
value += delta * lambda * sampleTime;
smoothModule->params[smoothParamId].value = value;
}
}
@@ -107,7 +108,7 @@ static void engineRun() {
}
}

double stepTime = mutexSteps / sampleRate;
double stepTime = mutexSteps * sampleTime;
ahead += stepTime;
auto currTime = std::chrono::high_resolution_clock::now();
const double aheadFactor = 2.0;
@@ -232,6 +233,7 @@ void engineSetSampleRate(float newSampleRate) {
VIPLock vipLock(vipMutex);
std::lock_guard<std::mutex> lock(mutex);
sampleRate = newSampleRate;
sampleTime = 1.0 / sampleRate;
// onSampleRateChange
for (Module *module : modules) {
module->onSampleRateChange();
@@ -242,5 +244,8 @@ float engineGetSampleRate() {
return sampleRate;
}

float engineGetSampleTime() {
return sampleTime;
}

} // namespace rack

Loading…
Cancel
Save