Skip to content

Commit 70491c7

Browse files
committed
added OpenFrameworks example project
1 parent 540c040 commit 70491c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+11350
-0
lines changed

OpenFrameworks/ofxMidi/.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
# xcode
3+
*.pbxuser
4+
*.perspectivev3
5+
*.mode*v3
6+
xcuserdata
7+
xcshareddata
8+
build
9+
*.app
10+
*.a
11+
12+
# OSX
13+
*.DS_*
14+
15+
# codeblocks
16+
*.depend
17+
*.layout
18+
example-input/obj
19+
example-output/obj
20+
*.cbTemp
21+
22+
# Win
23+
*.exe
24+
*.dll
25+
*.sdf
26+
*.suo
27+
*.vcxproj.user
28+
29+
# svn
30+
.svn/
31+
obj/
32+
bin/
33+
build/
34+
!data/

OpenFrameworks/ofxMidi/LICENSE.txt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Copyright (c) 2011-2012 Dan Wilcox <[email protected]>
2+
All rights reserved.
3+
4+
The following terms (the "Standard Improved BSD License") apply to all files associated with the software unless explicitly disclaimed in individual files:
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are
8+
met:
9+
10+
1. Redistributions of source code must retain the above copyright
11+
notice, this list of conditions and the following disclaimer.
12+
2. Redistributions in binary form must reproduce the above
13+
copyright notice, this list of conditions and the following
14+
disclaimer in the documentation and/or other materials provided
15+
with the distribution.
16+
3. The name of the author may not be used to endorse or promote
17+
products derived from this software without specific prior
18+
written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY
21+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23+
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
24+
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
26+
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
30+
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31+
THE POSSIBILITY OF SUCH DAMAGE.

