Openframeworks x Mobile           2011.08.20            黃怡靜          Janet Huang                          @janetyc
why I am here...
why openframeworks...
openFrameworks is an open source C++ toolkit           for creative coding.
Computer Technology            “is not a tool;it is a new material for expression”    Maeda, J. (2004). Creative Code. New...
Media                 Hardware   Openframeworks           Communication
cross platform    mac          iphone   windows   linux   android
Pros                  Cons  easy to use          experimental  open source          not complete                  &  inter...
basic libraries        openGL      graphic       rtAudio      audio input/output        freeType                    fonts ...
OF structure
OF component             openframeworks      apps      addons        libsexamples       addons
android app  osx app      iphone app  main.cpp      main.mm testApp.cpp   testApp.mm  testApp.h     testApp.h
#pragma once#include "ofMain.h"#include "ofxiPhone.h"#include "ofxiPhoneExtras.h"class testApp : public ofxiPhoneApp {!pub...
#include "testApp.h"//--------------------------------------------------------------void testApp::setup(){!! // register t...
//--------------------------------------------------------------void testApp::touchDown(ofTouchEventArgs &touch){}//------...
How to start ? 1. create a copy of emptyExample in apps folder 2. rename the folder and .xcodeproj file 3. open the project...
Let’s do it now.
audio   audioaccelerometer    graphic        touch                 imageinput                    output
audio input                                                 setup()   initialBufferSize ! = 512;   sampleRate ! ! ! = 4410...
accelerometer     ofxAccelerometer.getForce().x     ofxAccelerometer.getForce().y     ofxAccelerometer.getForce().ztouch e...
audio output ofSoundPlayer bird_sound;                     declaration bird_sound.loadSound("weeee.wav"); bird_sound.setVo...
graphics   - OpenGL (desktop)   - OpenGLES (iphone)  void testApp::draw()  {     ofFill();                  50     ofSetHe...
http://www.openframeworks.cc/documentation
sound                      funinteractive                      game
Cos Bird: an interactive sound game
CosBird   quiet   little noisy   more noisy   angry!
weeeeeeee
Live demo
Thanks very much.           http://twitter.com/janetyc           http://gplus.to/janetyc           janetyc@gmail.com
Upcoming SlideShare
Loading in...5
×

Openframworks x Mobile

2,230

Published on

I gave a talk in coscup 2011. My topic is about using openframeworks in mobile application. :)


You can download the demo code from github. https://github.com/janetyc/CosBird

Published in: Technology, Art & Photos
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,230
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
51
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide

