Browse Source

Lazy initialize portmidi and portaudio

tags/v0.3.0
Andrew Belt 7 years ago
parent
commit
6b33f9dbac
4 changed files with 12 additions and 6 deletions
  1. +6
    -0
      src/core/AudioInterface.cpp
  2. +6
    -0
      src/core/MidiInterface.cpp
  3. +0
    -3
      src/core/core.cpp
  4. +0
    -3
      src/core/core.hpp

+ 6
- 0
src/core/AudioInterface.cpp View File

@@ -7,13 +7,18 @@

using namespace rack;

static bool initialized = false;

void audioInit() {
if (initialized)
return;

PaError err = Pa_Initialize();
if (err) {
fprintf(stderr, "Failed to initialize PortAudio: %s\n", Pa_GetErrorText(err));
return;
}
initialized = true;
}


@@ -80,6 +85,7 @@ AudioInterface::AudioInterface() {
params.resize(NUM_PARAMS);
inputs.resize(NUM_INPUTS);
outputs.resize(NUM_OUTPUTS);
audioInit();
}

AudioInterface::~AudioInterface() {


+ 6
- 0
src/core/MidiInterface.cpp View File

@@ -7,13 +7,18 @@

using namespace rack;

static bool initialized = false;

void midiInit() {
if (initialized)
return;

PmError err = Pm_Initialize();
if (err) {
printf("Failed to initialize PortMidi: %s\n", Pm_GetErrorText(err));
return;
}
initialized = true;
}


@@ -56,6 +61,7 @@ MidiInterface::MidiInterface() {
params.resize(NUM_PARAMS);
inputs.resize(NUM_INPUTS);
outputs.resize(NUM_OUTPUTS);
midiInit();
}

MidiInterface::~MidiInterface() {


+ 0
- 3
src/core/core.cpp View File

@@ -12,8 +12,5 @@ struct CorePlugin : Plugin {


Plugin *init() {
audioInit();
midiInit();

return new CorePlugin();
}

+ 0
- 3
src/core/core.hpp View File

@@ -3,9 +3,6 @@

using namespace rack;

void audioInit();
void midiInit();

////////////////////
// module widgets
////////////////////


Loading…
Cancel
Save