Created
August 16, 2017 04:37
-
-
Save tado/ff31f92cc010d4381fce73cc7d36bc63 to your computer and use it in GitHub Desktop.
Using SuperCollider in openFrameworks for windows
This file contains hidden or 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
#include "ofApp.h" | |
void ofApp::setup() { | |
// start scsynth | |
STARTUPINFOA si; | |
GetStartupInfoA(&si); | |
CreateProcessA( | |
NULL, | |
".\\data\\server\\scsynth.exe -u 57110", | |
NULL, | |
NULL, | |
FALSE, | |
NULL, | |
NULL, | |
NULL, | |
&si, | |
&pi | |
); | |
//wait for server bootup... | |
Sleep(4000); | |
//OSC setup | |
sender.setup("127.0.0.1", 57110); | |
//load syntdef | |
ofxOscMessage m; | |
m.setAddress("/d_loadDir"); | |
m.addStringArg(".\\data\\synthdefs"); | |
sender.sendMessage(m); | |
} | |
void ofApp::exit() { | |
CloseHandle(pi.hThread); | |
TerminateProcess(pi.hProcess,0); | |
} | |
void ofApp::update(){ | |
} | |
void ofApp::draw(){ | |
} | |
void ofApp::keyPressed(int key){ | |
} | |
void ofApp::keyReleased(int key){ | |
if (key == 'a') { | |
//start synth | |
ofxOscMessage m; | |
m.setAddress("/s_new"); | |
m.addStringArg("sine"); | |
m.addInt32Arg(1000); | |
m.addInt32Arg(0); | |
m.addInt32Arg(0); | |
sender.sendMessage(m); | |
} | |
if (key == 's') { | |
//stop synth | |
ofxOscMessage m; | |
m.setAddress("/n_free"); | |
m.addInt32Arg(1000); | |
sender.sendMessage(m); | |
} | |
} |
This file contains hidden or 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
#pragma once | |
#include "ofMain.h" | |
#include "ofxOsc.h" | |
#include <windows.h> | |
class ofApp : public ofBaseApp{ | |
public: | |
void setup(); | |
void update(); | |
void draw(); | |
void exit(); | |
void keyPressed(int key); | |
void keyReleased(int key); | |
PROCESS_INFORMATION pi; | |
ofxOscSender sender; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment