midi controller

hallo together,

i am realy excited about OF. it has all i was searching for along time, for building my own applications fast and easy.

ididnt find any information on how to implement midi-functionaltity into of, or is it still in there?
maybe sombody cann give me a hint where i can find infos about it.

the other thing i am searching for is a way how i can stretch images to screen and a way to say a foreach loop how fast it should run.

thanks for your help in forward.

regards
robert

I’ve built an OF to midi app using the Arduino controller, if you look around on their site you’ll see some stuff on building an app to send/receive MIDI. There’s also some stuff here: http://itp.nyu.edu/physcomp/Labs/MIDIOutput

If you’re just looking to receive MIDI messages from another application then you can just take a look at the ofxMIDI addon. I think for sending MIDI messages to another app you’d be able to use the ofxOSC addon. Hope that gets you pointed in the right direction.

j

thanks for the hints.
i will look closer to this link.
can anyone give me a hint how c++ handles time.
i am searching how i can adjust the speed of loops for example.
i only need a place to start. a tutorial or something similar.

[quote author=“rak_multi”]
can anyone give me a hint how c++ handles time.
i am searching how i can adjust the speed of loops for example.[/quote]

there’s a couple ways of dealing with time within OF…

From the documentation

float ofGetElapsedTimef();
returns the amount of elapsed time, in seconds since the app started.

int ofGetElapsedTimeMillis();
returns the amount of elapsed time, in milliseconds since the app started (1000 = 1 second)

int ofGetFrameNum();
returns the number of frames since the app started

So you can use those functions as a way of detecting how long your program has been running.

Here is a semi-pseudocode example of how you could perform a certain action every 1000 milliseconds (ie. once every second)

  
  
int lastUpdate = 0;  
  
loop{  
  if((ofGetElapsedTimeMillis() - lastUpdate) >= 1000){  
    doSomething();  
    lastUpdate = ofGetElapsedTimeMillis();  
  }  
}  
  

There is also the good old sleeping approach… which is good if your code is running on its own thread (see ofxThread addon), or your app doesn’t need to be really responsive while executing the code block. Remember that your app will not be doing anything else while it is sleeping (unless of course it is multi-threaded).

void ofSleepMillis(int millis);
Forces the app to pause execution ( or ‘sleep’ ) for the specfied number of milliseconds.

So here is that semi-pseudocode example of how you could perform a certain action every 1000 milliseconds (ie. once every second) using the sleep method.

  
  
loop{  
  doSomething();  
  ofSleepMillis(1000);  
}  
  

hey plong0,

thanks verry much for your detailed reply.

this helps me verry much.
of helps so much.

hallo,

the loop stuff worked great to me. but now i have problems with compiling
the ofMidiIn addons in my apps.

do i have to consider something special wehen i compile under windows?
codeblocks cant find the midilistener. all other header files could be found.

any ideas on how i could fix that? or any hint for an other midiin addon for my
poti midicontroller?

thanks a lot

hi

midiIn needs the poco libraries to work as it’s casting events. poco is not included in v0.05. there’s some packages around the forum for all platforms named 0.057xx but are not official releases and some things are going to change for 006 which is just about to be released.

oh thanks i thought poco is only needed for mac.
do you have a link to the 0.57 version? i cant fin dit?

no, poco is kind of a multipurpose library we are using mainly for casting events. this is a codeblocks windows version:

http://www.openframeworks.cc/files/of-p-…-noApps.zip

hey arturo,

thank you verry much. for the link, the descriptions and the midi app.

