Created
June 27, 2017 15:07
-
-
Save eightlines/3d5b1705fcc138fa27f18f31c3c24ea7 to your computer and use it in GitHub Desktop.
Open Frameworks - Trying to implement ofSoundStream from a sub class
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
#include "ofApp.h" | |
ofApp *ofApp::_app = 0; | |
ofApp::ofApp() { _app = this; } | |
void ofApp::setup() { | |
} | |
void ofApp::gotMessage(ofMessage msg) { | |
} | |
void ofApp::audioIn(float *input, int bufferSize, int nChannels) { | |
cout << "ofApp::audioIn " << input << 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
#pragma once | |
#include "ofMain.h" | |
#include "screen_photo.h" | |
class ofApp : public ofBaseApp { | |
public: | |
ofApp(); | |
static ofApp &getInstance() { return *_app; } | |
void setup(); | |
void gotMessage(ofMessage msg); | |
void audioIn(float *input, int bufferSize, int nChannels); | |
private: | |
static ofApp *_app; | |
ScreenPhoto _photo; | |
}; |
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
#include "screen_photo.h" | |
#include "ofApp.h" | |
ScreenPhoto::ScreenPhoto() { | |
cout << "ScreenPhoto Constructor" << endl; | |
ofAddListener(ofEvents().update, this, &ScreenPhoto::update); | |
ofAddListener(ofEvents().draw, this, &ScreenPhoto::draw); | |
_grabber.initGrabber(640, 480); | |
ofApp &app = ofApp::getInstance(); | |
// _soundstream.setup(this, 0, 2, 44100, 256, 4); | |
_soundstream.setup(&app, 0, 2, 44100, 256, 4); | |
} | |
void ScreenPhoto::update(ofEventArgs &e) { | |
_grabber.update(); | |
} | |
void ScreenPhoto::draw(ofEventArgs &e) { | |
_grabber.draw(0, 0); | |
} | |
void ScreenPhoto::audioIn(float *input, int bufferSize, int nChannels) { | |
cout << "ScreenPhoto::audioIn " << input << 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
#pragma once | |
#include "ofMain.h" | |
class ScreenPhoto { | |
public: | |
ScreenPhoto(); | |
void audioIn(float *input, int bufferSize, int nChannels); | |
private: | |
ofVideoGrabber _grabber; | |
ofSoundStream _soundstream; | |
int _channels = 2; | |
int _sampleRate = 44100; | |
int _bufferSize = 256; | |
int _buffers = 4; | |
void update(ofEventArgs &e); | |
void draw(ofEventArgs &e); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment