diff --git a/libraries/README.md b/libraries/README.md new file mode 100644 index 0000000..3e74fb4 --- /dev/null +++ b/libraries/README.md @@ -0,0 +1,5 @@ +# libraries + +in Processing, you can add libraries inside of the IDE, which has a barebones +dependency manager. I honestly don't know if these are worth versioning, but +I'd rather have files to delete than be missing files. diff --git a/libraries/themidibus/CHANGELOG.txt b/libraries/themidibus/CHANGELOG.txt new file mode 100644 index 0000000..4a99d31 --- /dev/null +++ b/libraries/themidibus/CHANGELOG.txt @@ -0,0 +1,63 @@ +-Version 008 + Changes: + -Remove register/unregister dispose to be compatible with Processing 3.0 + +-Version 007 + + Changes: + -Added constructors to MidiBus which allow parent as Object, for use outside of Processing + -Simplify constructors + -Stop using deprecated methods from processing 1.0, switch to new processing 2.0 methods + -Introduce new class called Note and ControlChange + -Provide an object oriented interface using Note and ControlChange both via processing (PApplet) and with callbacks with listeners + -Allow sending timestamps to be disabled so MMJ can be used + -Attempted to improve startup speed + +-Version 005 + + Changes: + -Added library.properties for Processing 2.0 + -Added permanent URL for latest version http://www.smallbutdigital.com/releases/themidibus/themidibus-latest.zip and library.properties file http://www.smallbutdigital.com/releases/themidibus/themidibus-latest.txt + + Bug Fixes: + -Fixed two small issues in sendMessage(byte[] data) which made the method mostly useless before. + + Notable Bug Fixes: + -Fixed uninitialized listeners vector. + -Fixed available/unavailable devices detection: version 003 would sometimes list unavailable devices as available. + -Fixed exceptional cases which threw NullPointer exceptions. + -Added try-catch statements to catch some unusual exception from MMJ mac MIDI subsystem + -Implemented workaround for MMJ malloc problems when closing devices. + + Changes: + -New devices indexing system: + -Version 3 used mixed indicies for inputs and outputs, eg: + Available Midi Devices: + ----------------------- + [0] "IAC Driver - Bus 1" [Input] + [1] "IAC Driver - Bus 1" [Output] + [2] "Real Time Sequencer" [Input/Output] + [3] "Java Sound Synthesizer" [Output] + + -Version 4 now uses separate indicies for inputs and outputs, eg: + Available MIDI Devices: + ----------Input---------- + [0] "IAC Driver - Bus 1" + [1] "Real Time Sequencer" + ----------Output---------- + [0] "IAC Driver - Bus 1" + [1] "Real Time Sequencer" + [2] "Java Sound Synthesizer" + -The static method list() has been changed as per the new indexing system (and will also show unavailable devices) + -The static method returnList() has been replaced by the static methods availableInputs() and availableOutputs() + + New Features: + -Added overrides to Object methods for clone(), equals(Object obj), hashCode() and toString() + -Added attachedInputs() and attachedOutputs() methods. Theses methods return an array of the inputs/output currently attached to a given instance of the MidiBus object. + -Added removeInput(int device_num), removeInput(String device_name), removeOutput(int device_num) and removeOutput(String device_name). Theses methods allow the selective removal of attached inputs and outputs. + -Added static method unavailableDevices() which lists any devices that are detected but appear to be unavailable. (As per bug fix) + -Added new overloads to sendMessage(): + -sendMessage(byte[] data). Attempts to send an arbitrary array of bytes as a MIDI message. This method supports System Exclusive messages and Meta Messages, including messages with more than 2 data bytes. + -sendMessage(MidiMessage message). Attempts to send a MidiMessage object. + -sendMessage(int status). Attempts to send a message with only a status byte. + -sendMessage(int status, int data). Attempts to send a message with only a status byte and one data byte. diff --git a/libraries/themidibus/GNUGeneralPublicLicense.txt b/libraries/themidibus/GNUGeneralPublicLicense.txt new file mode 100644 index 0000000..42ecfd4 --- /dev/null +++ b/libraries/themidibus/GNUGeneralPublicLicense.txt @@ -0,0 +1,486 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includesded), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +tse explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise opyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily use for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, less of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights hae been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore,overed work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, throughipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parre a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to anyringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement d be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to lial Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is giy the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +ay consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/libraries/themidibus/INSTALL.txt b/libraries/themidibus/INSTALL.txt new file mode 100644 index 0000000..f38e81f --- /dev/null +++ b/libraries/themidibus/INSTALL.txt @@ -0,0 +1,7 @@ +The recommended way to install the MidiBus is the [Processing Library Manager](http://wiki.processing.org/w/How_to_Install_a_Contributed_Library). This way Processing will automatically notify you when a new version is available. + +If you wish to install the MidiBus manually you can simply drag this folder into your libraries folder. + +For Processing 1.0+, your libraries folder is located in your Processing sketch folder. + +Otherwise, if you're still using Processing BETA, your libraries folder can be found in same folder as Processing itself. \ No newline at end of file diff --git a/libraries/themidibus/README.md b/libraries/themidibus/README.md new file mode 100644 index 0000000..220dad5 --- /dev/null +++ b/libraries/themidibus/README.md @@ -0,0 +1,38 @@ +# The MidiBus + +The MidiBus is a MIDI library for Processing. It provides a quick and simple way to access and interact with installed MIDI system resources. The MidiBus is aimed primarily at real time MIDI applications. The focus is on strong MIDI I/O capabilities and keeping frills to a minimum (e.g. no built in sequencer, file read/write, MIDI recording/playback). + +## Download and Install (Stable) + +The recommended way to install the MidiBus is the [Processing Library Manager](http://wiki.processing.org/w/How_to_Install_a_Contributed_Library). This way Processing will automatically notify you when a new version is available. + +If you wish to install the MidiBus manually you can get the latest stable build including binaries and docs [via direct downloadd](http://smallbutdigital.com/releases/themidibus/themidibus-latest.zip). + +## Download and Install (Latest) + +The latest version can easily be cloned directly from github via + + git clone https://github.com/sparks/themidibus.git /your/processing/libraries/ + +### Compiling and Generating JavaDocs + +If you clone the latest version you will need to compile the library and generate the JavaDocs. This requires ``javac`` and ``ant``. + +To compile run ``ant`` + +To generate the JavaDocs run ``ant doc`` + +## About +Before you get started, it is important to understand that the MidiBus offers little functionality that isn't available from Java's native [javax.sound.midi package](http://docs.oracle.com/javase/6/docs/api/javax/sound/midi/package-summary.html). Anyone interested in working with MIDI in Java should take the time to read the documentation for the [javax.sound.midi package](http://docs.oracle.com/javase/6/docs/api/javax/sound/midi/package-summary.html). It offers a more full featured and flexible alternative to this package, although it does do so at the cost of added complexity. In addition, it may be worthwhile to skim [the "official" Java Tutorial for the javax.sound.* packages](http://docs.oracle.com/javase/tutorial/sound/index.html). + +## Getting Started + +The MidiBus is very straight forwards to use. A good place to start is the included Basic.pde example. From there you can look at the JavaDocs either [online](http://smallbutdigital.com/themidibus/themidibus/package-summary.html) or bundled with your library in the "reference" subdirectory. The JavaDocs are a comprehensive reference of all the MidiBus' available functionality. There are also a few advanced examples which can (hopefully) help answer the most common questions: how to work with multiple input/output devices, how to send uncommon MIDI messages and how to receive uncommon MIDI messages. + +## Using Alternate MIDI Subsytem + +The Apple MIDI subsystem has a number of problems. Most notably it doesn't seem to support MIDI messages with status >= 0xF0 such as SysEx messages. You can use [MMJ](http://www.humatic.de/htools/mmj.htm) as an alternate subsystem. To do so, download mmj and add both `mmj.jar` and `libmmj.jnilib` to the midibus `library` subdirectory. You must also disable timestamps in your MidiBus instance otherwise MMJ won't work properly. You can do so by calling `mybus.sendTimestamp(false)` + +## Liscence + +GPL3 \ No newline at end of file diff --git a/libraries/themidibus/bin/themidibus/ControlChange.class b/libraries/themidibus/bin/themidibus/ControlChange.class new file mode 100644 index 0000000..4669b32 Binary files /dev/null and b/libraries/themidibus/bin/themidibus/ControlChange.class differ diff --git a/libraries/themidibus/bin/themidibus/MidiBus$InputDeviceContainer.class b/libraries/themidibus/bin/themidibus/MidiBus$InputDeviceContainer.class new file mode 100644 index 0000000..8a108ae Binary files /dev/null and b/libraries/themidibus/bin/themidibus/MidiBus$InputDeviceContainer.class differ diff --git a/libraries/themidibus/bin/themidibus/MidiBus$MReceiver.class b/libraries/themidibus/bin/themidibus/MidiBus$MReceiver.class new file mode 100644 index 0000000..6367820 Binary files /dev/null and b/libraries/themidibus/bin/themidibus/MidiBus$MReceiver.class differ diff --git a/libraries/themidibus/bin/themidibus/MidiBus$OutputDeviceContainer.class b/libraries/themidibus/bin/themidibus/MidiBus$OutputDeviceContainer.class new file mode 100644 index 0000000..7d51549 Binary files /dev/null and b/libraries/themidibus/bin/themidibus/MidiBus$OutputDeviceContainer.class differ diff --git a/libraries/themidibus/bin/themidibus/MidiBus.class b/libraries/themidibus/bin/themidibus/MidiBus.class new file mode 100644 index 0000000..25798e2 Binary files /dev/null and b/libraries/themidibus/bin/themidibus/MidiBus.class differ diff --git a/libraries/themidibus/bin/themidibus/MidiListener.class b/libraries/themidibus/bin/themidibus/MidiListener.class new file mode 100644 index 0000000..3fb31f2 Binary files /dev/null and b/libraries/themidibus/bin/themidibus/MidiListener.class differ diff --git a/libraries/themidibus/bin/themidibus/Note.class b/libraries/themidibus/bin/themidibus/Note.class new file mode 100644 index 0000000..a060211 Binary files /dev/null and b/libraries/themidibus/bin/themidibus/Note.class differ diff --git a/libraries/themidibus/bin/themidibus/ObjectMidiListener.class b/libraries/themidibus/bin/themidibus/ObjectMidiListener.class new file mode 100644 index 0000000..29265eb Binary files /dev/null and b/libraries/themidibus/bin/themidibus/ObjectMidiListener.class differ diff --git a/libraries/themidibus/bin/themidibus/RawMidiListener.class b/libraries/themidibus/bin/themidibus/RawMidiListener.class new file mode 100644 index 0000000..ecdf648 Binary files /dev/null and b/libraries/themidibus/bin/themidibus/RawMidiListener.class differ diff --git a/libraries/themidibus/bin/themidibus/SimpleMidiListener.class b/libraries/themidibus/bin/themidibus/SimpleMidiListener.class new file mode 100644 index 0000000..598f40a Binary files /dev/null and b/libraries/themidibus/bin/themidibus/SimpleMidiListener.class differ diff --git a/libraries/themidibus/bin/themidibus/StandardMidiListener.class b/libraries/themidibus/bin/themidibus/StandardMidiListener.class new file mode 100644 index 0000000..12eb50c Binary files /dev/null and b/libraries/themidibus/bin/themidibus/StandardMidiListener.class differ diff --git a/libraries/themidibus/bin/themidibus/package-info.class b/libraries/themidibus/bin/themidibus/package-info.class new file mode 100644 index 0000000..f9d5b5c Binary files /dev/null and b/libraries/themidibus/bin/themidibus/package-info.class differ diff --git a/libraries/themidibus/build.xml b/libraries/themidibus/build.xml new file mode 100644 index 0000000..63b9096 --- /dev/null +++ b/libraries/themidibus/build.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libraries/themidibus/examples/AdvancedMIDIMessageIO/AdvancedMIDIMessageIO.pde b/libraries/themidibus/examples/AdvancedMIDIMessageIO/AdvancedMIDIMessageIO.pde new file mode 100644 index 0000000..144326a --- /dev/null +++ b/libraries/themidibus/examples/AdvancedMIDIMessageIO/AdvancedMIDIMessageIO.pde @@ -0,0 +1,102 @@ +import themidibus.*; //Import the library +import javax.sound.midi.MidiMessage; //Import the MidiMessage classes http://java.sun.com/j2se/1.5.0/docs/api/javax/sound/midi/MidiMessage.html +import javax.sound.midi.SysexMessage; +import javax.sound.midi.ShortMessage; + +MidiBus myBus; // The MidiBus + +void setup() { + size(400, 400); + background(0); + + MidiBus.list(); // List all available Midi devices on STDOUT. This will show each device's index and name. + myBus = new MidiBus(this, 0, 0); // Create a new MidiBus object + + // On mac you will need to use MMJ since Apple's MIDI subsystem doesn't properly support SysEx. + // However MMJ doesn't support sending timestamps so you have to turn off timestamps. + // myBus.sendTimestamps(false); +} + +void draw() { + int channel = 0; + int pitch = 64; + int velocity = 127; + + myBus.sendNoteOn(channel, pitch, velocity); // Send a Midi noteOn + delay(200); + myBus.sendNoteOff(channel, pitch, velocity); // Send a Midi nodeOff + delay(100); + + //Or for something different we could send a custom Midi message ... + + int status_byte = 0xA0; // For instance let us send aftertouch + int channel_byte = 0; // On channel 0 again + int first_byte = 64; // The same note; + int second_byte = 80; // But with less velocity + + myBus.sendMessage(status_byte, channel_byte, first_byte, second_byte); + + //Or we could even send a variable length sysex message + //IMPORTANT: On mac you will have to use the MMJ MIDI subsystem to be able to send SysexMessages. Consult README.md for more information + + myBus.sendMessage( + new byte[] { + (byte)0xF0, (byte)0x1, (byte)0x2, (byte)0x3, (byte)0x4, (byte)0xF7 + } + ); + //We could also do the same thing this way ... + + try { //All the methods of SysexMessage, ShortMessage, etc, require try catch blocks + SysexMessage message = new SysexMessage(); + message.setMessage( + 0xF0, + new byte[] { + (byte)0x5, (byte)0x6, (byte)0x7, (byte)0x8, (byte)0xF7 + }, + 5 + ); + myBus.sendMessage(message); + } catch(Exception e) { + + } + + delay(2000); +} + +// Notice all bytes below are converted to integeres using the following system: +// int i = (int)(byte & 0xFF) +// This properly convertes an unsigned byte (MIDI uses unsigned bytes) to a signed int +// Because java only supports signed bytes, you will get incorrect values if you don't do so + +void rawMidi(byte[] data) { // You can also use rawMidi(byte[] data, String bus_name) + // Receive some raw data + // data[0] will be the status byte + // data[1] and data[2] will contain the parameter of the message (e.g. pitch and volume for noteOn noteOff) + println(); + println("Raw Midi Data:"); + println("--------"); + println("Status Byte/MIDI Command:"+(int)(data[0] & 0xFF)); + // N.B. In some cases (noteOn, noteOff, controllerChange, etc) the first half of the status byte is the command and the second half if the channel + // In these cases (data[0] & 0xF0) gives you the command and (data[0] & 0x0F) gives you the channel + for (int i = 1;i < data.length;i++) { + println("Param "+(i+1)+": "+(int)(data[i] & 0xFF)); + } +} + +void midiMessage(MidiMessage message) { // You can also use midiMessage(MidiMessage message, long timestamp, String bus_name) + // Receive a MidiMessage + // MidiMessage is an abstract class, the actual passed object will be either javax.sound.midi.MetaMessage, javax.sound.midi.ShortMessage, javax.sound.midi.SysexMessage. + // Check it out here http://java.sun.com/j2se/1.5.0/docs/api/javax/sound/midi/package-summary.html + println(); + println("MidiMessage Data:"); + println("--------"); + println("Status Byte/MIDI Command:"+message.getStatus()); + for (int i = 1;i < message.getMessage().length;i++) { + println("Param "+(i+1)+": "+(int)(message.getMessage()[i] & 0xFF)); + } +} + +void delay(int time) { + int current = millis(); + while (millis () < current+time) Thread.yield(); +} diff --git a/libraries/themidibus/examples/Basic/Basic.pde b/libraries/themidibus/examples/Basic/Basic.pde new file mode 100644 index 0000000..30a5bed --- /dev/null +++ b/libraries/themidibus/examples/Basic/Basic.pde @@ -0,0 +1,76 @@ +import themidibus.*; //Import the library + +MidiBus myBus; // The MidiBus + +void setup() { + size(400, 400); + background(0); + + MidiBus.list(); // List all available Midi devices on STDOUT. This will show each device's index and name. + + // Either you can + // Parent In Out + // | | | + //myBus = new MidiBus(this, 0, 1); // Create a new MidiBus using the device index to select the Midi input and output devices respectively. + + // or you can ... + // Parent In Out + // | | | + //myBus = new MidiBus(this, "IncomingDeviceName", "OutgoingDeviceName"); // Create a new MidiBus using the device names to select the Midi input and output devices respectively. + + // or for testing you could ... + // Parent In Out + // | | | + myBus = new MidiBus(this, -1, "Java Sound Synthesizer"); // Create a new MidiBus with no input device and the default Java Sound Synthesizer as the output device. +} + +void draw() { + int channel = 0; + int pitch = 64; + int velocity = 127; + + myBus.sendNoteOn(channel, pitch, velocity); // Send a Midi noteOn + delay(200); + myBus.sendNoteOff(channel, pitch, velocity); // Send a Midi nodeOff + + int number = 0; + int value = 90; + + myBus.sendControllerChange(channel, number, value); // Send a controllerChange + delay(2000); +} + +void noteOn(int channel, int pitch, int velocity) { + // Receive a noteOn + println(); + println("Note On:"); + println("--------"); + println("Channel:"+channel); + println("Pitch:"+pitch); + println("Velocity:"+velocity); +} + +void noteOff(int channel, int pitch, int velocity) { + // Receive a noteOff + println(); + println("Note Off:"); + println("--------"); + println("Channel:"+channel); + println("Pitch:"+pitch); + println("Velocity:"+velocity); +} + +void controllerChange(int channel, int number, int value) { + // Receive a controllerChange + println(); + println("Controller Change:"); + println("--------"); + println("Channel:"+channel); + println("Number:"+number); + println("Value:"+value); +} + +void delay(int time) { + int current = millis(); + while (millis () < current+time) Thread.yield(); +} diff --git a/libraries/themidibus/examples/BasicWithClasses/BasicWithClasses.pde b/libraries/themidibus/examples/BasicWithClasses/BasicWithClasses.pde new file mode 100644 index 0000000..99429e0 --- /dev/null +++ b/libraries/themidibus/examples/BasicWithClasses/BasicWithClasses.pde @@ -0,0 +1,78 @@ +import themidibus.*; //Import the library + +MidiBus myBus; // The MidiBus + +void setup() { + size(400, 400); + background(0); + + MidiBus.list(); // List all available Midi devices on STDOUT. This will show each device's index and name. + + // Either you can + // Parent In Out + // | | | + //myBus = new MidiBus(this, 0, 1); // Create a new MidiBus using the device index to select the Midi input and output devices respectively. + + // or you can ... + // Parent In Out + // | | | + //myBus = new MidiBus(this, "IncomingDeviceName", "OutgoingDeviceName"); // Create a new MidiBus using the device names to select the Midi input and output devices respectively. + + // or for testing you could ... + // Parent In Out + // | | | + myBus = new MidiBus(this, -1, "Java Sound Synthesizer"); // Create a new MidiBus with no input device and the default Java Sound Synthesizer as the output device. +} + +void draw() { + int channel = 0; + int pitch = 64; + int velocity = 127; + Note note = new Note(channel, pitch, velocity); + + myBus.sendNoteOn(note); // Send a Midi noteOn + delay(200); + myBus.sendNoteOff(note); // Send a Midi nodeOff + + int number = 0; + int value = 90; + ControlChange change = new ControlChange(channel, number, velocity); + + myBus.sendControllerChange(change); // Send a controllerChange + delay(2000); +} + +void noteOn(Note note) { + // Receive a noteOn + println(); + println("Note On:"); + println("--------"); + println("Channel:"+note.channel()); + println("Pitch:"+note.pitch()); + println("Velocity:"+note.velocity()); +} + +void noteOff(Note note) { + // Receive a noteOff + println(); + println("Note Off:"); + println("--------"); + println("Channel:"+note.channel()); + println("Pitch:"+note.pitch()); + println("Velocity:"+note.velocity()); +} + +void controllerChange(ControlChange change) { + // Receive a controllerChange + println(); + println("Controller Change:"); + println("--------"); + println("Channel:"+change.channel()); + println("Number:"+change.number()); + println("Value:"+change.value()); +} + +void delay(int time) { + int current = millis(); + while (millis () < current+time) Thread.yield(); +} diff --git a/libraries/themidibus/examples/MultipleBuses/MultipleBuses.pde b/libraries/themidibus/examples/MultipleBuses/MultipleBuses.pde new file mode 100644 index 0000000..93f2d9f --- /dev/null +++ b/libraries/themidibus/examples/MultipleBuses/MultipleBuses.pde @@ -0,0 +1,115 @@ +import themidibus.*; //Import the library + +MidiBus busA; //The first MidiBus +MidiBus busB; //The second MidiBus + +void setup() { + size(400, 400); + background(0); + + MidiBus.list(); //List all available Midi devices. This will show each device's index and name. + + //This is a different way of listing the available Midi devices. + println(); + println("Available MIDI Devices:"); + + System.out.println("----------Input (from availableInputs())----------"); + String[] available_inputs = MidiBus.availableInputs(); //Returns an array of available input devices + for (int i = 0;i < available_inputs.length;i++) System.out.println("["+i+"] \""+available_inputs[i]+"\""); + + System.out.println("----------Output (from availableOutputs())----------"); + String[] available_outputs = MidiBus.availableOutputs(); //Returns an array of available output devices + for (int i = 0;i < available_outputs.length;i++) System.out.println("["+i+"] \""+available_outputs[i]+"\""); + + System.out.println("----------Unavailable (from unavailableDevices())----------"); + String[] unavailable = MidiBus.unavailableDevices(); //Returns an array of unavailable devices + for (int i = 0;i < unavailable.length;i++) System.out.println("["+i+"] \""+unavailable[i]+"\""); + + busA = new MidiBus(this, "IncomingA", "OutgoingA", "busA"); //Create a first new MidiBus attached to the IncommingA Midi input device and the OutgoingA Midi output device. We will name it busA. + busB = new MidiBus(this, "IncomingB", "OutgoingB", "busB"); //Create a second new MidiBus attached to the IncommingB Midi input device and the OutgoingB Midi output device. We will name it busB. + + busA.addOutput("OutgoingC"); //Add a new output device to busA called OutgoingC + busB.addInput("IncomingC"); //Add a new input device to busB called IncommingC + + //It is also possible to check what devices are currently attached as inputs or outputs on a bus + + println(); + println("Inputs on busA"); + println(busA.attachedInputs()); //Print the devices attached as inputs to busA + println(); + println("Outputs on busB"); + println(busB.attachedOutputs()); //Prints the devices attached as outpus to busB +} + +void draw() { + int channel = 0; + int pitch = 64; + int velocity = 127; + + busA.sendNoteOn(channel, pitch, velocity); //Send a noteOn to OutgoingA and OutgoingC through busA + delay(200); + busB.sendNoteOn(channel, pitch, velocity); //Send a noteOn to OutgoingB through busB + delay(100); + busA.sendNoteOff(channel, pitch, velocity); //Send a noteOff to OutgoingA and OutgoingC through busA + busB.sendNoteOff(channel, pitch, velocity); //Send a noteOff to OutgoingB through busB + + int number = 0; + int value = 90; + + busA.sendControllerChange(channel, number, value); //Send a controllerChange to OutgoingA and OutgoingC through busA + busB.sendControllerChange(channel, number+10, value+10); //Send a controllerChange to OutgoingB through busB + delay(2000); +} + +void noteOn(int channel, int pitch, int velocity, long timestamp, String bus_name) { + println(); + println("Note On:"); + println("--------"); + println("Channel:"+channel); + println("Pitch:"+pitch); + println("Velocity:"+velocity); + println("Timestamp:"+timestamp); + println("Recieved on Bus:"+bus_name); + if (bus_name == "busA") { + println("This came from IncomingA"); + } else if (bus_name == "busB") { + println("This came from IncomingB or IncomingC"); + } +} + +void noteOff(int channel, int pitch, int velocity, long timestamp, String bus_name) { + println(); + println("Note Off:"); + println("--------"); + println("Channel:"+channel); + println("Pitch:"+pitch); + println("Velocity:"+velocity); + println("Timestamp:"+timestamp); + println("Recieved on Bus:"+bus_name); + if (bus_name == "busA") { + println("This came from IncomingA"); + } else if (bus_name == "busB") { + println("This came from IncomingB or IncomingC"); + } +} + +void controllerChange(int channel, int number, int value, long timestamp, String bus_name) { + println(); + println("Controller Change:"); + println("--------"); + println("Channel:"+channel); + println("Number:"+number); + println("Value:"+value); + println("Timestamp:"+timestamp); + println("Recieved on Bus:"+bus_name); + if (bus_name == "busA") { + println("This came from IncomingA"); + } else if (bus_name == "busB") { + println("This came from IncomingB or IncomingC"); + } +} + +void delay(int time) { + int current = millis(); + while (millis () < current+time) Thread.yield(); +} diff --git a/libraries/themidibus/library.properties b/libraries/themidibus/library.properties new file mode 100644 index 0000000..6ad3267 --- /dev/null +++ b/libraries/themidibus/library.properties @@ -0,0 +1,11 @@ +name=The MidiBus +category=Data +authors=[Severin Smith](http://www.smallbutdigital.com/) +url=http://www.smallbutdigital.com/themidibus.php +sentence=The MidiBus is a minimal MIDI library for Processing, no frills, no limitations. +paragraph=The MidiBus is a MIDI library for Processing. It provides a quick and simple way to access and interact with installed MIDI system resources. The MidiBus is aimed primarily at real time MIDI applications. The focus is on strong MIDI I/O capabilities and keeping frills to a minimum (e.g. no built in sequencer, file read/write, MIDI recording/playback). +version=8 +prettyVersion=8 +lastUpdated=0 +minRevision=0 +maxRevision=0 diff --git a/libraries/themidibus/library/themidibus.jar b/libraries/themidibus/library/themidibus.jar new file mode 100644 index 0000000..c9bd69a Binary files /dev/null and b/libraries/themidibus/library/themidibus.jar differ diff --git a/libraries/themidibus/reference/allclasses-frame.html b/libraries/themidibus/reference/allclasses-frame.html new file mode 100644 index 0000000..f75f5ad --- /dev/null +++ b/libraries/themidibus/reference/allclasses-frame.html @@ -0,0 +1,26 @@ + + + + + +All Classes + + + + +