i downloaded the new files but still get an error.
any ideas? something missing?
i use the examples from ofxMidiIn

  
||=== emptyExample, debug ===|  
..\..\..\libs\openFrameworks\communication\ofArduino.h|129|warning: no newline at end of file|  
D:\openframeworks\apps\examples\midiIn\src\testApp.h|11|error: expected class-name before '{' token|  
D:\openframeworks\apps\examples\midiIn\src\testApp.h|34|error: `ofxMidiIn' does not name a type|  
||=== Build finished: 2 errors, 1 warnings ===|  
  

do i maybe have to add some more files to the mingw folder?

to add some new addon to oF in 005 you needed to add some code to ofAddons.h, it’s explained in the install.xml file. but this is going to change for 006 so just try chaging this in testApp.h:

  
  
#define OF_ADDON_USING_OFXMIDIIN  
  
#include "ofAddons.h"  

by:

  
  
#include "ofxMidiIn.h"  
#include "ofxMidiEvents.h"  

i still get some errors.
but i think its couse i dont know what the code is dooing.
i have to learn more c++ i learn how to interpret the errormessages.

i think i will have some time at the weekend.
thanks for the help

  
||Info: resolving vtable for Poco::EventArgsby linking to __imp___ZTVN4Poco9EventArgsE |  
||warning: auto-importing has been activated without --enable-auto-import specified on the command line.|  
||Warning: .drectve `-defaultlib:LIBCMT ' unrecognized|  
||Warning: .drectve `-defaultlib:OLDNAMES ' unrecognized|  
||Warning: .drectve `-defaultlib:LIBCMT ' unrecognized|  
||Warning: .drectve `-defaultlib:OLDNAMES ' unrecognized|  
||Warning: .drectve `-defaultlib:LIBCMT ' unrecognized|  
||Warning: .drectve `-defaultlib:OLDNAMES ' unrecognized|  
||Warning: .drectve `-defaultlib:LIBCMT ' unrecognized|  
||Warning: .drectve `-defaultlib:OLDNAMES ' unrecognized|  
||Warning: .drectve `-defaultlib:LIBCMT ' unrecognized|  
||Warning: .drectve `-defaultlib:OLDNAMES ' unrecognized|  
||Warning: .drectve `-defaultlib:LIBCMT ' unrecognized|  
||Warning: .drectve `-defaultlib:OLDNAMES ' unrecognized|  
||Warning: .drectve `-defaultlib:LIBCMT ' unrecognized|  
||Warning: .drectve `-defaultlib:OLDNAMES ' unrecognized|  
||Warning: .drectve `-defaultlib:LIBCMT ' unrecognized|  
||Warning: .drectve `-defaultlib:OLDNAMES ' unrecognized|  
||Warning: .drectve `-defaultlib:uuid.lib ' unrecognized|  
||Warning: .drectve `-defaultlib:uuid.lib ' unrecognized|  
||Warning: .drectve `-defaultlib:LIBCMT ' unrecognized|  
||Warning: .drectve `-defaultlib:OLDNAMES ' unrecognized|  
||Warning: .drectve `/DEFAULTLIB:"LIBC" /DEFAULTLIB:"OLDNAMES" ' unrecognized|  
obj\debug\src\main.o||In function `_ZN4Poco8DelegateI13ofAppListener11ofEventArgsLb1EE6notifyEPKvRS2_':|  
D:\openframeworks\apps\examples\midiIn\..\..\..\libs\poco\includes\Poco\AbstractDelegate.h:(.text$_ZN7testAppC1Ev[testApp::testApp()]+0xa1)||undefined reference to `ofxMidiIn::ofxMidiIn()'|  
obj\debug\src\testApp.o||In function `_ZN7testApp5setupEv':|  
D:\openframeworks\apps\examples\midiIn\src\testApp.cpp|8|undefined reference to `ofxMidiIn::listPorts()'|  
D:\openframeworks\apps\examples\midiIn\src\testApp.cpp|9|undefined reference to `ofxMidiIn::openPort(unsigned int)'|  
D:\openframeworks\apps\examples\midiIn\src\testApp.cpp|10|undefined reference to `ofxMidiIn::addListener(ofxMidiListener*)'|  
obj\debug\src\testApp.o||In function `_ZN11ofSimpleApp10mouseMovedEii':|  
D:\openframeworks\apps\examples\midiIn\..\..\..\libs\openFrameworks\app\ofSimpleApp.h:(.text$_ZN7testAppD1Ev[testApp::~testApp()]+0x81)||undefined reference to `ofxMidiIn::~ofxMidiIn()'|  
D:\openframeworks\apps\examples\midiIn\..\..\..\libs\openFrameworks\app\ofSimpleApp.h:(.text$_ZN7testAppD0Ev[testApp::~testApp()]+0x81)||undefined reference to `ofxMidiIn::~ofxMidiIn()'|  
||=== Build finished: 6 errors, 22 warnings ===|  
  

Hi

so, some addons, like this, need a library to work, you can find the library in the lib directory, there’s versions for the three platforms. You will need to add the windows one to your project.

There’s instructions on how to do this here:

http://wiki.openframeworks.cc/index.php-…-ing-addons

hi together,

i still have problems compiling the stuff.
do i have to edit the RtMidi files? for example delete the not needed parts for linux ,irix and mac? is it enough to include the header file?
i am a bit confused how to handle this.
maybe someone has a simple example codeblocks file, out of his existing fundus which can help me to understand how i have to handle things.

i use the newest beta files and i think i also added all the headerfiles and addons.

edit:

i included windows.h and mmsystem.h as described in the rtmidi file, but this had no effect anyway.

hey - it looks like codeblocks can’t find the rtMidi / addon files -
just to do a quick test can you try putting the files in the app’s src/ folder.

that might get rid of / change the errors you are getting.

You shouldn’t need to edit any of the cpp of h files :slight_smile:

i tried it but this had no effekt.

i get tons of undefined reference errors.
i think i will rebuild it all from a clean project.
maybe the compiler gets confused because some files are linked twice…

thanks for the help…

hey sorry didnt realized what was happening…

in rtMidi.h in the libs folder change line 43:

  
#define __LINUX_ALSASEQ__  

with

  
  
#define __WINDOWS_MM__  

that should make it compile for windows

i rebuild all and now it works. a really great addon.
i will upload a zipfile for codeblocks soon.
will this addon be part of the oncoming release?
thankyou

great that it’s working. no this is going to be just in the addons site, but will adapt it to the new release plus add some code so it automatically detects the platform it’s being compiled for.