Skip to content

Instantly share code, notes, and snippets.

@eightlines
Created June 27, 2017 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eightlines/3d5b1705fcc138fa27f18f31c3c24ea7 to your computer and use it in GitHub Desktop.
Save eightlines/3d5b1705fcc138fa27f18f31c3c24ea7 to your computer and use it in GitHub Desktop.
Open Frameworks - Trying to implement ofSoundStream from a sub class
#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;
}
#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;
};
#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;
}
#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