All Classes

+ + + diff --git a/libraries/themidibus/reference/allclasses-noframe.html b/libraries/themidibus/reference/allclasses-noframe.html new file mode 100644 index 0000000..0ff8f53 --- /dev/null +++ b/libraries/themidibus/reference/allclasses-noframe.html @@ -0,0 +1,26 @@ + + + + + +All Classes + + + + +

All Classes

+ + + diff --git a/libraries/themidibus/reference/constant-values.html b/libraries/themidibus/reference/constant-values.html new file mode 100644 index 0000000..7e2307b --- /dev/null +++ b/libraries/themidibus/reference/constant-values.html @@ -0,0 +1,111 @@ + + + + + +Constant Field Values + + + + + + + + + + +
+

Constant Field Values

+

Contents

+
+ + + + + + diff --git a/libraries/themidibus/reference/deprecated-list.html b/libraries/themidibus/reference/deprecated-list.html new file mode 100644 index 0000000..b4bd0d6 --- /dev/null +++ b/libraries/themidibus/reference/deprecated-list.html @@ -0,0 +1,111 @@ + + + + + +Deprecated List + + + + + + + +
+ + + + + +
+ + +
+

Deprecated API

+

Contents

+
+ +
+ + + + + +
+ + + + diff --git a/libraries/themidibus/reference/help-doc.html b/libraries/themidibus/reference/help-doc.html new file mode 100644 index 0000000..2239e9a --- /dev/null +++ b/libraries/themidibus/reference/help-doc.html @@ -0,0 +1,208 @@ + + + + + +API Help + + + + + + + +
+ + + + + +
+ + +
+

How This API Document Is Organized

+
This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
+
+
+
    +
  • +

    Package

    +

    Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:

    +
      +
    • Interfaces (italic)
    • +
    • Classes
    • +
    • Enums
    • +
    • Exceptions
    • +
    • Errors
    • +
    • Annotation Types
    • +
    +
  • +
  • +

    Class/Interface

    +

    Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

    +
      +
    • Class inheritance diagram
    • +
    • Direct Subclasses
    • +
    • All Known Subinterfaces
    • +
    • All Known Implementing Classes
    • +
    • Class/interface declaration
    • +
    • Class/interface description
    • +
    +
      +
    • Nested Class Summary
    • +
    • Field Summary
    • +
    • Constructor Summary
    • +
    • Method Summary
    • +
    +
      +
    • Field Detail
    • +
    • Constructor Detail
    • +
    • Method Detail
    • +
    +

    Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.

    +
  • +
  • +

    Annotation Type

    +

    Each annotation type has its own separate page with the following sections:

    +
      +
    • Annotation Type declaration
    • +
    • Annotation Type description
    • +
    • Required Element Summary
    • +
    • Optional Element Summary
    • +
    • Element Detail
    • +
    +
  • +
  • +

    Enum

    +

    Each enum has its own separate page with the following sections:

    +
      +
    • Enum declaration
    • +
    • Enum description
    • +
    • Enum Constant Summary
    • +
    • Enum Constant Detail
    • +
    +
  • +
  • +

    Tree (Class Hierarchy)

    +

    There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.

    +
      +
    • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
    • +
    • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
    • +
    +
  • +
  • +

    Deprecated API

    +

    The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.

    +
  • +
  • +

    Index

    +

    The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.

    +
  • +
  • +

    Prev/Next

    +

    These links take you to the next or previous class, interface, package, or related page.

    +
  • +
  • +

    Frames/No Frames

    +

    These links show and hide the HTML frames. All pages are available with or without frames.

    +
  • +
  • +

    All Classes

    +

    The All Classes link shows all classes and interfaces except non-static nested types.

    +
  • +
  • +

    Serialized Form

    +

    Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.

    +
  • +
  • +

    Constant Field Values

    +

    The Constant Field Values page lists the static final fields and their values.

    +
  • +
+This help file applies to API documentation generated using the standard doclet.
+ +
+ + + + + +
+ + + + diff --git a/libraries/themidibus/reference/index-all.html b/libraries/themidibus/reference/index-all.html new file mode 100644 index 0000000..ea2a526 --- /dev/null +++ b/libraries/themidibus/reference/index-all.html @@ -0,0 +1,700 @@ + + + + + +Index + + + + + + + +
+ + + + + +
+ + +
A B C D E F G H L M N O P R S T U V  + + +

A

+
+
addInput(int) - Method in class themidibus.MidiBus
+
+
Adds a new MIDI input device specified by the index device_num.
+
+
addInput(String) - Method in class themidibus.MidiBus
+
+
Adds a new MIDI input device specified by the name device_name.
+
+
addMidiListener(MidiListener) - Method in class themidibus.MidiBus
+
+
Adds a listener who will be notified each time a new MIDI message is received from a MIDI input device.
+
+
addOutput(int) - Method in class themidibus.MidiBus
+
+
Adds a new MIDI output device specified by the index device_num.
+
+
addOutput(String) - Method in class themidibus.MidiBus
+
+
Adds a new MIDI output device specified by the name device_name.
+
+
attachedInputs() - Method in class themidibus.MidiBus
+
+
Returns the names of all the attached input devices.
+
+
attachedOutputs() - Method in class themidibus.MidiBus
+
+
Returns the names of all the attached output devices.
+
+
availableInputs() - Static method in class themidibus.MidiBus
+
+
Returns the names of all the available input devices.
+
+
availableOutputs() - Static method in class themidibus.MidiBus
+
+
Returns the names of all the available output devices.
+
+
+ + + +

B

+
+
bus_name - Variable in class themidibus.ControlChange
+
 
+
bus_name - Variable in class themidibus.Note
+
 
+
+ + + +

C

+
+
channel - Variable in class themidibus.ControlChange
+
 
+
channel() - Method in class themidibus.ControlChange
+
+
Return the channel of the ControlChange
+
+
channel - Variable in class themidibus.Note
+
 
+
channel() - Method in class themidibus.Note
+
+
Return the channel of the Note
+
+
clearAll() - Method in class themidibus.MidiBus
+
+
Closes, clears and disposes of all input and output related Transmitters and Receivers.
+
+
clearInputs() - Method in class themidibus.MidiBus
+
+
Closes, clears and disposes of all input related Transmitters and Receivers.
+
+
clearOutputs() - Method in class themidibus.MidiBus
+
+
Closes, clears and disposes of all output related Receivers.
+
+
clone() - Method in class themidibus.MidiBus
+
+
Creates and returns a copy of this object.
+
+
close() - Method in class themidibus.MidiBus
+
+
Closes this MidiBus and all connections it has with other MIDI devices.
+
+
ControlChange - Class in themidibus
+
+
The ControlChange class represents a change in value from a controller.
+
+
ControlChange(int, int, int) - Constructor for class themidibus.ControlChange
+
+
Constructs a ControlChange object
+
+
ControlChange(int, int, int, long, String) - Constructor for class themidibus.ControlChange
+
+
Constructs a ControlChange object
+
+
controllerChange(ControlChange) - Method in interface themidibus.ObjectMidiListener
+
+
Objects notifying this ObjectMidiListener of a new ControllerChange events call this method.
+
+
controllerChange(int, int, int) - Method in class themidibus.PApplet
+
+
Is passed the channel, controller number and contoller value associated with every new ContollerChange MIDI message recieved by a MidiBus attached to this applet.
+
+
controllerChange(int, int, int, long, String) - Method in class themidibus.PApplet
+
+
Is passed the channel, pitch and velocity associated with every new NoteOff MIDI message recieved by a MidiBus attached to this applet and the name of the MidiBus which recieved the message.
+
+
controllerChange(ControlChange) - Method in class themidibus.PApplet
+
+
Is passed a ControlChange object representing controlChange event
+
+
controllerChange(int, int, int) - Method in interface themidibus.SimpleMidiListener
+
+
Objects notifying this SimpleMidiListener of a new ControllerChange MIDI message call this method.
+
+
+ + + +

D

+
+
dispose() - Method in class themidibus.MidiBus
+
+
Closes this MidiBus and all connections it has with other MIDI devices.
+
+
+ + + +

E

+
+
equals(Object) - Method in class themidibus.ControlChange
+
+
Check if all fields are equal.
+
+
equals(Object) - Method in class themidibus.MidiBus
+
+
Indicates whether some other object is "equal to" this one.
+
+
equals(Object) - Method in class themidibus.Note
+
+
Check if all fields are equal.
+
+
+ + + +

F

+
+
finalize() - Method in class themidibus.MidiBus
+
+
Override the finalize() method from java.lang.Object.
+
+
findMidiDevices() - Static method in class themidibus.MidiBus
+
+
Rescan for Midi Devices.
+
+
+ + + +

G

+
+
generateBusName() - Method in class themidibus.MidiBus
+
+
Generate a name for this MidiBus instance.
+
+
getBusName() - Method in class themidibus.MidiBus
+
+
Returns the name of this MidiBus.
+
+
+ + + +

H

+
+
hashCode() - Method in class themidibus.MidiBus
+
+
Returns a hash code value for the object.
+
+
+ + + +

L

+
+
list() - Static method in class themidibus.MidiBus
+
+
List all installed MIDI devices.
+
+
+ + + +

M

+
+
MidiBus - Class in themidibus
+
+
The MidiBus class provides a simple way to send and receive MIDI within Processing sketches.
+
+
MidiBus() - Constructor for class themidibus.MidiBus
+
+
Constructs a new Midibus.
+
+
MidiBus(Object) - Constructor for class themidibus.MidiBus
+
+
Constructs a new MidiBus and registers the specified parent (PApplet or other) for callbacks.
+
+
MidiBus(Object, String) - Constructor for class themidibus.MidiBus
+
+
Constructs a new MidiBus with the specified bus_name and registers the specified parent (PApplet or other) for callbacks.
+
+
MidiBus(Object, int, int) - Constructor for class themidibus.MidiBus
+
+
Constructs a new MidiBus and registers the specified parent (PApplet or other) for callbacks.
+
+
MidiBus(Object, int, int, String) - Constructor for class themidibus.MidiBus
+
+
Constructs a new MidiBus with the specified bus_name and registers the specified parent (PApplet or other) for callbacks.
+
+
MidiBus(Object, String, String) - Constructor for class themidibus.MidiBus
+
+
Constructs a new MidiBus and registers the specified parent (PApplet or other) for callbacks.
+
+
MidiBus(Object, String, String, String) - Constructor for class themidibus.MidiBus
+
+
Constructs a new MidiBus with the specified bus_name and registers the specified parent (PApplet or other) for callbacks.
+
+
MidiBus(Object, int, String) - Constructor for class themidibus.MidiBus
+
+
More flavors of constructor, similar to the others, but with mixed arguments
+
+
MidiBus(Object, int, String, String) - Constructor for class themidibus.MidiBus
+
+
More flavors of constructor, similar to the others, but with mixed arguments
+
+
MidiBus(Object, String, int) - Constructor for class themidibus.MidiBus
+
+
More flavors of constructor, similar to the others, but with mixed arguments
+
+
MidiBus(Object, String, int, String) - Constructor for class themidibus.MidiBus
+
+
More flavors of constructor, similar to the others, but with mixed arguments
+
+
MidiListener - Interface in themidibus
+
+
This is a placeholder interface which makes it easier to program and manipulate objects which implement subinterfaces of MidiListener like RawMidiListener, SimpleMidiListener or StandardMidiListener.
+
+
midiMessage(MidiMessage) - Method in class themidibus.PApplet
+
+
Is passed the raw MidiMessage associated with every new MIDI message recieved by a MidiBus attached to this applet.
+
+
midiMessage(MidiMessage, long, String) - Method in class themidibus.PApplet
+
+
Is passed the raw MidiMessage associated with every new MIDI message recieved by a MidiBus attached to this applet and the name of the MidiBus which recieved the message.
+
+
midiMessage(MidiMessage, long) - Method in interface themidibus.StandardMidiListener
+
+
Objects notifying this StandardMidiListener of a new MIDI message call this method and pass the MidiMessage
+
+
+ + + +

N

+
+
name() - Method in class themidibus.Note
+
+
Return the name of the note, e.g.
+
+
Note - Class in themidibus
+
+
The Note class represents a pressed or released key.
+
+
Note(int, int, int) - Constructor for class themidibus.Note
+
+
Constructs a Note object
+
+
Note(int, int, int, int) - Constructor for class themidibus.Note
+
+
Constructs a Note object
+
+
Note(int, int, int, long, String) - Constructor for class themidibus.Note
+
+
Constructs a Note object
+
+
Note(int, int, int, int, long, String) - Constructor for class themidibus.Note
+
+
Constructs a Note object
+
+
noteOff(Note) - Method in interface themidibus.ObjectMidiListener
+
+
Objects notifying this ObjectMidiListener of a new NoteOff events call this method.
+
+
noteOff(int, int, int) - Method in class themidibus.PApplet
+
+
Is passed the channel, pitch and velocity associated with every new NoteOff MIDI message recieved by a MidiBus attached to this applet.
+
+
noteOff(int, int, int, long, String) - Method in class themidibus.PApplet
+
+
Is passed the channel, pitch and velocity associated with every new NoteOff MIDI message recieved by a MidiBus attached to this applet and the name of the MidiBus which recieved the message.
+
+
noteOff(Note) - Method in class themidibus.PApplet
+
+
Is passed a Note object representing noteOff event
+
+
noteOff(int, int, int) - Method in interface themidibus.SimpleMidiListener
+
+
Objects notifying this SimpleMidiListener of a new NoteOff MIDI message call this method.
+
+
noteOn(Note) - Method in interface themidibus.ObjectMidiListener
+
+
Objects notifying this ObjectMidiListener of a new NoteOn events call this method.
+
+
noteOn(int, int, int) - Method in class themidibus.PApplet
+
+
Is passed the channel, pitch and velocity associated with every new NoteOn MIDI message recieved by a MidiBus attached to this applet.
+
+
noteOn(int, int, int, long, String) - Method in class themidibus.PApplet
+
+
Is passed the channel, pitch and velocity associated with every new NoteOn MIDI message recieved by a MidiBus attached to this applet and the name of the MidiBus which recieved the message.
+
+
noteOn(Note) - Method in class themidibus.PApplet
+
+
Is passed a Note object representing noteOn event
+
+
noteOn(int, int, int) - Method in interface themidibus.SimpleMidiListener
+
+
Objects notifying this SimpleMidiListener of a new NoteOn MIDI message call this method.
+
+
number - Variable in class themidibus.ControlChange
+
 
+
number() - Method in class themidibus.ControlChange
+
+
Return the number of the ControlChange
+
+
+ + + +

O

+
+
ObjectMidiListener - Interface in themidibus
+
+
A ObjectMidiListener can be notified of incomming NoteOn, NoteOff and ControllerChange events via Note and ControlChange objects, usually by a MidiBus object which it is connected to.
+
+
octave() - Method in class themidibus.Note
+
+
Return the octave of the Note.
+
+
+ + + +

P

+
+
PApplet - Class in themidibus
+
+
PApplet is your processing application or sketch.
+
+
PApplet() - Constructor for class themidibus.PApplet
+
 
+
pitch - Variable in class themidibus.Note
+
 
+
pitch() - Method in class themidibus.Note
+
+
Return the pitch of the Note
+
+
+ + + +

R

+
+
rawMidi(byte[]) - Method in class themidibus.PApplet
+
+
Is passed the raw data associated with every new MIDI message recieved by a MidiBus attached to this applet.
+
+
rawMidi(byte[], long, String) - Method in class themidibus.PApplet
+
+
Is passed the raw data associated with every new MIDI message recieved by a MidiBus attached to this applet and the name of the MidiBus which recieved the message.
+
+
RawMidiListener - Interface in themidibus
+
+
A RawMidiListener can be notified of incomming MIDI messages in raw form, usually by a MidiBus object which it is connect to.
+
+
rawMidiMessage(byte[]) - Method in interface themidibus.RawMidiListener
+
+
Objects notifying this RawMidiListener of a new MIDI message call this method and pass the raw message to it.
+
+
registerParent(Object) - Method in class themidibus.MidiBus
+
+
Registers an Object as the parent in order to recieve method callbacks as per PApplet.
+
+
relativePitch() - Method in class themidibus.Note
+
+
Return the pitch of the Note relative to C.
+
+
removeInput(int) - Method in class themidibus.MidiBus
+
+
Removes the MIDI input device specified by the index device_num.
+
+
removeInput(String) - Method in class themidibus.MidiBus
+
+
Removes the MIDI input device specified by the name device_name.
+
+
removeMidiListener(MidiListener) - Method in class themidibus.MidiBus
+
+
Removes a given listener.
+
+
removeOutput(int) - Method in class themidibus.MidiBus
+
+
Removes the MIDI output device specified by the index device_num.
+
+
removeOutput(String) - Method in class themidibus.MidiBus
+
+
Removes the MIDI output device specified by the name device_name.
+
+
+ + + +

S

+
+
sendControllerChange(int, int, int) - Method in class themidibus.MidiBus
+
+
Sends a ControllerChange message to a channel with the specified number and value.
+
+
sendControllerChange(ControlChange) - Method in class themidibus.MidiBus
+
+
Sends a ControllerChange message to a channel with the specified ControlChange.
+
+
sendMessage(byte[]) - Method in class themidibus.MidiBus
+
+
Sends a MIDI message with an unspecified number of bytes.
+
+
sendMessage(int) - Method in class themidibus.MidiBus
+
+
Sends a MIDI message that takes no data bytes.
+
+
sendMessage(int, int) - Method in class themidibus.MidiBus
+
+
Sends a MIDI message that takes only one data byte.
+
+
sendMessage(int, int, int) - Method in class themidibus.MidiBus
+
+
Sends a MIDI message that takes one or two data bytes.
+
+
sendMessage(int, int, int, int) - Method in class themidibus.MidiBus
+
+
Sends a channel message which takes up to two data bytes.
+
+
sendMessage(MidiMessage) - Method in class themidibus.MidiBus
+
+
Sends a MidiMessage object.
+
+
sendNoteOff(int, int, int) - Method in class themidibus.MidiBus
+
+
Sends a NoteOff message to a channel with the specified pitch and velocity.
+
+
sendNoteOff(Note) - Method in class themidibus.MidiBus
+
+
Sends a NoteOff message to a channel with the specified Note.
+
+
sendNoteOn(int, int, int) - Method in class themidibus.MidiBus
+
+
Sends a NoteOn message to a channel with the specified pitch and velocity.
+
+
sendNoteOn(Note) - Method in class themidibus.MidiBus
+
+
Sends a NoteOn message to a channel with the specified Note.
+
+
sendTimestamps() - Method in class themidibus.MidiBus
+
+
Returns whether this MidiBus is sending timestamps along with MIDI information to the MIDI subsystem.
+
+
sendTimestamps(boolean) - Method in class themidibus.MidiBus
+
+
Configure this MidiBus instance to send or not to send timestamps along with MIDI information to the MIDI subsystem.
+
+
setBusName(String) - Method in class themidibus.MidiBus
+
+
Changes the name of this MidiBus.
+
+
setChannel(int) - Method in class themidibus.ControlChange
+
+
Set channel of the ControlChange
+
+
setChannel(int) - Method in class themidibus.Note
+
+
Set channel of the Note
+
+
setNumber(int) - Method in class themidibus.ControlChange
+
+
Set number of the ControlChange
+
+
setPitch(int) - Method in class themidibus.Note
+
+
Set pitch of the Note
+
+
setTicks(int) - Method in class themidibus.Note
+
+
Set length in ticks of the Note
+
+
setValue(int) - Method in class themidibus.ControlChange
+
+
Set value of the ControlChange
+
+
setVelocity(int) - Method in class themidibus.Note
+
+
Set velocity of the Note
+
+
SimpleMidiListener - Interface in themidibus
+
+
A SimpleMidiListener can be notified of incomming NoteOn, NoteOff and ControllerChange MIDI messages, usually by a MidiBus object which it is connected to.
+
+
StandardMidiListener - Interface in themidibus
+
+
A StandardMidiListener can be notified of incomming MIDI messages in MidiMessage form, usually by a MidiBus object which it is connected to.
+
+
stop() - Method in class themidibus.MidiBus
+
+
Closes this MidiBus and all connections it has with other MIDI devices.
+
+
+ + + +

T

+
+
themidibus - package themidibus
+
+
The MidiBus provides a simple way to access and interact with installed MIDI system resources, although it's especially designed to be used with Processing, it could easily be adapted for use in any java program.
+
+
ticks - Variable in class themidibus.Note
+
 
