MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / initialise

Method initialise

Source/MainComponent.cpp:182–325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180 }
181
182 void initialise() override
183 {
184#ifdef JUCE_WINDOWS
185 // glewInit();
186#endif
187
188 mVG = nvgCreateGLES2(NVG_ANTIALIAS | NVG_STENCIL_STROKES);
189 mFontBoundsVG = nvgCreateGLES2(NVG_ANTIALIAS | NVG_STENCIL_STROKES);
190
191 if (mVG == nullptr)
192 printf("Could not init nanovg.\n");
193 if (mFontBoundsVG == nullptr)
194 printf("Could not init font bounds nanovg.\n");
195
196 Push2Control::CreateStaticFramebuffer();
197
198 mSynth.LoadResources(mVG, mFontBoundsVG);
199
200 /*for (auto deviceType : mGlobalManagers.mDeviceManager.getAvailableDeviceTypes())
201 {
202 ofLog() << "inputs:";
203 for (auto input : deviceType->getDeviceNames(true))
204 ofLog() << input.toStdString();
205 ofLog() << "outputs:";
206 for (auto output : deviceType->getDeviceNames(false))
207 ofLog() << output.toStdString();
208 }*/
209
210 const std::string kAutoDevice = "auto";
211 const std::string kNoneDevice = "none";
212
213 if (UserPrefs.devicetype.Get() != kAutoDevice)
214 mGlobalManagers.mDeviceManager.setCurrentAudioDeviceType(UserPrefs.devicetype.Get(), true);
215
216 SetGlobalSampleRateAndBufferSize(UserPrefs.samplerate.Get(), UserPrefs.buffersize.Get());
217
218 mSynth.Setup(&mGlobalManagers.mDeviceManager, &mGlobalManagers.mAudioFormatManager, this, &openGLContext);
219
220 std::string outputDevice = UserPrefs.audio_output_device.Get();
221 std::string inputDevice = UserPrefs.audio_input_device.Get();
222 if (!mGlobalManagers.mDeviceManager.getCurrentDeviceTypeObject()->hasSeparateInputsAndOutputs())
223 inputDevice = outputDevice; //asio must have identical input and output
224
225 AudioDeviceManager::AudioDeviceSetup preferredSetupOptions;
226 preferredSetupOptions.sampleRate = gSampleRate / UserPrefs.oversampling.Get();
227 preferredSetupOptions.bufferSize = gBufferSize / UserPrefs.oversampling.Get();
228 if (outputDevice != kAutoDevice && outputDevice != kNoneDevice)
229 preferredSetupOptions.outputDeviceName = outputDevice;
230 if (inputDevice != kAutoDevice && inputDevice != kNoneDevice)
231 preferredSetupOptions.inputDeviceName = inputDevice;
232
233#ifdef JUCE_WINDOWS
234 CoInitializeEx(0, COINIT_MULTITHREADED);
235#endif
236
237 int inputChannels = UserPrefs.max_input_channels.Get();
238 int outputChannels = UserPrefs.max_output_channels.Get();
239

Callers

nothing calls this directly

Calls 11

ofToStringFunction · 0.85
ofLogClass · 0.85
StringClass · 0.85
LoadResourcesMethod · 0.80
GetMethod · 0.80
SetFatalErrorMethod · 0.80
InitIOBuffersMethod · 0.80
sizeMethod · 0.80
SetupMethod · 0.45

Tested by

no test coverage detected