Skip to content

Instantly share code, notes, and snippets.

@admsyn
admsyn / view_to_tex.cpp
Last active January 16, 2018 20:26
NSView to ofTexture
void viewToTex(NSView * view, ofTexture& tex) {
// this is based on listing 11-3 at
// https://developer.apple.com/library/content/documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_texturedata/opengl_texturedata.html
NSBitmapImageRep * bitmap = [view bitmapImageRepForCachingDisplayInRect:view.visibleRect];
[view cacheDisplayInRect:view.visibleRect toBitmapImageRep:bitmap];
glPixelStorei(GL_UNPACK_ROW_LENGTH, bitmap.bytesPerRow / bitmap.samplesPerPixel);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
@admsyn
admsyn / gist:79cc02ebd147ce530cf1
Last active August 29, 2015 14:17
Setting up rtlsdr
void setup() {
cout << "Device Count: " << rtlsdr_get_device_count() << endl;
cout << "Open: " << rtlsdr_open(&device, 0) << endl;
rtlsdr_set_center_freq(device, 156050000);
rtlsdr_set_sample_rate(device, sampleRate);
rtlsdr_set_agc_mode(device, 1);
rtlsdr_set_freq_correction(device, 0);
rtlsdr_reset_buffer(device);
@admsyn
admsyn / ofApp.cpp
Created March 7, 2015 01:11
Physx in OF test (pyramid drop)
#include "ofApp.h"
using namespace physx;
#define actorFlags PxActorTypeSelectionFlag::eRIGID_DYNAMIC | PxActorTypeSelectionFlag::eRIGID_STATIC
PxDefaultAllocator defaultAllocator;
PxDefaultErrorCallback defaultErrorCallback;
const PxReal extent = 4;
const PxReal halfExtent = extent * 0.5;
@admsyn
admsyn / gist:4323266
Created December 17, 2012 23:03
libfreenect issue demo
adam:bin Adam$ pwd
/Users/Adam/workspace/scratch/libfreenect/build/bin
adam:bin Adam$ ls
cppview glview record regview
glpclview hiview regtest tiltdemo
adam:bin Adam$ ./glview
Kinect camera test
Number of devices found: 1
Could not open device
adam:bin Adam$ ./tiltdemo
@admsyn
admsyn / gist:4322559
Created December 17, 2012 21:42
ofxKinect issues
[verbose] ofxKinect: Context inited
[verbose] ofxKinect: 1 device found
[verbose] id: 0 serial: 0000000000000000
[error] ofxKinect: Could not open device 0
[warning] ofxKinect: Device -1 isn't delivering data, reconnecting tries: 1
[error] ofxKinect: Could not open device 0
[warning] ofxKinect: Device -1 isn't delivering data, reconnecting tries: 2
[error] ofxKinect: Could not open device 0
[warning] ofxKinect: Device -1 isn't delivering data, reconnecting tries: 3
[error] ofxKinect: Could not open device 0
@admsyn
admsyn / README.txt
Created November 24, 2012 15:45
Keep an installation alive with launchd & launchctl
Add this .plist to ~/Library/LaunchAgents to have it automatically
take effect whenever you log in. It will continue to be active until
you log out (even if you delete the file).
You can take manual control over it instead by putting the file
anywhere else, then using launchctl like this:
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
launchctl load path/to/the/plist/com.admsyn.keep-twitter-alive.plist
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
@admsyn
admsyn / Output
Created November 7, 2012 03:18
Sketching out some thoughts for an oF DSP chain
[A] : +0.0 +0.2 +0.0 +0.5 +0.0 +0.3 +0.0 -0.2 +0.0 -0.5 +0.0 -0.4 +0.0 +0.1 +0.0 +0.5
[B] : +0.5 +0.4 +0.2 -0.0 -0.3 -0.4 -0.5 -0.4 -0.3 -0.0 +0.2 +0.4 +0.5 +0.5 +0.3 +0.1
Mixer : use addSourceOnBus() instead of connectTo()
[C] : -0.1 -0.4 -0.5 -0.5 -0.4 -0.2 +0.1 +0.3 +0.5 +0.5 +0.4 +0.2 -0.0 -0.2 -0.4 -0.5
@admsyn
admsyn / gist:3790864
Created September 26, 2012 21:53
Firing up a RemoteIO
UInt32 propSize = sizeof(UInt32);
UInt32 inputAvailable;
AudioSessionGetProperty(kAudioSessionProperty_AudioInputAvailable,&propSize,&inputAvailable);
if(!inputAvailable)
{
std::cout << "No input available!" << std::endl;
return false;
}
@admsyn
admsyn / Output
Created August 24, 2012 16:49
Testing vDSP's FFT vs FFTW's
N = 1024 Accel: 0.05265 FFTW: 0.026213
N = 2048 Accel: 0.042565 FFTW: 0.049334
N = 4096 Accel: 0.049206 FFTW: 0.082782
N = 8192 Accel: 0.118918 FFTW: 0.173506
N = 16384 Accel: 0.200201 FFTW: 0.371488
N = 32768 Accel: 0.356826 FFTW: 1.01589
N = 65536 Accel: 0.844955 FFTW: 1.79316
N = 131072 Accel: 1.95759 FFTW: 3.99565
N = 262144 Accel: 4.34179 FFTW: 9.87287
N = 524288 Accel: 9.31858 FFTW: 19.6675