+
ticks() - Method in class themidibus.Note
+
+
Return the length in ticks of the Note
+
+
timestamp - Variable in class themidibus.ControlChange
+
 
+
timestamp - Variable in class themidibus.Note
+
 
+
toString() - Method in class themidibus.ControlChange
+
+
Returns a string in the format [c:channel, n:number, v:value, ts:timestamp, b:bus_name] e.g "[c:0, n:65, v:123, ts:1234, b:bus123]".
+
+
toString() - Method in class themidibus.MidiBus
+
+
Returns a string representation of the object.
+
+
toString() - Method in class themidibus.Note
+
+
Returns a string in the format [Note Name, c:channel, p:pitch, v:velocity, t:ticks, ts:timestamp, b:bus_name] e.g "[C, c:0, p:65, v:123, t:0, ts:1234, b:bus123]".
+
+
+ + + +

U

+
+
unavailableDevices() - Static method in class themidibus.MidiBus
+
+
Returns the names of all the unavailable devices.
+
+
+ + + +

V

+
+
value - Variable in class themidibus.ControlChange
+
 
+
value() - Method in class themidibus.ControlChange
+
+
Return the value of the ControlChange
+
+
velocity - Variable in class themidibus.Note
+
 
+
velocity() - Method in class themidibus.Note
+
+
Return the velocity of the Note
+
+
+A B C D E F G H L M N O P R S T U V 
+ +
+ + + + + +
+ + + + diff --git a/libraries/themidibus/reference/index.html b/libraries/themidibus/reference/index.html new file mode 100644 index 0000000..3df6834 --- /dev/null +++ b/libraries/themidibus/reference/index.html @@ -0,0 +1,64 @@ + + + + + +Generated Documentation (Untitled) + + + + + + +<noscript> +<div>JavaScript is disabled on your browser.</div> +</noscript> +<h2>Frame Alert</h2> +<p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="themidibus/package-summary.html">Non-frame version</a>.</p> + + + diff --git a/libraries/themidibus/reference/overview-tree.html b/libraries/themidibus/reference/overview-tree.html new file mode 100644 index 0000000..3a844a9 --- /dev/null +++ b/libraries/themidibus/reference/overview-tree.html @@ -0,0 +1,138 @@ + + + + + +Class Hierarchy + + + + + + + +
+ + + + + +
+ + +
+

Hierarchy For All Packages

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +

Interface Hierarchy

