├── UNLICENSE ├── README.md ├── 01-sandwiches ├── resources │ ├── lum.vert │ ├── sea.mp4 │ ├── lum.frag │ ├── pass.vert │ ├── video.vert │ ├── pass.frag │ └── video.frag ├── addons.make ├── README.md ├── src │ ├── main.cpp │ ├── ring.hpp │ ├── ofApp.h │ └── ofApp.cpp ├── Makefile └── config.make ├── 02-review ├── resources ├── addons.make ├── src │ ├── main.cpp │ ├── ofApp.h │ └── ofApp.cpp ├── Makefile └── config.make ├── .gitignore └── LICENSE /UNLICENSE: -------------------------------------------------------------------------------- 1 | LICENSE -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | :seedling: 2 | -------------------------------------------------------------------------------- /01-sandwiches/resources/lum.vert: -------------------------------------------------------------------------------- 1 | pass.vert -------------------------------------------------------------------------------- /02-review/resources: -------------------------------------------------------------------------------- 1 | ../01-sandwiches/resources -------------------------------------------------------------------------------- /01-sandwiches/addons.make: -------------------------------------------------------------------------------- 1 | ofxPoco 2 | ofxVideoRecorder 3 | -------------------------------------------------------------------------------- /01-sandwiches/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | make RunPackaged 3 | ``` 4 | -------------------------------------------------------------------------------- /02-review/addons.make: -------------------------------------------------------------------------------- 1 | ofxPoco 2 | ofxAudioAnalyzer 3 | ofxVideoRecorder 4 | ofxAudioDecoder 5 | -------------------------------------------------------------------------------- /01-sandwiches/resources/sea.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/whatever/mixtapes/main/01-sandwiches/resources/sea.mp4 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.depend 2 | *.layout 3 | *.mode1v3 4 | *.pbxuser 5 | 6 | .svn/ 7 | obj/ 8 | bin/ 9 | build/ 10 | !data/ 11 | 12 | *.swp 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /01-sandwiches/resources/lum.frag: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | void main () { 4 | vec2 pos = gl_TexCoord[0].xy; 5 | gl_FragColor = vec4(pos, 0.0f, 1.0f); 6 | } 7 | -------------------------------------------------------------------------------- /01-sandwiches/resources/pass.vert: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | void main () { 4 | gl_TexCoord[0] = gl_MultiTexCoord0; 5 | gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;; 6 | gl_FrontColor = gl_Color; 7 | gl_BackColor = vec4(0.f, 0.f, 0.f, 1.f); 8 | } 9 | -------------------------------------------------------------------------------- /01-sandwiches/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | int main() { 5 | float s = 0.3f; 6 | int w = 1080 / 4; 7 | int h = 1920 / 4; 8 | 9 | ofGLFWWindowSettings settings; 10 | settings.setGLVersion(3, 2); 11 | settings.setSize(w, h); 12 | 13 | ofCreateWindow(settings); 14 | ofRunApp(new ofApp()); 15 | } 16 | -------------------------------------------------------------------------------- /02-review/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofSetupOpenGL(1024, 768 ,OF_WINDOW); // <-------- setup the GL context 7 | 8 | // this kicks off the running of my app 9 | // can be OF_WINDOW or OF_FULLSCREEN 10 | // pass in width and height too: 11 | ofRunApp(new ofApp()); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /01-sandwiches/resources/video.vert: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | // OpenFrameworks pass ins <<< 4 | uniform mat4 modelViewMatrix; 5 | uniform mat4 projectionMatrix; 6 | uniform mat4 textureMatrix; 7 | uniform mat4 modelViewProjectionMatrix; 8 | 9 | in vec4 position; 10 | in vec4 color; 11 | in vec4 normal; 12 | in vec2 texcoord; 13 | // >>> END 14 | 15 | out vec2 varyingtexcoord; 16 | 17 | void main(){ 18 | varyingtexcoord = texcoord.xy; 19 | gl_Position = modelViewProjectionMatrix * position; 20 | } 21 | -------------------------------------------------------------------------------- /02-review/Makefile: -------------------------------------------------------------------------------- 1 | # Attempt to load a config.make file. 2 | # If none is found, project defaults in config.project.make will be used. 3 | ifneq ($(wildcard config.make),) 4 | include config.make 5 | endif 6 | 7 | # make sure the the OF_ROOT location is defined 8 | ifndef OF_ROOT 9 | OF_ROOT=$(realpath ../../../../generative/of_v0.11.0_osx_release) 10 | endif 11 | 12 | # call the project makefile! 13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk 14 | 15 | .PHONY: Packaged 16 | Packaged: Release 17 | cp resources/* ./bin/$(APPNAME).app/Contents/Resources/. 18 | 19 | RunPackaged: Packaged 20 | make RunRelease 21 | 22 | 23 | ayyy: 24 | rm -fr recorded.mov 25 | make RunPackaged 26 | open recorded.mov 27 | -------------------------------------------------------------------------------- /01-sandwiches/Makefile: -------------------------------------------------------------------------------- 1 | # Attempt to load a config.make file. 2 | # If none is found, project defaults in config.project.make will be used. 3 | ifneq ($(wildcard config.make),) 4 | include config.make 5 | endif 6 | 7 | # make sure the the OF_ROOT location is defined 8 | ifndef OF_ROOT 9 | OF_ROOT=$(realpath ../../../../generative/of_v0.11.0_osx_release) 10 | endif 11 | 12 | # call the project makefile! 13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk 14 | 15 | .PHONY: Packaged 16 | Packaged: Release 17 | cp resources/* ./bin/$(APPNAME).app/Contents/Resources/. 18 | 19 | RunPackaged: Packaged 20 | make RunRelease 21 | 22 | 23 | ayyy: 24 | rm -fr recorded.mov 25 | make RunPackaged 26 | open recorded.mov 27 | -------------------------------------------------------------------------------- /01-sandwiches/resources/pass.frag: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | uniform sampler2D texture; 4 | uniform float size = 1/1024.f; 5 | 6 | const float offset[3] = float[] (0.0, 1.3846153846, 3.2307692308); 7 | const float weight[3] = float[] (0.2270270270, 0.3162162162, 0.0702702703); 8 | 9 | float luminance (vec4 color) { 10 | return dot(vec3(.17f, .51f, .32f), color.rgb); 11 | } 12 | 13 | void main () { 14 | vec2 coord = gl_TexCoord[0].xy; 15 | 16 | vec4 color = texture2D(texture, coord) * weight[0]; 17 | float s = 4.f * size; 18 | color += texture2D(texture, coord + vec2(0, offset[1])*s) * weight[1]; 19 | color += texture2D(texture, coord - vec2(0, offset[1])*s) * weight[1]; 20 | color += texture2D(texture, coord + vec2(0, offset[2])*s) * weight[2]; 21 | color += texture2D(texture, coord - vec2(0, offset[2])*s) * weight[2]; 22 | 23 | gl_FragColor = color; 24 | gl_FragColor = vec4(1.0f, 1.0f, 1.0f, 0.5f); 25 | } 26 | -------------------------------------------------------------------------------- /01-sandwiches/src/ring.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define RING_MESH_COUNT 10 4 | 5 | #define TWOPI 3.1415*2 6 | 7 | class Ring { 8 | 9 | public: 10 | 11 | void update(unsigned int t) { 12 | 13 | float ts = ((float) t) / 1000.0f; 14 | 15 | for (int i=0; i < RING_MESH_COUNT; i++) { 16 | float u = ts + ((float) i)/((float) RING_MESH_COUNT)*TWOPI; 17 | float r = 100.0f; 18 | float x = r*cos(u); 19 | float y = r*sin(u); 20 | float z = 0.0f; 21 | meshes[i].resetTransform(); 22 | meshes[i].setScale(0.25f); 23 | meshes[i].setPosition(x, y, z); 24 | meshes[i].rotateDeg(+1.0f * 8 * u + i, ofVec3f(1.0f, 0.0f, 0.0f)); 25 | meshes[i].rotateDeg(+5.0f * 8 * u + i, ofVec3f(0.0f, 1.0f, 0.0f)); 26 | meshes[i].rotateDeg(-3.0f * 8 * u + i, ofVec3f(0.0f, 0.0f, 1.0f)); 27 | } 28 | }; 29 | 30 | void draw() { 31 | for (int i=0; i < RING_MESH_COUNT; i++) { 32 | meshes[i].draw(); 33 | } 34 | }; 35 | 36 | protected: 37 | ofBoxPrimitive meshes[RING_MESH_COUNT]; 38 | }; 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /01-sandwiches/src/ofApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | #include "ofxVideoRecorder.h" 5 | #include "ring.hpp" 6 | 7 | class ofApp : public ofBaseApp{ 8 | 9 | public: 10 | void setup(); 11 | void update(); 12 | void draw(); 13 | void keyPressed(int key); 14 | void keyReleased(int key); 15 | void mouseMoved(int x, int y ); 16 | void mouseDragged(int x, int y, int button); 17 | void mousePressed(int x, int y, int button); 18 | void mouseReleased(int x, int y, int button); 19 | void mouseEntered(int x, int y); 20 | void mouseExited(int x, int y); 21 | void windowResized(int w, int h); 22 | void dragEvent(ofDragInfo dragInfo); 23 | void gotMessage(ofMessage msg); 24 | 25 | void audioIn(ofSoundBuffer & input); 26 | 27 | // ... 28 | void exit(ofEventArgs &args); 29 | 30 | void update(unsigned int t); 31 | void setupMicrophone(); 32 | void setupRecorder(); 33 | 34 | unsigned int getElapsedMillis(); 35 | 36 | 37 | 38 | ofMesh videoMesh(ofTexture tex); 39 | void drawFooter(); 40 | 41 | protected: 42 | 43 | size_t frameWidth, frameHeight; 44 | 45 | // ... 46 | float speed; 47 | unsigned int start; 48 | float smoothedVol; 49 | 50 | ofEasyCam cam; 51 | ofBoxPrimitive box; 52 | ofSoundStream inStream; 53 | ofVideoPlayer player; 54 | 55 | ofVideoPlayer bgs[4]; 56 | 57 | ofFbo fbo; 58 | ofPixels pixels; 59 | 60 | // Recorder stuff 61 | ofxVideoRecorder recorder; 62 | void recordingComplete(ofxVideoRecorderOutputFileCompleteEventArgs& args); 63 | 64 | ofShader shader; 65 | 66 | Ring ring; 67 | }; 68 | -------------------------------------------------------------------------------- /02-review/src/ofApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #undef TARGET_OS_IOS 4 | #undef TARGET_OS_IPHONE 5 | #define TARGET_OS_MAC 1 6 | 7 | #include "ofMain.h" 8 | #include "ofxVideoRecorder.h" 9 | #include "ofSoundPlayerExtended.h" 10 | 11 | class ofApp : public ofBaseApp{ 12 | 13 | public: 14 | void setup(); 15 | void update(); 16 | void draw(); 17 | 18 | void keyPressed(int key); 19 | void keyReleased(int key); 20 | void mouseMoved(int x, int y ); 21 | void mouseDragged(int x, int y, int button); 22 | void mousePressed(int x, int y, int button); 23 | void mouseReleased(int x, int y, int button); 24 | void mouseEntered(int x, int y); 25 | void mouseExited(int x, int y); 26 | void windowResized(int w, int h); 27 | void dragEvent(ofDragInfo dragInfo); 28 | void gotMessage(ofMessage msg); 29 | 30 | void exit(ofEventArgs &args); 31 | 32 | void setupRecorder(); 33 | void recordingComplete(ofxVideoRecorderOutputFileCompleteEventArgs& args); 34 | 35 | void audioIn(ofSoundBuffer & input); 36 | // void audioOut(ofSoundBuffer &outBuffer); 37 | 38 | // void audioIn(float *input, int bufferSize, int nChannels); 39 | void setupMicrophone(); 40 | 41 | // Draw stuff 42 | void drawBars(float, std::vector&, float); 43 | 44 | protected: 45 | 46 | 47 | ofSoundPlayerExtended audioPlayer; 48 | 49 | ofFbo fbo; 50 | ofxVideoRecorder recorder; 51 | ofSoundStream outSoundStream; 52 | ofSoundStream inStream; 53 | 54 | ofSoundBuffer lastBuffer; 55 | 56 | std::vector buffer; 57 | std::vector spectrum; 58 | std::vector outBuffer; 59 | 60 | std::mutex audioMutex; 61 | }; 62 | -------------------------------------------------------------------------------- /01-sandwiches/resources/video.frag: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec2 varyingtexcoord; 4 | out vec4 outputColor; 5 | 6 | uniform sampler2DRect tex0; 7 | uniform sampler2DRect tex1; 8 | uniform float alpha; 9 | uniform float t; 10 | 11 | vec4 expanded(sampler2DRect t, vec2 pos, float a) { 12 | mat2 s = a * mat2(1, 0, 0, 1); 13 | vec4 c = texture(t, s*pos); 14 | return c; 15 | 16 | 17 | /* 18 | vec4 n = texture(t, pos + a*vec2(+0.0, +1.0)); 19 | vec4 e = texture(t, pos + a*vec2(+1.0, +0.0)); 20 | vec4 s = texture(t, pos + a*vec2(-0.0, -1.0)); 21 | vec4 w = texture(t, pos + a*vec2(-1.0, -0.0)); 22 | 23 | vec4 ne = texture(t, pos + a*vec2(+1.0, +1.0)); 24 | vec4 se = texture(t, pos + a*vec2(+1.0, -1.0)); 25 | vec4 sw = texture(t, pos + a*vec2(-1.0, -1.0)); 26 | vec4 nw = texture(t, pos + a*vec2(-1.0, +1.0)); 27 | 28 | vec4 c = texture(t, pos); 29 | 30 | vec4 res = vec4(0.0f); 31 | res += (n + e + s + w); 32 | res += (ne + se + sw + nw); 33 | res += c; 34 | res /= 9.0f; 35 | return res; 36 | */ 37 | } 38 | 39 | float lum(vec4 rgba) { 40 | return dot( 41 | vec4(0.2126, 0.7152, 0.0722, 0.0f), 42 | rgba 43 | ); 44 | } 45 | 46 | float f(float x, float y) { 47 | return 48 | 0.5f*(cos(x) + 0.1f) 49 | + 50 | 0.5f*(sin(y) + 0.1f); 51 | } 52 | 53 | vec2 df(float x, float y) { 54 | float h = 0.005f; 55 | float dx = (f(x+h, y) - f(x-h, y)) / h / 2.0f; 56 | float dy = (f(x, y+h) - f(x, y-h)) / h / 2.0f; 57 | return vec2(dx, dy); 58 | } 59 | 60 | 61 | #define PI 3.14159265359f 62 | #define XSCALE (1080.0f / 4.0f / 2.0f / PI / 4.0f) 63 | #define YSCALE (1920.0f / 4.0f / 2.0f / PI / 4.0f) 64 | 65 | 66 | // f 67 | float f_tex(sampler2DRect tex, vec2 pos) { 68 | return lum(texture(tex, pos)); 69 | } 70 | 71 | // df 72 | vec3 df_tex(sampler2DRect tex, vec2 pos) { 73 | const float h = 5.0f; 74 | float dx = (f_tex(tex, pos+vec2(h, 0)) - f_tex(tex, pos-vec2(h, 0)))/h/2.0f; 75 | float dy = (f_tex(tex, pos+vec2(0, h)) - f_tex(tex, pos-vec2(0, h)))/h/2.0f; 76 | float x = pos.x / XSCALE; 77 | float y = pos.y / YSCALE; 78 | return vec3(dx, dy, 1); 79 | } 80 | 81 | // Spearfish 82 | vec4 spearfish(sampler2DRect target, sampler2DRect mask, vec2 pos) { 83 | 84 | // Compute normal vector 85 | float z = f_tex(mask, pos); 86 | vec3 df = df_tex(mask, pos); 87 | vec3 n = normalize(vec3(-df.x, -df.y, 1)); 88 | 89 | // Compute where it hits 90 | vec3 h = vec3(0, 0, z); 91 | vec3 d = h + 300.3f*-n; 92 | 93 | vec4 col = texture(target, pos.xy + d.xy); 94 | 95 | return col; 96 | } 97 | 98 | // Whiff 99 | vec4 whiff(sampler2DRect target, sampler2DRect mask, vec2 pos) { 100 | float z = 1.0f/6.0f/(1.0f+lum(texture(mask, 0.5f*pos))); 101 | return expanded(target, pos, z); 102 | } 103 | 104 | void main() { 105 | outputColor = whiff(tex0, tex1, varyingtexcoord); 106 | // outputColor = spearfish(tex0, tex1, varyingtexcoord); 107 | } 108 | -------------------------------------------------------------------------------- /02-review/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | #include "ofApp.h" 2 | 3 | #define SAMPLE_RATE 44100 4 | #define FPS 30 5 | 6 | //-------------------------------------------------------------- 7 | void ofApp::setup(){ 8 | 9 | outBuffer = std::vector(0); 10 | 11 | ofSetFrameRate(FPS); 12 | 13 | // Set data root 14 | string newRoot = "../Resources"; 15 | ofEnableDataPath(); 16 | ofSetDataPathRoot(newRoot); 17 | 18 | auto audioPath = ofFilePath::getCurrentWorkingDirectory(); 19 | audioPath = ofFilePath::join(audioPath, "books-of-war.mp3"); 20 | audioPath = ofFilePath::getAbsolutePath(audioPath); 21 | std::cout << "Audio path = " << audioPath << "\n"; 22 | 23 | 24 | // Audio 25 | audioPlayer.load(audioPath); 26 | audioPlayer.setLoop(true); 27 | audioPlayer.setVolume(0.0); 28 | audioPlayer.play(); 29 | 30 | setupMicrophone(); 31 | 32 | fbo.allocate(100, 100, GL_RGB); 33 | setupRecorder(); 34 | } 35 | 36 | void ofApp::setupRecorder() { 37 | 38 | // Video 39 | recorder.setVideoCodec("mpeg4"); 40 | recorder.setVideoBitrate("1800k"); 41 | 42 | // Audio 43 | recorder.setAudioCodec("mp3"); 44 | recorder.setAudioBitrate("256k"); 45 | 46 | // Handler 47 | ofAddListener(recorder.outputFileCompleteEvent, this, &ofApp::recordingComplete); 48 | recorder.setup("../../../../recorded.mov", 100, 100, FPS, SAMPLE_RATE, 1); 49 | recorder.start(); 50 | } 51 | 52 | void ofApp::audioIn(ofSoundBuffer & input) { 53 | { 54 | auto soundBuffer = audioPlayer.getCurrentSoundBufferMono(256); 55 | 56 | for (int i=0; i < soundBuffer.getNumFrames(); i++) { 57 | std::cout << soundBuffer[i] << " "; 58 | } 59 | 60 | std::cout << "\n"; 61 | 62 | std::cout 63 | << soundBuffer.getNumFrames() << " " 64 | << soundBuffer.getNumChannels() << " " 65 | << "\n"; 66 | 67 | recorder.addAudioSamples(&soundBuffer[0], soundBuffer.getNumFrames(), soundBuffer.getNumChannels()); 68 | buffer = soundBuffer.getBuffer(); 69 | } 70 | 71 | } 72 | 73 | /* 74 | void ofApp::audioOut(ofSoundBuffer &buff) { 75 | 76 | std::cout << "<<< audioIn = " << buff.size() << "\n"; 77 | // buff.copyTo(lastBuffer, 100, 2); 78 | 79 | for (size_t i = 0; i < buff.getNumFrames(); i++) { 80 | std::cout << buff.getSample(i, 0) << " "; 81 | } 82 | std::cout << "\n"; 83 | 84 | lastBuffer = buff; 85 | 86 | std::cout << ">>> audioIn = " << lastBuffer.size() << "\n"; 87 | } 88 | */ 89 | 90 | void ofApp::drawBars(float y_pos, std::vector &ys, float scale) { 91 | 92 | if (ys.empty()) { 93 | return; 94 | } 95 | 96 | float w = ofGetWidth(); 97 | float h = 100; 98 | int width = (ofGetWidth()) / ys.size(); 99 | 100 | for (int i=0; i < ys.size(); i++) { 101 | float x = i*width; 102 | float y = y_pos; 103 | float h = ys[i]*scale; 104 | ofSetColor(255); 105 | ofDrawRectangle(x, y, width, h); 106 | } 107 | } 108 | 109 | void ofApp::setupMicrophone() { 110 | 111 | int bufferSize = 256; 112 | 113 | ofSoundStreamSettings settings; 114 | auto devices = inStream.getMatchingDevices("Microphone"); 115 | 116 | std::cout << "Device list:\n"; 117 | 118 | for (int i=0; i < devices.size(); i++) { 119 | auto device = devices[i]; 120 | std::cout << " " << i << ") " << device.name << "\n"; 121 | } 122 | 123 | assert(devices.size() > 0); 124 | 125 | std::cout << "\n\n"; 126 | 127 | std::cout << "Using \"" << devices[0].name << "\" as input device...\n"; 128 | settings.setInDevice(devices[0]); 129 | 130 | settings.setInListener(this); 131 | settings.sampleRate = 44100; 132 | settings.numOutputChannels = 0; 133 | settings.numInputChannels = 1; 134 | settings.bufferSize = bufferSize; 135 | 136 | inStream.setup(settings); 137 | inStream.stop(); 138 | inStream.start(); 139 | 140 | 141 | /* // 142 | { 143 | ofSoundStreamSettings settings; 144 | settings.numOutputChannels = 2; 145 | settings.sampleRate = 44100; 146 | settings.bufferSize = 512; 147 | settings.numBuffers = 4; 148 | settings.setOutListener(this); 149 | outSoundStream.setup(settings); 150 | } 151 | // */ 152 | } 153 | 154 | void ofApp::exit(ofEventArgs &args) { 155 | ofRemoveListener(recorder.outputFileCompleteEvent, this, &ofApp::recordingComplete); 156 | recorder.close(); 157 | } 158 | 159 | //-------------------------------------------------------------- 160 | void ofApp::update() { 161 | 162 | ofSoundUpdate(); 163 | 164 | fbo.begin(); 165 | ofClear(255, 0, 0, 255); 166 | ofSetColor(255, 255, 255); 167 | fbo.end(); 168 | 169 | ofPixels pixels; 170 | fbo.getTexture().readToPixels(pixels); 171 | recorder.addFrame(pixels); 172 | 173 | { 174 | auto soundBuffer = audioPlayer.getCurrentSoundBufferMono(512); 175 | 176 | std::cout 177 | << soundBuffer.size() << " " 178 | << soundBuffer.getNumFrames() << " " 179 | << soundBuffer.getNumChannels() << " " 180 | << "\n"; 181 | 182 | // recorder.addAudioSamples(&soundBuffer[0], soundBuffer.getNumFrames(), soundBuffer.getNumChannels()); 183 | } 184 | 185 | 186 | if (audioPlayer.isLoaded()) { 187 | outBuffer = audioPlayer.getCurrentBuffer(256); 188 | } 189 | 190 | // std::cout << recorder.hasAudioError() << ", " << recorder.hasVideoError() << "\n"; 191 | // 192 | } 193 | void ofApp::draw() { 194 | ofClear(0); 195 | ofSetColor(255, 0, 0); 196 | ofDrawRectangle(0, 0, ofGetWidth(), ofGetHeight()); 197 | 198 | drawBars(100, buffer, 100.0f); 199 | drawBars(500, outBuffer, 100.0f); 200 | } 201 | 202 | void ofApp::recordingComplete(ofxVideoRecorderOutputFileCompleteEventArgs& args) { 203 | } 204 | 205 | void ofApp::keyPressed(int key){ } 206 | void ofApp::keyReleased(int key){ } 207 | void ofApp::mouseMoved(int x, int y ){ } 208 | void ofApp::mouseDragged(int x, int y, int button){ } 209 | void ofApp::mousePressed(int x, int y, int button){ } 210 | void ofApp::mouseReleased(int x, int y, int button){ } 211 | void ofApp::mouseEntered(int x, int y){ } 212 | void ofApp::mouseExited(int x, int y){ } 213 | void ofApp::windowResized(int w, int h){ } 214 | void ofApp::gotMessage(ofMessage msg){ } 215 | void ofApp::dragEvent(ofDragInfo dragInfo){ } 216 | -------------------------------------------------------------------------------- /01-sandwiches/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../../../generative/of_v0.11.0_osx_release 10 | ################################################################################ 11 | # OF_ROOT = ../../../../generative/of_v0.11.0_osx_release 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /02-review/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../../../generative/of_v0.11.0_osx_release 10 | ################################################################################ 11 | # OF_ROOT = ../../../../generative/of_v0.11.0_osx_release 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /01-sandwiches/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "ofApp.h" 4 | 5 | #define FPS 60 6 | 7 | unsigned int now() { 8 | using namespace std::chrono; 9 | return duration_cast(system_clock::now().time_since_epoch()).count(); 10 | } 11 | 12 | void ofApp::setup(){ 13 | 14 | // Set data root 15 | string newRoot = "../Resources"; 16 | ofEnableDataPath(); 17 | ofSetDataPathRoot(newRoot); 18 | 19 | // Framerate 20 | ofSetFrameRate(FPS); 21 | 22 | // WxH 23 | frameWidth = ofGetWidth(); 24 | frameHeight = ofGetHeight(); 25 | fbo.allocate(frameWidth, frameHeight, GL_RGB); 26 | 27 | // ... 28 | setupRecorder(); 29 | 30 | auto renderer = ofGetGLRenderer(); 31 | std::cout << "01 Mixtape; " 32 | << "OpenGL = " << renderer->getGLVersionMajor() << "." << renderer->getGLVersionMinor() 33 | << "\n\n\n\n"; 34 | 35 | speed = 0.0f; 36 | smoothedVol = 3.0f; 37 | start = now(); 38 | 39 | setupMicrophone(); 40 | 41 | std::cout << "\n\n"; 42 | 43 | std::cout << "Loading shader...\n"; 44 | 45 | if (shader.load("video.vert", "video.frag")) { 46 | std::cout << "Shader successfully loaded!\n"; 47 | } 48 | 49 | std::cout << "Finished loading shader...\n"; 50 | 51 | auto videoPath = ofFilePath::getCurrentWorkingDirectory(); 52 | videoPath = ofFilePath::join(videoPath, "sea.mp4"); 53 | videoPath = ofFilePath::getAbsolutePath(videoPath); 54 | std::cout << "Video path = " << videoPath << "\n"; 55 | 56 | player.load(videoPath); 57 | player.play(); 58 | 59 | for (int i=0; i < 4; i++) { 60 | bgs[i].load(videoPath); 61 | bgs[i].play(); 62 | } 63 | } 64 | 65 | void ofApp::setupRecorder() { 66 | recorder.setVideoCodec("mpeg4"); 67 | recorder.setVideoBitrate("1800k"); 68 | ofAddListener(recorder.outputFileCompleteEvent, this, &ofApp::recordingComplete); 69 | recorder.setup("../../../../recorded.mov", frameWidth, frameHeight, FPS); 70 | recorder.start(); 71 | } 72 | 73 | void ofApp::exit(ofEventArgs &args) { 74 | ofRemoveListener(recorder.outputFileCompleteEvent, this, &ofApp::recordingComplete); 75 | recorder.close(); 76 | inStream.stop(); 77 | inStream.close(); 78 | } 79 | 80 | void ofApp::recordingComplete(ofxVideoRecorderOutputFileCompleteEventArgs& args) { 81 | } 82 | 83 | void ofApp::setupMicrophone() { 84 | 85 | int bufferSize = 256; 86 | 87 | ofSoundStreamSettings settings; 88 | auto devices = inStream.getMatchingDevices("Microphone"); 89 | 90 | std::cout << "Device list:\n"; 91 | 92 | for (int i=0; i < devices.size(); i++) { 93 | auto device = devices[i]; 94 | std::cout << " " << i << ") " << device.name << "\n"; 95 | } 96 | 97 | assert(devices.size() > 0); 98 | 99 | std::cout << "\n\n"; 100 | 101 | std::cout << "Using \"" << devices[0].name << "\" as input device...\n"; 102 | settings.setInDevice(devices[0]); 103 | 104 | settings.setInListener(this); 105 | settings.sampleRate = 44100; 106 | settings.numOutputChannels = 0; 107 | settings.numInputChannels = 1; 108 | settings.bufferSize = bufferSize; 109 | 110 | inStream.setup(settings); 111 | inStream.stop(); 112 | inStream.start(); 113 | } 114 | 115 | void ofApp::update() { 116 | player.update(); 117 | 118 | for (int i=0; i < 4; i++) { 119 | bgs[i].update(); 120 | } 121 | 122 | update(getElapsedMillis()); 123 | ring.update(getElapsedMillis()); 124 | 125 | if (recorder.isInitialized()) { 126 | recorder.addFrame(pixels); 127 | } 128 | } 129 | 130 | void ofApp::update(unsigned int t) { 131 | float ts = ((float) getElapsedMillis()) / 1000.0f * 33.0f; 132 | box.resetTransform(); 133 | // box.setScale(smoothedVol); 134 | box.setScale(1.0f); 135 | box.rotateDeg(+1.0f * ts, ofVec3f(1.0f, 0.0f, 0.0f)); 136 | box.rotateDeg(+5.0f * ts, ofVec3f(0.0f, 1.0f, 0.0f)); 137 | box.rotateDeg(-3.0f * ts, ofVec3f(0.0f, 0.0f, 1.0f)); 138 | 139 | speed = 0.3f + 4.0f*smoothedVol; 140 | player.setSpeed(speed/2.0f); 141 | bgs[0].setSpeed(0.45); 142 | } 143 | 144 | void ofApp::drawFooter() { 145 | ofDisableDepthTest(); 146 | 147 | ofSetColor(1); 148 | int h = 50; 149 | int w = ofGetViewportWidth(); 150 | int x = 0; 151 | int y = ofGetViewportHeight()-h; 152 | ofDrawRectangle(x, y, w, h); 153 | 154 | ofSetColor(255); 155 | ofDrawBitmapString("vol = " + to_string(speed), x+10, y+h-30); 156 | ofDrawBitmapString("elp = " + to_string(getElapsedMillis()), x+10, y+h-10); 157 | } 158 | 159 | void ofApp::draw() { 160 | ofClear(0); 161 | ofSetColor(255); 162 | 163 | cam.setGlobalPosition({ 164 | 0, 165 | 0, 166 | cam.getImagePlaneDistance(ofGetCurrentViewport()) 167 | }); 168 | 169 | 170 | fbo.begin(); 171 | 172 | // Clear 173 | ofDisableDepthTest(); 174 | 175 | // Draw video in background 176 | ofClear(0, 0, 0, 255); 177 | ofSetColor(255, 255, 255); 178 | player.draw(0, 0, frameWidth, frameHeight); 179 | 180 | fbo.end(); 181 | 182 | ofTexture tex = fbo.getTexture(); 183 | ofMesh mesh = videoMesh(tex); 184 | 185 | // XXX: Recursive Video Editing 186 | // XXX: Other software cannot make videos with infinit layers 187 | // XXX: So many videos with infinite layers... 188 | 189 | ofFbo t; 190 | t.allocate(frameWidth, frameHeight, GL_RGB); 191 | t.begin(); 192 | 193 | { // ... 194 | ofClear(255, 255, 255, 255); 195 | ofSetColor(255, 255, 255); 196 | shader.begin(); 197 | shader.setUniformTexture("tex0", fbo.getTexture(), 0); 198 | shader.setUniformTexture("tex1", bgs[0].getTexture(), 1); 199 | shader.setUniform1f("alpha", smoothedVol); 200 | float t = ((float) getElapsedMillis()) / 1000.0f; 201 | shader.setUniform1f("t", t); 202 | mesh.draw(); 203 | shader.end(); 204 | } 205 | 206 | { // Draw 3D stuff 207 | ofEnableDepthTest(); 208 | cam.begin(); 209 | ring.draw(); 210 | cam.end(); 211 | } 212 | 213 | { // Draw Footer 214 | drawFooter(); 215 | } 216 | 217 | t.end(); 218 | 219 | t.draw(0, 0, frameWidth, frameHeight); 220 | t.readToPixels(pixels); 221 | } 222 | 223 | ofMesh ofApp::videoMesh(ofTexture tex) { 224 | ofMesh mesh; 225 | 226 | float h = frameHeight; 227 | float w = frameWidth; 228 | 229 | auto nw = tex.getCoordFromPercent(0.0f, 0.0f); 230 | auto ne = tex.getCoordFromPercent(1.0f, 0.0f); 231 | auto se = tex.getCoordFromPercent(1.0f, 1.0f); 232 | auto sw = tex.getCoordFromPercent(0.0f, 1.0f); 233 | 234 | nw = glm::vec2(0, 0); 235 | ne = glm::vec2(w, 0); 236 | se = glm::vec2(w, h); 237 | sw = glm::vec2(0, h); 238 | 239 | // 0 240 | mesh.addVertex(ofPoint(0.0f, 0.0f)); 241 | mesh.addTexCoord(nw); 242 | 243 | // 1 244 | mesh.addVertex(ofPoint(w, 0.0f)); 245 | mesh.addTexCoord(ne); 246 | 247 | // 3 248 | mesh.addVertex(ofPoint(0.0f, h)); 249 | mesh.addTexCoord(sw); 250 | 251 | // 1 252 | mesh.addVertex(ofPoint(w, 0.0f)); 253 | mesh.addTexCoord(ne); 254 | 255 | // 3 256 | mesh.addVertex(ofPoint(0.0f, h)); 257 | mesh.addTexCoord(sw); 258 | 259 | // 2 260 | mesh.addVertex(ofPoint(w, h)); 261 | mesh.addTexCoord(se); 262 | return mesh; 263 | } 264 | 265 | unsigned int ofApp::getElapsedMillis() { 266 | return now() - start; 267 | } 268 | 269 | void ofApp::audioIn(ofSoundBuffer & input){ 270 | 271 | float v = 0.0f; 272 | for (size_t i=0; i < input.size(); i++) { 273 | v += input[i]*input[i]; 274 | } 275 | 276 | v /= (float) input.size(); 277 | v = sqrt(v); 278 | smoothedVol = 0.1f*smoothedVol + 0.9f*v; 279 | 280 | } 281 | 282 | void ofApp::keyPressed(int key) { } 283 | void ofApp::keyReleased(int key) { } 284 | void ofApp::mouseMoved(int x, int y ){ } 285 | void ofApp::mouseDragged(int x, int y, int button){ } 286 | void ofApp::mousePressed(int x, int y, int button){ } 287 | void ofApp::mouseReleased(int x, int y, int button){ } 288 | void ofApp::mouseEntered(int x, int y){ } 289 | void ofApp::mouseExited(int x, int y){ } 290 | void ofApp::windowResized(int w, int h){ } 291 | void ofApp::gotMessage(ofMessage msg){ } 292 | void ofApp::dragEvent(ofDragInfo dragInfo){ } 293 | --------------------------------------------------------------------------------