OpenFrameworks/ofxMidi/README.md

Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
ofxMidi
2+
=======
3+
<p align="center">
4+
<img src="https://raw.github.com/danomatika/ofxMidi/master/res/midi_din.png"/>
5+
</p>
6+
7+
Midi input and output addon for openFrameworks
8+
9+
Copyright (c) [Dan Wilcox](danomatika.com) 2011-2013<br/>
10+
(original implementation by Chris O'Shea, Arturo Castro, Kyle McDonald)
11+
12+
BSD Simplified License.
13+
14+
For information on usage and redistribution, and for a DISCLAIMER OF ALL
15+
WARRANTIES, see the file, "LICENSE.txt," in this distribution.
16+
17+
See Documentation on [Github](https://github.com/danomatika/ofxMidi) and the [OpenFrameworks Forum post](http://forum.openframeworks.cc/index.php/topic,2435.0.html).
18+
19+
OpenFrameworks is a cross platform open source toolkit for creative coding in C++.
20+
21+
[http://www.openframeworks.cc](http://www.openframeworks.cc)
22+
23+
Description
24+
-----------
25+
26+
ofxMidi provides [Music Instrument Digial Interface](http://en.wikipedia.org/wiki/Musical_Instrument_Digital_Interface) IO capability to an OpenFrameworks app
27+
28+
* ofxMidiIn: a single midi input port, derive from the ofxMidiListener class to receive messages
29+
* ofxMidiMessage: a received midi message
30+
* ofxMidiOut: a single midi output port, includes a stream << interface
31+
32+
This project utilizes [RtMidi](http://www.music.mcgill.ca/~gary/rtmidi/) for Mac, Windows, & Linux and [PGMidi](https://github.com/petegoodliffe/PGMidi) on iOS.
33+
34+
Installation
35+
------------
36+
37+
To use ofxMidi, first you need to download and install OpenFrameworks. ofxMidi is currently developed against the current stable version of Open Frameworks on github.
38+
39+
To get a copy of the repository you can download the source from [http://github.com/danomatika/ofxMidi/zipball/master](http://github.com/danomatika/ofxMidi/zipball/master) or, alternatively, you can use git clone:
40+
<pre>
41+
git clone git://github.com/danomatika/ofxMidi.git
42+
</pre>
43+
44+
The addon should sit in `openFrameworks/addons/ofxMidi/`.
45+
46+
#### Which version to use?
47+
48+
If you are using a stable version (007, ...) of OpenFrameworks then you want to use a git tag of ofxMidi for that version. You can select the tag in the Github "Current Branch" menu or clone and check it out using git.
49+
50+
For example, the following commands will clone ofxMidi and switch to the OF 007 tagged version:
51+
<pre>
52+
git clone git://github.com/danomatika/ofxMidi.git
53+
cd ofxPd
54+
git checkout 007
55+
</pre>
56+
57+
Midi Routing
58+
------------
59+
60+
### Mac OSX
61+
62+
Checkout a useful app for midi port routing called [MIDI Patchbay](http://notahat.com/midi_patchbay).
63+
64+
### Linux
65+
66+
Check out the Alsa utility apps aconnect & aconnectgui as well as the qjackctl gui for midi port routing control.
67+
68+
### Windows
69+
70+
Windows dosen't come with a virtual MIDI routing system like Linux (ALSA) and OSX (CoreMIDI).
71+
72+
If you want to connect your ofxMidi app to other software (synths, DAWs, etc) check out [loopMIDI](http://www.tobias-erichsen.de/loopMIDI.html). Run the app and create a few virtual ports which you can then connect to within your software.
73+
74+
Running the Example Project
75+
---------------------------
76+
77+
The example projects are in the ofxMidi/example-input/ or ofxMidi/example-output/ folders.
78+
79+
### OSX
80+
81+
Open the Xcode project, select the project scheme, and hit "Run".
82+
83+
### Linux
84+
85+
Open the Code::Blocks .workspace and hit F9 to build. Optionally, you can build the example with the Makefile.
86+
87+
To built and run it on the terminal:
88+
<pre>
89+
make
90+
make run
91+
</pre>
92+
93+
### Windows
94+
95+
An example Visual Studio solution as well as a Codeblocks workspace are included.
96+
97+
Creating a New ofxMidi Project
98+
------------------------------
99+
100+
_Note: These instructions are for manually creating a new project. You do not need to follow these steps if you use the ProjecGenerator app, except for Xcode where you currently need to add the CoreMIDI framework._
101+
102+
To develop your own project based on ofxMidi, simply copy the example project and rename it. You probably want to put it in your apps folder, for example, after copying:
103+
<pre>
104+
openFrameworks/addons/ofxPd/exampleInput/ => openFrameworks/apps/myApps/exampleInput/
105+
</pre>
106+
107+
It must be 3 levels down in the openframeworks folder structure.
108+
109+
Then rename the folder:
110+
<pre>
111+
openFrameworks/apps/myApps/myPdProject/
112+
</pre>
113+
114+
#### Xcode
115+
116+
Rename the project in Xcode (do not rename the .xcodeproj file in Finder!):
117+
* Xcode Menu->Project->Rename
118+
119+
#### Codeblocks (Win & Linux)
120+
121+
* rename the *.cbp and *.workspace files
122+
* open the workspace and readd the renamed project file by dragging it onto the project tree (it will complain about the missing project you renamed)
123+
* if you renamed the project *folder* make sure to set the project name to this folder name or C::B will not be able to run the binary:
124+
* right click on project in the tree (not the workspace)
125+
* Properties...->Title
126+
127+
#### Visual Studio
128+
129+
* rename the *.sln, *.vcxproj, & *.vcxproj.filters files
130+
* open the solution and delete the old project from the projects tree
131+
* go to File->Add->Existing Projects/Solutions and select the *.vcxproj file
132+
* right click on the project in the projects tree and rename it
133+
134+
Adding ofxMidi to an Existing Project
135+
-------------------------------------
136+
137+
_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._
138+
139+
### Xcode
140+
141+
* create a new group "ofxMidi"
142+
* drag these directories from ofxMidi into this new group: `ofxMidi/src`
143+
* if building for OSX, remove the src/ios & libs/pgmidi folder references
144+
* if building for iOS, remove the src/desktop & libs/rtmidi folder references
145+
* add the CoreMIDI framework to your project
146+
* click on your project in the sidebar
147+
* select the Summary tab
148+
* click the + under Linked Frameworks & Libraries
149+
* search for and select the CoreMIDI.framework from the list
150+
* add the following directories to your search path in your project's Project.xconfig file (See the Project.xconfig of the example project.):
151+
<pre>
152+
../../../addons/ofxMidi/src
153+
../../../addons/ofxMidi/libs/rtmidi
154+
</pre>
155+
156+
### Linux Makefiles/CodeBlocks
157+
158+
* edit addons.make in your project folder and add the following line to the end of the file:
159+
<pre>ofxMidi</pre>
160+
161+
### Win Codeblocks & Visual Studio
162+
163+
* add the ofxMidi sources to the project tree
164+
<pre>
165+
ofxMidi/src
166+
ofxMidi/libs/rtmidi
167+
</pre>
168+
* Codeblocks: right click on the project in the project tree and select Add Files Recursively...
169+
* Visual Studio: drag the ofxMidi/src & ofxMidi/libs/rtmidi folder onto the project tree
170+
* add the following search paths:
171+
<pre>
172+
..\\..\\..\addons\ofxMidi\src
173+
..\\..\\..\addons\ofxMidi\libs\rtmidi
174+
</pre>
175+
* Codeblocks
176+
* right click on the project in the project tree and select Build Options...
177+
* select the project name in the tree, not release or debug
178+
* Search directories tab->Add
179+
* Visual Studio
180+
* right click on the project in the project tree and select Properties
181+
* set the Configuration to All Configurations
182+
* Configuration Properties->C/C++->General->Additional Directories
183+
184+
KNOWN ISSUES
185+
------------
186+
187+
### Using static ofxMidi objects on Linux causes seg faults
188+
189+
Avoid creating static ofxMidiIn / ofxMidiOut objects on Linux as the compiler seems to set creation order so they are created *before* ALSA is ready. This leads to a confirmed seg fault on Ubuntu and probably all other flavors of Linux using ALSA. The midi apis on Windows and OSX do not share this problem.
190+
191+
Instead create a static ofPtr and initialize it later:
192+
193+
// in .h:
194+
195+
class MyClass {
196+
197+
...
198+
199+
static ofPtr<ofxMidiOut> s_midiOut;
200+
201+
...
202+
203+
}
204+
205+
// in .cpp:
206+
207+
ofPtr<ofxMidiOut> MyClass::s_midiOut;
208+
209+
...
210+
211+
// initialize somewhere else
212+
void MyClass::setup() {
213+
if(s_midiOut == NULL) {
214+
s_midiOut = ofPtr<ofxMidiOut>(new ofxMidiOut("ofxMidi Client"));
215+
}
216+
}
217+
218+
219+
DEVELOPING
220+
----------
221+
222+
You can help develop ofxMidi on GitHub: [https://github.com/danomatika/ofxMidi](https://github.com/danomatika/ofxMidi)
223+
224+
Create an account, clone or fork the repo, then request a push/merge. Please use the *develop* branch of updates and pull requests.
225+
226+
If you find any bugs or suggestions please log them to GitHub as well.
227+
228+
### Adding a Midi Backend
229+
230+
If you want to add a new midi backend (Android, Jack, etc), you'll need two classes derived from ofxBaseMidiIn & ofxBaseMidiOut.
231+
232+
Place your source files in a new folder named after your platform/library and add new include #ifdef flags to ofxMidiIn.h & ofxMidiIn.cpp.
233+
234+
Last, you'll need to add specific #ifdef flags to the static port info ofxMidiIn/Out functions (listPorts, getPortName, etc).
235+
236+
### Updating Midi Libraries
237+
238+
RtMidi & PGMidi can be updated by running the `update_rtmidi.sh` or `update_pgmidi.sh` shell scripts in the scripts folder.
239+
240+
For RtMidi, edit the version setting in the script header and run the script to download and place the RtMidi sources into `libs/rtmidi`.
241+
242+
PGMidi sources are placed in `libs/pgmidi`.
243+
244+
#### RtMidi.cpp include
245+
246+
Next, make sure to add the following include to `RtMidi.cpp` at around line 38 or there will be link errors:
247+
248+
#include "ofxConstants.h"
249+

0 commit comments

Comments
 (0)