+ +
+ +
+ + + + + +
+ + + + diff --git a/libraries/themidibus/reference/package-list b/libraries/themidibus/reference/package-list new file mode 100644 index 0000000..384b71b --- /dev/null +++ b/libraries/themidibus/reference/package-list @@ -0,0 +1 @@ +themidibus diff --git a/libraries/themidibus/reference/resources/background.gif b/libraries/themidibus/reference/resources/background.gif new file mode 100644 index 0000000..f471940 Binary files /dev/null and b/libraries/themidibus/reference/resources/background.gif differ diff --git a/libraries/themidibus/reference/resources/tab.gif b/libraries/themidibus/reference/resources/tab.gif new file mode 100644 index 0000000..1a73a83 Binary files /dev/null and b/libraries/themidibus/reference/resources/tab.gif differ diff --git a/libraries/themidibus/reference/resources/titlebar.gif b/libraries/themidibus/reference/resources/titlebar.gif new file mode 100644 index 0000000..17443b3 Binary files /dev/null and b/libraries/themidibus/reference/resources/titlebar.gif differ diff --git a/libraries/themidibus/reference/resources/titlebar_end.gif b/libraries/themidibus/reference/resources/titlebar_end.gif new file mode 100644 index 0000000..3ad78d4 Binary files /dev/null and b/libraries/themidibus/reference/resources/titlebar_end.gif differ diff --git a/libraries/themidibus/reference/stylesheet.css b/libraries/themidibus/reference/stylesheet.css new file mode 100644 index 0000000..0aeaa97 --- /dev/null +++ b/libraries/themidibus/reference/stylesheet.css @@ -0,0 +1,474 @@ +/* Javadoc style sheet */ +/* +Overall document style +*/ +body { + background-color:#ffffff; + color:#353833; + font-family:Arial, Helvetica, sans-serif; + font-size:76%; + margin:0; +} +a:link, a:visited { + text-decoration:none; + color:#4c6b87; +} +a:hover, a:focus { + text-decoration:none; + color:#bb7a2a; +} +a:active { + text-decoration:none; + color:#4c6b87; +} +a[name] { + color:#353833; +} +a[name]:hover { + text-decoration:none; + color:#353833; +} +pre { + font-size:1.3em; +} +h1 { + font-size:1.8em; +} +h2 { + font-size:1.5em; +} +h3 { + font-size:1.4em; +} +h4 { + font-size:1.3em; +} +h5 { + font-size:1.2em; +} +h6 { + font-size:1.1em; +} +ul { + list-style-type:disc; +} +code, tt { + font-size:1.2em; +} +dt code { + font-size:1.2em; +} +table tr td dt code { + font-size:1.2em; + vertical-align:top; +} +sup { + font-size:.6em; +} +/* +Document title and Copyright styles +*/ +.clear { + clear:both; + height:0px; + overflow:hidden; +} +.aboutLanguage { + float:right; + padding:0px 21px; + font-size:.8em; + z-index:200; + margin-top:-7px; +} +.legalCopy { + margin-left:.5em; +} +.bar a, .bar a:link, .bar a:visited, .bar a:active { + color:#FFFFFF; + text-decoration:none; +} +.bar a:hover, .bar a:focus { + color:#bb7a2a; +} +.tab { + background-color:#0066FF; + background-image:url(resources/titlebar.gif); + background-position:left top; + background-repeat:no-repeat; + color:#ffffff; + padding:8px; + width:5em; + font-weight:bold; +} +/* +Navigation bar styles +*/ +.bar { + background-image:url(resources/background.gif); + background-repeat:repeat-x; + color:#FFFFFF; + padding:.8em .5em .4em .8em; + height:auto;/*height:1.8em;*/ + font-size:1em; + margin:0; +} +.topNav { + background-image:url(resources/background.gif); + background-repeat:repeat-x; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; +} +.bottomNav { + margin-top:10px; + background-image:url(resources/background.gif); + background-repeat:repeat-x; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; +} +.subNav { + background-color:#dee3e9; + border-bottom:1px solid #9eadc0; + float:left; + width:100%; + overflow:hidden; +} +.subNav div { + clear:left; + float:left; + padding:0 0 5px 6px; +} +ul.navList, ul.subNavList { + float:left; + margin:0 25px 0 0; + padding:0; +} +ul.navList li{ + list-style:none; + float:left; + padding:3px 6px; +} +ul.subNavList li{ + list-style:none; + float:left; + font-size:90%; +} +.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { + color:#FFFFFF; + text-decoration:none; +} +.topNav a:hover, .bottomNav a:hover { + text-decoration:none; + color:#bb7a2a; +} +.navBarCell1Rev { + background-image:url(resources/tab.gif); + background-color:#a88834; + color:#FFFFFF; + margin: auto 5px; + border:1px solid #c9aa44; +} +/* +Page header and footer styles +*/ +.header, .footer { + clear:both; + margin:0 20px; + padding:5px 0 0 0; +} +.indexHeader { + margin:10px; + position:relative; +} +.indexHeader h1 { + font-size:1.3em; +} +.title { + color:#2c4557; + margin:10px 0; +} +.subTitle { + margin:5px 0 0 0; +} +.header ul { + margin:0 0 25px 0; + padding:0; +} +.footer ul { + margin:20px 0 5px 0; +} +.header ul li, .footer ul li { + list-style:none; + font-size:1.2em; +} +/* +Heading styles +*/ +div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { + background-color:#dee3e9; + border-top:1px solid #9eadc0; + border-bottom:1px solid #9eadc0; + margin:0 0 6px -8px; + padding:2px 5px; +} +ul.blockList ul.blockList ul.blockList li.blockList h3 { + background-color:#dee3e9; + border-top:1px solid #9eadc0; + border-bottom:1px solid #9eadc0; + margin:0 0 6px -8px; + padding:2px 5px; +} +ul.blockList ul.blockList li.blockList h3 { + padding:0; + margin:15px 0; +} +ul.blockList li.blockList h2 { + padding:0px 0 20px 0; +} +/* +Page layout container styles +*/ +.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer { + clear:both; + padding:10px 20px; + position:relative; +} +.indexContainer { + margin:10px; + position:relative; + font-size:1.0em; +} +.indexContainer h2 { + font-size:1.1em; + padding:0 0 3px 0; +} +.indexContainer ul { + margin:0; + padding:0; +} +.indexContainer ul li { + list-style:none; +} +.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { + font-size:1.1em; + font-weight:bold; + margin:10px 0 0 0; + color:#4E4E4E; +} +.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { + margin:10px 0 10px 20px; +} +.serializedFormContainer dl.nameValue dt { + margin-left:1px; + font-size:1.1em; + display:inline; + font-weight:bold; +} +.serializedFormContainer dl.nameValue dd { + margin:0 0 0 1px; + font-size:1.1em; + display:inline; +} +/* +List styles +*/ +ul.horizontal li { + display:inline; + font-size:0.9em; +} +ul.inheritance { + margin:0; + padding:0; +} +ul.inheritance li { + display:inline; + list-style:none; +} +ul.inheritance li ul.inheritance { + margin-left:15px; + padding-left:15px; + padding-top:1px; +} +ul.blockList, ul.blockListLast { + margin:10px 0 10px 0; + padding:0; +} +ul.blockList li.blockList, ul.blockListLast li.blockList { + list-style:none; + margin-bottom:25px; +} +ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { + padding:0px 20px 5px 10px; + border:1px solid #9eadc0; + background-color:#f9f9f9; +} +ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { + padding:0 0 5px 8px; + background-color:#ffffff; + border:1px solid #9eadc0; + border-top:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { + margin-left:0; + padding-left:0; + padding-bottom:15px; + border:none; + border-bottom:1px solid #9eadc0; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { + list-style:none; + border-bottom:none; + padding-bottom:0; +} +table tr td dl, table tr td dl dt, table tr td dl dd { + margin-top:0; + margin-bottom:1px; +} +/* +Table styles +*/ +.contentContainer table, .classUseContainer table, .constantValuesContainer table { + border-bottom:1px solid #9eadc0; + width:100%; +} +.contentContainer ul li table, .classUseContainer ul li table, .constantValuesContainer ul li table { + width:100%; +} +.contentContainer .description table, .contentContainer .details table { + border-bottom:none; +} +.contentContainer ul li table th.colOne, .contentContainer ul li table th.colFirst, .contentContainer ul li table th.colLast, .classUseContainer ul li table th, .constantValuesContainer ul li table th, .contentContainer ul li table td.colOne, .contentContainer ul li table td.colFirst, .contentContainer ul li table td.colLast, .classUseContainer ul li table td, .constantValuesContainer ul li table td{ + vertical-align:top; + padding-right:20px; +} +.contentContainer ul li table th.colLast, .classUseContainer ul li table th.colLast,.constantValuesContainer ul li table th.colLast, +.contentContainer ul li table td.colLast, .classUseContainer ul li table td.colLast,.constantValuesContainer ul li table td.colLast, +.contentContainer ul li table th.colOne, .classUseContainer ul li table th.colOne, +.contentContainer ul li table td.colOne, .classUseContainer ul li table td.colOne { + padding-right:3px; +} +.overviewSummary caption, .packageSummary caption, .contentContainer ul.blockList li.blockList caption, .summary caption, .classUseContainer caption, .constantValuesContainer caption { + position:relative; + text-align:left; + background-repeat:no-repeat; + color:#FFFFFF; + font-weight:bold; + clear:none; + overflow:hidden; + padding:0px; + margin:0px; +} +caption a:link, caption a:hover, caption a:active, caption a:visited { + color:#FFFFFF; +} +.overviewSummary caption span, .packageSummary caption span, .contentContainer ul.blockList li.blockList caption span, .summary caption span, .classUseContainer caption span, .constantValuesContainer caption span { + white-space:nowrap; + padding-top:8px; + padding-left:8px; + display:block; + float:left; + background-image:url(resources/titlebar.gif); + height:18px; +} +.overviewSummary .tabEnd, .packageSummary .tabEnd, .contentContainer ul.blockList li.blockList .tabEnd, .summary .tabEnd, .classUseContainer .tabEnd, .constantValuesContainer .tabEnd { + width:10px; + background-image:url(resources/titlebar_end.gif); + background-repeat:no-repeat; + background-position:top right; + position:relative; + float:left; +} +ul.blockList ul.blockList li.blockList table { + margin:0 0 12px 0px; + width:100%; +} +.tableSubHeadingColor { + background-color: #EEEEFF; +} +.altColor { + background-color:#eeeeef; +} +.rowColor { + background-color:#ffffff; +} +.overviewSummary td, .packageSummary td, .contentContainer ul.blockList li.blockList td, .summary td, .classUseContainer td, .constantValuesContainer td { + text-align:left; + padding:3px 3px 3px 7px; +} +th.colFirst, th.colLast, th.colOne, .constantValuesContainer th { + background:#dee3e9; + border-top:1px solid #9eadc0; + border-bottom:1px solid #9eadc0; + text-align:left; + padding:3px 3px 3px 7px; +} +td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { + font-weight:bold; +} +td.colFirst, th.colFirst { + border-left:1px solid #9eadc0; + white-space:nowrap; +} +td.colLast, th.colLast { + border-right:1px solid #9eadc0; +} +td.colOne, th.colOne { + border-right:1px solid #9eadc0; + border-left:1px solid #9eadc0; +} +table.overviewSummary { + padding:0px; + margin-left:0px; +} +table.overviewSummary td.colFirst, table.overviewSummary th.colFirst, +table.overviewSummary td.colOne, table.overviewSummary th.colOne { + width:25%; + vertical-align:middle; +} +table.packageSummary td.colFirst, table.overviewSummary th.colFirst { + width:25%; + vertical-align:middle; +} +/* +Content styles +*/ +.description pre { + margin-top:0; +} +.deprecatedContent { + margin:0; + padding:10px 0; +} +.docSummary { + padding:0; +} +/* +Formatting effect styles +*/ +.sourceLineNo { + color:green; + padding:0 30px 0 0; +} +h1.hidden { + visibility:hidden; + overflow:hidden; + font-size:.9em; +} +.block { + display:block; + margin:3px 0 0 0; +} +.strong { + font-weight:bold; +} diff --git a/libraries/themidibus/reference/themidibus/ControlChange.html b/libraries/themidibus/reference/themidibus/ControlChange.html new file mode 100644 index 0000000..65494bc --- /dev/null +++ b/libraries/themidibus/reference/themidibus/ControlChange.html @@ -0,0 +1,509 @@ + + + + + +ControlChange + + + + + + + + + + + +
+
themidibus
+

Class ControlChange

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • themidibus.ControlChange
    • +
    +
  • +
+
+
    +
  • +
    +
    +
    public class ControlChange
    +extends java.lang.Object
    +
    The ControlChange class represents a change in value from a controller.
    +
    Version:
    +
    008
    +
    Author:
    +
    Severin Smith, Marc Koderer
    +
    See Also:
    MidiBus, +ObjectMidiListener, +Note
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Field Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Fields 
      Modifier and TypeField and Description
      java.lang.Stringbus_name 
      intchannel 
      intnumber 
      longtimestamp 
      intvalue 
      +
    • +
    + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + + +
      Constructors 
      Constructor and Description
      ControlChange(int channel, + int number, + int value) +
      Constructs a ControlChange object
      +
      ControlChange(int channel, + int number, + int value, + long timestamp, + java.lang.String bus_name) +
      Constructs a ControlChange object
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Methods 
      Modifier and TypeMethod and Description
      intchannel() +
      Return the channel of the ControlChange
      +
      booleanequals(java.lang.Object obj) +
      Check if all fields are equal.
      +
      intnumber() +
      Return the number of the ControlChange
      +
      voidsetChannel(int channel) +
      Set channel of the ControlChange
      +
      voidsetNumber(int number) +
      Set number of the ControlChange
      +
      voidsetValue(int value) +
      Set value of the ControlChange
      +
      java.lang.StringtoString() +
      Returns a string in the format [c:channel, n:number, v:value, ts:timestamp, b:bus_name] e.g "[c:0, n:65, v:123, ts:1234, b:bus123]".
      +
      intvalue() +
      Return the value of the ControlChange
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        channel

        +
        public int channel
        +
      • +
      + + + +
        +
      • +

        number

        +
        public int number
        +
      • +
      + + + +
        +
      • +

        value

        +
        public int value
        +
      • +
      + + + +
        +
      • +

        timestamp

        +
        public long timestamp
        +
      • +
      + + + +
        +
      • +

        bus_name

        +
        public java.lang.String bus_name
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        ControlChange

        +
        public ControlChange(int channel,
        +             int number,
        +             int value)
        +
        Constructs a ControlChange object
        +
        Parameters:
        channel - the channel of the ControlChange
        number - the number of the ControlChange
        value - the value of the ControlChange
        +
      • +
      + + + +
        +
      • +

        ControlChange

        +
        public ControlChange(int channel,
        +             int number,
        +             int value,
        +             long timestamp,
        +             java.lang.String bus_name)
        +
        Constructs a ControlChange object
        +
        Parameters:
        channel - the channel of the ControlChange
        number - the number of the ControlChange
        value - the value of the ControlChange
        timestamp - the timestamp of the ControlChange
        bus_name - the name of MidiBus associated with the ControlChange
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        setChannel

        +
        public void setChannel(int channel)
        +
        Set channel of the ControlChange
        +
        Parameters:
        channel - the channel to set
        +
      • +
      + + + +
        +
      • +

        channel

        +
        public int channel()
        +
        Return the channel of the ControlChange
        +
        Returns:
        the channel
        +
      • +
      + + + +
        +
      • +

        setNumber

        +
        public void setNumber(int number)
        +
        Set number of the ControlChange
        +
        Parameters:
        number - the number to set
        +
      • +
      + + + +
        +
      • +

        number

        +
        public int number()
        +
        Return the number of the ControlChange
        +
        Returns:
        the number
        +
      • +
      + + + +
        +
      • +

        setValue

        +
        public void setValue(int value)
        +
        Set value of the ControlChange
        +
        Parameters:
        value - the value to set
        +
      • +
      + + + +
        +
      • +

        value

        +
        public int value()
        +
        Return the value of the ControlChange
        +
        Returns:
        the value
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public java.lang.String toString()
        +
        Returns a string in the format [c:channel, n:number, v:value, ts:timestamp, b:bus_name] e.g "[c:0, n:65, v:123, ts:1234, b:bus123]". If timestamp or bus_name isn't set, it is omitted.
        +
        +
        Overrides:
        +
        toString in class java.lang.Object
        +
        Returns:
        the string representation
        +
      • +
      + + + +
        +
      • +

        equals

        +
        public boolean equals(java.lang.Object obj)
        +
        Check if all fields are equal.
        +
        +
        Overrides:
        +
        equals in class java.lang.Object
        +
        Returns:
        true if both objects can be considered to be equals
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/libraries/themidibus/reference/themidibus/MidiBus.html b/libraries/themidibus/reference/themidibus/MidiBus.html new file mode 100644 index 0000000..6723f0e --- /dev/null +++ b/libraries/themidibus/reference/themidibus/MidiBus.html @@ -0,0 +1,1496 @@ + + + + + +MidiBus + + + + + + + + + + + +
+
themidibus
+

Class MidiBus

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • themidibus.MidiBus
    • +
    +
  • +
+
+
    +
  • +
    +
    +
    public class MidiBus
    +extends java.lang.Object
    +
    The MidiBus class provides a simple way to send and receive MIDI within Processing sketches. +

    +

    Typical Implementation, Simple

    +

    + A typical simple Processing MIDI application would begin by invoking the static method list() to learn what devices are available. Then using that information a new MidiBus object would be instantiated with with the desired MIDI input and/or output devices. The Processing sketch could then send midi via MidiBus's outgoing methods such as sendNoteOn(int channel, int pitch, int velocity), sendNoteOff(int channel, int pitch, int velocity) and sendControllerChange(int channel, int number, int value) and receive midi via the PApplet methods this package provides support for such as PApplet.noteOn(int channel, int pitch, int velocity), PApplet.noteOff(int channel, int pitch, int velocity) and PApplet.controllerChange(int channel, int number, int value). +

    Typical Implementation, Advanced

    +

    + If you wish to build more complex Processing MIDI applications you can add more input and output devices to any given instance of MidiBus via the addInput() and addOutput() methods. However it is important to understand that each MidiBus object acts like 2 MIDI buses, one for input and one for output. This means, that by design, outgoing MIDI messages are sent to all output devices connected to a given instance of MidiBus, and incomming messages from all input devices connected to a given instance of MidiBus are merged upon reception. In practice, this means that, by design, you cannot tell which of the devices connected to a given instance of MidiBus sent a particular message, nor can you send a MIDI message to one particular device connected to that object. Instead, for independent reception/transmission to different sets of MIDI devices, you can instantiate more than one MidiBus object inside your Processing sketch. Each instance of MidiBus will only send MIDI messages to output devices which are connected to it and inbound MIDI messages arriving at each MidiBus can be diferentiated using the the PApplet methods with the bus_name parameter.

    +
    Version:
    +
    008
    +
    Author:
    +
    Severin Smith
    +
    See Also:
    PApplet, +MidiListener, +RawMidiListener, +StandardMidiListener, +SimpleMidiListener
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Constructors 
      Constructor and Description
      MidiBus() +
      Constructs a new Midibus.
      +
      MidiBus(java.lang.Object parent) +
      Constructs a new MidiBus and registers the specified parent (PApplet or other) for callbacks.
      +
      MidiBus(java.lang.Object parent, + int in_device_num, + int out_device_num) +
      Constructs a new MidiBus and registers the specified parent (PApplet or other) for callbacks.
      +
      MidiBus(java.lang.Object parent, + int in_device_num, + int out_device_num, + java.lang.String bus_name) +
      Constructs a new MidiBus with the specified bus_name and registers the specified parent (PApplet or other) for callbacks.
      +
      MidiBus(java.lang.Object parent, + int in_device_num, + java.lang.String out_device_name) +
      More flavors of constructor, similar to the others, but with mixed arguments
      +
      MidiBus(java.lang.Object parent, + int in_device_num, + java.lang.String out_device_name, + java.lang.String bus_name) +
      More flavors of constructor, similar to the others, but with mixed arguments
      +
      MidiBus(java.lang.Object parent, + java.lang.String bus_name) +
      Constructs a new MidiBus with the specified bus_name and registers the specified parent (PApplet or other) for callbacks.
      +
      MidiBus(java.lang.Object parent, + java.lang.String in_device_name, + int out_device_num) +
      More flavors of constructor, similar to the others, but with mixed arguments
      +
      MidiBus(java.lang.Object parent, + java.lang.String in_device_name, + int out_device_num, + java.lang.String bus_name) +
      More flavors of constructor, similar to the others, but with mixed arguments
      +
      MidiBus(java.lang.Object parent, + java.lang.String in_device_name, + java.lang.String out_device_name) +
      Constructs a new MidiBus and registers the specified parent (PApplet or other) for callbacks.
      +
      MidiBus(java.lang.Object parent, + java.lang.String in_device_name, + java.lang.String out_device_name, + java.lang.String bus_name) +
      Constructs a new MidiBus with the specified bus_name and registers the specified parent (PApplet or other) for callbacks.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Methods 
      Modifier and TypeMethod and Description
      booleanaddInput(int device_num) +
      Adds a new MIDI input device specified by the index device_num.
      +
      booleanaddInput(java.lang.String device_name) +
      Adds a new MIDI input device specified by the name device_name.
      +
      booleanaddMidiListener(MidiListener listener) +
      Adds a listener who will be notified each time a new MIDI message is received from a MIDI input device.
      +
      booleanaddOutput(int device_num) +
      Adds a new MIDI output device specified by the index device_num.
      +
      booleanaddOutput(java.lang.String device_name) +
      Adds a new MIDI output device specified by the name device_name.
      +
      java.lang.String[]attachedInputs() +
      Returns the names of all the attached input devices.
      +
      java.lang.String[]attachedOutputs() +
      Returns the names of all the attached output devices.
      +
      static java.lang.String[]availableInputs() +
      Returns the names of all the available input devices.
      +
      static java.lang.String[]availableOutputs() +
      Returns the names of all the available output devices.
      +
      voidclearAll() +
      Closes, clears and disposes of all input and output related Transmitters and Receivers.
      +
      voidclearInputs() +
      Closes, clears and disposes of all input related Transmitters and Receivers.
      +
      voidclearOutputs() +
      Closes, clears and disposes of all output related Receivers.
      +
      MidiBusclone() +
      Creates and returns a copy of this object.
      +
      voidclose() +
      Closes this MidiBus and all connections it has with other MIDI devices.
      +
      voiddispose() +
      Closes this MidiBus and all connections it has with other MIDI devices.
      +
      booleanequals(java.lang.Object obj) +
      Indicates whether some other object is "equal to" this one.
      +
      protected voidfinalize() +
      Override the finalize() method from java.lang.Object.
      +
      static voidfindMidiDevices() +
      Rescan for Midi Devices.
      +
      voidgenerateBusName() +
      Generate a name for this MidiBus instance.
      +
      java.lang.StringgetBusName() +
      Returns the name of this MidiBus.
      +
      inthashCode() +
      Returns a hash code value for the object.
      +
      static voidlist() +
      List all installed MIDI devices.
      +
      java.lang.ObjectregisterParent(java.lang.Object parent) +
      Registers an Object as the parent in order to recieve method callbacks as per PApplet.
      +
      booleanremoveInput(int device_num) +
      Removes the MIDI input device specified by the index device_num.
      +
      booleanremoveInput(java.lang.String device_name) +
      Removes the MIDI input device specified by the name device_name.
      +
      booleanremoveMidiListener(MidiListener listener) +
      Removes a given listener.
      +
      booleanremoveOutput(int device_num) +
      Removes the MIDI output device specified by the index device_num.
      +
      booleanremoveOutput(java.lang.String device_name) +
      Removes the MIDI output device specified by the name device_name.
      +
      voidsendControllerChange(ControlChange change) +
      Sends a ControllerChange message to a channel with the specified ControlChange.
      +
      voidsendControllerChange(int channel, + int number, + int value) +
      Sends a ControllerChange message to a channel with the specified number and value.
      +
      voidsendMessage(byte[] data) +
      Sends a MIDI message with an unspecified number of bytes.
      +
      voidsendMessage(int status) +
      Sends a MIDI message that takes no data bytes.
      +
      voidsendMessage(int status, + int data) +
      Sends a MIDI message that takes only one data byte.
      +
      voidsendMessage(int status, + int data1, + int data2) +
      Sends a MIDI message that takes one or two data bytes.
      +
      voidsendMessage(int command, + int channel, + int data1, + int data2) +
      Sends a channel message which takes up to two data bytes.
      +
      voidsendMessage(javax.sound.midi.MidiMessage message) +
      Sends a MidiMessage object.
      +
      voidsendNoteOff(int channel, + int pitch, + int velocity) +
      Sends a NoteOff message to a channel with the specified pitch and velocity.
      +
      voidsendNoteOff(Note note) +
      Sends a NoteOff message to a channel with the specified Note.
      +
      voidsendNoteOn(int channel, + int pitch, + int velocity) +
      Sends a NoteOn message to a channel with the specified pitch and velocity.
      +
      voidsendNoteOn(Note note) +
      Sends a NoteOn message to a channel with the specified Note.
      +
      booleansendTimestamps() +
      Returns whether this MidiBus is sending timestamps along with MIDI information to the MIDI subsystem.
      +
      voidsendTimestamps(boolean sendTimestamps) +
      Configure this MidiBus instance to send or not to send timestamps along with MIDI information to the MIDI subsystem.
      +
      voidsetBusName(java.lang.String bus_name) +
      Changes the name of this MidiBus.
      +
      voidstop() +
      Closes this MidiBus and all connections it has with other MIDI devices.
      +
      java.lang.StringtoString() +
      Returns a string representation of the object.
      +
      static java.lang.String[]unavailableDevices() +
      Returns the names of all the unavailable devices.
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +getClass, notify, notifyAll, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+ +
+
+ + + + + + + diff --git a/libraries/themidibus/reference/themidibus/MidiListener.html b/libraries/themidibus/reference/themidibus/MidiListener.html new file mode 100644 index 0000000..8c0ed5c --- /dev/null +++ b/libraries/themidibus/reference/themidibus/MidiListener.html @@ -0,0 +1,168 @@ + + + + + +MidiListener + + + + + + + + + + + +
+
themidibus
+

Interface MidiListener

+
+
+
+ +
+
+ + + + + + + diff --git a/libraries/themidibus/reference/themidibus/Note.html b/libraries/themidibus/reference/themidibus/Note.html new file mode 100644 index 0000000..00084b1 --- /dev/null +++ b/libraries/themidibus/reference/themidibus/Note.html @@ -0,0 +1,655 @@ + + + + + +Note + + + + + + + + + + + +
+
themidibus
+

Class Note

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • themidibus.Note
    • +
    +
  • +
+
+
    +
  • +
    +
    +
    public class Note
    +extends java.lang.Object
    +
    The Note class represents a pressed or released key.
    +
    Version:
    +
    008
    +
    Author:
    +
    Severin Smith, Marc Koderer
    +
    See Also:
    MidiBus, +ObjectMidiListener, +ControlChange
    +
  • +
+
+
+
    +
  • + + + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + + + + + + + + +
      Constructors 
      Constructor and Description
      Note(int channel, + int pitch, + int velocity) +
      Constructs a Note object
      +
      Note(int channel, + int pitch, + int velocity, + int ticks) +
      Constructs a Note object
      +
      Note(int channel, + int pitch, + int velocity, + int ticks, + long timestamp, + java.lang.String bus_name) +
      Constructs a Note object
      +
      Note(int channel, + int pitch, + int velocity, + long timestamp, + java.lang.String bus_name) +
      Constructs a Note object
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Methods 
      Modifier and TypeMethod and Description
      intchannel() +
      Return the channel of the Note
      +
      booleanequals(java.lang.Object obj) +
      Check if all fields are equal.
      +
      java.lang.Stringname() +
      Return the name of the note, e.g.
      +
      intoctave() +
      Return the octave of the Note.
      +
      intpitch() +
      Return the pitch of the Note
      +
      intrelativePitch() +
      Return the pitch of the Note relative to C.
      +
      voidsetChannel(int channel) +
      Set channel of the Note
      +
      voidsetPitch(int pitch) +
      Set pitch of the Note
      +
      voidsetTicks(int ticks) +
      Set length in ticks of the Note
      +
      voidsetVelocity(int velocity) +
      Set velocity of the Note
      +
      longticks() +
      Return the length in ticks of the Note
      +
      java.lang.StringtoString() +
      Returns a string in the format [Note Name, c:channel, p:pitch, v:velocity, t:ticks, ts:timestamp, b:bus_name] e.g "[C, c:0, p:65, v:123, t:0, ts:1234, b:bus123]".
      +
      intvelocity() +
      Return the velocity of the Note
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        channel

        +
        public int channel
        +
      • +
      + + + +
        +
      • +

        pitch

        +
        public int pitch
        +
      • +
      + + + +
        +
      • +

        velocity

        +
        public int velocity
        +
      • +
      + + + +
        +
      • +

        ticks

        +
        public long ticks
        +
      • +
      + + + +
        +
      • +

        timestamp

        +
        public long timestamp
        +
      • +
      + + + +
        +
      • +

        bus_name

        +
        public java.lang.String bus_name
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        Note

        +
        public Note(int channel,
        +    int pitch,
        +    int velocity)
        +
        Constructs a Note object
        +
        Parameters:
        channel - the channel of the Note
        pitch - the pitch of the Note
        velocity - the velocity of the Note
        +
      • +
      + + + +
        +
      • +

        Note

        +
        public Note(int channel,
        +    int pitch,
        +    int velocity,
        +    int ticks)
        +
        Constructs a Note object
        +
        Parameters:
        channel - the channel of the Note
        pitch - the pitch of the Note
        velocity - the velocity of the Note
        ticks - the length in ticks of the Note
        +
      • +
      + + + +
        +
      • +

        Note

        +
        public Note(int channel,
        +    int pitch,
        +    int velocity,
        +    long timestamp,
        +    java.lang.String bus_name)
        +
        Constructs a Note object
        +
        Parameters:
        channel - the channel of the Note
        pitch - the pitch of the Note
        velocity - the velocity of the Note
        timestamp - the timestamp of the Note
        bus_name - the name of MidiBus associated with the Note
        +
      • +
      + + + +
        +
      • +

        Note

        +
        public Note(int channel,
        +    int pitch,
        +    int velocity,
        +    int ticks,
        +    long timestamp,
        +    java.lang.String bus_name)
        +
        Constructs a Note object
        +
        Parameters:
        channel - the channel of the Note
        pitch - the pitch of the Note
        velocity - the velocity of the Note
        ticks - the length in ticks of the Note
        timestamp - the timestamp of the Note
        bus_name - the name of MidiBus associated with the Note
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        setChannel

        +
        public void setChannel(int channel)
        +
        Set channel of the Note
        +
        Parameters:
        channel - the channel to set
        +
      • +
      + + + +
        +
      • +

        channel

        +
        public int channel()
        +
        Return the channel of the Note
        +
        Returns:
        the channel
        +
      • +
      + + + +
        +
      • +

        setPitch

        +
        public void setPitch(int pitch)
        +
        Set pitch of the Note
        +
        Parameters:
        pitch - the pitch to set
        +
      • +
      + + + +
        +
      • +

        pitch

        +
        public int pitch()
        +
        Return the pitch of the Note
        +
        Returns:
        the pitch
        +
      • +
      + + + +
        +
      • +

        relativePitch

        +
        public int relativePitch()
        +
        Return the pitch of the Note relative to C. Range is 0-12.
        +
        Returns:
        the relative pitch
        +
      • +
      + + + +
        +
      • +

        octave

        +
        public int octave()
        +
        Return the octave of the Note. Octaves are divided by the note C
        +
        Returns:
        the octave
        +
      • +
      + + + +
        +
      • +

        name

        +
        public java.lang.String name()
        +
        Return the name of the note, e.g. "C" or "G#".
        +
        Returns:
        the note name
        +
      • +
      + + + +
        +
      • +

        setVelocity

        +
        public void setVelocity(int velocity)
        +
        Set velocity of the Note
        +
        Parameters:
        velocity - the velocity to set
        +
      • +
      + + + +
        +
      • +

        velocity

        +
        public int velocity()
        +
        Return the velocity of the Note
        +
        Returns:
        the velocity
        +
      • +
      + + + +
        +
      • +

        setTicks

        +
        public void setTicks(int ticks)
        +
        Set length in ticks of the Note
        +
        Parameters:
        ticks - the ticks value to set
        +
      • +
      + + + +
        +
      • +

        ticks

        +
        public long ticks()
        +
        Return the length in ticks of the Note
        +
        Returns:
        the ticks length
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public java.lang.String toString()
        +
        Returns a string in the format [Note Name, c:channel, p:pitch, v:velocity, t:ticks, ts:timestamp, b:bus_name] e.g "[C, c:0, p:65, v:123, t:0, ts:1234, b:bus123]". If ticks, timestamp or bus_name isn't set, it is omitted.
        +
        +
        Overrides:
        +
        toString in class java.lang.Object
        +
        Returns:
        the string representation
        +
      • +
      + + + +
        +
      • +

        equals

        +
        public boolean equals(java.lang.Object obj)
        +
        Check if all fields are equal.
        +
        +
        Overrides:
        +
        equals in class java.lang.Object
        +
        Returns:
        true if both objects can be considered to be equals
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/libraries/themidibus/reference/themidibus/ObjectMidiListener.html b/libraries/themidibus/reference/themidibus/ObjectMidiListener.html new file mode 100644 index 0000000..14e086e --- /dev/null +++ b/libraries/themidibus/reference/themidibus/ObjectMidiListener.html @@ -0,0 +1,257 @@ + + + + + +ObjectMidiListener + + + + + + + + + + + +
+
themidibus
+

Interface ObjectMidiListener

+
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + +
      Methods 
      Modifier and TypeMethod and Description
      voidcontrollerChange(ControlChange change) +
      Objects notifying this ObjectMidiListener of a new ControllerChange events call this method.
      +
      voidnoteOff(Note note) +
      Objects notifying this ObjectMidiListener of a new NoteOff events call this method.
      +
      voidnoteOn(Note note) +
      Objects notifying this ObjectMidiListener of a new NoteOn events call this method.
      +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        noteOn

        +
        void noteOn(Note note)
        +
        Objects notifying this ObjectMidiListener of a new NoteOn events call this method.
        +
        Parameters:
        note - the note object associated with this event
        +
      • +
      + + + +
        +
      • +

        noteOff

        +
        void noteOff(Note note)
        +
        Objects notifying this ObjectMidiListener of a new NoteOff events call this method.
        +
        Parameters:
        note - the note object associated with this event
        +
      • +
      + + + +
        +
      • +

        controllerChange

        +
        void controllerChange(ControlChange change)
        +
        Objects notifying this ObjectMidiListener of a new ControllerChange events call this method.
        +
        Parameters:
        change - the ControlChange object associated with this event
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/libraries/themidibus/reference/themidibus/PApplet.html b/libraries/themidibus/reference/themidibus/PApplet.html new file mode 100644 index 0000000..66e3a1c --- /dev/null +++ b/libraries/themidibus/reference/themidibus/PApplet.html @@ -0,0 +1,519 @@ + + + + + +PApplet + + + + + + + + + + + +
+
themidibus
+

Class PApplet

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • themidibus.PApplet
    • +
    +
  • +
+
+
    +
  • +
    +
    +
    public class PApplet
    +extends java.lang.Object
    +
    PApplet is your processing application or sketch. In it you can implement the following methods which will be called whenerever a MidiBus object attached to the PApplet, recieves a new incomming MIDI message of the appropriate type. +

    + Note: This page is a dummy page for documentation of the MidiBus' extention of the regular PApplet's functionality, for the full documentation of PApplet please visits the Processing javadocs

    +
    Version:
    +
    008
    +
    Author:
    +
    Severin Smith
    +
    See Also:
    MidiBus, +MidiListener, +RawMidiListener, +StandardMidiListener, +SimpleMidiListener
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      PApplet() 
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Methods 
      Modifier and TypeMethod and Description
      voidcontrollerChange(ControlChange change) +
      Is passed a ControlChange object representing controlChange event
      +
      voidcontrollerChange(int channel, + int number, + int value) +
      Is passed the channel, controller number and contoller value associated with every new ContollerChange MIDI message recieved by a MidiBus attached to this applet.
      +
      voidcontrollerChange(int channel, + int number, + int value, + long timestamp, + java.lang.String bus_name) +
      Is passed the channel, pitch and velocity associated with every new NoteOff MIDI message recieved by a MidiBus attached to this applet and the name of the MidiBus which recieved the message.
      +
      voidmidiMessage(javax.sound.midi.MidiMessage message) +
      Is passed the raw MidiMessage associated with every new MIDI message recieved by a MidiBus attached to this applet.
      +
      voidmidiMessage(javax.sound.midi.MidiMessage message, + long timestamp, + java.lang.String bus_name) +
      Is passed the raw MidiMessage associated with every new MIDI message recieved by a MidiBus attached to this applet and the name of the MidiBus which recieved the message.
      +
      voidnoteOff(int channel, + int pitch, + int velocity) +
      Is passed the channel, pitch and velocity associated with every new NoteOff MIDI message recieved by a MidiBus attached to this applet.
      +
      voidnoteOff(int channel, + int pitch, + int velocity, + long timestamp, + java.lang.String bus_name) +
      Is passed the channel, pitch and velocity associated with every new NoteOff MIDI message recieved by a MidiBus attached to this applet and the name of the MidiBus which recieved the message.
      +
      voidnoteOff(Note note) +
      Is passed a Note object representing noteOff event
      +
      voidnoteOn(int channel, + int pitch, + int velocity) +
      Is passed the channel, pitch and velocity associated with every new NoteOn MIDI message recieved by a MidiBus attached to this applet.
      +
      voidnoteOn(int channel, + int pitch, + int velocity, + long timestamp, + java.lang.String bus_name) +
      Is passed the channel, pitch and velocity associated with every new NoteOn MIDI message recieved by a MidiBus attached to this applet and the name of the MidiBus which recieved the message.
      +
      voidnoteOn(Note note) +
      Is passed a Note object representing noteOn event
      +
      voidrawMidi(byte[] data) +
      Is passed the raw data associated with every new MIDI message recieved by a MidiBus attached to this applet.
      +
      voidrawMidi(byte[] data, + long timestamp, + java.lang.String bus_name) +
      Is passed the raw data associated with every new MIDI message recieved by a MidiBus attached to this applet and the name of the MidiBus which recieved the message.
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        PApplet

        +
        public PApplet()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        controllerChange

        +
        public void controllerChange(int channel,
        +                    int number,
        +                    int value)
        +
        Is passed the channel, controller number and contoller value associated with every new ContollerChange MIDI message recieved by a MidiBus attached to this applet.
        +
        Parameters:
        channel - the channel on which the ContollerChange arrived
        number - the controller number associated with the ContollerChange
        value - the controller value associated with the ContollerChange
        See Also:
        controllerChange(int channel, int pitch, int velocity, long timestamp, String bus_name)
        +
      • +
      + + + +
        +
      • +

        controllerChange

        +
        public void controllerChange(int channel,
        +                    int number,
        +                    int value,
        +                    long timestamp,
        +                    java.lang.String bus_name)
        +
        Is passed the channel, pitch and velocity associated with every new NoteOff MIDI message recieved by a MidiBus attached to this applet and the name of the MidiBus which recieved the message.
        +
        Parameters:
        channel - the channel on which the ContollerChange arrived
        number - the controller number associated with the ContollerChange
        value - the controller value associated with the ContollerChange
        timestamp - the timestamp on the midi message
        bus_name - the name of MidiBus which recieved the ContollerChange
        See Also:
        controllerChange(int channel, int pitch, int velocity)
        +
      • +
      + + + + + + + + + + + +
        +
      • +

        midiMessage

        +
        public void midiMessage(javax.sound.midi.MidiMessage message,
        +               long timestamp,
        +               java.lang.String bus_name)
        +
        Is passed the raw MidiMessage associated with every new MIDI message recieved by a MidiBus attached to this applet and the name of the MidiBus which recieved the message.
        +
        Parameters:
        message - the MidiMessage recieved
        timestamp - the timestamp on the midi message
        bus_name - the name of MidiBus which recieved the MIDI message
        See Also:
        midiMessage(MidiMessage message)
        +
      • +
      + + + +
        +
      • +

        noteOff

        +
        public void noteOff(int channel,
        +           int pitch,
        +           int velocity)
        +
        Is passed the channel, pitch and velocity associated with every new NoteOff MIDI message recieved by a MidiBus attached to this applet.
        +
        Parameters:
        channel - the channel on which the NoteOff arrived
        pitch - the pitch associated with the NoteOff
        velocity - the velocity associated with the NoteOff
        See Also:
        noteOff(int channel, int pitch, int velocity, long timestamp, String bus_name)
        +
      • +
      + + + +
        +
      • +

        noteOff

        +
        public void noteOff(int channel,
        +           int pitch,
        +           int velocity,
        +           long timestamp,
        +           java.lang.String bus_name)
        +
        Is passed the channel, pitch and velocity associated with every new NoteOff MIDI message recieved by a MidiBus attached to this applet and the name of the MidiBus which recieved the message.
        +
        Parameters:
        channel - the channel on which the NoteOff arrived
        pitch - the pitch associated with the NoteOff
        velocity - the velocity associated with the NoteOff
        timestamp - the timestamp on the midi message
        bus_name - the name of MidiBus which recieved the NoteOff
        See Also:
        noteOff(int channel, int pitch, int velocity)
        +
      • +
      + + + + + + + +
        +
      • +

        noteOn

        +
        public void noteOn(int channel,
        +          int pitch,
        +          int velocity)
        +
        Is passed the channel, pitch and velocity associated with every new NoteOn MIDI message recieved by a MidiBus attached to this applet.
        +
        Parameters:
        channel - the channel on which the NoteOn arrived
        pitch - the pitch associated with the NoteOn
        velocity - the velocity associated with the NoteOn
        See Also:
        noteOn(int channel, int pitch, int velocity, long timestamp, String bus_name)
        +
      • +
      + + + +
        +
      • +

        noteOn

        +
        public void noteOn(int channel,
        +          int pitch,
        +          int velocity,
        +          long timestamp,
        +          java.lang.String bus_name)
        +
        Is passed the channel, pitch and velocity associated with every new NoteOn MIDI message recieved by a MidiBus attached to this applet and the name of the MidiBus which recieved the message.
        +
        Parameters:
        channel - the channel on which the NoteOn arrived
        pitch - the pitch associated with the NoteOn
        velocity - the velocity associated with the NoteOn
        timestamp - the timestamp on the midi message
        bus_name - the name of MidiBus which recieved the NoteOn
        See Also:
        noteOn(int channel, int pitch, int velocity)
        +
      • +
      + + + + + + + +
        +
      • +

        rawMidi

        +
        public void rawMidi(byte[] data)
        +
        Is passed the raw data associated with every new MIDI message recieved by a MidiBus attached to this applet.
        +
        Parameters:
        data - the raw data associated with the MIDI message
        See Also:
        rawMidi(byte[] data, long timestamp, String bus_name)
        +
      • +
      + + + +
        +
      • +

        rawMidi

        +
        public void rawMidi(byte[] data,
        +           long timestamp,
        +           java.lang.String bus_name)
        +
        Is passed the raw data associated with every new MIDI message recieved by a MidiBus attached to this applet and the name of the MidiBus which recieved the message.
        +
        Parameters:
        data - the raw data associated with the MIDI message
        timestamp - the timestamp on the midi message
        bus_name - the name of MidiBus which recieved the MIDI message
        See Also:
        rawMidi(byte[] data)
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/libraries/themidibus/reference/themidibus/RawMidiListener.html b/libraries/themidibus/reference/themidibus/RawMidiListener.html new file mode 100644 index 0000000..45f2697 --- /dev/null +++ b/libraries/themidibus/reference/themidibus/RawMidiListener.html @@ -0,0 +1,221 @@ + + + + + +RawMidiListener + + + + + + + + + + + +
+
themidibus
+

Interface RawMidiListener

+
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + +
      Methods 
      Modifier and TypeMethod and Description
      voidrawMidiMessage(byte[] data) +
      Objects notifying this RawMidiListener of a new MIDI message call this method and pass the raw message to it.
      +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        rawMidiMessage

        +
        void rawMidiMessage(byte[] data)
        +
        Objects notifying this RawMidiListener of a new MIDI message call this method and pass the raw message to it.
        +
        Parameters:
        data - the data bytes that make up the MIDI message
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/libraries/themidibus/reference/themidibus/SimpleMidiListener.html b/libraries/themidibus/reference/themidibus/SimpleMidiListener.html new file mode 100644 index 0000000..9328e5f --- /dev/null +++ b/libraries/themidibus/reference/themidibus/SimpleMidiListener.html @@ -0,0 +1,267 @@ + + + + + +SimpleMidiListener + + + + + + + + + + + +
+
themidibus
+

Interface SimpleMidiListener

+
+
+
+
    +
  • +
    +
    All Superinterfaces:
    +
    MidiListener
    +
    +
    +
    +
    public interface SimpleMidiListener
    +extends MidiListener
    +
    A SimpleMidiListener can be notified of incomming NoteOn, NoteOff and ControllerChange MIDI messages, usually by a MidiBus object which it is connected to. Typically it would analyse and react to incomming MIDI messages in some useful way.
    +
    Version:
    +
    008
    +
    Author:
    +
    Severin Smith
    +
    See Also:
    MidiListener, +RawMidiListener, +StandardMidiListener, +ObjectMidiListener, +MidiBus
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + +
      Methods 
      Modifier and TypeMethod and Description
      voidcontrollerChange(int channel, + int number, + int value) +
      Objects notifying this SimpleMidiListener of a new ControllerChange MIDI message call this method.
      +
      voidnoteOff(int channel, + int pitch, + int velocity) +
      Objects notifying this SimpleMidiListener of a new NoteOff MIDI message call this method.
      +
      voidnoteOn(int channel, + int pitch, + int velocity) +
      Objects notifying this SimpleMidiListener of a new NoteOn MIDI message call this method.
      +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        noteOn

        +
        void noteOn(int channel,
        +          int pitch,
        +          int velocity)
        +
        Objects notifying this SimpleMidiListener of a new NoteOn MIDI message call this method.
        +
        Parameters:
        channel - the channel on which the NoteOn arrived
        pitch - the pitch associated with the NoteOn
        velocity - the velocity associated with the NoteOn
        +
      • +
      + + + +
        +
      • +

        noteOff

        +
        void noteOff(int channel,
        +           int pitch,
        +           int velocity)
        +
        Objects notifying this SimpleMidiListener of a new NoteOff MIDI message call this method.
        +
        Parameters:
        channel - the channel on which the NoteOff arrived
        pitch - the pitch associated with the NoteOff
        velocity - the velocity associated with the NoteOff
        +
      • +
      + + + +
        +
      • +

        controllerChange

        +
        void controllerChange(int channel,
        +                    int number,
        +                    int value)
        +
        Objects notifying this SimpleMidiListener of a new ControllerChange MIDI message call this method.
        +
        Parameters:
        channel - the channel on which the ContollerChange arrived
        number - the controller number associated with the ContollerChange
        value - the controller value associated with the ContollerChange
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/libraries/themidibus/reference/themidibus/StandardMidiListener.html b/libraries/themidibus/reference/themidibus/StandardMidiListener.html new file mode 100644 index 0000000..203a087 --- /dev/null +++ b/libraries/themidibus/reference/themidibus/StandardMidiListener.html @@ -0,0 +1,224 @@ + + + + + +StandardMidiListener + + + + + + + + + + + +
+
themidibus
+

Interface StandardMidiListener

+
+
+
+
    +
  • +
    +
    All Superinterfaces:
    +
    MidiListener
    +
    +
    +
    +
    public interface StandardMidiListener
    +extends MidiListener
    +
    A StandardMidiListener can be notified of incomming MIDI messages in MidiMessage form, usually by a MidiBus object which it is connected to. Typically it would analyse and react to incomming MIDI messages in some useful way.
    +
    Version:
    +
    008
    +
    Author:
    +
    Severin Smith
    +
    See Also:
    MidiListener, +RawMidiListener, +SimpleMidiListener, +ObjectMidiListener, +MidiBus, +MidiMessage
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + +
      Methods 
      Modifier and TypeMethod and Description
      voidmidiMessage(javax.sound.midi.MidiMessage message, + long timeStamp) +
      Objects notifying this StandardMidiListener of a new MIDI message call this method and pass the MidiMessage
      +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        midiMessage

        +
        void midiMessage(javax.sound.midi.MidiMessage message,
        +               long timeStamp)
        +
        Objects notifying this StandardMidiListener of a new MIDI message call this method and pass the MidiMessage
        +
        Parameters:
        message - the MidiMessage received
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/libraries/themidibus/reference/themidibus/package-frame.html b/libraries/themidibus/reference/themidibus/package-frame.html new file mode 100644 index 0000000..e003db2 --- /dev/null +++ b/libraries/themidibus/reference/themidibus/package-frame.html @@ -0,0 +1,30 @@ + + + + + +themidibus + + + + +

themidibus

+ + + diff --git a/libraries/themidibus/reference/themidibus/package-summary.html b/libraries/themidibus/reference/themidibus/package-summary.html new file mode 100644 index 0000000..151ed95 --- /dev/null +++ b/libraries/themidibus/reference/themidibus/package-summary.html @@ -0,0 +1,218 @@ + + + + + +themidibus + + + + + + + + + + +
+

Package themidibus

+
+
The MidiBus provides a simple way to access and interact with installed MIDI system resources, although it's especially designed to be used with Processing, it could easily be adapted for use in any java program.
+
+

See: Description

+
+
+
    +
  • + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Interface Summary 
    InterfaceDescription
    MidiListener +
    This is a placeholder interface which makes it easier to program and manipulate objects which implement subinterfaces of MidiListener like RawMidiListener, SimpleMidiListener or StandardMidiListener.
    +
    ObjectMidiListener +
    A ObjectMidiListener can be notified of incomming NoteOn, NoteOff and ControllerChange events via Note and ControlChange objects, usually by a MidiBus object which it is connected to.
    +
    RawMidiListener +
    A RawMidiListener can be notified of incomming MIDI messages in raw form, usually by a MidiBus object which it is connect to.
    +
    SimpleMidiListener +
    A SimpleMidiListener can be notified of incomming NoteOn, NoteOff and ControllerChange MIDI messages, usually by a MidiBus object which it is connected to.
    +
    StandardMidiListener +
    A StandardMidiListener can be notified of incomming MIDI messages in MidiMessage form, usually by a MidiBus object which it is connected to.
    +
    +
  • +
  • + + + + + + + + + + + + + + + + + + + + + + + + +
    Class Summary 
    ClassDescription
    ControlChange +
    The ControlChange class represents a change in value from a controller.
    +
    MidiBus +
    The MidiBus class provides a simple way to send and receive MIDI within Processing sketches.
    +
    Note +
    The Note class represents a pressed or released key.
    +
    PApplet +
    PApplet is your processing application or sketch.
    +
    +
  • +
+ + + +

Package themidibus Description

+
The MidiBus provides a simple way to access and interact with installed MIDI system resources, although it's especially designed to be used with Processing, it could easily be adapted for use in any java program. +

+ IMPORTANT: Mac users may want to install mmj, a Mac OS X universal binary java MIDI subsystem - or an equivalent third party MIDI subsystem - because the apple implementation is lacking support for a number of advanced MIDI features. Mmj is recommended because it works, it's free and it's almost open source (CC licence). Please check README.md for more information. If you do use MMJ you will want to set MidiBus.sendTimestamps(boolean sendTimestamps) to false, otherwise messages won't be sent. +

+ Keeping with the spirit of Processing's easy to use sketching/prototyping style, the MidiBus offers a clean and simple way to get at MIDI ressources. Getting the basic functionality of the MidiBus up and running in a sketch is a matter of only a few line. The MidiBus class provides everything needed send and receive MIDI inside a sketch. To jump right into the Midibus, either refer to the paragraph titled "Typical Implementation, Simple" in the description for the MidiBus class, or check out the code examples distributed with this library. +


+ It is important to understand that the MidiBus offers little functionality that isn't available from Java's native javax.sound.midi package. Anyone interested in working with MIDI in Java should take the time to read the documentation for the javax.sound.midi. It offers a more full featured and flexible alternative to this package, although it does do so at the cost of added complexity. In addition, it may be worthwhile to skim the "official" Java Tutorial for the javax.sound.* packages. +


+

Related Documentation

+
+
Version:
+
008
+
Author:
+
Severin Smith
+
+ + + + + + diff --git a/libraries/themidibus/reference/themidibus/package-tree.html b/libraries/themidibus/reference/themidibus/package-tree.html new file mode 100644 index 0000000..a83f6cf --- /dev/null +++ b/libraries/themidibus/reference/themidibus/package-tree.html @@ -0,0 +1,134 @@ + + + + + +themidibus Class Hierarchy + + + + + + + +
+ + + + + +
+ + +
+

Hierarchy For Package themidibus

+
+
+

Class Hierarchy

+ +

Interface Hierarchy

+ +
+ +
+ + + + + +
+ + + + diff --git a/libraries/themidibus/src/themidibus/ControlChange.java b/libraries/themidibus/src/themidibus/ControlChange.java new file mode 100644 index 0000000..a83f4a7 --- /dev/null +++ b/libraries/themidibus/src/themidibus/ControlChange.java @@ -0,0 +1,162 @@ +/** + * Copyright (c) 2009 Severin Smith + * + * This file is part of a library called The MidiBus (themidibus) - http://www.smallbutdigital.com/themidibus.php. + * + * The MidiBus is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The MidiBus is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with the MidiBus. If not, see . +*/ + +package themidibus; + +/** + * The ControlChange class represents a change in value from a controller. + * + * @version 008 + * @author Severin Smith, Marc Koderer + * @see MidiBus + * @see ObjectMidiListener + * @see Note +*/ + +public class ControlChange { + + public int channel; + public int number; + public int value; + + public long timestamp; + public String bus_name; + + /** + * Constructs a ControlChange object + * + * @param channel the channel of the ControlChange + * @param number the number of the ControlChange + * @param value the value of the ControlChange + */ + public ControlChange(int channel, int number, int value) { + this(channel, number, value, -1, null); + } + + + /** + * Constructs a ControlChange object + * + * @param channel the channel of the ControlChange + * @param number the number of the ControlChange + * @param value the value of the ControlChange + * @param timestamp the timestamp of the ControlChange + * @param bus_name the name of MidiBus associated with the ControlChange + */ + public ControlChange(int channel, int number, int value, long timestamp, String bus_name) { + this.channel = channel; + this.number = number; + this.value = value; + + this.timestamp = timestamp; + this.bus_name = bus_name; + } + + /** + * Set channel of the ControlChange + * + * @param channel the channel to set + */ + public void setChannel(int channel) { + this.channel = channel; + } + + /** + * Return the channel of the ControlChange + * + * @return the channel + */ + public int channel() { + return channel; + } + + /** + * Set number of the ControlChange + * + * @param number the number to set + */ + public void setNumber(int number) { + this.number = number; + } + + /** + * Return the number of the ControlChange + * + * @return the number + */ + public int number() { + return number; + } + + /** + * Set value of the ControlChange + * + * @param value the value to set + */ + public void setValue(int value) { + this.value = value; + } + + /** + * Return the value of the ControlChange + * + * @return the value + */ + public int value() { + return value; + } + + /** + * Returns a string in the format [c:channel, n:number, v:value, ts:timestamp, b:bus_name] e.g "[c:0, n:65, v:123, ts:1234, b:bus123]". If timestamp or bus_name isn't set, it is omitted. + * + * @return the string representation + */ + public String toString() { + String result = "[c:" + channel + ", v:" + number + ", n:" + value; + if(timestamp != -1) result += ", ts:" + timestamp; + if(bus_name != null) result += ", b:" + bus_name; + result += "]"; + + return result; + } + + /** + * Check if all fields are equal. + * + * @return true if both objects can be considered to be equals + */ + public boolean equals(Object obj) { + if(this == obj) return true; + if(obj == null) return false; + + if(getClass() != obj.getClass()) return false; + + ControlChange other = (ControlChange)obj; + + if(other.channel != this.channel) return false; + if(other.number != this.number) return false; + if(other.value != this.value) return false; + + if(other.timestamp != this.timestamp) return false; + if(other.bus_name != this.bus_name) return false; + + return true; + } + +} diff --git a/libraries/themidibus/src/themidibus/MidiBus.java b/libraries/themidibus/src/themidibus/MidiBus.java new file mode 100644 index 0000000..0ae3aa8 --- /dev/null +++ b/libraries/themidibus/src/themidibus/MidiBus.java @@ -0,0 +1,1783 @@ +/** + * Copyright (c) 2009 Severin Smith + * + * This file is part of a library called The MidiBus (themidibus) - http://www.smallbutdigital.com/themidibus.php. + * + * The MidiBus is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * The MidiBus is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with the MidiBus. If not, see . +*/ + +package themidibus; + +import javax.sound.midi.*; +import java.util.Vector; +import java.util.Formatter; + +import processing.core.PApplet; +import java.lang.reflect.Method; + +/** + * The MidiBus class provides a simple way to send and receive MIDI within Processing sketches. + *

+ *

Typical Implementation, Simple

+ *

+ * A typical simple Processing MIDI application would begin by invoking the static method {@link #list()} to learn what devices are available. Then using that information a new MidiBus object would be instantiated with with the desired MIDI input and/or output devices. The Processing sketch could then send midi via MidiBus's outgoing methods such as {@link #sendNoteOn(int channel, int pitch, int velocity)}, {@link #sendNoteOff(int channel, int pitch, int velocity)} and {@link #sendControllerChange(int channel, int number, int value)} and receive midi via the PApplet methods this package provides support for such as {@link PApplet#noteOn(int channel, int pitch, int velocity)}, {@link PApplet#noteOff(int channel, int pitch, int velocity)} and {@link PApplet#controllerChange(int channel, int number, int value)}. + *

Typical Implementation, Advanced

+ *

+ * If you wish to build more complex Processing MIDI applications you can add more input and output devices to any given instance of MidiBus via the addInput() and addOutput() methods. However it is important to understand that each MidiBus object acts like 2 MIDI buses, one for input and one for output. This means, that by design, outgoing MIDI messages are sent to all output devices connected to a given instance of MidiBus, and incomming messages from all input devices connected to a given instance of MidiBus are merged upon reception. In practice, this means that, by design, you cannot tell which of the devices connected to a given instance of MidiBus sent a particular message, nor can you send a MIDI message to one particular device connected to that object. Instead, for independent reception/transmission to different sets of MIDI devices, you can instantiate more than one MidiBus object inside your Processing sketch. Each instance of MidiBus will only send MIDI messages to output devices which are connected to it and inbound MIDI messages arriving at each MidiBus can be diferentiated using the the {@link PApplet} methods with the bus_name parameter. + * + * @version 008 + * @author Severin Smith + * @see PApplet + * @see MidiListener + * @see RawMidiListener + * @see StandardMidiListener + * @see SimpleMidiListener +*/ +public class MidiBus { + + static MidiDevice.Info[] available_devices; + + String bus_name; + + Vector input_devices; + Vector output_devices; + + Vector listeners; + + Object parent; + + Method method_note_on, method_note_off, method_controller_change, method_raw_midi, method_midi_message; + Method method_note_on_with_bus_name, method_note_off_with_bus_name, method_controller_change_with_bus_name, method_raw_midi_with_bus_name, method_midi_message_with_bus_name; + Method method_note_on_wcla, method_note_off_wcla, method_controller_change_wcla; + + boolean sendTimestamps; + + /* -- Constructors -- */ + + /** + * Constructs a new Midibus. The new Midibus's bus_name will be generated automatically. + * + * @see #addInput(int device_num) + * @see #addInput(String device_name) + * @see #addOutput(int device_num) + * @see #addOutput(String device_name) + * @see #list() + */ + public MidiBus() { + init(null, null); + } + + /** + * Constructs a new MidiBus and registers the specified parent (PApplet or other) for callbacks. No input or output MIDI devices will be opened. The new MidiBus's bus_name will be generated automatically. + * + * @param parent the parent to which this MidiBus is attached. + * @see #addInput(int device_num) + * @see #addInput(String device_name) + * @see #addOutput(int device_num) + * @see #addOutput(String device_name) + * @see #list() + */ + public MidiBus(Object parent) { + init(parent, null); + } + + /** + * Constructs a new MidiBus with the specified bus_name and registers the specified parent (PApplet or other) for callbacks. No input or output MIDI devices will be opened. + * + * @param parent the parent to which this MidiBus is attached. + * @param bus_name the String which which identifies this MidiBus. + * @see #addInput(int device_num) + * @see #addInput(String device_name) + * @see #addOutput(int device_num) + * @see #addOutput(String device_name) + * @see #list() + */ + public MidiBus(Object parent, String bus_name) { + init(parent, bus_name); + } + + /** + * Constructs a new MidiBus and registers the specified parent (PApplet or other) for callbacks. Opens the MIDI input and output devices specified by the indexes in_device_num and out_device_num. A value of -1 can be passed to in_device_num if no input MIDI device is to be opened, or to out_device_num if no output MIDI device is to be opened. The new MidiBus's bus_name will be generated automatically. + * + * @param parent the parent to which this MidiBus is attached. + * @param in_device_num the index of the MIDI input device to be opened. + * @param out_device_num the index of the MIDI output device to be opened. + * @see #addInput(int device_num) + * @see #addInput(String device_name) + * @see #addOutput(int device_num) + * @see #addOutput(String device_name) + * @see #list() + */ + public MidiBus(Object parent, int in_device_num, int out_device_num) { + init(parent, null); + addInput(in_device_num); + addOutput(out_device_num); + } + + /** + * Constructs a new MidiBus with the specified bus_name and registers the specified parent (PApplet or other) for callbacks. Opens the MIDI input and output devices specified by the indexes in_device_num and out_device_num. A value of -1 can be passed to in_device_num if no input MIDI device is to be opened, or to out_device_num if no output MIDI device is to be opened. + * + * @param parent the parent to which this MidiBus is attached. + * @param in_device_num the index of the MIDI input device to be opened. + * @param out_device_num the index of the MIDI output device to be opened. + * @param bus_name the String which which identifies this MidiBus. + * @see #addInput(int device_num) + * @see #addInput(String device_name) + * @see #addOutput(int device_num) + * @see #addOutput(String device_name) + * @see #list() + */ + public MidiBus(Object parent, int in_device_num, int out_device_num, String bus_name) { + init(parent, bus_name); + addInput(in_device_num); + addOutput(out_device_num); + } + + /** + * Constructs a new MidiBus and registers the specified parent (PApplet or other) for callbacks. Opens the MIDI input and output devices specified by the names in_device_name and out_device_name. An empty String can be passed to in_device_name if no input MIDI device is to be opened, or to out_device_name if no output MIDI device is to be opened. The new MidiBus's bus_name will be generated automatically. + *

+ * If two or more MIDI inputs have the same name, whichever appears first when {@link #list()} is called will be added, simlarly for two or more MIDI outputs with the same name. If this behavior is problematic use {@link #MidiBus(Object parent, int in_device_num, int out_device_num)} instead. + * + * @param parent the parent to which this MidiBus is attached. + * @param in_device_name the name of the MIDI input device to be opened. + * @param out_device_name the name of the MIDI output device to be opened. + * @see #addInput(int device_num) + * @see #addInput(String device_name) + * @see #addOutput(int device_num) + * @see #addOutput(String device_name) + * @see #list() + */ + public MidiBus(Object parent, String in_device_name, String out_device_name) { + init(parent, null); + addInput(in_device_name); + addOutput(out_device_name); + } + + /** + * Constructs a new MidiBus with the specified bus_name and registers the specified parent (PApplet or other) for callbacks. Opens the MIDI input and output devices specified by the names out_device_name and out_device_name. An empty String can be passed to in_device_name if no input MIDI device is to be opened, or to out_device_name if no output MIDI device is to be opened. + *

+ * If two or more MIDI inputs have the same name, whichever appears first when {@link #list()} is called will be added, simlarly for two or more MIDI outputs with the same name. If this behavior is problematic use {@link #MidiBus(Object parent, int in_device_num, int out_device_num, String bus_name)} instead. + * + * @param parent the parent to which this MidiBus is attached. + * @param in_device_name the name of the MIDI input device to be opened. + * @param out_device_name the name of the MIDI output device to be opened. + * @param bus_name the String which which identifies this MidiBus. + * @see #addInput(int device_num) + * @see #addInput(String device_name) + * @see #addOutput(int device_num) + * @see #addOutput(String device_name) + * @see #list() + */ + public MidiBus(Object parent, String in_device_name, String out_device_name, String bus_name) { + init(parent, bus_name); + addInput(in_device_name); + addOutput(out_device_name); + } + + /* -- Yet even more delicious constructor flavors -- */ + + /** + * More flavors of constructor, similar to the others, but with mixed arguments + * + * @param parent the parent to which this MidiBus is attached. + * @param in_device_num the name of the MIDI input device to be opened. + * @param out_device_name the name of the MIDI output device to be opened. + * @see #addInput(int device_num) + * @see #addInput(String device_name) + * @see #addOutput(int device_num) + * @see #addOutput(String device_name) + * @see #list() + */ + public MidiBus(Object parent, int in_device_num, String out_device_name) { + init(parent, null); + addInput(in_device_num); + addOutput(out_device_name); + } + + /** + * More flavors of constructor, similar to the others, but with mixed arguments + * + * @param parent the parent to which this MidiBus is attached. + * @param in_device_num the name of the MIDI input device to be opened. + * @param out_device_name the name of the MIDI output device to be opened. + * @param bus_name the String which which identifies this MidiBus. + * @see #addInput(int device_num) + * @see #addInput(String device_name) + * @see #addOutput(int device_num) + * @see #addOutput(String device_name) + * @see #list() + */ + public MidiBus(Object parent, int in_device_num, String out_device_name, String bus_name) { + init(parent, bus_name); + addInput(in_device_num); + addOutput(out_device_name); + } + + /** + * More flavors of constructor, similar to the others, but with mixed arguments + * + * @param parent the parent to which this MidiBus is attached. + * @param in_device_name the name of the MIDI input device to be opened. + * @param out_device_num the name of the MIDI output device to be opened. + * @see #addInput(int device_num) + * @see #addInput(String device_name) + * @see #addOutput(int device_num) + * @see #addOutput(String device_name) + * @see #list() + */ + public MidiBus(Object parent, String in_device_name, int out_device_num) { + init(parent, null); + addInput(in_device_name); + addOutput(out_device_num); + } + + /** + * More flavors of constructor, similar to the others, but with mixed arguments + * + * @param parent the parent to which this MidiBus is attached. + * @param in_device_name the name of the MIDI input device to be opened. + * @param out_device_num the name of the MIDI output device to be opened. + * @param bus_name the String which which identifies this MidiBus. + * @see #addInput(int device_num) + * @see #addInput(String device_name) + * @see #addOutput(int device_num) + * @see #addOutput(String device_name) + * @see #list() + */ + public MidiBus(Object parent, String in_device_name, int out_device_num, String bus_name) { + init(parent, bus_name); + addInput(in_device_name); + addOutput(out_device_num); + } + + /* -- Constructor Functions -- */ + + /** + * Perfoms the initialisation of new MidiBus objects, is private for a reason, and is only ever called within the constructors. This method exists only for the purpose of cleaner and easier to maintain code. + * Creates a new (hopefully/probably) unique bus_name value for new MidiBus objects that weren't given one. + * If two MidiBus object were to have the same name, this would be bad, but not fatal, so there's no point in spending too much time worrying about it. + */ + private void init(Object parent, String bus_name) { + registerParent(parent); + + /* -- */ + + if(bus_name == null) { + generateBusName(); + } else { + this.bus_name = bus_name; + } + + /* -- */ + + input_devices = new Vector(); + output_devices = new Vector(); + + listeners = new Vector(); + + sendTimestamps = true; + } + + /* -- Input/Output Handling -- */ + + /** + * Returns the names of all the attached input devices. + * + * @return the names of the attached inputs. + * @see #attachedOutputs() + */ + public String[] attachedInputs() { + MidiDevice.Info[] devices_info = attachedInputsMidiDeviceInfo(); + String[] devices = new String[devices_info.length]; + + for(int i = 0;i < devices_info.length;i++) { + devices[i] = devices_info[i].getName(); + } + + return devices; + } + + /** + * Returns the names of all the attached output devices. + * + * @return the names of the attached outputs. + * @see #attachedInputs() + */ + public String[] attachedOutputs() { + MidiDevice.Info[] devices_info = attachedOutputsMidiDeviceInfo(); + String[] devices = new String[devices_info.length]; + + for(int i = 0;i < devices_info.length;i++) { + devices[i] = devices_info[i].getName(); + } + + return devices; + } + + /** + * Returns the MidiDevice.Info of all the attached input devices. + * + * @return the MidiDevice.Info of the attached inputs. + */ + MidiDevice.Info[] attachedInputsMidiDeviceInfo() { + MidiDevice.Info[] devices = new MidiDevice.Info[input_devices.size()]; + + for(int i = 0;i < input_devices.size();i++) { + devices[i] = input_devices.get(i).info; + } + + return devices; + } + + /** + * Returns the MidiDevice.Info of all the attached output devices. + * + * @return the MidiDevice.Info of the attached outputs. + */ + MidiDevice.Info[] attachedOutputsMidiDeviceInfo() { + MidiDevice.Info[] devices = new MidiDevice.Info[output_devices.size()]; + + for(int i = 0;i < output_devices.size();i++) { + devices[i] = output_devices.get(i).info; + } + + return devices; + } + + /** + * Adds a new MIDI input device specified by the index device_num. If the MIDI input device has already been added, it will not be added again. + * + * @param device_num the index of the MIDI input device to be added. + * @return true if and only if the input device was successfully added. + * @see #addInput(String device_name) + * @see #list() + */ + public boolean addInput(int device_num) { + if(device_num == -1) return false; + + MidiDevice.Info[] devices = availableInputsMidiDeviceInfo(); + + if(device_num >= devices.length || device_num < 0) { + System.err.println("\nThe MidiBus Warning: The chosen input device numbered ["+device_num+"] was not added because it doesn't exist"); + return false; + } + + return addInput(devices[device_num]); + } + + + /** + * Removes the MIDI input device specified by the index device_num. + * + * @param device_num the index of the MIDI input device to be removed. + * @return true if and only if the input device was successfully removed. + * @see #removeInput(String device_name) + * @see #attachedInputs() + */ + public synchronized boolean removeInput(int device_num) { + try { + InputDeviceContainer container = input_devices.get(device_num); + + input_devices.remove(container); + + container.transmitter.close(); + container.receiver.close(); + + return true; + } catch(ArrayIndexOutOfBoundsException e) { + return false; + } + } + + /** + * Adds a new MIDI input device specified by the name device_name. If the MIDI input device has already been added, it will not be added again. + *

+ * If two or more MIDI inputs have the same name, whichever appears first when {@link #list()} is called will be added. If this behavior is problematic use {@link #addInput(int device_num)} instead. + * + * @param device_name the name of the MIDI input device to be added. + * @return true if and only if the input device was successfully added. + * @see #addInput(int device_num) + * @see #list() + */ + public boolean addInput(String device_name) { + if(device_name.equals("")) return false; + + MidiDevice.Info[] devices = availableInputsMidiDeviceInfo(); + + for(int i = 0;i < devices.length;i++) { + if(devices[i].getName().equals(device_name)) return addInput(devices[i]); + } + + System.err.println("\nThe MidiBus Warning: No available input MIDI devices named: \""+device_name+"\" were found"); + return false; + } + + /** + * Removes the MIDI input device specified by the name device_name. + *

+ * If two or more attached MIDI inputs have the same name, whichever appears first when {@link #attachedInputs()} is called will be removed. If this behavior is problematic use {@link #removeInput(int device_num)} instead. + * + * @param device_name the name of the MIDI input device to be removed. + * @return true if and only if the input device was successfully removed. + * @see #removeInput(int device_num) + * @see #attachedInputs() + */ + public synchronized boolean removeInput(String device_name) { + for(InputDeviceContainer container : input_devices) { + if(container.info.getName().equals(device_name)) { + input_devices.remove(container); + + container.transmitter.close(); + container.receiver.close(); + + return true; + } + } + return false; + } + + /** + * Adds a new MIDI input device specified by the MidiDevice.Info device_info. If the MIDI input device has already been added, it will not be added again. + * + * @param device_info the MidiDevice.Info of the MIDI input device to be added. + * @return true if and only if the input device was successfully added. + */ + synchronized boolean addInput(MidiDevice.Info device_info) { + try { + MidiDevice new_device = MidiSystem.getMidiDevice(device_info); + + if(new_device.getMaxTransmitters() == 0) { + System.err.println("\nThe MidiBus Warning: The chosen input device \""+device_info.getName()+"\" was not added because it is output only"); + return false; + } + + for(InputDeviceContainer container : input_devices) { + if(device_info.getName().equals(container.info.getName())) return false; + } + + if(!new_device.isOpen()) new_device.open(); + + MReceiver receiver = new MReceiver(); + Transmitter transmitter = new_device.getTransmitter(); + transmitter.setReceiver(receiver); + + InputDeviceContainer new_container = new InputDeviceContainer(new_device); + new_container.transmitter = transmitter; + new_container.receiver = receiver; + + input_devices.add(new_container); + + return true; + } catch(MidiUnavailableException e) { + System.err.println("\nThe MidiBus Warning: The chosen input device \""+device_info.getName()+"\" was not added because it is unavailable"); + return false; + } + } + + /** + * Adds a new MIDI output device specified by the index device_num. If the MIDI output device has already been added, it will not be added again. + * + * @param device_num the index of the MIDI output device to be added. + * @return true if and only if the output device was successfully added. + * @see #addOutput(String device_name) + * @see #list() + */ + public boolean addOutput(int device_num) { + if(device_num == -1) return false; + + MidiDevice.Info[] devices = availableOutputsMidiDeviceInfo(); + + if(device_num >= devices.length || device_num < 0) { + System.err.println("\nThe MidiBus Warning: The chosen output device numbered ["+device_num+"] was not added because it doesn't exist"); + return false; + } + + return addOutput(devices[device_num]); + } + + /** + * Removes the MIDI output device specified by the index device_num. + * + * @param device_num the index of the MIDI output device to be removed. + * @return true if and only if the output device was successfully removed. + * @see #removeInput(String device_name) + * @see #attachedOutputs() + */ + public synchronized boolean removeOutput(int device_num) { + try { + OutputDeviceContainer container = output_devices.get(device_num); + + output_devices.remove(container); + + container.receiver.close(); + + return true; + } catch(ArrayIndexOutOfBoundsException e) { + return false; + } + } + + /** + * Adds a new MIDI output device specified by the name device_name. If the MIDI output device has already been added, it will not be added again. + *

+ * If two or more MIDI outputs have the same name, whichever appears first when {@link #list()} is called will be added. If this behavior is problematic use {@link #addOutput(int device_num)} instead. + * + * @param device_name the name of the MIDI output device to be added. + * @return true if and only if the output device was successfully added. + * @see #addOutput(int device_num) + * @see #list() + */ + public boolean addOutput(String device_name) { + if(device_name.equals("")) return false; + + MidiDevice.Info[] devices = availableOutputsMidiDeviceInfo(); + + for(int i = 0;i < devices.length;i++) { + if(devices[i].getName().equals(device_name)) return addOutput(devices[i]); + } + + System.err.println("\nThe MidiBus Warning: No available input MIDI devices named: \""+device_name+"\" were found"); + return false; + } + + /** + * Removes the MIDI output device specified by the name device_name. + *

+ * If two or more attached MIDI outputs have the same name, whichever appears first when {@link #attachedOutputs()} is called will be removed. If this behavior is problematic use {@link #removeOutput(int device_num)} instead. + * + * @param device_name the name of the MIDI output device to be removed. + * @return true if and only if the output device was successfully removed. + * @see #removeOutput(int device_num) + * @see #attachedOutputs() + */ + public synchronized boolean removeOutput(String device_name) { + for(OutputDeviceContainer container : output_devices) { + if(container.info.getName().equals(device_name)) { + output_devices.remove(container); + + container.receiver.close(); + + return true; + } + } + return false; + } + + /** + * Adds a new MIDI output device specified by the MidiDevice.Info device_info. If the MIDI output device has already been added, it will not be added again. + * + * @param device_info the MidiDevice.Info of the MIDI output device to be added. + * @return true if and only if the input device was successfully added. + */ + synchronized boolean addOutput(MidiDevice.Info device_info) { + try { + MidiDevice new_device = MidiSystem.getMidiDevice(device_info); + + if(new_device.getMaxReceivers() == 0) { + System.err.println("\nThe MidiBus Warning: The chosen output device \""+device_info.getName()+"\" was not added because it is input only"); + return false; + } + + for(OutputDeviceContainer container : output_devices) { + if(device_info.getName().equals(container.info.getName())) return false; + } + + if(!new_device.isOpen()) new_device.open(); + + OutputDeviceContainer new_container = new OutputDeviceContainer(new_device); + new_container.receiver = new_device.getReceiver(); + + output_devices.add(new_container); + + return true; + } catch(MidiUnavailableException e) { + System.err.println("\nThe MidiBus Warning: The chosen output device \""+device_info.getName()+"\" was not added because it is unavailable"); + return false; + } + } + + /** + * Closes, clears and disposes of all input related Transmitters and Receivers. + * + * @see #clearOutputs() + * @see #clearAll() + */ + public synchronized void clearInputs() { + //We are purposefully not closing devices here, because in some cases that will be slow, and we might want later + //Also it's broken on MAC + try{ + for(InputDeviceContainer container : input_devices) { + container.transmitter.close(); + container.receiver.close(); + } + } catch(Exception e) { + System.err.println("The MidiBus Warning: Unexpected error during clearInputs()"); + } + + input_devices.clear(); + } + + /** + * Closes, clears and disposes of all output related Receivers. + * + * @see #clearInputs() + * @see #clearAll() + */ + public synchronized void clearOutputs() { + //We are purposefully not closing devices here, because in some cases that will be slow, and we might want later + //Also it's broken on MAC + try{ + for(OutputDeviceContainer container : output_devices) { + container.receiver.close(); + } + } catch(Exception e) { + System.err.println("The MidiBus Warning: Unexpected error during clearOutputs()"); + } + + output_devices.clear(); + } + + /** + * Closes, clears and disposes of all input and output related Transmitters and Receivers. + * + * @see #clearInputs() + * @see #clearOutputs() + */ + public void clearAll() { + clearInputs(); + clearOutputs(); + } + + /** + * Closes all MidiDevices, should only be called when closing the application, will interrupt all MIDI I/O. Call publicly from stop(), close() or dispose() + * + * @see #clearOutputs() + * @see #clearInputs() + * @see #clearAll() + * @see #stop() + * @see #close() + * @see #dispose() + */ + void closeAllMidiDevices() { + if(MidiBus.available_devices == null) findMidiDevices(); + MidiDevice device; + + for(int i = 0;i < MidiBus.available_devices.length;i++) { + try { + device = MidiSystem.getMidiDevice(MidiBus.available_devices[i]); + if(device.isOpen()) device.close(); + } catch(MidiUnavailableException e) { + //Device wasn't available, which is fine since we wanted to close it anyways + } + } + + } + + /* -- MIDI Out -- */ + + /** + * Sends a MIDI message with an unspecified number of bytes. The first byte should be always be the status byte. If the message is a Meta message of a System Exclusive message it can have more than 3 byte, otherwise all extra bytes will be dropped. + * + * @param data the bytes of the MIDI message. + * @see #sendMessage(int status) + * @see #sendMessage(int status, int data) + * @see #sendMessage(int status, int data1, int data2) + * @see #sendMessage(int command, int channel, int data1, int data2) + * @see #sendMessage(MidiMessage message) + * @see #sendNoteOn(int channel, int pitch, int velocity) + * @see #sendNoteOn(Note note) + * @see #sendNoteOff(int channel, int pitch, int velocity) + * @see #sendNoteOff(Note note) + * @see #sendControllerChange(int channel, int number, int value) + * @see #sendControllerChange(ControlChange change) + */ + public void sendMessage(byte[] data) { + if((int)((byte)data[0] & 0xFF) == MetaMessage.META) { + MetaMessage message = new MetaMessage(); + try { + byte[] payload = new byte[data.length-2]; + System.arraycopy(data, 2, payload, 0, data.length-2); + message.setMessage((int)((byte)data[1] & 0xFF), payload, data.length-2); + sendMessage(message); + } catch(InvalidMidiDataException e) { + System.err.println("\nThe MidiBus Warning: Message not sent, invalid MIDI data"); + } + } else if((int)((byte)data[0] & 0xFF) == SysexMessage.SYSTEM_EXCLUSIVE || (int)((byte)data[0] & 0xFF) == SysexMessage.SPECIAL_SYSTEM_EXCLUSIVE) { + SysexMessage message = new SysexMessage(); + try { + message.setMessage(data, data.length); + sendMessage(message); + } catch(InvalidMidiDataException e) { + System.err.println("\nThe MidiBus Warning: Message not sent, invalid MIDI data"); + } + } else { + ShortMessage message = new ShortMessage(); + try { + if(data.length > 2) message.setMessage((int)((byte)data[0] & 0xFF), (int)((byte)data[1] & 0xFF), (int)((byte)data[2] & 0xFF)); + else if(data.length > 1) message.setMessage((int)((byte)data[0] & 0xFF), (int)((byte)data[1] & 0xFF), 0); + else message.setMessage((int)((byte)data[0] & 0xFF)); + sendMessage(message); + } catch(InvalidMidiDataException e) { + System.err.println("\nThe MidiBus Warning: Message not sent, invalid MIDI data"); + } + } + } + + /** + * Sends a MIDI message that takes no data bytes. + * + * @param status the status byte + * @see #sendMessage(byte[] data) + * @see #sendMessage(int status, int data) + * @see #sendMessage(int status, int data1, int data2) + * @see #sendMessage(int command, int channel, int data1, int data2) + * @see #sendMessage(MidiMessage message) + * @see #sendNoteOn(int channel, int pitch, int velocity) + * @see #sendNoteOn(Note note) + * @see #sendNoteOff(int channel, int pitch, int velocity) + * @see #sendNoteOff(Note note) + * @see #sendControllerChange(int channel, int number, int value) + * @see #sendControllerChange(ControlChange change) + */ + public void sendMessage(int status) { + ShortMessage message = new ShortMessage(); + try { + message.setMessage(status); + sendMessage(message); + } catch(InvalidMidiDataException e) { + System.out.println(e); + System.err.println("\nThe MidiBus Warning: Message not sent, invalid MIDI data"); + } + } + + /** + * Sends a MIDI message that takes only one data byte. If the message does not take data, the data byte is ignored. + * + * @param status the status byte + * @param data the data byte + * @see #sendMessage(byte[] data) + * @see #sendMessage(int status) + * @see #sendMessage(int status, int data1, int data2) + * @see #sendMessage(int command, int channel, int data1, int data2) + * @see #sendMessage(MidiMessage message) + * @see #sendNoteOn(int channel, int pitch, int velocity) + * @see #sendNoteOn(Note note) + * @see #sendNoteOff(int channel, int pitch, int velocity) + * @see #sendNoteOff(Note note) + * @see #sendControllerChange(int channel, int number, int value) + * @see #sendControllerChange(ControlChange change) + */ + public void sendMessage(int status, int data) { + sendMessage(status, data, 0); + } + + /** + * Sends a MIDI message that takes one or two data bytes. If the message takes only one data byte, the second data byte is ignored; if the message does not take any data bytes, both data bytes are ignored. + * + * @param status the status byte. + * @param data1 the first data byte. + * @param data2 the second data byte. + * @see #sendMessage(byte[] data) + * @see #sendMessage(int status) + * @see #sendMessage(int status, int data) + * @see #sendMessage(int command, int channel, int data1, int data2) + * @see #sendMessage(MidiMessage message) + * @see #sendNoteOn(int channel, int pitch, int velocity) + * @see #sendNoteOn(Note note) + * @see #sendNoteOff(int channel, int pitch, int velocity) + * @see #sendNoteOff(Note note) + * @see #sendControllerChange(int channel, int number, int value) + * @see #sendControllerChange(ControlChange change) + */ + public void sendMessage(int status, int data1, int data2) { + ShortMessage message = new ShortMessage(); + try { + message.setMessage(status, data1, data2); + sendMessage(message); + } catch(InvalidMidiDataException e) { + System.err.println("\nThe MidiBus Warning: Message not sent, invalid MIDI data"); + } + } + + /** + * Sends a channel message which takes up to two data bytes. If the message only takes one data byte, the second data byte is ignored; if the message does not take any data bytes, both data bytes are ignored. + * + * @param command the MIDI command represented by this message. + * @param channel the channel associated with the message. + * @param data1 the first data byte. + * @param data2 the second data byte. + * @see #sendMessage(byte[] data) + * @see #sendMessage(int status) + * @see #sendMessage(int status, int data) + * @see #sendMessage(int status, int data1, int data2) + * @see #sendMessage(MidiMessage message) + * @see #sendNoteOn(int channel, int pitch, int velocity) + * @see #sendNoteOn(Note note) + * @see #sendNoteOff(int channel, int pitch, int velocity) + * @see #sendNoteOff(Note note) + * @see #sendControllerChange(int channel, int number, int value) + * @see #sendControllerChange(ControlChange change) + */ + public void sendMessage(int command, int channel, int data1, int data2) { + ShortMessage message = new ShortMessage(); + try { + message.setMessage(command, channel, data1, data2); + sendMessage(message); + } catch(InvalidMidiDataException e) { + System.err.println("\nThe MidiBus Warning: Message not sent, invalid MIDI data"); + } + } + + /** + * Sends a MidiMessage object. + * + * @param message the MidiMessage. + * @see #sendMessage(byte[] data) + * @see #sendMessage(int status) + * @see #sendMessage(int status, int data) + * @see #sendMessage(int status, int data1, int data2) + * @see #sendMessage(int command, int channel, int data1, int data2) + * @see #sendNoteOn(int channel, int pitch, int velocity) + * @see #sendNoteOn(Note note) + * @see #sendNoteOff(int channel, int pitch, int velocity) + * @see #sendNoteOff(Note note) + * @see #sendControllerChange(int channel, int number, int value) + * @see #sendControllerChange(ControlChange change) + */ + public synchronized void sendMessage(MidiMessage message) { + for(OutputDeviceContainer container : output_devices) { + if(sendTimestamps) container.receiver.send(message, System.currentTimeMillis()); + else container.receiver.send(message, 0); + } + } + + /** + * Sends a NoteOn message to a channel with the specified pitch and velocity. + * + * @param channel the channel associated with the message. + * @param pitch the pitch associated with the message. + * @param velocity the velocity associated with the message. + * @see #sendMessage(byte[] data) + * @see #sendMessage(int status) + * @see #sendMessage(int status, int data) + * @see #sendMessage(int status, int data1, int data2) + * @see #sendMessage(int command, int channel, int data1, int data2) + * @see #sendMessage(MidiMessage message) + * @see #sendNoteOn(Note note) + * @see #sendNoteOff(int channel, int pitch, int velocity) + * @see #sendNoteOff(Note note) + * @see #sendControllerChange(int channel, int number, int value) + * @see #sendControllerChange(ControlChange change) + * + */ + public void sendNoteOn(int channel, int pitch, int velocity) { + ShortMessage message = new ShortMessage(); + try { + message.setMessage(ShortMessage.NOTE_ON, constrain(channel,0,15), constrain(pitch,0,127), constrain(velocity,0,127)); + sendMessage(message); + } catch(InvalidMidiDataException e) { + System.err.println("\nThe MidiBus Warning: Message not sent, invalid MIDI data"); + } + } + + /** + * Sends a NoteOn message to a channel with the specified Note. + * + * @param note the Note object for the message. + * @see #sendMessage(byte[] data) + * @see #sendMessage(int status) + * @see #sendMessage(int status, int data) + * @see #sendMessage(int status, int data1, int data2) + * @see #sendMessage(int command, int channel, int data1, int data2) + * @see #sendMessage(MidiMessage message) + * @see #sendNoteOn(int channel, int pitch, int velocity) + * @see #sendNoteOff(int channel, int pitch, int velocity) + * @see #sendNoteOff(Note note) + * @see #sendControllerChange(int channel, int number, int value) + * @see #sendControllerChange(ControlChange change) + */ + public void sendNoteOn(Note note) { + sendNoteOn(note.channel(), note.pitch(), note.velocity()); + } + + /** + * Sends a NoteOff message to a channel with the specified pitch and velocity. + * + * @param channel the channel associated with the message. + * @param pitch the pitch associated with the message. + * @param velocity the velocity associated with the message. + * @see #sendMessage(byte[] data) + * @see #sendMessage(int status) + * @see #sendMessage(int status, int data) + * @see #sendMessage(int status, int data1, int data2) + * @see #sendMessage(int command, int channel, int data1, int data2) + * @see #sendMessage(MidiMessage message) + * @see #sendNoteOn(int channel, int pitch, int velocity) + * @see #sendNoteOn(Note note) + * @see #sendNoteOff(Note note) + * @see #sendControllerChange(int channel, int number, int value) + * @see #sendControllerChange(ControlChange change) + */ + public void sendNoteOff(int channel, int pitch, int velocity) { + ShortMessage message = new ShortMessage(); + try { + message.setMessage(ShortMessage.NOTE_OFF, constrain(channel,0,15), constrain(pitch,0,127), constrain(velocity,0,127)); + sendMessage(message); + } catch(InvalidMidiDataException e) { + System.err.println("\nThe MidiBus Warning: Message not sent, invalid MIDI data"); + } + } + + /** + * Sends a NoteOff message to a channel with the specified Note. + * + * @param note the Note object for the message. + * @see #sendMessage(byte[] data) + * @see #sendMessage(int status) + * @see #sendMessage(int status, int data) + * @see #sendMessage(int status, int data1, int data2) + * @see #sendMessage(int command, int channel, int data1, int data2) + * @see #sendMessage(MidiMessage message) + * @see #sendNoteOn(int channel, int pitch, int velocity) + * @see #sendNoteOn(Note note) + * @see #sendNoteOff(int channel, int pitch, int velocity) + * @see #sendControllerChange(int channel, int number, int value) + * @see #sendControllerChange(ControlChange change) + */ + public void sendNoteOff(Note note) { + sendNoteOff(note.channel, note.pitch(), note.velocity()); + } + + /** + * Sends a ControllerChange message to a channel with the specified number and value. + * + * @param channel the channel associated with the message. + * @param number the number associated with the message. + * @param value the value associated with the message. + * @see #sendMessage(byte[] data) + * @see #sendMessage(int status) + * @see #sendMessage(int status, int data) + * @see #sendMessage(int status, int data1, int data2) + * @see #sendMessage(int command, int channel, int data1, int data2) + * @see #sendMessage(MidiMessage message) + * @see #sendNoteOn(int channel, int pitch, int velocity) + * @see #sendNoteOn(Note note) + * @see #sendNoteOff(int channel, int pitch, int velocity) + * @see #sendNoteOff(Note note) + * @see #sendControllerChange(ControlChange change) + */ + public void sendControllerChange(int channel, int number, int value) { + ShortMessage message = new ShortMessage(); + try { + message.setMessage(ShortMessage.CONTROL_CHANGE, constrain(channel,0,15), constrain(number,0,127), constrain(value,0,127)); + sendMessage(message); + } catch(InvalidMidiDataException e) { + System.err.println("\nThe MidiBus Warning: Message not sent, invalid MIDI data"); + } + } + + /** + * Sends a ControllerChange message to a channel with the specified ControlChange. + * + * @param change the ControlChange object for the message. + * @see #sendMessage(byte[] data) + * @see #sendMessage(int status) + * @see #sendMessage(int status, int data) + * @see #sendMessage(int status, int data1, int data2) + * @see #sendMessage(int command, int channel, int data1, int data2) + * @see #sendMessage(MidiMessage message) + * @see #sendNoteOn(int channel, int pitch, int velocity) + * @see #sendNoteOn(Note note) + * @see #sendNoteOff(int channel, int pitch, int velocity) + * @see #sendNoteOff(Note note) + * @see #sendControllerChange(int channel, int number, int value) + */ + public void sendControllerChange(ControlChange change) { + sendControllerChange(change.channel(), change.number(), change.value()); + } + + /* -- MIDI In -- */ + + /** + * Notifies all types of listeners of a new MIDI message from one of the MIDI input devices. + * + * @param message the new inbound MidiMessage. + */ + void notifyListeners(MidiMessage message, long timeStamp) { + byte[] data = message.getMessage(); + + for(MidiListener listener : listeners) { + + /* -- RawMidiListener -- */ + + if(listener instanceof RawMidiListener) ((RawMidiListener)listener).rawMidiMessage(data); + + /* -- SimpleMidiListener -- */ + + if(listener instanceof SimpleMidiListener) { + if((int)((byte)data[0] & 0xF0) == ShortMessage.NOTE_ON) { + ((SimpleMidiListener)listener).noteOn((int)(data[0] & 0x0F),(int)(data[1] & 0xFF),(int)(data[2] & 0xFF)); + } else if((int)((byte)data[0] & 0xF0) == ShortMessage.NOTE_OFF) { + ((SimpleMidiListener)listener).noteOff((int)(data[0] & 0x0F),(int)(data[1] & 0xFF),(int)(data[2] & 0xFF)); + } else if((int)((byte)data[0] & 0xF0) == ShortMessage.CONTROL_CHANGE) { + ((SimpleMidiListener)listener).controllerChange((int)(data[0] & 0x0F),(int)(data[1] & 0xFF),(int)(data[2] & 0xFF)); + } + } + + /* -- StandardMidiListener -- */ + + if(listener instanceof StandardMidiListener) ((StandardMidiListener)listener).midiMessage(message, timeStamp); + + /* -- ObjectMidiListener -- */ + + if(listener instanceof ObjectMidiListener) { + if((int)((byte)data[0] & 0xF0) == ShortMessage.NOTE_ON) { + ((ObjectMidiListener)listener).noteOn(new Note((int)(data[0] & 0x0F),(int)(data[1] & 0xFF),(int)(data[2] & 0xFF))); + } else if((int)((byte)data[0] & 0xF0) == ShortMessage.NOTE_OFF) { + ((ObjectMidiListener)listener).noteOff(new Note((int)(data[0] & 0x0F),(int)(data[1] & 0xFF),(int)(data[2] & 0xFF))); + } else if((int)((byte)data[0] & 0xF0) == ShortMessage.CONTROL_CHANGE) { + ((ObjectMidiListener)listener).controllerChange(new ControlChange((int)(data[0] & 0x0F),(int)(data[1] & 0xFF),(int)(data[2] & 0xFF))); + } + } + + } + } + + /** + * Notifies any of the supported methods implemented inside the parent of a new MIDI message from one of the MIDI input devices. + * + * @param message the new inbound MidiMessage. + */ + void notifyParent(MidiMessage message, long timeStamp) { + if(parent == null) return; + + byte[] data = message.getMessage(); + + if((int)((byte)data[0] & 0xF0) == ShortMessage.NOTE_ON) { + if(method_note_on != null) { + try { + method_note_on.invoke(parent, new Object[] { (int)(data[0] & 0x0F), (int)(data[1] & 0xFF), (int)(data[2] & 0xFF) }); + } catch(Exception e) { + System.err.println("\nThe MidiBus Warning: Disabling noteOn(int channel, int pitch, int velocity) because an unkown exception was thrown and caught"); + e.printStackTrace(); + method_note_on = null; + } + + } + if(method_note_on_with_bus_name != null) { + try { + method_note_on_with_bus_name.invoke(parent, new Object[] { (int)(data[0] & 0x0F), (int)(data[1] & 0xFF), (int)(data[2] & 0xFF), timeStamp, bus_name }); + } catch(Exception e) { + System.err.println("\nThe MidiBus Warning: Disabling noteOn(int channel, int pitch, int velocity, String bus_name) with bus_name because an unkown exception was thrown and caught"); + e.printStackTrace(); + method_note_on_with_bus_name = null; + } + } + if(method_note_on_wcla != null){ + try { + method_note_on_wcla.invoke(parent, new Note((int)(data[0] & 0x0F), (int)(data[1] & 0xFF), (int)(data[2] & 0xFF), timeStamp, bus_name)); + } catch(Exception e) { + System.err.println("\nThe MidiBus Warning: Disabling noteOn(Note note) because an unkown exception was thrown and caught"); + e.printStackTrace(); + method_note_on_wcla = null; + } + } + } else if((int)((byte)data[0] & 0xF0) == ShortMessage.NOTE_OFF) { + if(method_note_off != null) { + try { + method_note_off.invoke(parent, new Object[] { (int)(data[0] & 0x0F), (int)(data[1] & 0xFF), (int)(data[2] & 0xFF) }); + } catch(Exception e) { + System.err.println("\nThe MidiBus Warning: Disabling noteOff(int channel, int pitch, int velocity) because an unkown exception was thrown and caught"); + e.printStackTrace(); + method_note_off = null; + } + } + if(method_note_off_with_bus_name != null) { + try { + method_note_off_with_bus_name.invoke(parent, new Object[] { (int)(data[0] & 0x0F), (int)(data[1] & 0xFF), (int)(data[2] & 0xFF), timeStamp, bus_name }); + } catch(Exception e) { + System.err.println("\nThe MidiBus Warning: Disabling noteOff(int channel, int pitch, int velocity, String bus_name) with bus_name because an unkown exception was thrown and caught"); + e.printStackTrace(); + method_note_off_with_bus_name = null; + } + } + if(method_note_off_wcla != null){ + try { + method_note_off_wcla.invoke(parent, new Note((int)(data[0] & 0x0F), (int)(data[1] & 0xFF), (int)(data[2] & 0xFF), timeStamp, bus_name)); + } catch(Exception e) { + System.err.println("\nThe MidiBus Warning: Disabling noteOff(Note note) because an unkown exception was thrown and caught"); + e.printStackTrace(); + method_note_off_wcla = null; + } + } + } else if((int)((byte)data[0] & 0xF0) == ShortMessage.CONTROL_CHANGE) { + if(method_controller_change != null) { + try { + method_controller_change.invoke(parent, new Object[] { (int)(data[0] & 0x0F), (int)(data[1] & 0xFF), (int)(data[2] & 0xFF) }); + } catch(Exception e) { + System.err.println("\nThe MidiBus Warning: Disabling controllerChange(int channel, int number, int value) because an unkown exception was thrown and caught"); + e.printStackTrace(); + method_controller_change = null; + } + } + if(method_controller_change_with_bus_name != null) { + try { + method_controller_change_with_bus_name.invoke(parent, new Object[] { (int)(data[0] & 0x0F), (int)(data[1] & 0xFF), (int)(data[2] & 0xFF), timeStamp, bus_name }); + } catch(Exception e) { + System.err.println("\nThe MidiBus Warning: Disabling controllerChange(int channel, int number, int value, String bus_name) with bus_name because an unkown exception was thrown and caught"); + e.printStackTrace(); + method_controller_change_with_bus_name = null; + } + } + if(method_controller_change_wcla != null){ + try { + method_controller_change_wcla.invoke(parent, new ControlChange((int)(data[0] & 0x0F), (int)(data[1] & 0xFF), (int)(data[2] & 0xFF), timeStamp, bus_name)); + } catch(Exception e) { + System.err.println("\nThe MidiBus Warning: Disabling noteOff(Note note) because an unkown exception was thrown and caught"); + e.printStackTrace(); + method_controller_change_wcla = null; + } + } + } + + if(method_raw_midi != null) { + try { + method_raw_midi.invoke(parent, new Object[] { data }); + } catch(Exception e) { + System.err.println("\nThe MidiBus Warning: Disabling rawMidi(byte[] data) because an unkown exception was thrown and caught"); + e.printStackTrace(); + method_raw_midi = null; + } + } + if(method_raw_midi_with_bus_name != null) { + try { + method_raw_midi_with_bus_name.invoke(parent, new Object[] { data, timeStamp, bus_name }); + } catch(Exception e) { + System.err.println("\nThe MidiBus Warning: Disabling rawMidi(byte[] data, String bus_name) with bus_name because an unkown exception was thrown and caught"); + e.printStackTrace(); + method_raw_midi_with_bus_name = null; + } + } + + if(method_midi_message != null) { + try { + method_midi_message.invoke(parent, new Object[] { message }); + } catch(Exception e) { + System.err.println("\nThe MidiBus Warning: Disabling midiMessage(MidiMessage message) because an unkown exception was thrown and caught"); + e.printStackTrace(); + method_midi_message = null; + } + } + if(method_midi_message_with_bus_name != null) { + try { + method_midi_message_with_bus_name.invoke(parent, new Object[] { message, timeStamp, bus_name }); + } catch(Exception e) { + System.err.println("\nThe MidiBus Warning: Disabling midiMessage(MidiMessage message, String bus_name) with bus_name because an unkown exception was thrown and caught"); + e.printStackTrace(); + method_midi_message_with_bus_name = null; + } + } + + } + + /* -- Listener Handling -- */ + + /** + * Registers an Object as the parent in order to recieve method callbacks as per {@link PApplet}. Calling this will replace the previous parent Object if any was set. + * + * @param parent the object to register. + * @return the previous parent object if any was set. + * @see #addMidiListener(MidiListener listener) + */ + public Object registerParent(Object parent) { + Object old_parent = this.parent; + + if(old_parent != null) { + method_note_on = null; + method_note_off = null; + method_controller_change = null; + method_raw_midi = null; + method_midi_message = null; + + method_note_on_with_bus_name = null; + method_note_off_with_bus_name = null; + method_controller_change_with_bus_name = null; + method_raw_midi_with_bus_name = null; + method_midi_message_with_bus_name = null; + } + + this.parent = parent; + + if(parent != null) { + + if(parent instanceof processing.core.PApplet) { + ((processing.core.PApplet) parent).registerMethod("dispose", this); + } + + try { + method_note_on = parent.getClass().getMethod("noteOn", new Class[] { Integer.TYPE, Integer.TYPE, Integer.TYPE }); + } catch(Exception e) { + // no such method, or an error.. which is fine, just ignore + } + + try { + method_note_off = parent.getClass().getMethod("noteOff", new Class[] { Integer.TYPE, Integer.TYPE, Integer.TYPE }); + } catch(Exception e) { + // no such method, or an error.. which is fine, just ignore + } + + try { + method_controller_change = parent.getClass().getMethod("controllerChange", new Class[] { Integer.TYPE, Integer.TYPE, Integer.TYPE }); + } catch(Exception e) { + // no such method, or an error.. which is fine, just ignore + } + + try { + method_raw_midi = parent.getClass().getMethod("rawMidi", new Class[] { byte[].class }); + } catch(Exception e) { + // no such method, or an error.. which is fine, just ignore + } + + try { + method_midi_message = parent.getClass().getMethod("midiMessage", new Class[] { MidiMessage.class }); + } catch(Exception e) { + // no such method, or an error.. which is fine, just ignore + } + + try { + method_note_on_with_bus_name = parent.getClass().getMethod("noteOn", new Class[] { Integer.TYPE, Integer.TYPE, Integer.TYPE, Long.TYPE, String.class }); + } catch(Exception e) { + // no such method, or an error.. which is fine, just ignore + } + + try { + method_note_off_with_bus_name = parent.getClass().getMethod("noteOff", new Class[] { Integer.TYPE, Integer.TYPE, Integer.TYPE, Long.TYPE, String.class }); + } catch(Exception e) { + // no such method, or an error.. which is fine, just ignore + } + + try { + method_controller_change_with_bus_name = parent.getClass().getMethod("controllerChange", new Class[] { Integer.TYPE, Integer.TYPE, Integer.TYPE, Long.TYPE, String.class }); + } catch(Exception e) { + // no such method, or an error.. which is fine, just ignore + } + + try { + method_raw_midi_with_bus_name = parent.getClass().getMethod("rawMidi", new Class[] { byte[].class, Long.TYPE, String.class }); + } catch(Exception e) { + // no such method, or an error.. which is fine, just ignore + } + + try { + method_midi_message_with_bus_name = parent.getClass().getMethod("midiMessage", new Class[] { MidiMessage.class, Long.TYPE, String.class }); + } catch(Exception e) { + // no such method, or an error.. which is fine, just ignore + } + + try { + method_note_on_wcla = parent.getClass().getMethod("noteOn", new Class[] { Note.class}); + } catch(Exception e) { + // no such method, or an error.. which is fine, just ignore + } + + try { + method_note_off_wcla = parent.getClass().getMethod("noteOff", new Class[] { Note.class }); + } catch(Exception e) { + // no such method, or an error.. which is fine, just ignore + } + + try { + method_controller_change_wcla = parent.getClass().getMethod("controllerChange", new Class[] { ControlChange.class }); + } catch(Exception e) { + // no such method, or an error.. which is fine, just ignore + } + + } + + return old_parent; + } + + /** + * Adds a listener who will be notified each time a new MIDI message is received from a MIDI input device. If the listener has already been added, it will not be added again. + * + * @param listener the listener to add. + * @return true if and only the listener was sucessfully added. + * @see #removeMidiListener(MidiListener listener) + * @see #registerParent(Object parent) + */ + public boolean addMidiListener(MidiListener listener) { + for(MidiListener current : listeners) if(current == listener) return false; + + listeners.add(listener); + + return true; + } + + /** + * Removes a given listener. + * + * @param listener the listener to remove. + * @return true if and only the listener was sucessfully removed. + * @see #addMidiListener(MidiListener listener) + */ + public boolean removeMidiListener(MidiListener listener) { + for(MidiListener current : listeners) { + if(current == listener) { + listeners.remove(listener); + return true; + } + } + return false; + } + + + /* -- Utilites -- */ + + /** + * It's just convient ... move along... + */ + int constrain(int value, int min, int max) { + if(value > max) value = max; + if(value < min) value = min; + return value; + } + + /** + * Returns whether this MidiBus is sending timestamps along with MIDI information to the MIDI subsystem. + * + * @return true if this MidiBus is sending timestamps. + */ + public boolean sendTimestamps() { + return sendTimestamps; + } + + /** + * Configure this MidiBus instance to send or not to send timestamps along with MIDI information to the MIDI subsystem. + * + * @param sendTimestamps set to true if you want timestamps to be sent, otherwise set to false. + */ + public void sendTimestamps(boolean sendTimestamps) { + this.sendTimestamps = sendTimestamps; + } + + /** + * Returns the name of this MidiBus. + * + * @return the name of this MidiBus. + * @see #setBusName(String bus_name) + * @see #generateBusName() + */ + public String getBusName() { + return bus_name; + } + + /** + * Changes the name of this MidiBus. + * + * @param bus_name the new name of this MidiBus. + * @see #getBusName() + * @see #generateBusName() + */ + public void setBusName(String bus_name) { + this.bus_name = bus_name; + } + + /** + * Generate a name for this MidiBus instance. + * + * @see #setBusName(String bus_name) + * @see #getBusName() + */ + public void generateBusName() { + String id = new Formatter().format("%08d", System.currentTimeMillis()%100000000).toString(); + bus_name = "MidiBus_"+id; + } + + /* -- Object -- */ + + /** + * Returns a string representation of the object. + * + * @return a string representation of the object. + */ + public String toString() { + String output = "MidiBus: "+bus_name+" ["; + output += input_devices.size()+" input(s), "; + output += output_devices.size()+" output(s), "; + output += listeners.size()+" listener(s)]"; + return output; + } + + /** + * Indicates whether some other object is "equal to" this one. + * + * @param obj the reference object with which to compare. + * @return if this object is the same as the obj argument; false otherwise. + */ + public boolean equals(Object obj) { + if(obj instanceof MidiBus) { + MidiBus midibus = (MidiBus)obj; + if(!this.getBusName().equals(midibus.getBusName())) return false; + if(!this.input_devices.equals(midibus.input_devices)) return false; + if(!this.output_devices.equals(midibus.output_devices)) return false; + if(!this.listeners.equals(midibus.listeners)) return false; + return true; + } + return false; + } + + /** + * Creates and returns a copy of this object. + * + * @return a clone of this instance. + */ + public MidiBus clone() { + MidiBus clone = new MidiBus(parent, bus_name); + + for(InputDeviceContainer container : input_devices) { + clone.addInput(container.info); + } + + for(OutputDeviceContainer container : output_devices) { + clone.addOutput(container.info); + } + + for(MidiListener listener : listeners) { + clone.addMidiListener(listener); + } + + return clone; + } + + /** + * Returns a hash code value for the object. + * + * @return a hash code value for this object. + */ + public int hashCode() { + return bus_name.hashCode()+input_devices.hashCode()+output_devices.hashCode()+listeners.hashCode(); + } + + /** + * Override the finalize() method from java.lang.Object. + * + */ + protected void finalize() { + close(); + } + + /* -- Shutting Down -- */ + + /** + * Closes this MidiBus and all connections it has with other MIDI devices. This method exists as per standard javax.sound.midi syntax. It is functionaly equivalent to stop() and dispose(). + * + * @see #stop() + * @see #dispose() + */ + public void close() { + closeAllMidiDevices(); + } + + /** + * Closes this MidiBus and all connections it has with other MIDI devices. This method exit as per standard Processing syntax for users who are doing their sketch cleanup themselves using the stop() function. It is functionaly equivalent to close() and dispose(). + * + * @see #close() + * @see #dispose() + */ + public void stop() { + close(); + } + + /** + * Closes this MidiBus and all connections it has with other MIDI devices. This method exit as per standard Processing library syntax and is called automatically whenever the parent applet shuts down. It is functionaly equivalent to close() and stop(). + * + * @see #close() + * @see #stop() + */ + public void dispose() { + close(); + } + + /* -- Static methods -- */ + + /** + * List all installed MIDI devices. The index, name and type (input/output/unavailable) of each devices will be indicated. + * + * @see #availableInputs() + * @see #availableOutputs() + * @see #unavailableDevices() + */ + static public void list() { + String[] available_inputs = availableInputs(); + String[] available_outputs = availableOutputs(); + String[] unavailable = unavailableDevices(); + + if(available_inputs.length == 0 && available_outputs.length == 0 && unavailable.length == 0) return; + + System.out.println("\nAvailable MIDI Devices:"); + if(available_inputs.length != 0) { + System.out.println("----------Input----------"); + for(int i = 0;i < available_inputs.length;i++) System.out.println("["+i+"] \""+available_inputs[i]+"\""); + } + if(available_outputs.length != 0) { + System.out.println("----------Output----------"); + for(int i = 0;i < available_outputs.length;i++) System.out.println("["+i+"] \""+available_outputs[i]+"\""); + } + if(unavailable.length != 0) { + System.out.println("----------Unavailable----------"); + for(int i = 0;i < unavailable.length;i++) System.out.println("["+i+"] \""+unavailable[i]+"\""); + } + } + + /** + * Rescan for Midi Devices. This is autocalled once when the MidiBus starts up. It should be called again if you need to refresh the list of available MidiDevices while your program is running. + * + */ + static public void findMidiDevices() { + MidiBus.available_devices = MidiSystem.getMidiDeviceInfo(); + } + + /** + * Returns the names of all the available input devices. + * + * @return the names of the available inputs. + * @see #list() + * @see #availableOutputs() + * @see #unavailableDevices() + */ + static public String[] availableInputs() { + MidiDevice.Info[] devices_info = availableInputsMidiDeviceInfo(); + String[] devices = new String[devices_info.length]; + + for(int i = 0;i < devices_info.length;i++) { + devices[i] = devices_info[i].getName(); + } + + return devices; + } + + /** + * Returns the names of all the available output devices. + * + * @return the names of the available outputs. + * @see #list() + * @see #availableInputs() + * @see #unavailableDevices() + */ + static public String[] availableOutputs() { + MidiDevice.Info[] devices_info = availableOutputsMidiDeviceInfo(); + String[] devices = new String[devices_info.length]; + + for(int i = 0;i < devices_info.length;i++) { + devices[i] = devices_info[i].getName(); + } + + return devices; + } + + /** + * Returns the names of all the unavailable devices. + * + * @return the names of the unavailable devices. + * @see #list() + * @see #availableInputs() + * @see #availableOutputs() + */ + static public String[] unavailableDevices() { + MidiDevice.Info[] devices_info = unavailableMidiDeviceInfo(); + String[] devices = new String[devices_info.length]; + + for(int i = 0;i < devices_info.length;i++) { + devices[i] = devices_info[i].getName(); + } + + return devices; + } + + /** + * Returns the MidiDevice.Info of all the available input devices. + * + * @return the MidiDevice.Info of the available inputs. + */ + static MidiDevice.Info[] availableInputsMidiDeviceInfo() { + if(MidiBus.available_devices == null) findMidiDevices(); + MidiDevice device; + + Vector devices_list = new Vector(); + + for(int i = 0;i < MidiBus.available_devices.length;i++) { + try { + device = MidiSystem.getMidiDevice(MidiBus.available_devices[i]); + //This open close checks to make sure the announced device is truely available + //There are many reports on Windows that some devices lie about their availability + //(For instance the Microsoft GS Wavetable Synth) + //But in theory I guess this could happen on any OS, so I'll just do it all the time. + // if(!device.isOpen()) { + // device.open(); + // device.close(); + // } + if (device.getMaxTransmitters() != 0) devices_list.add(MidiBus.available_devices[i]); + } catch(MidiUnavailableException e) { + //Device was unavailable which is fine, we only care about available inputs + } + } + + MidiDevice.Info[] devices = new MidiDevice.Info[devices_list.size()]; + + devices_list.toArray(devices); + + return devices; + } + + /** + * Returns the MidiDevice.Info of all the available output devices. + * + * @return the MidiDevice.Info of the available output. + */ + static MidiDevice.Info[] availableOutputsMidiDeviceInfo() { + if(MidiBus.available_devices == null) findMidiDevices(); + MidiDevice device; + + Vector devices_list = new Vector(); + + for(int i = 0;i < MidiBus.available_devices.length;i++) { + try { + device = MidiSystem.getMidiDevice(MidiBus.available_devices[i]); + //This open close checks to make sure the announced device is truely available + //There are many reports on Windows that some devices lie about their availability + //(For instance the Microsoft GS Wavetable Synth) + //But in theory I guess this could happen on any OS, so I'll just do it all the time. + // if(!device.isOpen()) { + // device.open(); + // device.close(); + // } + if (device.getMaxReceivers() != 0) devices_list.add(MidiBus.available_devices[i]); + } catch(MidiUnavailableException e) { + //Device was unavailable which is fine, we only care about available output + } + } + + MidiDevice.Info[] devices = new MidiDevice.Info[devices_list.size()]; + + devices_list.toArray(devices); + + return devices; + } + + /** + * Returns the MidiDevice.Info of all the unavailable devices. + * + * @return the MidiDevice.Info of the unavailable devices. + */ + static MidiDevice.Info[] unavailableMidiDeviceInfo() { + if(MidiBus.available_devices == null) findMidiDevices(); + MidiDevice device; + + Vector devices_list = new Vector(); + + for(int i = 0;i < MidiBus.available_devices.length;i++) { + try { + device = MidiSystem.getMidiDevice(MidiBus.available_devices[i]); + //This open close checks to make sure the announced device is truely available + //There are many reports on Windows that some devices lie about their availability + //(For instance the Microsoft GS Wavetable Synth) + //But in theory I guess this could happen on any OS, so I'll just do it all the time. + // if(!device.isOpen()) { + // device.open(); + // device.close(); + // } + } catch(MidiUnavailableException e) { + devices_list.add(MidiBus.available_devices[i]); + } + } + + MidiDevice.Info[] devices = new MidiDevice.Info[devices_list.size()]; + + devices_list.toArray(devices); + + return devices; + } + + /* -- Nested Classes -- */ + + private class MReceiver implements Receiver { + + MReceiver() { + + } + + public void close() { + + } + + public void send(MidiMessage message, long timeStamp) { + + if(message.getStatus() == ShortMessage.NOTE_ON && message.getMessage()[2] == 0) { + try { + ShortMessage tmp_message = (ShortMessage)message; + tmp_message.setMessage(ShortMessage.NOTE_OFF, tmp_message.getData1(), tmp_message.getData2()); + message = tmp_message; + } catch(Exception e) { + System.err.println("\nThe MidiBus Warning: Mystery error during noteOn (0 velocity) to noteOff conversion"); + } + } + + notifyListeners(message, timeStamp); + notifyParent(message, timeStamp); + } + + } + + private class InputDeviceContainer { + + MidiDevice.Info info; + + Transmitter transmitter; + Receiver receiver; + + InputDeviceContainer(MidiDevice device) { + this.info = device.getDeviceInfo(); + } + + public boolean equals(Object container) { + if(container instanceof InputDeviceContainer && ((InputDeviceContainer)container).info.getName().equals(this.info.getName())) return true; + else return false; + } + + public int hashCode() { + return info.getName().hashCode(); + } + + } + + private class OutputDeviceContainer { + + MidiDevice.Info info; + + Receiver receiver; + + OutputDeviceContainer(MidiDevice device) { + this.info = device.getDeviceInfo(); + } + + public boolean equals(Object container) { + if(container instanceof OutputDeviceContainer && ((OutputDeviceContainer)container).info.getName().equals(this.info.getName())) return true; + else return false; + } + + public int hashCode() { + return info.getName().hashCode(); + } + + } + +} \ No newline at end of file diff --git a/libraries/themidibus/src/themidibus/MidiListener.java b/libraries/themidibus/src/themidibus/MidiListener.java new file mode 100644 index 0000000..a0032e9 --- /dev/null +++ b/libraries/themidibus/src/themidibus/MidiListener.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2009 Severin Smith + * + * This file is part of a library called The MidiBus (themidibus) - http://www.smallbutdigital.com/themidibus.php. + * + * The MidiBus is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The MidiBus is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with the MidiBus. If not, see . +*/ + +package themidibus; + +/** + * This is a placeholder interface which makes it easier to program and manipulate objects which implement subinterfaces of MidiListener like {@link RawMidiListener}, {@link SimpleMidiListener} or {@link StandardMidiListener}. It makes it easier to create lists and arrays of such object and allows for a standard method {@link MidiBus#addMidiListener(MidiListener listener)} to add any type of listener to a MidiBus object. + * + * @version 008 + * @author Severin Smith + * @see RawMidiListener + * @see SimpleMidiListener + * @see StandardMidiListener + * @see ObjectMidiListener + * @see MidiBus +*/ +public interface MidiListener { + +} \ No newline at end of file diff --git a/libraries/themidibus/src/themidibus/Note.java b/libraries/themidibus/src/themidibus/Note.java new file mode 100644 index 0000000..8e4e815 --- /dev/null +++ b/libraries/themidibus/src/themidibus/Note.java @@ -0,0 +1,254 @@ +/** + * Copyright (c) 2009 Severin Smith + * + * This file is part of a library called The MidiBus (themidibus) - http://www.smallbutdigital.com/themidibus.php. + * + * The MidiBus is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The MidiBus is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with the MidiBus. If not, see . +*/ + +package themidibus; + +/** + * The Note class represents a pressed or released key. + * + * @version 008 + * @author Severin Smith, Marc Koderer + * @see MidiBus + * @see ObjectMidiListener + * @see ControlChange +*/ + +public class Note { + + static String[] pitchMap = new String[] { + "C", + "C#", + "D", + "D#", + "E", + "F", + "F#", + "G", + "G#", + "A", + "A#", + "B" + }; + + public int channel; + public int pitch; + public int velocity; + + public long ticks; + + public long timestamp; + public String bus_name; + + /** + * Constructs a Note object + * + * @param channel the channel of the Note + * @param pitch the pitch of the Note + * @param velocity the velocity of the Note + */ + public Note(int channel, int pitch, int velocity) { + this(channel, pitch, velocity, 0, -1, null); + } + + /** + * Constructs a Note object + * + * @param channel the channel of the Note + * @param pitch the pitch of the Note + * @param velocity the velocity of the Note + * @param ticks the length in ticks of the Note + */ + public Note(int channel, int pitch, int velocity, int ticks) { + this(channel, pitch, velocity, ticks, -1, null); + } + + /** + * Constructs a Note object + * + * @param channel the channel of the Note + * @param pitch the pitch of the Note + * @param velocity the velocity of the Note + * @param timestamp the timestamp of the Note + * @param bus_name the name of MidiBus associated with the Note + */ + public Note(int channel, int pitch, int velocity, long timestamp, String bus_name) { + this(channel, pitch, velocity, 0, timestamp, bus_name); + } + + /** + * Constructs a Note object + * + * @param channel the channel of the Note + * @param pitch the pitch of the Note + * @param velocity the velocity of the Note + * @param ticks the length in ticks of the Note + * @param timestamp the timestamp of the Note + * @param bus_name the name of MidiBus associated with the Note + */ + public Note(int channel, int pitch, int velocity, int ticks, long timestamp, String bus_name) { + this.channel = channel; + this.pitch = pitch; + this.velocity = velocity; + + this.ticks = ticks; + + this.timestamp = timestamp; + this.bus_name = bus_name; + } + + /** + * Set channel of the Note + * + * @param channel the channel to set + */ + public void setChannel(int channel) { + this.channel = channel; + } + + /** + * Return the channel of the Note + * + * @return the channel + */ + public int channel() { + return channel; + } + + /** + * Set pitch of the Note + * + * @param pitch the pitch to set + */ + public void setPitch(int pitch) { + this.pitch = pitch; + } + + /** + * Return the pitch of the Note + * + * @return the pitch + */ + public int pitch() { + return pitch; + } + + /** + * Return the pitch of the Note relative to C. Range is 0-12. + * + * @return the relative pitch + */ + public int relativePitch() { + return pitch; + } + + /** + * Return the octave of the Note. Octaves are divided by the note C + * + * @return the octave + */ + public int octave() { + return pitch/12; + } + + /** + * Return the name of the note, e.g. "C" or "G#". + * + * @return the note name + */ + public String name() { + return pitchMap[pitch%12]; + } + + /** + * Set velocity of the Note + * + * @param velocity the velocity to set + */ + public void setVelocity(int velocity) { + this.velocity = velocity; + } + + /** + * Return the velocity of the Note + * + * @return the velocity + */ + public int velocity() { + return velocity; + } + + /** + * Set length in ticks of the Note + * + * @param ticks the ticks value to set + */ + public void setTicks(int ticks) { + this.ticks = ticks; + } + + /** + * Return the length in ticks of the Note + * + * @return the ticks length + */ + public long ticks() { + return ticks; + } + + /** + * Returns a string in the format [Note Name, c:channel, p:pitch, v:velocity, t:ticks, ts:timestamp, b:bus_name] e.g "[C, c:0, p:65, v:123, t:0, ts:1234, b:bus123]". If ticks, timestamp or bus_name isn't set, it is omitted. + * + * @return the string representation + */ + public String toString() { + String result = "[" + name() + ", c:" + channel + ", p:" + pitch + ", v:" + velocity; + if(ticks != 0) result += ", t:" + ticks; + if(timestamp != -1) result += ", ts:" + timestamp; + if(bus_name != null) result += ", b:" + bus_name; + result += "]"; + + return result; + } + + /** + * Check if all fields are equal. + * + * @return true if both objects can be considered to be equals + */ + public boolean equals(Object obj) { + if(this == obj) return true; + if(obj == null) return false; + + if(getClass() != obj.getClass()) return false; + + Note other = (Note)obj; + + if(other.channel != this.channel) return false; + if(other.pitch != this.pitch) return false; + if(other.velocity != this.velocity) return false; + + if(other.ticks != this.ticks) return false; + + if(other.timestamp != this.timestamp) return false; + if(other.bus_name != this.bus_name) return false; + + return true; + } + +} diff --git a/libraries/themidibus/src/themidibus/ObjectMidiListener.java b/libraries/themidibus/src/themidibus/ObjectMidiListener.java new file mode 100644 index 0000000..008af03 --- /dev/null +++ b/libraries/themidibus/src/themidibus/ObjectMidiListener.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2009 Severin Smith + * + * This file is part of a library called The MidiBus (themidibus) - http://www.smallbutdigital.com/themidibus.php. + * + * The MidiBus is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The MidiBus is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with the MidiBus. If not, see . +*/ + +package themidibus; + +/** + * A ObjectMidiListener can be notified of incomming NoteOn, NoteOff and ControllerChange events via {@link Note} and {@link ControlChange} objects, usually by a MidiBus object which it is connected to. Typically it would analyse and react to incomming messages in some useful way. + * + * @version 008 + * @author Severin Smith, Marc Koderer + * @see MidiListener + * @see RawMidiListener + * @see SimpleMidiListener + * @see StandardMidiListener + * @see Note + * @see ControlChange + * @see MidiBus +*/ + +public interface ObjectMidiListener extends MidiListener { + + /** + * Objects notifying this ObjectMidiListener of a new NoteOn events call this method. + * + * @param note the note object associated with this event + */ + public void noteOn(Note note); + + /** + * Objects notifying this ObjectMidiListener of a new NoteOff events call this method. + * + * @param note the note object associated with this event + */ + public void noteOff(Note note); + + /** + * Objects notifying this ObjectMidiListener of a new ControllerChange events call this method. + * + * @param change the ControlChange object associated with this event + */ + public void controllerChange(ControlChange change); + +} \ No newline at end of file diff --git a/libraries/themidibus/src/themidibus/PApplet.java b/libraries/themidibus/src/themidibus/PApplet.java new file mode 100644 index 0000000..d549355 --- /dev/null +++ b/libraries/themidibus/src/themidibus/PApplet.java @@ -0,0 +1,192 @@ +/** + * Copyright (c) 2009 Severin Smith + * + * This file is part of a library called The MidiBus (themidibus) - http://www.smallbutdigital.com/themidibus.php. + * + * The MidiBus is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The MidiBus is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with the MidiBus. If not, see . +*/ + +package themidibus; +import javax.sound.midi.MidiMessage; + +/** + * PApplet is your processing application or sketch. In it you can implement the following methods which will be called whenerever a MidiBus object attached to the PApplet, recieves a new incomming MIDI message of the appropriate type. + *

+ * Note: This page is a dummy page for documentation of the MidiBus' extention of the regular PApplet's functionality, for the full documentation of PApplet please visits the Processing javadocs + * + * @version 008 + * @author Severin Smith + * @see MidiBus + * @see MidiListener + * @see RawMidiListener + * @see StandardMidiListener + * @see SimpleMidiListener +*/ +public class PApplet{ + + /** + * Is passed the channel, controller number and contoller value associated with every new ContollerChange MIDI message recieved by a MidiBus attached to this applet. + * + * @param channel the channel on which the ContollerChange arrived + * @param number the controller number associated with the ContollerChange + * @param value the controller value associated with the ContollerChange + * @see #controllerChange(int channel, int pitch, int velocity, long timestamp, String bus_name) + */ + public void controllerChange(int channel, int number, int value) { + + } + + /** + * Is passed the channel, pitch and velocity associated with every new NoteOff MIDI message recieved by a MidiBus attached to this applet and the name of the MidiBus which recieved the message. + * + * @param channel the channel on which the ContollerChange arrived + * @param number the controller number associated with the ContollerChange + * @param value the controller value associated with the ContollerChange + * @param timestamp the timestamp on the midi message + * @param bus_name the name of MidiBus which recieved the ContollerChange + * @see #controllerChange(int channel, int pitch, int velocity) + */ + public void controllerChange(int channel, int number, int value, long timestamp, String bus_name) { + + } + + /** + * Is passed a ControlChange object representing controlChange event + * + * @param change the ControlChange object + * @see #controllerChange(int channel, int pitch, int velocity) + * @see themidibus.ObjectMidiListener#controllerChange(ControlChange) + */ + public void controllerChange(ControlChange change) { + + } + + /** + * Is passed the raw MidiMessage associated with every new MIDI message recieved by a MidiBus attached to this applet. + * + * @param message the MidiMessage recieved + * @see #midiMessage(MidiMessage message, long timestamp, String bus_name) + */ + public void midiMessage(MidiMessage message) { + + } + + /** + * Is passed the raw MidiMessage associated with every new MIDI message recieved by a MidiBus attached to this applet and the name of the MidiBus which recieved the message. + * + * @param message the MidiMessage recieved + * @param timestamp the timestamp on the midi message + * @param bus_name the name of MidiBus which recieved the MIDI message + * @see #midiMessage(MidiMessage message) + */ + public void midiMessage(MidiMessage message, long timestamp, String bus_name) { + + } + + /** + * Is passed the channel, pitch and velocity associated with every new NoteOff MIDI message recieved by a MidiBus attached to this applet. + * + * @param channel the channel on which the NoteOff arrived + * @param pitch the pitch associated with the NoteOff + * @param velocity the velocity associated with the NoteOff + * @see #noteOff(int channel, int pitch, int velocity, long timestamp, String bus_name) + */ + public void noteOff(int channel, int pitch, int velocity) { + + } + + /** + * Is passed the channel, pitch and velocity associated with every new NoteOff MIDI message recieved by a MidiBus attached to this applet and the name of the MidiBus which recieved the message. + * + * @param channel the channel on which the NoteOff arrived + * @param pitch the pitch associated with the NoteOff + * @param velocity the velocity associated with the NoteOff + * @param timestamp the timestamp on the midi message + * @param bus_name the name of MidiBus which recieved the NoteOff + * @see #noteOff(int channel, int pitch, int velocity) + */ + public void noteOff(int channel, int pitch, int velocity, long timestamp, String bus_name) { + + } + + /** + * Is passed a Note object representing noteOff event + * + * @param note the Note object + * @see #noteOff(int channel, int pitch, int velocity) + * @see themidibus.ObjectMidiListener#noteOn(Note) + */ + public void noteOff(Note note) { + + } + + /** + * Is passed the channel, pitch and velocity associated with every new NoteOn MIDI message recieved by a MidiBus attached to this applet. + * + * @param channel the channel on which the NoteOn arrived + * @param pitch the pitch associated with the NoteOn + * @param velocity the velocity associated with the NoteOn + * @see #noteOn(int channel, int pitch, int velocity, long timestamp, String bus_name) + */ + public void noteOn(int channel, int pitch, int velocity) { + + } + + /** + * Is passed the channel, pitch and velocity associated with every new NoteOn MIDI message recieved by a MidiBus attached to this applet and the name of the MidiBus which recieved the message. + * + * @param channel the channel on which the NoteOn arrived + * @param pitch the pitch associated with the NoteOn + * @param velocity the velocity associated with the NoteOn + * @param timestamp the timestamp on the midi message + * @param bus_name the name of MidiBus which recieved the NoteOn + * @see #noteOn(int channel, int pitch, int velocity) + */ + public void noteOn(int channel, int pitch, int velocity, long timestamp, String bus_name) { + + } + + /** + * Is passed a Note object representing noteOn event + * + * @param note the Note object + * @see #noteOn(int channel, int pitch, int velocity) + * @see themidibus.ObjectMidiListener#noteOff(Note) + */ + public void noteOn(Note note) { + + } + + /** + * Is passed the raw data associated with every new MIDI message recieved by a MidiBus attached to this applet. + * + * @param data the raw data associated with the MIDI message + * @see #rawMidi(byte[] data, long timestamp, String bus_name) + */ + public void rawMidi(byte[] data) { + + } + + /** + * Is passed the raw data associated with every new MIDI message recieved by a MidiBus attached to this applet and the name of the MidiBus which recieved the message. + * + * @param data the raw data associated with the MIDI message + * @param timestamp the timestamp on the midi message + * @param bus_name the name of MidiBus which recieved the MIDI message + * @see #rawMidi(byte[] data) + */ + public void rawMidi(byte[] data, long timestamp, String bus_name) { + + } +} diff --git a/libraries/themidibus/src/themidibus/RawMidiListener.java b/libraries/themidibus/src/themidibus/RawMidiListener.java new file mode 100644 index 0000000..d08588c --- /dev/null +++ b/libraries/themidibus/src/themidibus/RawMidiListener.java @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2009 Severin Smith + * + * This file is part of a library called The MidiBus (themidibus) - http://www.smallbutdigital.com/themidibus.php. + * + * The MidiBus is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The MidiBus is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with the MidiBus. If not, see . +*/ + +package themidibus; + +/** + * A RawMidiListener can be notified of incomming MIDI messages in raw form, usually by a MidiBus object which it is connect to. Typically it would analyse and react to incomming MIDI messages in some useful way. + * + * @version 008 + * @author Severin Smith + * @see MidiListener + * @see SimpleMidiListener + * @see StandardMidiListener + * @see ObjectMidiListener + * @see MidiBus +*/ +public interface RawMidiListener extends MidiListener { + /** + * Objects notifying this RawMidiListener of a new MIDI message call this method and pass the raw message to it. + * + * @param data the data bytes that make up the MIDI message + */ + public void rawMidiMessage(byte[] data); +} \ No newline at end of file diff --git a/libraries/themidibus/src/themidibus/SimpleMidiListener.java b/libraries/themidibus/src/themidibus/SimpleMidiListener.java new file mode 100644 index 0000000..6fb9f7e --- /dev/null +++ b/libraries/themidibus/src/themidibus/SimpleMidiListener.java @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2009 Severin Smith + * + * This file is part of a library called The MidiBus (themidibus) - http://www.smallbutdigital.com/themidibus.php. + * + * The MidiBus is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The MidiBus is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with the MidiBus. If not, see . +*/ + +package themidibus; + +/** + * A SimpleMidiListener can be notified of incomming NoteOn, NoteOff and ControllerChange MIDI messages, usually by a MidiBus object which it is connected to. Typically it would analyse and react to incomming MIDI messages in some useful way. + * + * @version 008 + * @author Severin Smith + * @see MidiListener + * @see RawMidiListener + * @see StandardMidiListener + * @see ObjectMidiListener + * @see MidiBus +*/ + +public interface SimpleMidiListener extends MidiListener { + + /** + * Objects notifying this SimpleMidiListener of a new NoteOn MIDI message call this method. + * + * @param channel the channel on which the NoteOn arrived + * @param pitch the pitch associated with the NoteOn + * @param velocity the velocity associated with the NoteOn + */ + public void noteOn(int channel, int pitch, int velocity); + + /** + * Objects notifying this SimpleMidiListener of a new NoteOff MIDI message call this method. + * + * @param channel the channel on which the NoteOff arrived + * @param pitch the pitch associated with the NoteOff + * @param velocity the velocity associated with the NoteOff + */ + public void noteOff(int channel, int pitch, int velocity); + + /** + * Objects notifying this SimpleMidiListener of a new ControllerChange MIDI message call this method. + * + * @param channel the channel on which the ContollerChange arrived + * @param number the controller number associated with the ContollerChange + * @param value the controller value associated with the ContollerChange + */ + public void controllerChange(int channel, int number, int value); + +} \ No newline at end of file diff --git a/libraries/themidibus/src/themidibus/StandardMidiListener.java b/libraries/themidibus/src/themidibus/StandardMidiListener.java new file mode 100644 index 0000000..18b2c32 --- /dev/null +++ b/libraries/themidibus/src/themidibus/StandardMidiListener.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2009 Severin Smith + * + * This file is part of a library called The MidiBus (themidibus) - http://www.smallbutdigital.com/themidibus.php. + * + * The MidiBus is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The MidiBus is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with the MidiBus. If not, see . +*/ + +package themidibus; + +import javax.sound.midi.MidiMessage; + +/** + * A StandardMidiListener can be notified of incomming MIDI messages in MidiMessage form, usually by a MidiBus object which it is connected to. Typically it would analyse and react to incomming MIDI messages in some useful way. + * + * @version 008 + * @author Severin Smith + * @see MidiListener + * @see RawMidiListener + * @see SimpleMidiListener + * @see ObjectMidiListener + * @see MidiBus + * @see javax.sound.midi.MidiMessage +*/ +public interface StandardMidiListener extends MidiListener { + /** + * Objects notifying this StandardMidiListener of a new MIDI message call this method and pass the MidiMessage + * + * @param message the MidiMessage received + */ + public void midiMessage(MidiMessage message, long timeStamp); +} \ No newline at end of file diff --git a/libraries/themidibus/src/themidibus/package-info.java b/libraries/themidibus/src/themidibus/package-info.java new file mode 100644 index 0000000..0fedd13 --- /dev/null +++ b/libraries/themidibus/src/themidibus/package-info.java @@ -0,0 +1,42 @@ +/** + * Copyright (c) 2009 Severin Smith + * + * This file is part of a library called The MidiBus (themidibus) - http://www.smallbutdigital.com/themidibus.php. + * + * The MidiBus is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The MidiBus is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with the MidiBus. If not, see . +*/ + +/** + * The MidiBus provides a simple way to access and interact with installed MIDI system resources, although it's especially designed to be used with Processing, it could easily be adapted for use in any java program. + *

+ * IMPORTANT: Mac users may want to install mmj, a Mac OS X universal binary java MIDI subsystem - or an equivalent third party MIDI subsystem - because the apple implementation is lacking support for a number of advanced MIDI features. Mmj is recommended because it works, it's free and it's almost open source (CC licence). Please check README.md for more information. If you do use MMJ you will want to set {@link themidibus.MidiBus#sendTimestamps(boolean sendTimestamps)} to false, otherwise messages won't be sent. + *

+ * Keeping with the spirit of Processing's easy to use sketching/prototyping style, the MidiBus offers a clean and simple way to get at MIDI ressources. Getting the basic functionality of the MidiBus up and running in a sketch is a matter of only a few line. The {@link themidibus.MidiBus} class provides everything needed send and receive MIDI inside a sketch. To jump right into the Midibus, either refer to the paragraph titled "Typical Implementation, Simple" in the description for the {@link themidibus.MidiBus} class, or check out the code examples distributed with this library. + *


+ * It is important to understand that the MidiBus offers little functionality that isn't available from Java's native javax.sound.midi package. Anyone interested in working with MIDI in Java should take the time to read the documentation for the javax.sound.midi. It offers a more full featured and flexible alternative to this package, although it does do so at the cost of added complexity. In addition, it may be worthwhile to skim the "official" Java Tutorial for the javax.sound.* packages. + *


+ *

Related Documentation

+ * + * + * @version 008 + * @author Severin Smith +*/ + +package themidibus;