Openframworks x Mobile

  1. 1. Openframeworks x Mobile 2011.08.20 黃怡靜 Janet Huang @janetyc
  2. 2. why I am here...
  3. 3. why openframeworks...
  4. 4. openFrameworks is an open source C++ toolkit for creative coding.
  5. 5. Computer Technology “is not a tool;it is a new material for expression” Maeda, J. (2004). Creative Code. New York: Thames & Hudson Inc.
  6. 6. Media Hardware Openframeworks Communication
  7. 7. cross platform mac iphone windows linux android
  8. 8. Pros Cons easy to use experimental open source not complete & interactivity
  9. 9. basic libraries openGL graphic rtAudio audio input/output freeType fonts freeImage image input/output quicktime video playing sequence grabbing
  10. 10. OF structure
  11. 11. OF component openframeworks apps addons libsexamples addons
  12. 12. android app osx app iphone app main.cpp main.mm testApp.cpp testApp.mm testApp.h testApp.h
  13. 13. #pragma once#include "ofMain.h"#include "ofxiPhone.h"#include "ofxiPhoneExtras.h"class testApp : public ofxiPhoneApp {!public:! void setup();! void update();! void draw();! void exit();!! void touchDown(ofTouchEventArgs &touch);! void touchMoved(ofTouchEventArgs &touch);! void touchUp(ofTouchEventArgs &touch);! void touchDoubleTap(ofTouchEventArgs &touch);! void touchCancelled(ofTouchEventArgs &touch);! void lostFocus();! void gotFocus();! void gotMemoryWarning();! void deviceOrientationChanged(intnewOrientation);}; testApp.h
  14. 14. #include "testApp.h"//--------------------------------------------------------------void testApp::setup(){!! // register touch events! ofRegisterTouchEvents(this);!! // initialize the accelerometer! ofxAccelerometer.setup();!! //iPhoneAlerts will be sent to this.! ofxiPhoneAlerts.addListener(this);!! //If you want a landscape oreintation! //iPhoneSetOrientation(OFXIPHONE_ORIENTATION_LANDSCAPE_RIGHT);!! ofBackground(127,127,127);}//--------------------------------------------------------------void testApp::update(){}//--------------------------------------------------------------void testApp::draw(){!}//--------------------------------------------------------------void testApp::exit(){} testApp.mm
  15. 15. //--------------------------------------------------------------void testApp::touchDown(ofTouchEventArgs &touch){}//--------------------------------------------------------------void testApp::touchMoved(ofTouchEventArgs &touch){}//-------------------------------------------------------------- touch eventvoid testApp::touchUp(ofTouchEventArgs &touch){}//--------------------------------------------------------------void testApp::touchDoubleTap(ofTouchEventArgs &touch){}//--------------------------------------------------------------void testApp::lostFocus(){}//--------------------------------------------------------------void testApp::gotFocus(){} alert engine//--------------------------------------------------------------void testApp::gotMemoryWarning(){}//--------------------------------------------------------------void testApp::deviceOrientationChanged(int newOrientation){}//--------------------------------------------------------------void testApp::touchCancelled(ofTouchEventArgs& args){} testApp.mm
  16. 16. How to start ? 1. create a copy of emptyExample in apps folder 2. rename the folder and .xcodeproj file 3. open the project 4. rename target 5. make sure it builds and runs
  17. 17. Let’s do it now.
  18. 18. audio audioaccelerometer graphic touch imageinput output
  19. 19. audio input setup() initialBufferSize ! = 512; sampleRate ! ! ! = 44100; drawCounter! ! ! = 0; bufferCounter! ! = 0; ! buffer!! ! ! = new float[initialBufferSize]; memset(buffer, 0, initialBufferSize * sizeof(float)); ! ofSoundStreamSetup(0, 1, this, sampleRate, initialBufferSize, 4); ofSetFrameRate(60); // 0 output channels, // 1 input channels // 44100 samples per second // 512 samples per buffer // 4 num buffers (latency) void testApp::audioIn(float * input, int bufferSize, int nChannels){ ! if( initialBufferSize != bufferSize ){ ! ! ofLog(OF_LOG_ERROR, "your buffer size was set to %i - but the stream needs a buffer size of %i", initialBufferSize, bufferSize); ! ! return; ! }! ! ! // samples are "interleaved" ! for (int i = 0; i < bufferSize; i++){ ! ! buffer[i] = input[i]; ! } } testApp.mm
  20. 20. accelerometer ofxAccelerometer.getForce().x ofxAccelerometer.getForce().y ofxAccelerometer.getForce().ztouch event //-------------------------------------------------------------- void testApp::touchDown(ofTouchEventArgs &touch){ touch.x } touch.y //-------------------------------------------------------------- (0,0) void testApp::touchMoved(ofTouchEventArgs &touch){ } //-------------------------------------------------------------- void testApp::touchUp(ofTouchEventArgs &touch){ } //-------------------------------------------------------------- void testApp::touchDoubleTap(ofTouchEventArgs &touch){ }
  21. 21. audio output ofSoundPlayer bird_sound; declaration bird_sound.loadSound("weeee.wav"); bird_sound.setVolume(1.0f); setup bird_sound.setMultiPlay(false); bird_sound.play(); playdraw image ofImage head_img; declaration head_img.loadImage("bird_cos.png"); setup head_img.draw(x_pos, y_pos, width, height); play
  22. 22. graphics - OpenGL (desktop) - OpenGLES (iphone) void testApp::draw() { ofFill(); 50 ofSetHexColor(0x3ABEE3); ofCircle(100, 100, 50); }polygonExample
  23. 23. http://www.openframeworks.cc/documentation
  24. 24. sound funinteractive game
  25. 25. Cos Bird: an interactive sound game
  26. 26. CosBird quiet little noisy more noisy angry!
  27. 27. weeeeeeee
  28. 28. Live demo
  29. 29. Thanks very much. http://twitter.com/janetyc http://gplus.to/janetyc janetyc@gmail.com
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×