Adding ofxMidi to an Existing Project

Note: These instructions are for manually adding ofxMidi to a project. You do not need to follow these steps if you use the ProjecGenerator app to regenerate your project files, except for Xcode where you currently need to add the CoreMIDI framework._

### Xcode

create a new group "ofxMidi"

drag these directories from ofxMidi into this new group: `ofxMidi/src`

  • if building for OSX, remove the src/ios & libs/pgmidi folder references
  • if building for iOS, remove the src/desktop & libs/rtmidi folder references

add the CoreMIDI framework to your project

  • click on your project in the sidebar
  • select the Summary tab
  • click the + under Linked Frameworks & Libraries
  • search for and select the CoreMIDI.framework from the list

add the following directories to your search path in your project's Project.xconfig file (See the Project.xconfig of the example project.):

<pre> ../../../addons/ofxMidi/src ../../../addons/ofxMidi/libs/rtmidi </pre>

Problem: #include "RtMidi.h" -> 'RtMidi.h' file not found Solved: Use OF Tool inside XCode (adds libs folder)

ofxMidi @ ofxLua -> Create a Wrapper

  • Add ofxMidiLua.cpp and ofxMidiLua.h at my project
  • Add ofxMidiLua bindings at gea wrapper.
/*
 * Copyright (c) 2014 Aris Bezas <aribezas@gmail.com>
 *
 * BSD Simplified License.
 * For information on usage and redistribution, and for a DISCLAIMER OF ALL
 * WARRANTIES, see the file, "LICENSE.txt," in this distribution.
 *
 * See https://github.com/igoumninja/ofxLua branch gea for documentation
 *
 */
#include "ofApp.h"
#include "ofxGea.h"
#include "ofxMidiLua.h"
#include "ofxLua.h"

//#include <luabind/operator.hpp>

namespace bindings {

luabind::scope registerGea() {

    using namespace luabind;

    return

            ///////////////////////////////
            /// \section geaOSC.h

            class_<ofxGea>("gea")
                .def(constructor<>())

//                .def("test", &test)
                .def("setup", (void(ofxGea::*)()) &ofxGea::setup)
                .def("update", (void(ofxGea::*)()) &ofxGea::update)
                .def("test", (void(ofxGea::*)()) &ofxGea::test)
                .def("takis", (int(ofxGea::*)()) &ofxGea::takis),

            class_<ofxMidiLua>("midi")
                .def(constructor<>())
                .def("setup", (void(ofxMidiLua::*)()) &ofxMidiLua::setup)
                .def("update", (void(ofxMidiLua::*)()) &ofxMidiLua::update)
                .def("init", (void(ofxMidiLua::*)(int, float)) &ofxMidiLua::init)
                .def("map", (float(ofxMidiLua::*)(int, float, float)) &ofxMidiLua::map),

            class_<ofApp>("app")
                .def(constructor<>())
                .def("test", (void(ofApp::*)()) &ofApp::test)
                .def("amp", (float(ofApp::*)()) &ofApp::amp)

    ;

}
} // namespace

Implementation at lua-script

midi = of.midi()
----------------------------------------------------
function setup()
        of.setWindowTitle("gea with Midi")
        midi:setup()
        of.background(0)

end
----------------------------------------------------
function update()
         midi:update()
end
----------------------------------------------------
function draw()
      of.fill()
      of.setColor(0,30,midi:map(19,0,255),250)
      of.rect(0,0,of.getWidth(), of.getHeight())
end
----------------------------------------------------
function exit()
end
----------------------------------------------------

Initialize values

Posted on .
blog comments powered by Disqus