forked from surge-synthesizer/surge
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The gui is well separable from the patch/parameter/dsp/synth code so a headless mode should have been readily doable at any time. With this commit, it is done. This shows a small example of setting up and running a 2 oscillator detuned saw configuration of surge. On Linux, one VSTGUI symbol is still pulled in for a reason I can't determine, so introduce it in a fixes file which we need to address in a future issue if/as we develop headless. Closes surge-synthesizer#499.
- Loading branch information
Showing
10 changed files
with
240 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include "DisplayInfo.h" | ||
#include "UserInteractions.h" | ||
|
||
namespace Surge | ||
{ | ||
namespace GUI | ||
{ | ||
|
||
using namespace VSTGUI; | ||
|
||
float getDisplayBackingScaleFactor(CFrame *) | ||
{ | ||
return 1.0; | ||
} | ||
|
||
CRect getScreenDimensions(CFrame *) | ||
{ | ||
return CRect(CPoint(0,0), CPoint(1024,768)); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
|
||
#include <iostream> | ||
#include <iomanip> | ||
|
||
class HeadlessPluginLayerProxy | ||
{ | ||
public: | ||
void updateDisplay() | ||
{ | ||
std::cerr << "HeadlessPluginLayerProxy::updateDisplay" << std::endl; | ||
} | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
** There are a few symbols which on Linux currently get linked | ||
** for a very difficult to determine reason. We should fix this, | ||
** but for the meantime lets add this file to patch the link | ||
** errors | ||
*/ | ||
#if LINUX | ||
namespace VSTGUI | ||
{ | ||
void doAssert(const char*, const char*, const char*) | ||
{ | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "UserInteractions.h" | ||
#include <iostream> | ||
#include <iomanip> | ||
|
||
namespace Surge | ||
{ | ||
namespace UserInteractions | ||
{ | ||
void promptError(const Surge::Error &e) | ||
{ | ||
promptError(e.getMessage(), e.getTitle()); | ||
} | ||
|
||
void promptError(const std::string &message, | ||
const std::string &title) | ||
{ | ||
std::cerr << "Surge Error\n" | ||
<< title << "\n" | ||
<< message << "\n" << std::flush; | ||
} | ||
|
||
UserInteractions::MessageResult promptOKCancel(const std::string &message, | ||
const std::string &title) | ||
{ | ||
std::cerr << "Surge OkCancel\n" | ||
<< title << "\n" | ||
<< message << "\n" | ||
<< "Returning CANCEL" << std::flush; | ||
return UserInteractions::CANCEL; | ||
} | ||
|
||
void openURL(const std::string &url) | ||
{ | ||
} | ||
}; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#include <iostream> | ||
#include <iomanip> | ||
|
||
#include "SurgeSynthesizer.h" | ||
|
||
#include "HeadlessPluginLayerProxy.h" | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
std::cout << "Surge Headless Mode" << std::endl; | ||
|
||
HeadlessPluginLayerProxy *parent = new HeadlessPluginLayerProxy(); | ||
std::unique_ptr<SurgeSynthesizer> surge(new SurgeSynthesizer(parent)); | ||
surge->setSamplerate(44100); | ||
|
||
/* | ||
** Change a parameter in the scene. Do this by traversing the | ||
** graph in the current patch (which is in surge->storage). | ||
** | ||
** Clearly a more fulsome headless API would provide wrappers around | ||
** this for common activities. This sets up a pair of detuned saw waves | ||
** both active. | ||
*/ | ||
surge->storage.getPatch().scene[0].osc[0].pitch.set_value_f01(4); | ||
surge->storage.getPatch().scene[0].mute_o2.set_value_f01(0,true); | ||
surge->storage.getPatch().scene[0].osc[1].pitch.set_value_f01(1); | ||
|
||
/* | ||
** Play a note. channel, note, velocity, detune | ||
*/ | ||
surge->playNote((char)0, (char)60, (char)100, 0); | ||
|
||
/* | ||
** Strip off some processing first to avoid the attach transient | ||
*/ | ||
for(auto i=0; i<20; ++i) surge->process(); | ||
|
||
/* | ||
** Then run the sampler | ||
*/ | ||
int blockCount = 30; | ||
int overSample = 8; | ||
float overS = 0; | ||
int sampleCount = 0; | ||
for(auto i=0; i<blockCount; ++i ) | ||
{ | ||
surge->process(); | ||
|
||
for (int sm=0;sm<BLOCK_SIZE;++sm) | ||
{ | ||
float avgOut = 0; | ||
for (int oi=0; oi<surge->getNumOutputs(); ++oi) | ||
{ | ||
avgOut += surge->output[oi][sm]; | ||
} | ||
|
||
overS += avgOut; | ||
if (((sampleCount-1)%overSample) == 0) | ||
{ | ||
overS /= overSample; | ||
int gWidth = (int)((overS + 1)*30); | ||
std::cout << "Sample: " << std::setw( 15 ) << overS << std::setw(gWidth) << "X" << std::endl;; | ||
} | ||
sampleCount ++; | ||
|
||
} | ||
} | ||
} |