Browse Source

Added engine pausing/resuming (in sample rate choose menu)

tags/v0.4.0
Andrew Belt 7 years ago
parent
commit
35c4e272e2
3 changed files with 13 additions and 1 deletions
  1. +1
    -0
      include/engine.hpp
  2. +10
    -0
      src/app/Toolbar.cpp
  3. +2
    -1
      src/engine.cpp

+ 1
- 0
include/engine.hpp View File

@@ -55,6 +55,7 @@ void engineRemoveWire(Wire *wire);
void engineSetParamSmooth(Module *module, int paramId, float value);

extern float gSampleRate;
extern bool gPaused;


} // namespace rack

+ 10
- 0
src/app/Toolbar.cpp View File

@@ -57,6 +57,12 @@ struct FileChoice : ChoiceButton {
};


struct PauseItem : MenuItem {
void onAction() {
gPaused = !gPaused;
}
};

struct SampleRateItem : MenuItem {
float sampleRate;
void onAction() {
@@ -70,6 +76,10 @@ struct SampleRateChoice : ChoiceButton {
menu->box.pos = getAbsolutePos().plus(Vec(0, box.size.y));
menu->box.size.x = box.size.x;

PauseItem *pauseItem = new PauseItem();
pauseItem->text = gPaused ? "Resume Engine" : "Pause Engine";
menu->pushChild(pauseItem);

float sampleRates[] = {44100, 48000, 88200, 96000, 176400, 192000};
int sampleRatesLen = sizeof(sampleRates) / sizeof(sampleRates[0]);
for (int i = 0; i < sampleRatesLen; i++) {


+ 2
- 1
src/engine.cpp View File

@@ -15,6 +15,7 @@
namespace rack {

float gSampleRate;
bool gPaused = false;


static bool running = false;
@@ -85,7 +86,7 @@ static void engineRun() {
while (running) {
vipMutex.wait();

{
if (!gPaused) {
std::lock_guard<std::mutex> lock(mutex);
for (int i = 0; i < mutexSteps; i++) {
engineStep();


Loading…
Cancel
Save