initial commit
commit
e62cefe13e
|
|
@ -0,0 +1,73 @@
|
|||
# This file is used to ignore files which are generated
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
*~
|
||||
*.autosave
|
||||
*.a
|
||||
*.core
|
||||
*.moc
|
||||
*.o
|
||||
*.obj
|
||||
*.orig
|
||||
*.rej
|
||||
*.so
|
||||
*.so.*
|
||||
*_pch.h.cpp
|
||||
*_resource.rc
|
||||
*.qm
|
||||
.#*
|
||||
*.*#
|
||||
core
|
||||
!core/
|
||||
tags
|
||||
.DS_Store
|
||||
.directory
|
||||
*.debug
|
||||
Makefile*
|
||||
*.prl
|
||||
*.app
|
||||
moc_*.cpp
|
||||
ui_*.h
|
||||
qrc_*.cpp
|
||||
Thumbs.db
|
||||
*.res
|
||||
*.rc
|
||||
/.qmake.cache
|
||||
/.qmake.stash
|
||||
|
||||
# qtcreator generated files
|
||||
*.pro.user*
|
||||
|
||||
# xemacs temporary files
|
||||
*.flc
|
||||
|
||||
# Vim temporary files
|
||||
.*.swp
|
||||
|
||||
# Visual Studio generated files
|
||||
*.ib_pdb_index
|
||||
*.idb
|
||||
*.ilk
|
||||
*.pdb
|
||||
*.sln
|
||||
*.suo
|
||||
*.vcproj
|
||||
*vcproj.*.*.user
|
||||
*.ncb
|
||||
*.sdf
|
||||
*.opensdf
|
||||
*.vcxproj
|
||||
*vcxproj.*
|
||||
|
||||
# MinGW generated files
|
||||
*.Debug
|
||||
*.Release
|
||||
|
||||
# Python byte code
|
||||
*.pyc
|
||||
|
||||
# Binaries
|
||||
# --------
|
||||
*.dll
|
||||
*.exe
|
||||
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
QT += widgets
|
||||
SOURCES += \
|
||||
src/main.cpp
|
||||
|
||||
include($$PWD/libs/QMidi/QMidi.pri)
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
*build-*
|
||||
*.pro.user*
|
||||
*.DS_Store
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
language: cpp
|
||||
sudo: required
|
||||
|
||||
install: . scripts/ci/$TRAVIS_OS_NAME/install.sh
|
||||
script: . scripts/ci/common/script.sh
|
||||
|
|
@ -0,0 +1,674 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
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 includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), 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
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License 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 remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted 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 used 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, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless 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 have 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, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered 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, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "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 a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
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 parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are 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 any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement 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 or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would 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 link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General 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 given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by 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.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
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
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may 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
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
macx{
|
||||
DEFINES += __MACOSX_CORE__=1
|
||||
LIBS += -framework CoreMidi
|
||||
LIBS += -framework CoreAudio
|
||||
LIBS += -framework CoreFoundation
|
||||
}
|
||||
|
||||
linux{
|
||||
DEFINES += define __LINUX_ALSA__=1
|
||||
LIBS += -lasound
|
||||
}
|
||||
win32{
|
||||
DEFINES += __WINDOWS_MM__=1
|
||||
}
|
||||
INCLUDEPATH += $$PWD
|
||||
INCLUDEPATH += $$PWD/libs/rtmidi
|
||||
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/libs/rtmidi/RtMidi.h \
|
||||
$$PWD/qmidiin.h \
|
||||
$$PWD/qmidiout.h \
|
||||
$$PWD/qmidimessage.h \
|
||||
$$PWD/qmidimapper.h \
|
||||
$$PWD/qmidipianoroll.h
|
||||
SOURCES += \
|
||||
$$PWD/libs/rtmidi/RtMidi.cpp \
|
||||
$$PWD/qmidiin.cpp \
|
||||
$$PWD/qmidiout.cpp \
|
||||
$$PWD/qmidimessage.cpp \
|
||||
$$PWD/qmidimapper.cpp \
|
||||
$$PWD/qmidipianoroll.cpp
|
||||
|
||||
DISTFILES += \
|
||||
$$PWD/README.md
|
||||
$$PWD/LICENSE
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
QMidi
|
||||
===
|
||||
|
||||
Description
|
||||
---
|
||||
QMidi is a Qt library which wraps rtMidi library and allows you to communicate with midi devices.
|
||||
|
||||
This is a work in progress and not very stable. Some features are still missing.
|
||||
|
||||
Build status
|
||||
---
|
||||
[](https://travis-ci.org/thomasgeissl/QMidi)
|
||||
|
||||
Dependencies
|
||||
---
|
||||
* rtMidi <http://github.com/thestk/rtMidi> (already included)
|
||||
* Qt > 5.5
|
||||
|
||||
Contribution
|
||||
---
|
||||
|
||||
License
|
||||
---
|
||||
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 http://www.gnu.org/licenses/.
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
/config
|
||||
/configure
|
||||
/Makefile.in
|
||||
/aclocal.m4
|
||||
/autom4te.cache
|
||||
/configure
|
||||
/m4
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,763 @@
|
|||
/**********************************************************************/
|
||||
/*! \class RtMidi
|
||||
\brief An abstract base class for realtime MIDI input/output.
|
||||
|
||||
This class implements some common functionality for the realtime
|
||||
MIDI input/output subclasses RtMidiIn and RtMidiOut.
|
||||
|
||||
RtMidi WWW site: http://music.mcgill.ca/~gary/rtmidi/
|
||||
|
||||
RtMidi: realtime MIDI i/o C++ classes
|
||||
Copyright (c) 2003-2014 Gary P. Scavone
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation files
|
||||
(the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
Any person wishing to distribute modifications to the Software is
|
||||
asked to send the modifications to the original developer so that
|
||||
they can be incorporated into the canonical version. This is,
|
||||
however, not a binding provision of this license.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
||||
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
/**********************************************************************/
|
||||
|
||||
/*!
|
||||
\file RtMidi.h
|
||||
*/
|
||||
|
||||
#ifndef RTMIDI_H
|
||||
#define RTMIDI_H
|
||||
|
||||
#define RTMIDI_VERSION "2.1.0"
|
||||
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
/************************************************************************/
|
||||
/*! \class RtMidiError
|
||||
\brief Exception handling class for RtMidi.
|
||||
|
||||
The RtMidiError class is quite simple but it does allow errors to be
|
||||
"caught" by RtMidiError::Type. See the RtMidi documentation to know
|
||||
which methods can throw an RtMidiError.
|
||||
*/
|
||||
/************************************************************************/
|
||||
|
||||
class RtMidiError : public std::exception
|
||||
{
|
||||
public:
|
||||
//! Defined RtMidiError types.
|
||||
enum Type {
|
||||
WARNING, /*!< A non-critical error. */
|
||||
DEBUG_WARNING, /*!< A non-critical error which might be useful for debugging. */
|
||||
UNSPECIFIED, /*!< The default, unspecified error type. */
|
||||
NO_DEVICES_FOUND, /*!< No devices found on system. */
|
||||
INVALID_DEVICE, /*!< An invalid device ID was specified. */
|
||||
MEMORY_ERROR, /*!< An error occured during memory allocation. */
|
||||
INVALID_PARAMETER, /*!< An invalid parameter was specified to a function. */
|
||||
INVALID_USE, /*!< The function was called incorrectly. */
|
||||
DRIVER_ERROR, /*!< A system driver error occured. */
|
||||
SYSTEM_ERROR, /*!< A system error occured. */
|
||||
THREAD_ERROR /*!< A thread error occured. */
|
||||
};
|
||||
|
||||
//! The constructor.
|
||||
RtMidiError( const std::string& message, Type type = RtMidiError::UNSPECIFIED ) throw() : message_(message), type_(type) {}
|
||||
|
||||
//! The destructor.
|
||||
virtual ~RtMidiError( void ) throw() {}
|
||||
|
||||
//! Prints thrown error message to stderr.
|
||||
virtual void printMessage( void ) const throw() { std::cerr << '\n' << message_ << "\n\n"; }
|
||||
|
||||
//! Returns the thrown error message type.
|
||||
virtual const Type& getType(void) const throw() { return type_; }
|
||||
|
||||
//! Returns the thrown error message string.
|
||||
virtual const std::string& getMessage(void) const throw() { return message_; }
|
||||
|
||||
//! Returns the thrown error message as a c-style string.
|
||||
virtual const char* what( void ) const throw() { return message_.c_str(); }
|
||||
|
||||
protected:
|
||||
std::string message_;
|
||||
Type type_;
|
||||
};
|
||||
|
||||
//! RtMidi error callback function prototype.
|
||||
/*!
|
||||
\param type Type of error.
|
||||
\param errorText Error description.
|
||||
|
||||
Note that class behaviour is undefined after a critical error (not
|
||||
a warning) is reported.
|
||||
*/
|
||||
typedef void (*RtMidiErrorCallback)( RtMidiError::Type type, const std::string &errorText, void *userData );
|
||||
|
||||
class MidiApi;
|
||||
|
||||
class RtMidi
|
||||
{
|
||||
public:
|
||||
|
||||
//! MIDI API specifier arguments.
|
||||
enum Api {
|
||||
UNSPECIFIED, /*!< Search for a working compiled API. */
|
||||
MACOSX_CORE, /*!< Macintosh OS-X Core Midi API. */
|
||||
LINUX_ALSA, /*!< The Advanced Linux Sound Architecture API. */
|
||||
UNIX_JACK, /*!< The JACK Low-Latency MIDI Server API. */
|
||||
WINDOWS_MM, /*!< The Microsoft Multimedia MIDI API. */
|
||||
RTMIDI_DUMMY /*!< A compilable but non-functional API. */
|
||||
};
|
||||
|
||||
//! A static function to determine the current RtMidi version.
|
||||
static std::string getVersion( void ) throw();
|
||||
|
||||
//! A static function to determine the available compiled MIDI APIs.
|
||||
/*!
|
||||
The values returned in the std::vector can be compared against
|
||||
the enumerated list values. Note that there can be more than one
|
||||
API compiled for certain operating systems.
|
||||
*/
|
||||
static void getCompiledApi( std::vector<RtMidi::Api> &apis ) throw();
|
||||
|
||||
//! Pure virtual openPort() function.
|
||||
virtual void openPort( unsigned int portNumber = 0, const std::string portName = std::string( "RtMidi" ) ) = 0;
|
||||
|
||||
//! Pure virtual openVirtualPort() function.
|
||||
virtual void openVirtualPort( const std::string portName = std::string( "RtMidi" ) ) = 0;
|
||||
|
||||
//! Pure virtual getPortCount() function.
|
||||
virtual unsigned int getPortCount() = 0;
|
||||
|
||||
//! Pure virtual getPortName() function.
|
||||
virtual std::string getPortName( unsigned int portNumber = 0 ) = 0;
|
||||
|
||||
//! Pure virtual closePort() function.
|
||||
virtual void closePort( void ) = 0;
|
||||
|
||||
//! Returns true if a port is open and false if not.
|
||||
virtual bool isPortOpen( void ) const = 0;
|
||||
|
||||
//! Set an error callback function to be invoked when an error has occured.
|
||||
/*!
|
||||
The callback function will be called whenever an error has occured. It is best
|
||||
to set the error callback function before opening a port.
|
||||
*/
|
||||
virtual void setErrorCallback( RtMidiErrorCallback errorCallback = NULL, void *userData = 0 ) = 0;
|
||||
|
||||
protected:
|
||||
|
||||
RtMidi();
|
||||
virtual ~RtMidi();
|
||||
|
||||
MidiApi *rtapi_;
|
||||
};
|
||||
|
||||
/**********************************************************************/
|
||||
/*! \class RtMidiIn
|
||||
\brief A realtime MIDI input class.
|
||||
|
||||
This class provides a common, platform-independent API for
|
||||
realtime MIDI input. It allows access to a single MIDI input
|
||||
port. Incoming MIDI messages are either saved to a queue for
|
||||
retrieval using the getMessage() function or immediately passed to
|
||||
a user-specified callback function. Create multiple instances of
|
||||
this class to connect to more than one MIDI device at the same
|
||||
time. With the OS-X, Linux ALSA, and JACK MIDI APIs, it is also
|
||||
possible to open a virtual input port to which other MIDI software
|
||||
clients can connect.
|
||||
|
||||
by Gary P. Scavone, 2003-2014.
|
||||
*/
|
||||
/**********************************************************************/
|
||||
|
||||
// **************************************************************** //
|
||||
//
|
||||
// RtMidiIn and RtMidiOut class declarations.
|
||||
//
|
||||
// RtMidiIn / RtMidiOut are "controllers" used to select an available
|
||||
// MIDI input or output interface. They present common APIs for the
|
||||
// user to call but all functionality is implemented by the classes
|
||||
// MidiInApi, MidiOutApi and their subclasses. RtMidiIn and RtMidiOut
|
||||
// each create an instance of a MidiInApi or MidiOutApi subclass based
|
||||
// on the user's API choice. If no choice is made, they attempt to
|
||||
// make a "logical" API selection.
|
||||
//
|
||||
// **************************************************************** //
|
||||
|
||||
class RtMidiIn : public RtMidi
|
||||
{
|
||||
public:
|
||||
|
||||
//! User callback function type definition.
|
||||
typedef void (*RtMidiCallback)( double timeStamp, std::vector<unsigned char> *message, void *userData);
|
||||
|
||||
//! Default constructor that allows an optional api, client name and queue size.
|
||||
/*!
|
||||
An exception will be thrown if a MIDI system initialization
|
||||
error occurs. The queue size defines the maximum number of
|
||||
messages that can be held in the MIDI queue (when not using a
|
||||
callback function). If the queue size limit is reached,
|
||||
incoming messages will be ignored.
|
||||
|
||||
If no API argument is specified and multiple API support has been
|
||||
compiled, the default order of use is ALSA, JACK (Linux) and CORE,
|
||||
JACK (OS-X).
|
||||
|
||||
\param api An optional API id can be specified.
|
||||
\param clientName An optional client name can be specified. This
|
||||
will be used to group the ports that are created
|
||||
by the application.
|
||||
\param queueSizeLimit An optional size of the MIDI input queue can be specified.
|
||||
*/
|
||||
RtMidiIn( RtMidi::Api api=UNSPECIFIED,
|
||||
const std::string clientName = std::string( "RtMidi Input Client"),
|
||||
unsigned int queueSizeLimit = 100 );
|
||||
|
||||
//! If a MIDI connection is still open, it will be closed by the destructor.
|
||||
~RtMidiIn ( void ) throw();
|
||||
|
||||
//! Returns the MIDI API specifier for the current instance of RtMidiIn.
|
||||
RtMidi::Api getCurrentApi( void ) throw();
|
||||
|
||||
//! Open a MIDI input connection given by enumeration number.
|
||||
/*!
|
||||
\param portNumber An optional port number greater than 0 can be specified.
|
||||
Otherwise, the default or first port found is opened.
|
||||
\param portName An optional name for the application port that is used to connect to portId can be specified.
|
||||
*/
|
||||
void openPort( unsigned int portNumber = 0, const std::string portName = std::string( "RtMidi Input" ) );
|
||||
|
||||
//! Create a virtual input port, with optional name, to allow software connections (OS X, JACK and ALSA only).
|
||||
/*!
|
||||
This function creates a virtual MIDI input port to which other
|
||||
software applications can connect. This type of functionality
|
||||
is currently only supported by the Macintosh OS-X, any JACK,
|
||||
and Linux ALSA APIs (the function returns an error for the other APIs).
|
||||
|
||||
\param portName An optional name for the application port that is
|
||||
used to connect to portId can be specified.
|
||||
*/
|
||||
void openVirtualPort( const std::string portName = std::string( "RtMidi Input" ) );
|
||||
|
||||
//! Set a callback function to be invoked for incoming MIDI messages.
|
||||
/*!
|
||||
The callback function will be called whenever an incoming MIDI
|
||||
message is received. While not absolutely necessary, it is best
|
||||
to set the callback function before opening a MIDI port to avoid
|
||||
leaving some messages in the queue.
|
||||
|
||||
\param callback A callback function must be given.
|
||||
\param userData Optionally, a pointer to additional data can be
|
||||
passed to the callback function whenever it is called.
|
||||
*/
|
||||
void setCallback( RtMidiCallback callback, void *userData = 0 );
|
||||
|
||||
//! Cancel use of the current callback function (if one exists).
|
||||
/*!
|
||||
Subsequent incoming MIDI messages will be written to the queue
|
||||
and can be retrieved with the \e getMessage function.
|
||||
*/
|
||||
void cancelCallback();
|
||||
|
||||
//! Close an open MIDI connection (if one exists).
|
||||
void closePort( void );
|
||||
|
||||
//! Returns true if a port is open and false if not.
|
||||
virtual bool isPortOpen() const;
|
||||
|
||||
//! Return the number of available MIDI input ports.
|
||||
/*!
|
||||
\return This function returns the number of MIDI ports of the selected API.
|
||||
*/
|
||||
unsigned int getPortCount();
|
||||
|
||||
//! Return a string identifier for the specified MIDI input port number.
|
||||
/*!
|
||||
\return The name of the port with the given Id is returned.
|
||||
\retval An empty string is returned if an invalid port specifier is provided.
|
||||
*/
|
||||
std::string getPortName( unsigned int portNumber = 0 );
|
||||
|
||||
//! Specify whether certain MIDI message types should be queued or ignored during input.
|
||||
/*!
|
||||
By default, MIDI timing and active sensing messages are ignored
|
||||
during message input because of their relative high data rates.
|
||||
MIDI sysex messages are ignored by default as well. Variable
|
||||
values of "true" imply that the respective message type will be
|
||||
ignored.
|
||||
*/
|
||||
void ignoreTypes( bool midiSysex = true, bool midiTime = true, bool midiSense = true );
|
||||
|
||||
//! Fill the user-provided vector with the data bytes for the next available MIDI message in the input queue and return the event delta-time in seconds.
|
||||
/*!
|
||||
This function returns immediately whether a new message is
|
||||
available or not. A valid message is indicated by a non-zero
|
||||
vector size. An exception is thrown if an error occurs during
|
||||
message retrieval or an input connection was not previously
|
||||
established.
|
||||
*/
|
||||
double getMessage( std::vector<unsigned char> *message );
|
||||
|
||||
//! Set an error callback function to be invoked when an error has occured.
|
||||
/*!
|
||||
The callback function will be called whenever an error has occured. It is best
|
||||
to set the error callback function before opening a port.
|
||||
*/
|
||||
virtual void setErrorCallback( RtMidiErrorCallback errorCallback = NULL, void *userData = 0 );
|
||||
|
||||
protected:
|
||||
void openMidiApi( RtMidi::Api api, const std::string clientName, unsigned int queueSizeLimit );
|
||||
|
||||
};
|
||||
|
||||
/**********************************************************************/
|
||||
/*! \class RtMidiOut
|
||||
\brief A realtime MIDI output class.
|
||||
|
||||
This class provides a common, platform-independent API for MIDI
|
||||
output. It allows one to probe available MIDI output ports, to
|
||||
connect to one such port, and to send MIDI bytes immediately over
|
||||
the connection. Create multiple instances of this class to
|
||||
connect to more than one MIDI device at the same time. With the
|
||||
OS-X, Linux ALSA and JACK MIDI APIs, it is also possible to open a
|
||||
virtual port to which other MIDI software clients can connect.
|
||||
|
||||
by Gary P. Scavone, 2003-2014.
|
||||
*/
|
||||
/**********************************************************************/
|
||||
|
||||
class RtMidiOut : public RtMidi
|
||||
{
|
||||
public:
|
||||
|
||||
//! Default constructor that allows an optional client name.
|
||||
/*!
|
||||
An exception will be thrown if a MIDI system initialization error occurs.
|
||||
|
||||
If no API argument is specified and multiple API support has been
|
||||
compiled, the default order of use is ALSA, JACK (Linux) and CORE,
|
||||
JACK (OS-X).
|
||||
*/
|
||||
RtMidiOut( RtMidi::Api api=UNSPECIFIED,
|
||||
const std::string clientName = std::string( "RtMidi Output Client") );
|
||||
|
||||
//! The destructor closes any open MIDI connections.
|
||||
~RtMidiOut( void ) throw();
|
||||
|
||||
//! Returns the MIDI API specifier for the current instance of RtMidiOut.
|
||||
RtMidi::Api getCurrentApi( void ) throw();
|
||||
|
||||
//! Open a MIDI output connection.
|
||||
/*!
|
||||
An optional port number greater than 0 can be specified.
|
||||
Otherwise, the default or first port found is opened. An
|
||||
exception is thrown if an error occurs while attempting to make
|
||||
the port connection.
|
||||
*/
|
||||
void openPort( unsigned int portNumber = 0, const std::string portName = std::string( "RtMidi Output" ) );
|
||||
|
||||
//! Close an open MIDI connection (if one exists).
|
||||
void closePort( void );
|
||||
|
||||
//! Returns true if a port is open and false if not.
|
||||
virtual bool isPortOpen() const;
|
||||
|
||||
//! Create a virtual output port, with optional name, to allow software connections (OS X, JACK and ALSA only).
|
||||
/*!
|
||||
This function creates a virtual MIDI output port to which other
|
||||
software applications can connect. This type of functionality
|
||||
is currently only supported by the Macintosh OS-X, Linux ALSA
|
||||
and JACK APIs (the function does nothing with the other APIs).
|
||||
An exception is thrown if an error occurs while attempting to
|
||||
create the virtual port.
|
||||
*/
|
||||
void openVirtualPort( const std::string portName = std::string( "RtMidi Output" ) );
|
||||
|
||||
//! Return the number of available MIDI output ports.
|
||||
unsigned int getPortCount( void );
|
||||
|
||||
//! Return a string identifier for the specified MIDI port type and number.
|
||||
/*!
|
||||
An empty string is returned if an invalid port specifier is provided.
|
||||
*/
|
||||
std::string getPortName( unsigned int portNumber = 0 );
|
||||
|
||||
//! Immediately send a single message out an open MIDI output port.
|
||||
/*!
|
||||
An exception is thrown if an error occurs during output or an
|
||||
output connection was not previously established.
|
||||
*/
|
||||
void sendMessage( std::vector<unsigned char> *message );
|
||||
|
||||
//! Set an error callback function to be invoked when an error has occured.
|
||||
/*!
|
||||
The callback function will be called whenever an error has occured. It is best
|
||||
to set the error callback function before opening a port.
|
||||
*/
|
||||
virtual void setErrorCallback( RtMidiErrorCallback errorCallback = NULL, void *userData = 0 );
|
||||
|
||||
protected:
|
||||
void openMidiApi( RtMidi::Api api, const std::string clientName );
|
||||
};
|
||||
|
||||
|
||||
// **************************************************************** //
|
||||
//
|
||||
// MidiInApi / MidiOutApi class declarations.
|
||||
//
|
||||
// Subclasses of MidiInApi and MidiOutApi contain all API- and
|
||||
// OS-specific code necessary to fully implement the RtMidi API.
|
||||
//
|
||||
// Note that MidiInApi and MidiOutApi are abstract base classes and
|
||||
// cannot be explicitly instantiated. RtMidiIn and RtMidiOut will
|
||||
// create instances of a MidiInApi or MidiOutApi subclass.
|
||||
//
|
||||
// **************************************************************** //
|
||||
|
||||
class MidiApi
|
||||
{
|
||||
public:
|
||||
|
||||
MidiApi();
|
||||
virtual ~MidiApi();
|
||||
virtual RtMidi::Api getCurrentApi( void ) = 0;
|
||||
virtual void openPort( unsigned int portNumber, const std::string portName ) = 0;
|
||||
virtual void openVirtualPort( const std::string portName ) = 0;
|
||||
virtual void closePort( void ) = 0;
|
||||
|
||||
virtual unsigned int getPortCount( void ) = 0;
|
||||
virtual std::string getPortName( unsigned int portNumber ) = 0;
|
||||
|
||||
inline bool isPortOpen() const { return connected_; }
|
||||
void setErrorCallback( RtMidiErrorCallback errorCallback, void *userData );
|
||||
|
||||
//! A basic error reporting function for RtMidi classes.
|
||||
void error( RtMidiError::Type type, std::string errorString );
|
||||
|
||||
protected:
|
||||
virtual void initialize( const std::string& clientName ) = 0;
|
||||
|
||||
void *apiData_;
|
||||
bool connected_;
|
||||
std::string errorString_;
|
||||
RtMidiErrorCallback errorCallback_;
|
||||
bool firstErrorOccurred_;
|
||||
void *errorCallbackUserData_;
|
||||
};
|
||||
|
||||
class MidiInApi : public MidiApi
|
||||
{
|
||||
public:
|
||||
|
||||
MidiInApi( unsigned int queueSizeLimit );
|
||||
virtual ~MidiInApi( void );
|
||||
void setCallback( RtMidiIn::RtMidiCallback callback, void *userData );
|
||||
void cancelCallback( void );
|
||||
virtual void ignoreTypes( bool midiSysex, bool midiTime, bool midiSense );
|
||||
double getMessage( std::vector<unsigned char> *message );
|
||||
|
||||
// A MIDI structure used internally by the class to store incoming
|
||||
// messages. Each message represents one and only one MIDI message.
|
||||
struct MidiMessage {
|
||||
std::vector<unsigned char> bytes;
|
||||
double timeStamp;
|
||||
|
||||
// Default constructor.
|
||||
MidiMessage()
|
||||
:bytes(0), timeStamp(0.0) {}
|
||||
};
|
||||
|
||||
struct MidiQueue {
|
||||
unsigned int front;
|
||||
unsigned int back;
|
||||
unsigned int size;
|
||||
unsigned int ringSize;
|
||||
MidiMessage *ring;
|
||||
|
||||
// Default constructor.
|
||||
MidiQueue()
|
||||
:front(0), back(0), size(0), ringSize(0) {}
|
||||
};
|
||||
|
||||
// The RtMidiInData structure is used to pass private class data to
|
||||
// the MIDI input handling function or thread.
|
||||
struct RtMidiInData {
|
||||
MidiQueue queue;
|
||||
MidiMessage message;
|
||||
unsigned char ignoreFlags;
|
||||
bool doInput;
|
||||
bool firstMessage;
|
||||
void *apiData;
|
||||
bool usingCallback;
|
||||
RtMidiIn::RtMidiCallback userCallback;
|
||||
void *userData;
|
||||
bool continueSysex;
|
||||
|
||||
// Default constructor.
|
||||
RtMidiInData()
|
||||
: ignoreFlags(7), doInput(false), firstMessage(true),
|
||||
apiData(0), usingCallback(false), userCallback(0), userData(0),
|
||||
continueSysex(false) {}
|
||||
};
|
||||
|
||||
protected:
|
||||
RtMidiInData inputData_;
|
||||
};
|
||||
|
||||
class MidiOutApi : public MidiApi
|
||||
{
|
||||
public:
|
||||
|
||||
MidiOutApi( void );
|
||||
virtual ~MidiOutApi( void );
|
||||
virtual void sendMessage( std::vector<unsigned char> *message ) = 0;
|
||||
};
|
||||
|
||||
// **************************************************************** //
|
||||
//
|
||||
// Inline RtMidiIn and RtMidiOut definitions.
|
||||
//
|
||||
// **************************************************************** //
|
||||
|
||||
inline RtMidi::Api RtMidiIn :: getCurrentApi( void ) throw() { return rtapi_->getCurrentApi(); }
|
||||
inline void RtMidiIn :: openPort( unsigned int portNumber, const std::string portName ) { rtapi_->openPort( portNumber, portName ); }
|
||||
inline void RtMidiIn :: openVirtualPort( const std::string portName ) { rtapi_->openVirtualPort( portName ); }
|
||||
inline void RtMidiIn :: closePort( void ) { rtapi_->closePort(); }
|
||||
inline bool RtMidiIn :: isPortOpen() const { return rtapi_->isPortOpen(); }
|
||||
inline void RtMidiIn :: setCallback( RtMidiCallback callback, void *userData ) { ((MidiInApi *)rtapi_)->setCallback( callback, userData ); }
|
||||
inline void RtMidiIn :: cancelCallback( void ) { ((MidiInApi *)rtapi_)->cancelCallback(); }
|
||||
inline unsigned int RtMidiIn :: getPortCount( void ) { return rtapi_->getPortCount(); }
|
||||
inline std::string RtMidiIn :: getPortName( unsigned int portNumber ) { return rtapi_->getPortName( portNumber ); }
|
||||
inline void RtMidiIn :: ignoreTypes( bool midiSysex, bool midiTime, bool midiSense ) { ((MidiInApi *)rtapi_)->ignoreTypes( midiSysex, midiTime, midiSense ); }
|
||||
inline double RtMidiIn :: getMessage( std::vector<unsigned char> *message ) { return ((MidiInApi *)rtapi_)->getMessage( message ); }
|
||||
inline void RtMidiIn :: setErrorCallback( RtMidiErrorCallback errorCallback, void *userData ) { rtapi_->setErrorCallback(errorCallback, userData); }
|
||||
|
||||
inline RtMidi::Api RtMidiOut :: getCurrentApi( void ) throw() { return rtapi_->getCurrentApi(); }
|
||||
inline void RtMidiOut :: openPort( unsigned int portNumber, const std::string portName ) { rtapi_->openPort( portNumber, portName ); }
|
||||
inline void RtMidiOut :: openVirtualPort( const std::string portName ) { rtapi_->openVirtualPort( portName ); }
|
||||
inline void RtMidiOut :: closePort( void ) { rtapi_->closePort(); }
|
||||
inline bool RtMidiOut :: isPortOpen() const { return rtapi_->isPortOpen(); }
|
||||
inline unsigned int RtMidiOut :: getPortCount( void ) { return rtapi_->getPortCount(); }
|
||||
inline std::string RtMidiOut :: getPortName( unsigned int portNumber ) { return rtapi_->getPortName( portNumber ); }
|
||||
inline void RtMidiOut :: sendMessage( std::vector<unsigned char> *message ) { ((MidiOutApi *)rtapi_)->sendMessage( message ); }
|
||||
inline void RtMidiOut :: setErrorCallback( RtMidiErrorCallback errorCallback, void *userData ) { rtapi_->setErrorCallback(errorCallback, userData); }
|
||||
|
||||
// **************************************************************** //
|
||||
//
|
||||
// MidiInApi and MidiOutApi subclass prototypes.
|
||||
//
|
||||
// **************************************************************** //
|
||||
|
||||
#if !defined(__LINUX_ALSA__) && !defined(__UNIX_JACK__) && !defined(__MACOSX_CORE__) && !defined(__WINDOWS_MM__)
|
||||
#define __RTMIDI_DUMMY__
|
||||
#endif
|
||||
|
||||
#if defined(__MACOSX_CORE__)
|
||||
|
||||
class MidiInCore: public MidiInApi
|
||||
{
|
||||
public:
|
||||
MidiInCore( const std::string clientName, unsigned int queueSizeLimit );
|
||||
~MidiInCore( void );
|
||||
RtMidi::Api getCurrentApi( void ) { return RtMidi::MACOSX_CORE; };
|
||||
void openPort( unsigned int portNumber, const std::string portName );
|
||||
void openVirtualPort( const std::string portName );
|
||||
void closePort( void );
|
||||
unsigned int getPortCount( void );
|
||||
std::string getPortName( unsigned int portNumber );
|
||||
|
||||
protected:
|
||||
void initialize( const std::string& clientName );
|
||||
};
|
||||
|
||||
class MidiOutCore: public MidiOutApi
|
||||
{
|
||||
public:
|
||||
MidiOutCore( const std::string clientName );
|
||||
~MidiOutCore( void );
|
||||
RtMidi::Api getCurrentApi( void ) { return RtMidi::MACOSX_CORE; };
|
||||
void openPort( unsigned int portNumber, const std::string portName );
|
||||
void openVirtualPort( const std::string portName );
|
||||
void closePort( void );
|
||||
unsigned int getPortCount( void );
|
||||
std::string getPortName( unsigned int portNumber );
|
||||
void sendMessage( std::vector<unsigned char> *message );
|
||||
|
||||
protected:
|
||||
void initialize( const std::string& clientName );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__UNIX_JACK__)
|
||||
|
||||
class MidiInJack: public MidiInApi
|
||||
{
|
||||
public:
|
||||
MidiInJack( const std::string clientName, unsigned int queueSizeLimit );
|
||||
~MidiInJack( void );
|
||||
RtMidi::Api getCurrentApi( void ) { return RtMidi::UNIX_JACK; };
|
||||
void openPort( unsigned int portNumber, const std::string portName );
|
||||
void openVirtualPort( const std::string portName );
|
||||
void closePort( void );
|
||||
unsigned int getPortCount( void );
|
||||
std::string getPortName( unsigned int portNumber );
|
||||
|
||||
protected:
|
||||
std::string clientName;
|
||||
|
||||
void connect( void );
|
||||
void initialize( const std::string& clientName );
|
||||
};
|
||||
|
||||
class MidiOutJack: public MidiOutApi
|
||||
{
|
||||
public:
|
||||
MidiOutJack( const std::string clientName );
|
||||
~MidiOutJack( void );
|
||||
RtMidi::Api getCurrentApi( void ) { return RtMidi::UNIX_JACK; };
|
||||
void openPort( unsigned int portNumber, const std::string portName );
|
||||
void openVirtualPort( const std::string portName );
|
||||
void closePort( void );
|
||||
unsigned int getPortCount( void );
|
||||
std::string getPortName( unsigned int portNumber );
|
||||
void sendMessage( std::vector<unsigned char> *message );
|
||||
|
||||
protected:
|
||||
std::string clientName;
|
||||
|
||||
void connect( void );
|
||||
void initialize( const std::string& clientName );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__LINUX_ALSA__)
|
||||
|
||||
class MidiInAlsa: public MidiInApi
|
||||
{
|
||||
public:
|
||||
MidiInAlsa( const std::string clientName, unsigned int queueSizeLimit );
|
||||
~MidiInAlsa( void );
|
||||
RtMidi::Api getCurrentApi( void ) { return RtMidi::LINUX_ALSA; };
|
||||
void openPort( unsigned int portNumber, const std::string portName );
|
||||
void openVirtualPort( const std::string portName );
|
||||
void closePort( void );
|
||||
unsigned int getPortCount( void );
|
||||
std::string getPortName( unsigned int portNumber );
|
||||
|
||||
protected:
|
||||
void initialize( const std::string& clientName );
|
||||
};
|
||||
|
||||
class MidiOutAlsa: public MidiOutApi
|
||||
{
|
||||
public:
|
||||
MidiOutAlsa( const std::string clientName );
|
||||
~MidiOutAlsa( void );
|
||||
RtMidi::Api getCurrentApi( void ) { return RtMidi::LINUX_ALSA; };
|
||||
void openPort( unsigned int portNumber, const std::string portName );
|
||||
void openVirtualPort( const std::string portName );
|
||||
void closePort( void );
|
||||
unsigned int getPortCount( void );
|
||||
std::string getPortName( unsigned int portNumber );
|
||||
void sendMessage( std::vector<unsigned char> *message );
|
||||
|
||||
protected:
|
||||
void initialize( const std::string& clientName );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__WINDOWS_MM__)
|
||||
|
||||
class MidiInWinMM: public MidiInApi
|
||||
{
|
||||
public:
|
||||
MidiInWinMM( const std::string clientName, unsigned int queueSizeLimit );
|
||||
~MidiInWinMM( void );
|
||||
RtMidi::Api getCurrentApi( void ) { return RtMidi::WINDOWS_MM; };
|
||||
void openPort( unsigned int portNumber, const std::string portName );
|
||||
void openVirtualPort( const std::string portName );
|
||||
void closePort( void );
|
||||
unsigned int getPortCount( void );
|
||||
std::string getPortName( unsigned int portNumber );
|
||||
|
||||
protected:
|
||||
void initialize( const std::string& clientName );
|
||||
};
|
||||
|
||||
class MidiOutWinMM: public MidiOutApi
|
||||
{
|
||||
public:
|
||||
MidiOutWinMM( const std::string clientName );
|
||||
~MidiOutWinMM( void );
|
||||
RtMidi::Api getCurrentApi( void ) { return RtMidi::WINDOWS_MM; };
|
||||
void openPort( unsigned int portNumber, const std::string portName );
|
||||
void openVirtualPort( const std::string portName );
|
||||
void closePort( void );
|
||||
unsigned int getPortCount( void );
|
||||
std::string getPortName( unsigned int portNumber );
|
||||
void sendMessage( std::vector<unsigned char> *message );
|
||||
|
||||
protected:
|
||||
void initialize( const std::string& clientName );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__RTMIDI_DUMMY__)
|
||||
|
||||
class MidiInDummy: public MidiInApi
|
||||
{
|
||||
public:
|
||||
MidiInDummy( const std::string /*clientName*/, unsigned int queueSizeLimit ) : MidiInApi( queueSizeLimit ) { errorString_ = "MidiInDummy: This class provides no functionality."; error( RtMidiError::WARNING, errorString_ ); }
|
||||
RtMidi::Api getCurrentApi( void ) { return RtMidi::RTMIDI_DUMMY; }
|
||||
void openPort( unsigned int /*portNumber*/, const std::string /*portName*/ ) {}
|
||||
void openVirtualPort( const std::string /*portName*/ ) {}
|
||||
void closePort( void ) {}
|
||||
unsigned int getPortCount( void ) { return 0; }
|
||||
std::string getPortName( unsigned int portNumber ) { return ""; }
|
||||
|
||||
protected:
|
||||
void initialize( const std::string& /*clientName*/ ) {}
|
||||
};
|
||||
|
||||
class MidiOutDummy: public MidiOutApi
|
||||
{
|
||||
public:
|
||||
MidiOutDummy( const std::string /*clientName*/ ) { errorString_ = "MidiOutDummy: This class provides no functionality."; error( RtMidiError::WARNING, errorString_ ); }
|
||||
RtMidi::Api getCurrentApi( void ) { return RtMidi::RTMIDI_DUMMY; }
|
||||
void openPort( unsigned int /*portNumber*/, const std::string /*portName*/ ) {}
|
||||
void openVirtualPort( const std::string /*portName*/ ) {}
|
||||
void closePort( void ) {}
|
||||
unsigned int getPortCount( void ) { return 0; }
|
||||
std::string getPortName( unsigned int /*portNumber*/ ) { return ""; }
|
||||
void sendMessage( std::vector<unsigned char> * /*message*/ ) {}
|
||||
|
||||
protected:
|
||||
void initialize( const std::string& /*clientName*/ ) {}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,153 @@
|
|||
# Process this file with autoconf to produce a configure script.
|
||||
AC_INIT(RtMidi, 2.1.0, gary@music.mcgill.ca, rtmidi)
|
||||
AC_CONFIG_AUX_DIR(config)
|
||||
AC_CONFIG_SRCDIR(RtMidi.cpp)
|
||||
AC_CONFIG_FILES([rtmidi-config librtmidi.pc Makefile tests/Makefile])
|
||||
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
|
||||
|
||||
# Fill GXX with something before test.
|
||||
AC_SUBST( GXX, ["no"] )
|
||||
AC_SUBST(noinst_LIBRARIES)
|
||||
|
||||
# Checks for programs.
|
||||
AC_PROG_CXX(g++ CC c++ cxx)
|
||||
AM_PROG_AR
|
||||
AC_PATH_PROG(AR, ar, no)
|
||||
if [[ $AR = "no" ]] ; then
|
||||
AC_MSG_ERROR("Could not find ar - needed to create a library");
|
||||
fi
|
||||
|
||||
LT_INIT([win32-dll])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
# Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
#AC_CHECK_HEADERS(sys/ioctl.h unistd.h)
|
||||
|
||||
# Check for debug
|
||||
AC_MSG_CHECKING(whether to compile debug version)
|
||||
AC_ARG_ENABLE(debug,
|
||||
[ --enable-debug = enable various debug output],
|
||||
[AC_SUBST( cppflag, [-D__RTMIDI_DEBUG__] ) AC_SUBST( cxxflag, [-g] ) AC_SUBST( object_path, [Debug] ) AC_MSG_RESULT(yes)],
|
||||
[AC_SUBST( cppflag, [] ) AC_SUBST( cxxflag, [-O3] ) AC_SUBST( object_path, [Release] ) AC_MSG_RESULT(no)])
|
||||
|
||||
# Set paths if prefix is defined
|
||||
if test "x$prefix" != "x" && test "x$prefix" != "xNONE"; then
|
||||
LIBS="$LIBS -L$prefix/lib"
|
||||
CPPFLAGS="$CPPFLAGS -I$prefix/include"
|
||||
fi
|
||||
|
||||
# For -I and -D flags
|
||||
CPPFLAGS="$CPPFLAGS $cppflag"
|
||||
|
||||
# For debugging and optimization ... overwrite default because it has both -g and -O2
|
||||
#CXXFLAGS="$CXXFLAGS $cxxflag"
|
||||
CXXFLAGS="$cxxflag"
|
||||
|
||||
# Check compiler and use -Wall if gnu.
|
||||
if [test $GXX = "yes" ;] then
|
||||
AC_SUBST( cxxflag, ["-Wall -Wextra"] )
|
||||
fi
|
||||
|
||||
CXXFLAGS="$CXXFLAGS $cxxflag"
|
||||
|
||||
# Checks for package options and external software
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
AC_SUBST( sharedlib, ["librtmidi.so"] )
|
||||
AC_SUBST( sharedname, ["librtmidi.so.\$(RELEASE)"] )
|
||||
AC_SUBST( libflags, ["-shared -Wl,-soname,\$(SHARED).\$(MAJOR) -o \$(SHARED).\$(RELEASE)"] )
|
||||
case $host in
|
||||
*-apple*)
|
||||
AC_SUBST( sharedlib, ["librtmidi.dylib"] )
|
||||
AC_SUBST( sharedname, ["librtmidi.\$(RELEASE).dylib"] )
|
||||
AC_SUBST( libflags, ["-dynamiclib -o librtmidi.\$(RELEASE).dylib"] )
|
||||
esac
|
||||
|
||||
AC_SUBST( api, [""] )
|
||||
AC_SUBST( req, [""] )
|
||||
AC_MSG_CHECKING(for MIDI API)
|
||||
case $host in
|
||||
*-*-linux*)
|
||||
AC_ARG_WITH(jack, [ --with-jack = choose JACK server support (mac and linux only)], [
|
||||
api="$api -D__UNIX_JACK__"
|
||||
AC_MSG_RESULT(using JACK)
|
||||
AC_CHECK_LIB(jack, jack_client_open, , AC_MSG_ERROR(JACK support requires the jack library!))], )
|
||||
|
||||
# Look for ALSA flag
|
||||
AC_ARG_WITH(alsa, [ --with-alsa = choose native ALSA sequencer API support (linux only)], [
|
||||
api="$api -D__LINUX_ALSA__"
|
||||
req="$req alsa"
|
||||
AC_MSG_RESULT(using ALSA)
|
||||
AC_CHECK_LIB(asound, snd_seq_open, , AC_MSG_ERROR(ALSA support requires the asound library!))], )
|
||||
|
||||
if [test "$api" == "";] then
|
||||
AC_MSG_RESULT(using ALSA)
|
||||
AC_SUBST( api, [-D__LINUX_ALSA__] )
|
||||
req="$req alsa"
|
||||
AC_CHECK_LIB(asound, snd_seq_open, , AC_MSG_ERROR(ALSA sequencer support requires the asound library!))
|
||||
fi
|
||||
|
||||
# Checks for pthread library.
|
||||
AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtMidi requires the pthread library!))
|
||||
;;
|
||||
|
||||
*-apple*)
|
||||
AC_ARG_WITH(jack, [ --with-jack = choose JACK server support (mac and linux only)], [
|
||||
api="$api -D__UNIX_JACK__"
|
||||
AC_MSG_RESULT(using JACK)
|
||||
AC_CHECK_LIB(jack, jack_client_open, , AC_MSG_ERROR(JACK support requires the jack library!))], )
|
||||
|
||||
# Look for Core flag
|
||||
AC_ARG_WITH(core, [ --with-core = choose CoreMidi API support (mac only)], [
|
||||
api="$api -D__MACOSX_CORE__"
|
||||
AC_MSG_RESULT(using CoreMidi)
|
||||
AC_CHECK_HEADER(CoreMIDI/CoreMIDI.h, [], [AC_MSG_ERROR(CoreMIDI header files not found!)] )
|
||||
LIBS="$LIBS -framework CoreMIDI -framework CoreFoundation -framework CoreAudio" ], )
|
||||
|
||||
# If no api flags specified, use CoreMidi
|
||||
if [test "$api" == ""; ] then
|
||||
AC_SUBST( api, [-D__MACOSX_CORE__] )
|
||||
AC_MSG_RESULT(using CoreMidi)
|
||||
AC_CHECK_HEADER(CoreMIDI/CoreMIDI.h,
|
||||
[],
|
||||
[AC_MSG_ERROR(CoreMIDI header files not found!)] )
|
||||
AC_SUBST( LIBS, ["-framework CoreMIDI -framework CoreFoundation -framework CoreAudio"] )
|
||||
fi
|
||||
;;
|
||||
|
||||
*-mingw32*)
|
||||
# Look for WinMM flag
|
||||
AC_ARG_WITH(winmm, [ --with-winmm = choose Windows MultiMedia (MM) API support (windoze only)], [
|
||||
api="$api -D__WINDOWS_MM__"
|
||||
AC_MSG_RESULT(using WinMM)
|
||||
AC_SUBST( LIBS, [-lwinmm] )], )
|
||||
|
||||
AC_ARG_WITH(winks, [ --with-winks = choose kernel streaming support (windoze only)], [
|
||||
api="$api -D__WINDOWS_KS__"
|
||||
AC_SUBST( LIBS, ["-lsetupapi -lksuser"] )
|
||||
AC_MSG_RESULT(using kernel streaming) ], )
|
||||
|
||||
# I can't get the following check to work so just manually add the library
|
||||
# or could try the following? AC_LIB_WINMM([midiOutGetNumDevs])
|
||||
# AC_CHECK_LIB(winmm, midiInGetNumDevs, , AC_MSG_ERROR(Windows MIDI support requires the winmm library!) )],)
|
||||
|
||||
# If no api flags specified, use WinMM
|
||||
if [test "$api" == "";] then
|
||||
AC_SUBST( api, [-D__WINDOWS_MM__] )
|
||||
AC_MSG_RESULT(using WinMM)
|
||||
AC_SUBST( LIBS, [-lwinmm] )
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
# Default case for unknown realtime systems.
|
||||
AC_MSG_ERROR(Unknown system type for MIDI support!)
|
||||
;;
|
||||
esac
|
||||
|
||||
CPPFLAGS="$CPPFLAGS $api"
|
||||
|
||||
AC_OUTPUT
|
||||
|
||||
chmod oug+x rtmidi-config
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,9 @@
|
|||
<HR>
|
||||
|
||||
<table><tr><td><img src="../images/mcgill.gif" width=165></td>
|
||||
<td>©2003-2014 Gary P. Scavone, McGill University. All Rights Reserved.<br>
|
||||
Maintained by Gary P. Scavone, gary at music.mcgill.ca</td></tr>
|
||||
</table>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>The RtMidi Tutorial</TITLE>
|
||||
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
|
||||
</HEAD>
|
||||
<BODY BGCOLOR="#FFFFFF">
|
||||
<CENTER>
|
||||
<a class="qindex" href="index.html">Tutorial</a> <a class="qindex" href="annotated.html">Class/Enum List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> </CENTER>
|
||||
<HR>
|
||||
|
|
@ -0,0 +1,469 @@
|
|||
/*! \mainpage The RtMidi Tutorial
|
||||
|
||||
<CENTER>\ref intro \ref download \ref start \ref error \ref probing \ref output \ref input \ref virtual \ref compiling \ref debug \ref multi \ref apinotes \ref acknowledge \ref license</CENTER>
|
||||
|
||||
\section intro Introduction
|
||||
|
||||
RtMidi is a set of C++ classes (RtMidiIn, RtMidiOut and API-specific classes) that provides a common API (Application Programming Interface) for realtime MIDI input/output across Linux (ALSA & JACK), Macintosh OS X (CoreMIDI & JACK), and Windows (Multimedia Library) operating systems. RtMidi significantly simplifies the process of interacting with computer MIDI hardware and software. It was designed with the following goals:
|
||||
|
||||
<UL>
|
||||
<LI>object oriented C++ design</LI>
|
||||
<LI>simple, common API across all supported platforms</LI>
|
||||
<LI>only one header and one source file for easy inclusion in programming projects</LI>
|
||||
<LI>MIDI device enumeration</LI>
|
||||
</UL>
|
||||
|
||||
Where applicable, multiple API support can be compiled and a particular API specified when creating an RtAudio instance.
|
||||
|
||||
MIDI input and output functionality are separated into two classes, RtMidiIn and RtMidiOut. Each class instance supports only a single MIDI connection. RtMidi does not provide timing functionality (i.e., output messages are sent immediately). Input messages are timestamped with delta times in seconds (via a \c double floating point type). MIDI data is passed to the user as raw bytes using an std::vector<unsigned char>.
|
||||
|
||||
\section whatsnew What's New (Version 2.1)
|
||||
|
||||
A minor API change was made. The RtError class was renamed RtMidiError and embedded directly in RtMidi.h. Thus, all references to RtError should be renamed to RtMidiError and the RtError.h file should be deleted. The Windows Kernel Streaming support was removed because it was uncompilable and incomplete.
|
||||
|
||||
\section download Download
|
||||
|
||||
Latest Release (30 March 2014): <A href="http://www.music.mcgill.ca/~gary/rtmidi/release/rtmidi-2.1.0.tar.gz">Version 2.1.0</A>
|
||||
|
||||
\section start Getting Started
|
||||
|
||||
The first thing that must be done when using RtMidi is to create an instance of the RtMidiIn or RtMidiOut subclasses. RtMidi is an abstract base class, which itself cannot be instantiated. Each default constructor attempts to establish any necessary "connections" with the underlying MIDI system. RtMidi uses C++ exceptions to report errors, necessitating try/catch blocks around many member functions. An RtMidiError can be thrown during instantiation in some circumstances. A warning message may also be reported if no MIDI devices are found during instantiation. The RtMidi classes have been designed to work with "hot pluggable" or virtual (software) MIDI devices, making it possible to connect to MIDI devices that may not have been present when the classes were instantiated. The following code example demonstrates default object construction and destruction:
|
||||
|
||||
\code
|
||||
|
||||
#include "RtMidi.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
RtMidiIn *midiin = 0;
|
||||
|
||||
// RtMidiIn constructor
|
||||
try {
|
||||
midiin = new RtMidiIn();
|
||||
}
|
||||
catch (RtMidiError &error) {
|
||||
// Handle the exception here
|
||||
error.printMessage();
|
||||
}
|
||||
|
||||
// Clean up
|
||||
delete midiin;
|
||||
}
|
||||
\endcode
|
||||
|
||||
Obviously, this example doesn't demonstrate any of the real functionality of RtMidi. However, all uses of RtMidi must begin with construction and must end with class destruction. Further, it is necessary that all class methods that can throw a C++ exception be called within a try/catch block.
|
||||
|
||||
|
||||
\section error Error Handling
|
||||
|
||||
RtMidi uses a C++ exception handler called RtMidiError, which is
|
||||
declared and defined in RtMidi.h. The RtMidiError class is quite
|
||||
simple but it does allow errors to be "caught" by RtMidiError::Type.
|
||||
Many RtMidi methods can "throw" an RtMidiError, most typically if a
|
||||
driver error occurs or an invalid function argument is specified.
|
||||
There are a number of cases within RtMidi where warning messages may
|
||||
be displayed but an exception is not thrown. A client error callback
|
||||
function can be specified (via the RtMidi::setErrorCallback function)
|
||||
that is invoked when an error occurs. By default, error messages are
|
||||
not automatically displayed in RtMidi unless the preprocessor
|
||||
definition __RTMIDI_DEBUG__ is defined during compilation. Messages
|
||||
associated with caught exceptions can be displayed with, for example,
|
||||
the RtMidiError::printMessage() function.
|
||||
|
||||
|
||||
\section probing Probing Ports
|
||||
|
||||
A client generally must query the available MIDI ports before deciding which to use. The following example outlines how this can be done.
|
||||
|
||||
\code
|
||||
// midiprobe.cpp
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include "RtMidi.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
RtMidiIn *midiin = 0;
|
||||
RtMidiOut *midiout = 0;
|
||||
|
||||
// RtMidiIn constructor
|
||||
try {
|
||||
midiin = new RtMidiIn();
|
||||
}
|
||||
catch ( RtMidiError &error ) {
|
||||
error.printMessage();
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
// Check inputs.
|
||||
unsigned int nPorts = midiin->getPortCount();
|
||||
std::cout << "\nThere are " << nPorts << " MIDI input sources available.\n";
|
||||
std::string portName;
|
||||
for ( unsigned int i=0; i<nPorts; i++ ) {
|
||||
try {
|
||||
portName = midiin->getPortName(i);
|
||||
}
|
||||
catch ( RtMidiError &error ) {
|
||||
error.printMessage();
|
||||
goto cleanup;
|
||||
}
|
||||
std::cout << " Input Port #" << i+1 << ": " << portName << '\n';
|
||||
}
|
||||
|
||||
// RtMidiOut constructor
|
||||
try {
|
||||
midiout = new RtMidiOut();
|
||||
}
|
||||
catch ( RtMidiError &error ) {
|
||||
error.printMessage();
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
// Check outputs.
|
||||
nPorts = midiout->getPortCount();
|
||||
std::cout << "\nThere are " << nPorts << " MIDI output ports available.\n";
|
||||
for ( unsigned int i=0; i<nPorts; i++ ) {
|
||||
try {
|
||||
portName = midiout->getPortName(i);
|
||||
}
|
||||
catch (RtMidiError &error) {
|
||||
error.printMessage();
|
||||
goto cleanup;
|
||||
}
|
||||
std::cout << " Output Port #" << i+1 << ": " << portName << '\n';
|
||||
}
|
||||
std::cout << '\n';
|
||||
|
||||
// Clean up
|
||||
cleanup:
|
||||
delete midiin;
|
||||
delete midiout;
|
||||
|
||||
return 0;
|
||||
}
|
||||
\endcode
|
||||
|
||||
\section output MIDI Output
|
||||
|
||||
The RtMidiOut class provides simple functionality to immediately send messages over a MIDI connection. No timing functionality is provided.
|
||||
|
||||
In the following example, we omit necessary error checking and details regarding OS-dependent sleep functions. For a complete example, see the \c midiout.cpp program in the \c tests directory.
|
||||
|
||||
\code
|
||||
// midiout.cpp
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include "RtMidi.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
RtMidiOut *midiout = new RtMidiOut();
|
||||
std::vector<unsigned char> message;
|
||||
|
||||
// Check available ports.
|
||||
unsigned int nPorts = midiout->getPortCount();
|
||||
if ( nPorts == 0 ) {
|
||||
std::cout << "No ports available!\n";
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Open first available port.
|
||||
midiout->openPort( 0 );
|
||||
|
||||
// Send out a series of MIDI messages.
|
||||
|
||||
// Program change: 192, 5
|
||||
message.push_back( 192 );
|
||||
message.push_back( 5 );
|
||||
midiout->sendMessage( &message );
|
||||
|
||||
// Control Change: 176, 7, 100 (volume)
|
||||
message[0] = 176;
|
||||
message[1] = 7;
|
||||
message.push_back( 100 );
|
||||
midiout->sendMessage( &message );
|
||||
|
||||
// Note On: 144, 64, 90
|
||||
message[0] = 144;
|
||||
message[1] = 64;
|
||||
message[2] = 90;
|
||||
midiout->sendMessage( &message );
|
||||
|
||||
SLEEP( 500 ); // Platform-dependent ... see example in tests directory.
|
||||
|
||||
// Note Off: 128, 64, 40
|
||||
message[0] = 128;
|
||||
message[1] = 64;
|
||||
message[2] = 40;
|
||||
midiout->sendMessage( &message );
|
||||
|
||||
// Clean up
|
||||
cleanup:
|
||||
delete midiout;
|
||||
|
||||
return 0;
|
||||
}
|
||||
\endcode
|
||||
|
||||
|
||||
\section input MIDI Input
|
||||
|
||||
The RtMidiIn class uses an internal callback function or thread to receive incoming MIDI messages from a port or device. These messages are then either queued and read by the user via calls to the RtMidiIn::getMessage() function or immediately passed to a user-specified callback function (which must be "registered" using the RtMidiIn::setCallback() function). We'll provide examples of both usages.
|
||||
|
||||
The RtMidiIn class provides the RtMidiIn::ignoreTypes() function to specify that certain MIDI message types be ignored. By default, system exclusive, timing, and active sensing messages are ignored.
|
||||
|
||||
\subsection qmidiin Queued MIDI Input
|
||||
|
||||
The RtMidiIn::getMessage() function does not block. If a MIDI message is available in the queue, it is copied to the user-provided \c std::vector<unsigned char> container. When no MIDI message is available, the function returns an empty container. The default maximum MIDI queue size is 1024 messages. This value may be modified with the RtMidiIn::setQueueSizeLimit() function. If the maximum queue size limit is reached, subsequent incoming MIDI messages are discarded until the queue size is reduced.
|
||||
|
||||
In the following example, we omit some necessary error checking and details regarding OS-dependent sleep functions. For a more complete example, see the \c qmidiin.cpp program in the \c tests directory.
|
||||
|
||||
\code
|
||||
// qmidiin.cpp
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <signal.h>
|
||||
#include "RtMidi.h"
|
||||
|
||||
bool done;
|
||||
static void finish(int ignore){ done = true; }
|
||||
|
||||
int main()
|
||||
{
|
||||
RtMidiIn *midiin = new RtMidiIn();
|
||||
std::vector<unsigned char> message;
|
||||
int nBytes, i;
|
||||
double stamp;
|
||||
|
||||
// Check available ports.
|
||||
unsigned int nPorts = midiin->getPortCount();
|
||||
if ( nPorts == 0 ) {
|
||||
std::cout << "No ports available!\n";
|
||||
goto cleanup;
|
||||
}
|
||||
midiin->openPort( 0 );
|
||||
|
||||
// Don't ignore sysex, timing, or active sensing messages.
|
||||
midiin->ignoreTypes( false, false, false );
|
||||
|
||||
// Install an interrupt handler function.
|
||||
done = false;
|
||||
(void) signal(SIGINT, finish);
|
||||
|
||||
// Periodically check input queue.
|
||||
std::cout << "Reading MIDI from port ... quit with Ctrl-C.\n";
|
||||
while ( !done ) {
|
||||
stamp = midiin->getMessage( &message );
|
||||
nBytes = message.size();
|
||||
for ( i=0; i<nBytes; i++ )
|
||||
std::cout << "Byte " << i << " = " << (int)message[i] << ", ";
|
||||
if ( nBytes > 0 )
|
||||
std::cout << "stamp = " << stamp << std::endl;
|
||||
|
||||
// Sleep for 10 milliseconds ... platform-dependent.
|
||||
SLEEP( 10 );
|
||||
}
|
||||
|
||||
// Clean up
|
||||
cleanup:
|
||||
delete midiin;
|
||||
|
||||
return 0;
|
||||
}
|
||||
\endcode
|
||||
|
||||
\subsection cmidiin MIDI Input with User Callback
|
||||
|
||||
When set, a user-provided callback function will be invoked after the input of a complete MIDI message. It is possible to provide a pointer to user data that can be accessed in the callback function (not shown here). It is necessary to set the callback function immediately after opening the port to avoid having incoming messages written to the queue (which is not emptied when a callback function is set). If you are worried about this happening, you can check the queue using the RtMidi::getMessage() function to verify it is empty (after the callback function is set).
|
||||
|
||||
In the following example, we omit some necessary error checking. For a more complete example, see the \c cmidiin.cpp program in the \c tests directory.
|
||||
|
||||
\code
|
||||
// cmidiin.cpp
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include "RtMidi.h"
|
||||
|
||||
void mycallback( double deltatime, std::vector< unsigned char > *message, void *userData )
|
||||
{
|
||||
unsigned int nBytes = message->size();
|
||||
for ( unsigned int i=0; i<nBytes; i++ )
|
||||
std::cout << "Byte " << i << " = " << (int)message->at(i) << ", ";
|
||||
if ( nBytes > 0 )
|
||||
std::cout << "stamp = " << deltatime << std::endl;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
RtMidiIn *midiin = new RtMidiIn();
|
||||
|
||||
// Check available ports.
|
||||
unsigned int nPorts = midiin->getPortCount();
|
||||
if ( nPorts == 0 ) {
|
||||
std::cout << "No ports available!\n";
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
midiin->openPort( 0 );
|
||||
|
||||
// Set our callback function. This should be done immediately after
|
||||
// opening the port to avoid having incoming messages written to the
|
||||
// queue.
|
||||
midiin->setCallback( &mycallback );
|
||||
|
||||
// Don't ignore sysex, timing, or active sensing messages.
|
||||
midiin->ignoreTypes( false, false, false );
|
||||
|
||||
std::cout << "\nReading MIDI input ... press <enter> to quit.\n";
|
||||
char input;
|
||||
std::cin.get(input);
|
||||
|
||||
// Clean up
|
||||
cleanup:
|
||||
delete midiin;
|
||||
|
||||
return 0;
|
||||
}
|
||||
\endcode
|
||||
|
||||
\section virtual Virtual Ports
|
||||
|
||||
The Linux ALSA, Macintosh CoreMIDI and JACK APIs allow for the establishment of virtual input and output MIDI ports to which other software clients can connect. RtMidi incorporates this functionality with the RtMidiIn::openVirtualPort() and RtMidiOut::openVirtualPort() functions. Any messages sent with the RtMidiOut::sendMessage() function will also be transmitted through an open virtual output port. If a virtual input port is open and a user callback function is set, the callback function will be invoked when messages arrive via that port. If a callback function is not set, the user must poll the input queue to check whether messages have arrived. No notification is provided for the establishment of a client connection via a virtual port.
|
||||
|
||||
\section compiling Compiling
|
||||
|
||||
In order to compile RtMidi for a specific OS and API, it is necessary to supply the appropriate preprocessor definition and library within the compiler statement:
|
||||
<P>
|
||||
|
||||
<TABLE BORDER=2 COLS=5 WIDTH="100%">
|
||||
<TR BGCOLOR="beige">
|
||||
<TD WIDTH="5%"><B>OS:</B></TD>
|
||||
<TD WIDTH="5%"><B>MIDI API:</B></TD>
|
||||
<TD WIDTH="5%"><B>Preprocessor Definition:</B></TD>
|
||||
<TD WIDTH="5%"><B>Library or Framework:</B></TD>
|
||||
<TD><B>Example Compiler Statement:</B></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>Linux</TD>
|
||||
<TD>ALSA Sequencer</TD>
|
||||
<TD>__LINUX_ALSA__</TD>
|
||||
<TD><TT>asound, pthread</TT></TD>
|
||||
<TD><TT>g++ -Wall -D__LINUX_ALSA__ -o midiprobe midiprobe.cpp RtMidi.cpp -lasound -lpthread</TT></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>Linux or Mac</TD>
|
||||
<TD>JACK MIDI</TD>
|
||||
<TD>__UNIX_JACK__</TD>
|
||||
<TD><TT>jack</TT></TD>
|
||||
<TD><TT>g++ -Wall -D__UNIX_JACK__ -o midiprobe midiprobe.cpp RtMidi.cpp -ljack</TT></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>Macintosh OS X</TD>
|
||||
<TD>CoreMIDI</TD>
|
||||
<TD>__MACOSX_CORE__</TD>
|
||||
<TD><TT>CoreMIDI, CoreAudio, CoreFoundation</TT></TD>
|
||||
<TD><TT>g++ -Wall -D__MACOSX_CORE__ -o midiprobe midiprobe.cpp RtMidi.cpp -framework CoreMIDI -framework CoreAudio -framework CoreFoundation</TT></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>Windows</TD>
|
||||
<TD>Multimedia Library</TD>
|
||||
<TD>__WINDOWS_MM__</TD>
|
||||
<TD><TT>winmm.lib, multithreaded</TT></TD>
|
||||
<TD><I>compiler specific</I></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<P>
|
||||
|
||||
The example compiler statements above could be used to compile the <TT>midiprobe.cpp</TT> example file, assuming that <TT>midiprobe.cpp</TT>, <TT>RtMidi.h</TT> and <TT>RtMidi.cpp</TT> all exist in the same directory.
|
||||
|
||||
\section debug Debugging
|
||||
|
||||
If you are having problems getting RtMidi to run on your system, try passing the preprocessor definition <TT>__RTMIDI_DEBUG__</TT> to the compiler (or define it in RtMidi.h). A variety of warning messages will be displayed that may help in determining the problem. Also try using the programs included in the <tt>tests</tt> directory. The program <tt>midiprobe</tt> displays the queried capabilities of all MIDI ports found.
|
||||
|
||||
\section multi Using Simultaneous Multiple APIs
|
||||
|
||||
Support for each MIDI API is encapsulated in specific MidiInApi or MidiOutApi subclasses, making it possible to compile and instantiate multiple API-specific subclasses on a given operating system. For example, one can compile both CoreMIDI and JACK support on the OS-X operating system by providing the appropriate preprocessor definitions for each. In a run-time situation, one might first attempt to determine whether any JACK ports are available. This can be done by specifying the api argument RtMidi::UNIX_JACK when attempting to create an instance of RtMidiIn or RtMidiOut. If no available ports are found, then an instance of RtMidi with the api argument RtMidi::MACOSX_CORE can be created. Alternately, if no api argument is specified, RtMidi will first look for JACK ports and if none are found, then CoreMIDI ports (in linux, the search order is JACK and then ALSA. In theory, it should also be possible to have separate instances of RtMidi open at the same time with different underlying API support, though this has not been tested.
|
||||
|
||||
The static function RtMidi::getCompiledApi() is provided to determine the available compiled API support. The function RtMidi::getCurrentApi() indicates the API selected for a given RtMidi instance.
|
||||
|
||||
\section apinotes API Notes
|
||||
|
||||
RtMidi is designed to provide a common API across the various supported operating systems and audio libraries. Despite that, some issues should be mentioned with regard to each.
|
||||
|
||||
\subsection linux Linux:
|
||||
|
||||
RtMidi for Linux was developed using the Fedora distribution. Two different MIDI APIs are supported on Linux platforms: <A href="http://www.alsa-project.org/">ALSA</A> and <A href="http://jackit.sourceforge.net/">JACK</A>. A decision was made to not include support for the OSS API because the OSS API provides very limited functionality and because <A href="http://www.alsa-project.org/">ALSA</A> support is now incorporated in the Linux kernel. The ALSA sequencer and JACK APIs allows for virtual software input and output ports.
|
||||
|
||||
\subsection macosx Macintosh OS X (CoreAudio):
|
||||
|
||||
The Apple CoreMIDI API allows for the establishment of virtual input and output ports to which other software applications can connect.
|
||||
|
||||
The RtMidi JACK support can be compiled on Macintosh OS-X systems, as well as in Linux.
|
||||
|
||||
\subsection windowsds Windows (Multimedia Library):
|
||||
|
||||
The \c configure script provides support for the MinGW compiler.
|
||||
|
||||
The Windows Multimedia library MIDI calls used in RtMidi do not make use of streaming functionality. Incoming system exclusive messages read by RtMidiIn are limited to a length as defined by the preprocessor definition RT_SYSEX_BUFFER_SIZE (set in RtMidi.cpp). The default value is 1024. There is no such limit for outgoing sysex messages via RtMidiOut.
|
||||
|
||||
RtMidi was originally developed with Visual C++ version 6.0 but has been tested with Virtual Studio 2010.
|
||||
|
||||
\section acknowledge Development & Acknowledgements
|
||||
|
||||
RtMidi is on github (https://github.com/thestk/rtmidi). Many thanks to the developers that are helping to maintain and improve RtMidi.
|
||||
|
||||
In years past, the following people provided bug fixes and improvements:
|
||||
<UL>
|
||||
<LI>Sebastien Alaiwan (JACK memory leaks, Windows kernel streaming)</LI>
|
||||
<LI>Jean-Baptiste Berruchon (Windows sysex code)</LI>
|
||||
<LI>Pedro Lopez-Cabanillas (ALSA sequencer API, client naming)</LI>
|
||||
<LI>Jason Champion (MSW project file for library build)</LI>
|
||||
<LI>Eduardo Coutinho (Windows device names)</LI>
|
||||
<LI>Paul Dean (increment optimization)</LI>
|
||||
<LI>Luc Deschenaux (sysex issues)</LI>
|
||||
<LI>John Dey (OS-X timestamps)</LI>
|
||||
<LI>Christoph Eckert (ALSA sysex fixes)</LI>
|
||||
<LI>Martin Koegler (various fixes)</LI>
|
||||
<LI>Immanuel Litzroth (OS-X sysex fix)</LI>
|
||||
<LI>Jon McCormack (Snow Leopard updates)</LI>
|
||||
<LI>Axel Schmidt (client naming)</LI>
|
||||
<LI>Alexander Svetalkin (JACK MIDI)</LI>
|
||||
<LI>Casey Tucker (OS-X driver information, sysex sending)</LI>
|
||||
<LI>Bastiaan Verreijt (Windows sysex multi-buffer code)</LI>
|
||||
<LI>Dan Wilcox</LI>
|
||||
</UL>
|
||||
|
||||
\section license License
|
||||
|
||||
RtMidi: realtime MIDI i/o C++ classes<BR>
|
||||
Copyright (c) 2003-2014 Gary P. Scavone
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation files
|
||||
(the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
Any person wishing to distribute modifications to the Software is
|
||||
asked to send the modifications to the original developer so that
|
||||
they can be incorporated into the canonical version. This is,
|
||||
however, not a binding provision of this license.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
||||
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.5 KiB |
|
|
@ -0,0 +1,103 @@
|
|||
RtMidi - a set of C++ classes that provides a common API for realtime MIDI input/output across Linux (ALSA & JACK), Macintosh OS X (CoreMidi & JACK), and Windows (Multimedia, Kernel Streaming).
|
||||
|
||||
By Gary P. Scavone, 2003-2014
|
||||
|
||||
v2.1.0: (30 March 2014)
|
||||
- renamed RtError class to RtMidiError and embedded it in RtMidi.h (and deleted RtError.h)
|
||||
- fix to CoreMidi implementation to support dynamic port changes
|
||||
- removed global ALSA sequencer objects because they were not thread safe (Martin Koegler)
|
||||
- fix for ALSA timing ignore flag (Devin Anderson)
|
||||
- fix for ALSA incorrect use of snd_seq_create_port() function (Tobias Schlemmer)
|
||||
- fix for international character support in CoreMidi (Martin Finke)
|
||||
- fix for unicode conversion in WinMM (Dan Wilcox)
|
||||
- added custom error hook that allows the client to capture an RtMidi error outside of the RtMidi code (Pavel Mogilevskiy)
|
||||
- added RtMidi::isPortOpen function (Pavel Mogilevskiy)
|
||||
- updated OS-X sysex sending mechanism to use normal message sending, which fixes a problem where virtual ports didn't receive sysex messages
|
||||
- Windows update to avoid lockups when shutting down while sending/receiving sysex messages (ptarabbia)
|
||||
- OS-X fix to avoid empty messages in callbacks when ignoring sysex messages and split sysexes are received (codepainters)
|
||||
- ALSA openPort fix to better distinguish sender and receiver (Russell Smyth)
|
||||
- Windows Kernel Streaming support removed because it was uncompilable and incomplete
|
||||
|
||||
v2.0.1: (26 July 2012)
|
||||
- small fixes for problems reported by Chris Arndt (scoping, preprocessor, and include)
|
||||
|
||||
v2.0.0: (18 June 2012)
|
||||
- revised structure to support multiple simultaneous compiled APIs
|
||||
- revised ALSA client hierarchy so subsequent instances share same client (thanks to Dan Wilcox)
|
||||
- added beta Windows kernel streaming support (thanks to Sebastien Alaiwan)
|
||||
- updates to compile as a shared library or dll
|
||||
- updated license
|
||||
- various memory-leak fixes (thanks to Sebastien Alaiwan and Martin Koegler)
|
||||
- fix for continue sysex problem (thanks to Luc Deschenaux)
|
||||
- removed SGI (IRIX) support
|
||||
|
||||
v1.0.15: (11 August 2011)
|
||||
- updates for wide character support in Windows
|
||||
- stopped using std::queue and implemented internal MIDI ring buffer (for thread safety ... thanks to Michael Behrman)
|
||||
- removal of the setQueueSizeLimit() function ... queue size limit now an optional arguement to constructor
|
||||
|
||||
v1.0.14: (17 April 2011)
|
||||
- bug fix to Jack MIDI support (thanks to Alexander Svetalkin and Pedro Lopez-Cabanillas)
|
||||
|
||||
v1.0.13: (7 April 2011)
|
||||
- updated RtError.h to the same version as in RtAudio
|
||||
- new Jack MIDI support in Linux (thanks to Alexander Svetalkin)
|
||||
|
||||
v1.0.12: (17 February 2011)
|
||||
- Windows 64-bit pointer fixes (thanks to Ward Kockelkorn)
|
||||
- removed possible exceptions from getPortName() functions
|
||||
- changed sysex sends in OS-X to use MIDISendSysex() function (thanks to Casey Tucker)
|
||||
- bug fixes to time code parsing in OS-X and ALSA (thanks to Greg)
|
||||
- added MSW project file to build as library (into lib/ directory ... thanks to Jason Champion)
|
||||
|
||||
v1.0.11: (29 January 2010)
|
||||
- added CoreServices/CoreServices.h include for OS-X 10.6 and gcc4.2 compile (thanks to Jon McCormack)
|
||||
- various increment optimizations (thanks to Paul Dean)
|
||||
- fixed incorrectly located snd_seq_close() function in ALSA API (thanks to Pedro Lopez-Cabanillas)
|
||||
- updates to Windows sysex code to better deal with possible delivery problems (thanks to Bastiaan Verreijt)
|
||||
|
||||
v1.0.10: (3 June 2009)
|
||||
- fix adding timestamp to OS-X sendMessage() function (thanks to John Dey)
|
||||
|
||||
v1.0.9: (30 April 2009)
|
||||
- added #ifdef AVOID_TIMESTAMPING to conditionally compile support for event timestamping of ALSA sequencer events. This is useful for programs not needing timestamps, saving valuable system resources.
|
||||
- updated functionality in OSX_CORE for getting driver name (thanks to Casey Tucker)
|
||||
|
||||
v1.0.8: (29 January 2009)
|
||||
- bug fixes for concatenating segmented sysex messages in ALSA (thanks to Christoph Eckert)
|
||||
- update to ALSA sequencer port enumeration (thanks to Pedro Lopez-Cabonillas)
|
||||
- bug fixes for concatenating segmented sysex messages in OS-X (thanks to Emmanuel Litzroth)
|
||||
- added functionality for naming clients (thanks to Pedro Lopez-Cabonillas and Axel Schmidt)
|
||||
- bug fix in Windows when receiving sysex messages if the ignore flag was set (thanks to Pedro Lopez-Cabonillas)
|
||||
|
||||
v1.0.7: (7 December 2007)
|
||||
- configure and Makefile changes for MinGW
|
||||
- renamed midiinfo.cpp to midiprobe.cpp and updated VC++ project/workspace
|
||||
|
||||
v1.0.6: (9 March 2006)
|
||||
- bug fix for timestamp problem in ALSA (thanks to Pedro Lopez-Cabanillas)
|
||||
|
||||
v1.0.5: (18 November 2005)
|
||||
- added optional port name to openVirtualPort() functions
|
||||
- fixed UNICODE problem in Windows getting device names (thanks Eduardo Coutinho!).
|
||||
- fixed bug in Windows with respect to getting Sysex data (thanks Jean-Baptiste Berruchon!)
|
||||
|
||||
v1.0.4: (14 October 2005)
|
||||
- added check for status byte == 0xF8 if ignoring timing messages
|
||||
- changed pthread attribute to SCHED_OTHER (from SCHED_RR) to avoid thread problem when realtime cababilities are not enabled.
|
||||
- now using ALSA sequencer time stamp information (thanks to Pedro Lopez-Cabanillas)
|
||||
- fixed memory leak in ALSA implementation
|
||||
- now concatenate segmented sysex messages in ALSA
|
||||
|
||||
v1.0.3: (22 November 2004)
|
||||
- added common pure virtual functions to RtMidi abstract base class
|
||||
|
||||
v1.0.2: (21 September 2004)
|
||||
- added warning messages to openVirtualPort() functions in Windows and Irix (where it can't be implemented)
|
||||
|
||||
v1.0.1: (20 September 2004)
|
||||
- changed ALSA preprocessor definition to __LINUX_ALSASEQ__
|
||||
|
||||
v1.0.0: (17 September 2004)
|
||||
- first release of new independent class with both input and output functionality
|
||||
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
prefix=@prefix@
|
||||
exec_prefix=${prefix}
|
||||
libdir=${exec_prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
|
||||
Name: librtmidi
|
||||
Description: RtMidi - a set of C++ classes that provide a common API for realtime MIDI input/output
|
||||
Version: 2.1.0
|
||||
Requires: @req@
|
||||
Libs: -L${libdir} -lrtmidi
|
||||
Libs.private: -lpthread
|
||||
Cflags: -pthread -I${includedir} @CPPFLAGS@
|
||||
|
|
@ -0,0 +1 @@
|
|||
This directory contains a Visual Studio 2008 project, contributed by Jason Champion, to build rtmidi as a library. The library builds to the <rtmidi-x.x.x>\lib directory.
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
RtMidi - a set of C++ classes that provide a common API for realtime MIDI input/output across Linux (ALSA & JACK), Macintosh OS X (CoreMidi & JACK) and Windows (Multimedia).
|
||||
|
||||
By Gary P. Scavone, 2003-2014.
|
||||
|
||||
This distribution of RtMidi contains the following:
|
||||
|
||||
doc: RtMidi documentation (see doc/html/index.html)
|
||||
tests: example RtMidi programs
|
||||
|
||||
On unix systems, type "./configure" in the top level directory, then "make" in the tests/ directory to compile the test programs. In Windows, open the Visual C++ workspace file located in the tests/ directory.
|
||||
|
||||
If you checked out the code from git, please run "autoconf" before "./configure".
|
||||
|
||||
OVERVIEW:
|
||||
|
||||
RtMidi is a set of C++ classes (RtMidiIn, RtMidiOut, and API specific classes) that provide a common API (Application Programming Interface) for realtime MIDI input/output across Linux (ALSA, JACK), Macintosh OS X (CoreMIDI, JACK), and Windows (Multimedia Library) operating systems. RtMidi significantly simplifies the process of interacting with computer MIDI hardware and software. It was designed with the following goals:
|
||||
|
||||
- object oriented C++ design
|
||||
- simple, common API across all supported platforms
|
||||
- only one header and one source file for easy inclusion in programming projects
|
||||
- MIDI device enumeration
|
||||
|
||||
MIDI input and output functionality are separated into two classes, RtMidiIn and RtMidiOut. Each class instance supports only a single MIDI connection. RtMidi does not provide timing functionality (i.e., output messages are sent immediately). Input messages are timestamped with delta times in seconds (via a double floating point type). MIDI data is passed to the user as raw bytes using an std::vector<unsigned char>.
|
||||
|
||||
FURTHER READING:
|
||||
|
||||
For complete documentation on RtMidi, see the doc directory of the distribution or surf to http://music.mcgill.ca/~gary/rtmidi/.
|
||||
|
||||
|
||||
LEGAL AND ETHICAL:
|
||||
|
||||
The RtMidi license is similar to the the MIT License, with the added "feature" that modifications be sent to the developer.
|
||||
|
||||
RtMidi: realtime MIDI i/o C++ classes
|
||||
Copyright (c) 2003-2014 Gary P. Scavone
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation files
|
||||
(the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
Any person wishing to distribute modifications to the Software is
|
||||
asked to send the modifications to the original developer so that
|
||||
they can be incorporated into the canonical version. This is,
|
||||
however, not a binding provision of this license.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
||||
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
#! /bin/sh
|
||||
if (test "x$#" != "x1") ; then
|
||||
echo "Usage: $0 [--libs | --cxxflags | --cppflags]"
|
||||
exit;
|
||||
fi
|
||||
|
||||
LIBRARY="@LIBS@"
|
||||
CXXFLAGS="@CXXFLAGS@"
|
||||
CPPFLAGS="@CPPFLAGS@"
|
||||
|
||||
if (test "x$1" = "x--libs") ; then
|
||||
echo "$LIBRARY -lrtmidi"
|
||||
elif (test "x$1" = "x--cxxflags") ; then
|
||||
echo "$CXXFLAGS"
|
||||
elif (test "x$1" = "x--cppflags") ; then
|
||||
echo "$CPPFLAGS"
|
||||
else
|
||||
echo "Unknown option: $1"
|
||||
fi
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "cmidiin"=".\cmidiin.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "midiout"=".\midiout.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "midiprobe"=".\midiprobe.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "qmidiin"=".\qmidiin.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "sysextest"=".\sysextest.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
//*****************************************//
|
||||
// cmidiin.cpp
|
||||
// by Gary Scavone, 2003-2004.
|
||||
//
|
||||
// Simple program to test MIDI input and
|
||||
// use of a user callback function.
|
||||
//
|
||||
//*****************************************//
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include "RtMidi.h"
|
||||
|
||||
void usage( void ) {
|
||||
// Error function in case of incorrect command-line
|
||||
// argument specifications.
|
||||
std::cout << "\nuseage: cmidiin <port>\n";
|
||||
std::cout << " where port = the device to use (default = 0).\n\n";
|
||||
exit( 0 );
|
||||
}
|
||||
|
||||
void mycallback( double deltatime, std::vector< unsigned char > *message, void */*userData*/ )
|
||||
{
|
||||
unsigned int nBytes = message->size();
|
||||
for ( unsigned int i=0; i<nBytes; i++ )
|
||||
std::cout << "Byte " << i << " = " << (int)message->at(i) << ", ";
|
||||
if ( nBytes > 0 )
|
||||
std::cout << "stamp = " << deltatime << std::endl;
|
||||
}
|
||||
|
||||
// This function should be embedded in a try/catch block in case of
|
||||
// an exception. It offers the user a choice of MIDI ports to open.
|
||||
// It returns false if there are no ports available.
|
||||
bool chooseMidiPort( RtMidiIn *rtmidi );
|
||||
|
||||
int main( int argc, char ** /*argv[]*/ )
|
||||
{
|
||||
RtMidiIn *midiin = 0;
|
||||
|
||||
// Minimal command-line check.
|
||||
if ( argc > 2 ) usage();
|
||||
|
||||
try {
|
||||
|
||||
// RtMidiIn constructor
|
||||
midiin = new RtMidiIn();
|
||||
|
||||
// Call function to select port.
|
||||
if ( chooseMidiPort( midiin ) == false ) goto cleanup;
|
||||
|
||||
// Set our callback function. This should be done immediately after
|
||||
// opening the port to avoid having incoming messages written to the
|
||||
// queue instead of sent to the callback function.
|
||||
midiin->setCallback( &mycallback );
|
||||
|
||||
// Don't ignore sysex, timing, or active sensing messages.
|
||||
midiin->ignoreTypes( false, false, false );
|
||||
|
||||
std::cout << "\nReading MIDI input ... press <enter> to quit.\n";
|
||||
char input;
|
||||
std::cin.get(input);
|
||||
|
||||
} catch ( RtMidiError &error ) {
|
||||
error.printMessage();
|
||||
}
|
||||
|
||||
cleanup:
|
||||
|
||||
delete midiin;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool chooseMidiPort( RtMidiIn *rtmidi )
|
||||
{
|
||||
std::cout << "\nWould you like to open a virtual input port? [y/N] ";
|
||||
|
||||
std::string keyHit;
|
||||
std::getline( std::cin, keyHit );
|
||||
if ( keyHit == "y" ) {
|
||||
rtmidi->openVirtualPort();
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string portName;
|
||||
unsigned int i = 0, nPorts = rtmidi->getPortCount();
|
||||
if ( nPorts == 0 ) {
|
||||
std::cout << "No input ports available!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( nPorts == 1 ) {
|
||||
std::cout << "\nOpening " << rtmidi->getPortName() << std::endl;
|
||||
}
|
||||
else {
|
||||
for ( i=0; i<nPorts; i++ ) {
|
||||
portName = rtmidi->getPortName(i);
|
||||
std::cout << " Input port #" << i << ": " << portName << '\n';
|
||||
}
|
||||
|
||||
do {
|
||||
std::cout << "\nChoose a port number: ";
|
||||
std::cin >> i;
|
||||
} while ( i >= nPorts );
|
||||
std::getline( std::cin, keyHit ); // used to clear out stdin
|
||||
}
|
||||
|
||||
rtmidi->openPort( i );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
# Microsoft Developer Studio Project File - Name="cmidiin" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=cmidiin - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "cmidiin.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "cmidiin.mak" CFG="cmidiin - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "cmidiin - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "cmidiin - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "cmidiin - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "cmidiin___Win32_Release"
|
||||
# PROP BASE Intermediate_Dir "cmidiin___Win32_Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ""
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_MM__" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:console /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "cmidiin - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "cmidiin___Win32_Debug"
|
||||
# PROP BASE Intermediate_Dir "cmidiin___Win32_Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ""
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_MM__" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "cmidiin - Win32 Release"
|
||||
# Name "cmidiin - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\cmidiin.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\RtMidi.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\RtMidi.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
//*****************************************//
|
||||
// midiout.cpp
|
||||
// by Gary Scavone, 2003-2004.
|
||||
//
|
||||
// Simple program to test MIDI output.
|
||||
//
|
||||
//*****************************************//
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include "RtMidi.h"
|
||||
|
||||
// Platform-dependent sleep routines.
|
||||
#if defined(__WINDOWS_MM__)
|
||||
#include <windows.h>
|
||||
#define SLEEP( milliseconds ) Sleep( (DWORD) milliseconds )
|
||||
#else // Unix variants
|
||||
#include <unistd.h>
|
||||
#define SLEEP( milliseconds ) usleep( (unsigned long) (milliseconds * 1000.0) )
|
||||
#endif
|
||||
|
||||
// This function should be embedded in a try/catch block in case of
|
||||
// an exception. It offers the user a choice of MIDI ports to open.
|
||||
// It returns false if there are no ports available.
|
||||
bool chooseMidiPort( RtMidiOut *rtmidi );
|
||||
|
||||
int main( void )
|
||||
{
|
||||
RtMidiOut *midiout = 0;
|
||||
std::vector<unsigned char> message;
|
||||
|
||||
// RtMidiOut constructor
|
||||
try {
|
||||
midiout = new RtMidiOut();
|
||||
}
|
||||
catch ( RtMidiError &error ) {
|
||||
error.printMessage();
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
// Call function to select port.
|
||||
try {
|
||||
if ( chooseMidiPort( midiout ) == false ) goto cleanup;
|
||||
}
|
||||
catch ( RtMidiError &error ) {
|
||||
error.printMessage();
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Send out a series of MIDI messages.
|
||||
|
||||
// Program change: 192, 5
|
||||
message.push_back( 192 );
|
||||
message.push_back( 5 );
|
||||
midiout->sendMessage( &message );
|
||||
|
||||
SLEEP( 500 );
|
||||
|
||||
message[0] = 0xF1;
|
||||
message[1] = 60;
|
||||
midiout->sendMessage( &message );
|
||||
|
||||
// Control Change: 176, 7, 100 (volume)
|
||||
message[0] = 176;
|
||||
message[1] = 7;
|
||||
message.push_back( 100 );
|
||||
midiout->sendMessage( &message );
|
||||
|
||||
// Note On: 144, 64, 90
|
||||
message[0] = 144;
|
||||
message[1] = 64;
|
||||
message[2] = 90;
|
||||
midiout->sendMessage( &message );
|
||||
|
||||
SLEEP( 500 );
|
||||
|
||||
// Note Off: 128, 64, 40
|
||||
message[0] = 128;
|
||||
message[1] = 64;
|
||||
message[2] = 40;
|
||||
midiout->sendMessage( &message );
|
||||
|
||||
SLEEP( 500 );
|
||||
|
||||
// Control Change: 176, 7, 40
|
||||
message[0] = 176;
|
||||
message[1] = 7;
|
||||
message[2] = 40;
|
||||
midiout->sendMessage( &message );
|
||||
|
||||
SLEEP( 500 );
|
||||
|
||||
// Sysex: 240, 67, 4, 3, 2, 247
|
||||
message[0] = 240;
|
||||
message[1] = 67;
|
||||
message[2] = 4;
|
||||
message.push_back( 3 );
|
||||
message.push_back( 2 );
|
||||
message.push_back( 247 );
|
||||
midiout->sendMessage( &message );
|
||||
|
||||
// Clean up
|
||||
cleanup:
|
||||
delete midiout;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool chooseMidiPort( RtMidiOut *rtmidi )
|
||||
{
|
||||
std::cout << "\nWould you like to open a virtual output port? [y/N] ";
|
||||
|
||||
std::string keyHit;
|
||||
std::getline( std::cin, keyHit );
|
||||
if ( keyHit == "y" ) {
|
||||
rtmidi->openVirtualPort();
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string portName;
|
||||
unsigned int i = 0, nPorts = rtmidi->getPortCount();
|
||||
if ( nPorts == 0 ) {
|
||||
std::cout << "No output ports available!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( nPorts == 1 ) {
|
||||
std::cout << "\nOpening " << rtmidi->getPortName() << std::endl;
|
||||
}
|
||||
else {
|
||||
for ( i=0; i<nPorts; i++ ) {
|
||||
portName = rtmidi->getPortName(i);
|
||||
std::cout << " Output port #" << i << ": " << portName << '\n';
|
||||
}
|
||||
|
||||
do {
|
||||
std::cout << "\nChoose a port number: ";
|
||||
std::cin >> i;
|
||||
} while ( i >= nPorts );
|
||||
}
|
||||
|
||||
std::cout << "\n";
|
||||
rtmidi->openPort( i );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
# Microsoft Developer Studio Project File - Name="midiout" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=midiout - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "midiout.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "midiout.mak" CFG="midiout - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "midiout - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "midiout - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "midiout - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "midiout___Win32_Release"
|
||||
# PROP BASE Intermediate_Dir "midiout___Win32_Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ""
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_MM__" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:console /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "midiout - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "midiout___Win32_Debug"
|
||||
# PROP BASE Intermediate_Dir "midiout___Win32_Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ""
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_MM__" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "midiout - Win32 Release"
|
||||
# Name "midiout - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\midiout.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\RtMidi.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\RtMidi.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
// midiprobe.cpp
|
||||
//
|
||||
// Simple program to check MIDI inputs and outputs.
|
||||
//
|
||||
// by Gary Scavone, 2003-2012.
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <map>
|
||||
#include "RtMidi.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
// Create an api map.
|
||||
std::map<int, std::string> apiMap;
|
||||
apiMap[RtMidi::MACOSX_CORE] = "OS-X CoreMidi";
|
||||
apiMap[RtMidi::WINDOWS_MM] = "Windows MultiMedia";
|
||||
apiMap[RtMidi::UNIX_JACK] = "Jack Client";
|
||||
apiMap[RtMidi::LINUX_ALSA] = "Linux ALSA";
|
||||
apiMap[RtMidi::RTMIDI_DUMMY] = "RtMidi Dummy";
|
||||
|
||||
std::vector< RtMidi::Api > apis;
|
||||
RtMidi :: getCompiledApi( apis );
|
||||
|
||||
std::cout << "\nCompiled APIs:\n";
|
||||
for ( unsigned int i=0; i<apis.size(); i++ )
|
||||
std::cout << " " << apiMap[ apis[i] ] << std::endl;
|
||||
|
||||
RtMidiIn *midiin = 0;
|
||||
RtMidiOut *midiout = 0;
|
||||
|
||||
try {
|
||||
|
||||
// RtMidiIn constructor ... exception possible
|
||||
midiin = new RtMidiIn();
|
||||
|
||||
std::cout << "\nCurrent input API: " << apiMap[ midiin->getCurrentApi() ] << std::endl;
|
||||
|
||||
// Check inputs.
|
||||
unsigned int nPorts = midiin->getPortCount();
|
||||
std::cout << "\nThere are " << nPorts << " MIDI input sources available.\n";
|
||||
|
||||
for ( unsigned i=0; i<nPorts; i++ ) {
|
||||
std::string portName = midiin->getPortName(i);
|
||||
std::cout << " Input Port #" << i+1 << ": " << portName << '\n';
|
||||
}
|
||||
|
||||
// RtMidiOut constructor ... exception possible
|
||||
midiout = new RtMidiOut();
|
||||
|
||||
std::cout << "\nCurrent output API: " << apiMap[ midiout->getCurrentApi() ] << std::endl;
|
||||
|
||||
// Check outputs.
|
||||
nPorts = midiout->getPortCount();
|
||||
std::cout << "\nThere are " << nPorts << " MIDI output ports available.\n";
|
||||
|
||||
for ( unsigned i=0; i<nPorts; i++ ) {
|
||||
std::string portName = midiout->getPortName(i);
|
||||
std::cout << " Output Port #" << i+1 << ": " << portName << std::endl;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
} catch ( RtMidiError &error ) {
|
||||
error.printMessage();
|
||||
}
|
||||
|
||||
delete midiin;
|
||||
delete midiout;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
# Microsoft Developer Studio Project File - Name="midiprobe" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=midiprobe - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "midiprobe.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "midiprobe.mak" CFG="midiprobe - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "midiprobe - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "midiprobe - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "midiprobe - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "midiprobe___Win32_Release"
|
||||
# PROP BASE Intermediate_Dir "midiprobe___Win32_Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ""
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_MM__" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:console /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "midiprobe - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "midiprobe___Win32_Debug"
|
||||
# PROP BASE Intermediate_Dir "midiprobe___Win32_Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ""
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_MM__" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "midiprobe - Win32 Release"
|
||||
# Name "midiprobe - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\midiprobe.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\RtMidi.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\RtMidi.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
//*****************************************//
|
||||
// qmidiin.cpp
|
||||
// by Gary Scavone, 2003-2004.
|
||||
//
|
||||
// Simple program to test MIDI input and
|
||||
// retrieval from the queue.
|
||||
//
|
||||
//*****************************************//
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <signal.h>
|
||||
#include "RtMidi.h"
|
||||
|
||||
// Platform-dependent sleep routines.
|
||||
#if defined(__WINDOWS_MM__)
|
||||
#include <windows.h>
|
||||
#define SLEEP( milliseconds ) Sleep( (DWORD) milliseconds )
|
||||
#else // Unix variants
|
||||
#include <unistd.h>
|
||||
#define SLEEP( milliseconds ) usleep( (unsigned long) (milliseconds * 1000.0) )
|
||||
#endif
|
||||
|
||||
bool done;
|
||||
static void finish( int /*ignore*/ ){ done = true; }
|
||||
|
||||
void usage( void ) {
|
||||
// Error function in case of incorrect command-line
|
||||
// argument specifications.
|
||||
std::cout << "\nusage: qmidiin <port>\n";
|
||||
std::cout << " where port = the device to use (default = 0).\n\n";
|
||||
exit( 0 );
|
||||
}
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
RtMidiIn *midiin = 0;
|
||||
std::vector<unsigned char> message;
|
||||
int nBytes, i;
|
||||
double stamp;
|
||||
|
||||
// Minimal command-line check.
|
||||
if ( argc > 2 ) usage();
|
||||
|
||||
// RtMidiIn constructor
|
||||
try {
|
||||
midiin = new RtMidiIn();
|
||||
}
|
||||
catch ( RtMidiError &error ) {
|
||||
error.printMessage();
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
// Check available ports vs. specified.
|
||||
unsigned int port = 0;
|
||||
unsigned int nPorts = midiin->getPortCount();
|
||||
if ( argc == 2 ) port = (unsigned int) atoi( argv[1] );
|
||||
if ( port >= nPorts ) {
|
||||
delete midiin;
|
||||
std::cout << "Invalid port specifier!\n";
|
||||
usage();
|
||||
}
|
||||
|
||||
try {
|
||||
midiin->openPort( port );
|
||||
}
|
||||
catch ( RtMidiError &error ) {
|
||||
error.printMessage();
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Don't ignore sysex, timing, or active sensing messages.
|
||||
midiin->ignoreTypes( false, false, false );
|
||||
|
||||
// Install an interrupt handler function.
|
||||
done = false;
|
||||
(void) signal(SIGINT, finish);
|
||||
|
||||
// Periodically check input queue.
|
||||
std::cout << "Reading MIDI from port ... quit with Ctrl-C.\n";
|
||||
while ( !done ) {
|
||||
stamp = midiin->getMessage( &message );
|
||||
nBytes = message.size();
|
||||
for ( i=0; i<nBytes; i++ )
|
||||
std::cout << "Byte " << i << " = " << (int)message[i] << ", ";
|
||||
if ( nBytes > 0 )
|
||||
std::cout << "stamp = " << stamp << std::endl;
|
||||
|
||||
// Sleep for 10 milliseconds.
|
||||
SLEEP( 10 );
|
||||
}
|
||||
|
||||
// Clean up
|
||||
cleanup:
|
||||
delete midiin;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
# Microsoft Developer Studio Project File - Name="qmidiin" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=qmidiin - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "qmidiin.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "qmidiin.mak" CFG="qmidiin - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "qmidiin - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "qmidiin - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "qmidiin - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "qmidiin___Win32_Release"
|
||||
# PROP BASE Intermediate_Dir "qmidiin___Win32_Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ""
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_MM__" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:console /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "qmidiin - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "qmidiin___Win32_Debug"
|
||||
# PROP BASE Intermediate_Dir "qmidiin___Win32_Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ""
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_MM__" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "qmidiin - Win32 Release"
|
||||
# Name "qmidiin - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\qmidiin.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\RtMidi.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\RtMidi.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
|
|
@ -0,0 +1,152 @@
|
|||
//*****************************************//
|
||||
// sysextest.cpp
|
||||
// by Gary Scavone, 2003-2005.
|
||||
//
|
||||
// Simple program to test MIDI sysex sending and receiving.
|
||||
//
|
||||
//*****************************************//
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <typeinfo>
|
||||
#include "RtMidi.h"
|
||||
|
||||
void usage( void ) {
|
||||
std::cout << "\nuseage: sysextest N\n";
|
||||
std::cout << " where N = length of sysex message to send / receive.\n\n";
|
||||
exit( 0 );
|
||||
}
|
||||
|
||||
// Platform-dependent sleep routines.
|
||||
#if defined(__WINDOWS_MM__)
|
||||
#include <windows.h>
|
||||
#define SLEEP( milliseconds ) Sleep( (DWORD) milliseconds )
|
||||
#else // Unix variants
|
||||
#include <unistd.h>
|
||||
#define SLEEP( milliseconds ) usleep( (unsigned long) (milliseconds * 1000.0) )
|
||||
#endif
|
||||
|
||||
// This function should be embedded in a try/catch block in case of
|
||||
// an exception. It offers the user a choice of MIDI ports to open.
|
||||
// It returns false if there are no ports available.
|
||||
bool chooseMidiPort( RtMidi *rtmidi );
|
||||
|
||||
void mycallback( double deltatime, std::vector< unsigned char > *message, void * /*userData*/ )
|
||||
{
|
||||
unsigned int nBytes = message->size();
|
||||
for ( unsigned int i=0; i<nBytes; i++ )
|
||||
std::cout << "Byte " << i << " = " << (int)message->at(i) << ", ";
|
||||
if ( nBytes > 0 )
|
||||
std::cout << "stamp = " << deltatime << std::endl;
|
||||
}
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
RtMidiOut *midiout = 0;
|
||||
RtMidiIn *midiin = 0;
|
||||
std::vector<unsigned char> message;
|
||||
unsigned int i, nBytes;
|
||||
|
||||
// Minimal command-line check.
|
||||
if ( argc != 2 ) usage();
|
||||
nBytes = (unsigned int) atoi( argv[1] );
|
||||
|
||||
// RtMidiOut and RtMidiIn constructors
|
||||
try {
|
||||
midiout = new RtMidiOut();
|
||||
midiin = new RtMidiIn();
|
||||
}
|
||||
catch ( RtMidiError &error ) {
|
||||
error.printMessage();
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Don't ignore sysex, timing, or active sensing messages.
|
||||
midiin->ignoreTypes( false, true, true );
|
||||
|
||||
try {
|
||||
if ( chooseMidiPort( midiin ) == false ) goto cleanup;
|
||||
if ( chooseMidiPort( midiout ) == false ) goto cleanup;
|
||||
}
|
||||
catch ( RtMidiError &error ) {
|
||||
error.printMessage();
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
midiin->setCallback( &mycallback );
|
||||
|
||||
message.push_back( 0xF6 );
|
||||
midiout->sendMessage( &message );
|
||||
SLEEP( 500 ); // pause a little
|
||||
|
||||
// Create a long sysex message of numbered bytes and send it out ... twice.
|
||||
for ( int n=0; n<2; n++ ) {
|
||||
message.clear();
|
||||
message.push_back( 240 );
|
||||
for ( i=0; i<nBytes; i++ )
|
||||
message.push_back( i % 128 );
|
||||
message.push_back( 247 );
|
||||
midiout->sendMessage( &message );
|
||||
|
||||
SLEEP( 500 ); // pause a little
|
||||
}
|
||||
|
||||
// Clean up
|
||||
cleanup:
|
||||
delete midiout;
|
||||
delete midiin;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool chooseMidiPort( RtMidi *rtmidi )
|
||||
{
|
||||
bool isInput = false;
|
||||
if ( typeid( *rtmidi ) == typeid( RtMidiIn ) )
|
||||
isInput = true;
|
||||
|
||||
if ( isInput )
|
||||
std::cout << "\nWould you like to open a virtual input port? [y/N] ";
|
||||
else
|
||||
std::cout << "\nWould you like to open a virtual output port? [y/N] ";
|
||||
|
||||
std::string keyHit;
|
||||
std::getline( std::cin, keyHit );
|
||||
if ( keyHit == "y" ) {
|
||||
rtmidi->openVirtualPort();
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string portName;
|
||||
unsigned int i = 0, nPorts = rtmidi->getPortCount();
|
||||
if ( nPorts == 0 ) {
|
||||
if ( isInput )
|
||||
std::cout << "No input ports available!" << std::endl;
|
||||
else
|
||||
std::cout << "No output ports available!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( nPorts == 1 ) {
|
||||
std::cout << "\nOpening " << rtmidi->getPortName() << std::endl;
|
||||
}
|
||||
else {
|
||||
for ( i=0; i<nPorts; i++ ) {
|
||||
portName = rtmidi->getPortName(i);
|
||||
if ( isInput )
|
||||
std::cout << " Input port #" << i << ": " << portName << '\n';
|
||||
else
|
||||
std::cout << " Output port #" << i << ": " << portName << '\n';
|
||||
}
|
||||
|
||||
do {
|
||||
std::cout << "\nChoose a port number: ";
|
||||
std::cin >> i;
|
||||
} while ( i >= nPorts );
|
||||
}
|
||||
|
||||
std::cout << std::endl;
|
||||
rtmidi->openPort( i );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
# Microsoft Developer Studio Project File - Name="sysextest" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=sysextest - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "sysextest.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "sysextest.mak" CFG="sysextest - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "sysextest - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "sysextest - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "sysextest - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "sysextest___Win32_Release"
|
||||
# PROP BASE Intermediate_Dir "sysextest___Win32_Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ""
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GR /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_MM__" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:console /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "sysextest - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "sysextest___Win32_Debug"
|
||||
# PROP BASE Intermediate_Dir "sysextest___Win32_Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ""
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GR /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_MM__" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "sysextest - Win32 Release"
|
||||
# Name "sysextest - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\RtMidi.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\sysextest.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\RtMidi.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
#include "qmidiin.h"
|
||||
#include <QDebug>
|
||||
QMidiIn::QMidiIn(QObject *parent) : QObject(parent),
|
||||
_midiIn(new RtMidiIn())
|
||||
{
|
||||
_midiIn->setCallback(&QMidiIn::callback, this);
|
||||
}
|
||||
|
||||
QStringList QMidiIn::getPorts()
|
||||
{
|
||||
//TODO: make this static
|
||||
QStringList ports;
|
||||
for(unsigned int i = 0; i < _midiIn->getPortCount(); i++)
|
||||
{
|
||||
ports.append(QString::fromStdString(_midiIn->getPortName(i)));
|
||||
}
|
||||
return ports;
|
||||
}
|
||||
void QMidiIn::openPort(unsigned int index)
|
||||
{
|
||||
_midiIn->openPort(index);
|
||||
}
|
||||
|
||||
void QMidiIn::openVirtualPort(QString name)
|
||||
{
|
||||
_midiIn->openVirtualPort(name.toStdString());
|
||||
}
|
||||
void QMidiIn::openPort(QString name)
|
||||
{
|
||||
for(unsigned int i = 0; i < _midiIn->getPortCount(); i++)
|
||||
{
|
||||
if(name == QString::fromStdString(_midiIn->getPortName(i)))
|
||||
{
|
||||
_midiIn->openPort(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
void QMidiIn::setIgnoreTypes(bool sysex, bool time, bool sense)
|
||||
{
|
||||
_midiIn->ignoreTypes(sysex, time, sense);
|
||||
}
|
||||
void QMidiIn::onMidiMessageReceive(QMidiMessage *msg)
|
||||
{
|
||||
msg->moveToThread(thread());
|
||||
emit midiMessageReceived(msg);
|
||||
}
|
||||
|
||||
void QMidiIn::callback(double deltatime, std::vector<unsigned char> *message, void *userData)
|
||||
{
|
||||
QMidiIn* midiIn = (QMidiIn*) userData;
|
||||
QMidiMessage *midiMessage = new QMidiMessage();
|
||||
|
||||
if((message->at(0)) >= MIDI_SYSEX) {
|
||||
midiMessage->setStatus((QMidiStatus)(message->at(0) & 0xFF));
|
||||
midiMessage->setChannel(0);
|
||||
} else {
|
||||
midiMessage->setStatus((QMidiStatus) (message->at(0) & 0xF0));
|
||||
midiMessage->setChannel((message->at(0) & 0x0F)+1);
|
||||
}
|
||||
|
||||
midiMessage->setDeltaTime(deltatime*1000); //convert s to ms
|
||||
// midiMessage->portNum = portNum;
|
||||
// midiMessage->portName = portName;
|
||||
|
||||
switch(midiMessage->getStatus()) {
|
||||
case MIDI_NOTE_ON :
|
||||
case MIDI_NOTE_OFF:
|
||||
midiMessage->setPitch((unsigned int) message->at(1));
|
||||
midiMessage->setVelocity((unsigned int) message->at(2));
|
||||
break;
|
||||
case MIDI_CONTROL_CHANGE:
|
||||
midiMessage->setControl((unsigned int) message->at(1));
|
||||
midiMessage->setValue((unsigned int) message->at(2));
|
||||
break;
|
||||
case MIDI_PROGRAM_CHANGE:
|
||||
case MIDI_AFTERTOUCH:
|
||||
midiMessage->setValue((unsigned int) message->at(1));
|
||||
break;
|
||||
case MIDI_PITCH_BEND:
|
||||
midiMessage->setValue((unsigned int) (message->at(2) << 7) +
|
||||
(unsigned int) message->at(1)); // msb + lsb
|
||||
break;
|
||||
case MIDI_POLY_AFTERTOUCH:
|
||||
midiMessage->setPitch((unsigned int) message->at(1));
|
||||
midiMessage->setValue((unsigned int) message->at(2));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
unsigned int nBytes = message->size();
|
||||
qDebug()<<"channel"<<(int)(message->at(0))-144;
|
||||
for ( unsigned int i=0; i<nBytes; i++ )
|
||||
std::cout << "Byte " << i << " = " << (int)message->at(i) << ", ";
|
||||
if ( nBytes > 0 )
|
||||
std::cout << "stamp = " << deltatime << std::endl;
|
||||
|
||||
midiIn->onMidiMessageReceive(midiMessage);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
#ifndef QMIDIIN_H
|
||||
#define QMIDIIN_H
|
||||
|
||||
#include <QStringList>
|
||||
#include <QObject>
|
||||
#include "RtMidi.h"
|
||||
#include "qmidimessage.h"
|
||||
|
||||
|
||||
class QMidiIn : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QMidiIn(QObject *parent = 0);
|
||||
QStringList getPorts();
|
||||
void openPort(QString name);
|
||||
void openPort(unsigned int index);
|
||||
void openVirtualPort(QString name);
|
||||
void setIgnoreTypes(bool sysex = true, bool time = true, bool sense = true);
|
||||
private:
|
||||
void onMidiMessageReceive(QMidiMessage *msg);
|
||||
static void callback( double deltatime, std::vector< unsigned char > *message, void *userData );
|
||||
|
||||
private:
|
||||
RtMidiIn *_midiIn;
|
||||
|
||||
signals:
|
||||
void midiMessageReceived(QMidiMessage *message);
|
||||
|
||||
public slots:
|
||||
};
|
||||
|
||||
#endif // QMIDIIN_H
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#include "qmidimapper.h"
|
||||
|
||||
QMidiMapper::QMidiMapper(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QMidiMapper::setMappingState(bool value)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QMidiMapper::setWidget(QWidget *widget)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QMidiMapper::onMidiMessageReceive(QMidiMessage *message)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef QMIDIMAPPER_H
|
||||
#define QMIDIMAPPER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
#include "qmidimessage.h"
|
||||
|
||||
class QMidiMapper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QMidiMapper(QObject *parent = 0);
|
||||
private:
|
||||
QWidget *_widgetToMap;
|
||||
signals:
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void setMappingState(bool value = true);
|
||||
void setWidget(QWidget *widget);
|
||||
void onMidiMessageReceive(QMidiMessage *message);
|
||||
};
|
||||
|
||||
#endif // QMIDIMAPPER_H
|
||||
|
|
@ -0,0 +1,158 @@
|
|||
#include "qmidimessage.h"
|
||||
|
||||
QMidiMessage::QMidiMessage(QObject *parent) : QObject(parent)
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
QMidiMessage::~QMidiMessage()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QMidiMessage::QMidiMessage(const QMidiMessage &other)
|
||||
{
|
||||
_status = other._status;
|
||||
_channel = other._channel;
|
||||
_pitch = other._pitch;
|
||||
_velocity = other._velocity;
|
||||
_control = other._control;
|
||||
_value = other._value;
|
||||
_deltaTime = other._deltaTime;
|
||||
_rawMessage = other._rawMessage;
|
||||
}
|
||||
|
||||
QMidiMessage *QMidiMessage::clear()
|
||||
{
|
||||
_status = MIDI_UNKNOWN;
|
||||
_channel = 1;
|
||||
_pitch = 0;
|
||||
_velocity = 0;
|
||||
_control = 0;
|
||||
_value = 0;
|
||||
_deltaTime = 0;
|
||||
_rawMessage.clear();
|
||||
}
|
||||
|
||||
QMidiStatus QMidiMessage::getStatus()
|
||||
{
|
||||
return _status;
|
||||
}
|
||||
|
||||
unsigned int QMidiMessage::getChannel()
|
||||
{
|
||||
return _channel;
|
||||
}
|
||||
|
||||
unsigned int QMidiMessage::getPitch()
|
||||
{
|
||||
return _pitch;
|
||||
}
|
||||
|
||||
unsigned int QMidiMessage::getVelocity()
|
||||
{
|
||||
return _velocity;
|
||||
}
|
||||
|
||||
unsigned int QMidiMessage::getControl()
|
||||
{
|
||||
return _control;
|
||||
}
|
||||
|
||||
unsigned int QMidiMessage::getValue()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
double QMidiMessage::getDeltaTime()
|
||||
{
|
||||
return _deltaTime;
|
||||
}
|
||||
|
||||
QMidiMessage *QMidiMessage::setStatus(QMidiStatus status)
|
||||
{
|
||||
_status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
QMidiMessage *QMidiMessage::setChannel(unsigned int channel)
|
||||
{
|
||||
_channel = channel;
|
||||
return this;
|
||||
}
|
||||
|
||||
QMidiMessage *QMidiMessage::setPitch(unsigned int pitch)
|
||||
{
|
||||
_pitch = pitch;
|
||||
return this;
|
||||
}
|
||||
|
||||
QMidiMessage *QMidiMessage::setVelocity(unsigned int velocity)
|
||||
{
|
||||
_velocity = velocity;
|
||||
return this;
|
||||
}
|
||||
|
||||
QMidiMessage *QMidiMessage::setControl(unsigned int control)
|
||||
{
|
||||
_control = control;
|
||||
return this;
|
||||
}
|
||||
|
||||
QMidiMessage *QMidiMessage::setValue(unsigned int value)
|
||||
{
|
||||
_value = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
QMidiMessage *QMidiMessage::setDeltaTime(double deltaTime)
|
||||
{
|
||||
_deltaTime = deltaTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
QMidiMessage *QMidiMessage::setRawMessage(std::vector<unsigned char> rawMessage)
|
||||
{
|
||||
_rawMessage = rawMessage;
|
||||
return this;
|
||||
}
|
||||
|
||||
std::vector<unsigned char> QMidiMessage::getRawMessage()
|
||||
{
|
||||
if(_rawMessage.size() == 0)
|
||||
{
|
||||
switch(_status)
|
||||
{
|
||||
case MIDI_NOTE_ON:{
|
||||
_rawMessage.push_back(MIDI_NOTE_ON+_channel-1);
|
||||
_rawMessage.push_back(_pitch);
|
||||
_rawMessage.push_back(_velocity);
|
||||
break;
|
||||
}
|
||||
case MIDI_NOTE_OFF:{
|
||||
_rawMessage.push_back(MIDI_NOTE_OFF+_channel-1);
|
||||
_rawMessage.push_back(_pitch);
|
||||
_rawMessage.push_back(_velocity);
|
||||
break;
|
||||
}
|
||||
case MIDI_CONTROL_CHANGE:{
|
||||
_rawMessage.push_back(MIDI_CONTROL_CHANGE+_channel-1);
|
||||
_rawMessage.push_back(_control);
|
||||
_rawMessage.push_back(_value);
|
||||
break;
|
||||
}
|
||||
case MIDI_PROGRAM_CHANGE:{
|
||||
_rawMessage.push_back(MIDI_PROGRAM_CHANGE+_channel-1);
|
||||
_rawMessage.push_back(_control);
|
||||
_rawMessage.push_back(_value);
|
||||
break;
|
||||
}
|
||||
//TODO: check protocol and implement other cases
|
||||
default:{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return _rawMessage;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
#ifndef QMIDIMESSAGE_H
|
||||
#define QMIDIMESSAGE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <vector>
|
||||
|
||||
//https://github.com/danomatika/ofxMidi/blob/master/src/ofxMidiConstants.h
|
||||
enum QMidiStatus {
|
||||
|
||||
MIDI_UNKNOWN = 0x00,
|
||||
|
||||
// channel voice messages
|
||||
MIDI_NOTE_OFF = 0x80,
|
||||
MIDI_NOTE_ON = 0x90,
|
||||
MIDI_CONTROL_CHANGE = 0xB0,
|
||||
MIDI_PROGRAM_CHANGE = 0xC0,
|
||||
MIDI_PITCH_BEND = 0xE0,
|
||||
MIDI_AFTERTOUCH = 0xD0, // aka channel pressure
|
||||
MIDI_POLY_AFTERTOUCH = 0xA0, // aka key pressure
|
||||
|
||||
// system messages
|
||||
MIDI_SYSEX = 0xF0,
|
||||
MIDI_TIME_CODE = 0xF1,
|
||||
MIDI_SONG_POS_POINTER = 0xF2,
|
||||
MIDI_SONG_SELECT = 0xF3,
|
||||
MIDI_TUNE_REQUEST = 0xF6,
|
||||
MIDI_SYSEX_END = 0xF7,
|
||||
MIDI_TIME_CLOCK = 0xF8,
|
||||
MIDI_START = 0xFA,
|
||||
MIDI_CONTINUE = 0xFB,
|
||||
MIDI_STOP = 0xFC,
|
||||
MIDI_ACTIVE_SENSING = 0xFE,
|
||||
MIDI_SYSTEM_RESET = 0xFF
|
||||
};
|
||||
|
||||
// number range defines
|
||||
// because it's sometimes hard to remember these ...
|
||||
#define MIDI_MIN_BEND 0
|
||||
#define MIDI_MAX_BEND 16383
|
||||
|
||||
class QMidiMessage : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QMidiMessage(QObject *parent = 0);
|
||||
~QMidiMessage();
|
||||
QMidiMessage(const QMidiMessage &other);
|
||||
|
||||
QMidiMessage* clear();
|
||||
QMidiStatus getStatus();
|
||||
unsigned int getChannel();
|
||||
unsigned int getPitch();
|
||||
unsigned int getVelocity();
|
||||
unsigned int getControl();
|
||||
unsigned int getValue();
|
||||
double getDeltaTime();
|
||||
|
||||
QMidiMessage* setStatus(QMidiStatus status);
|
||||
QMidiMessage* setChannel(unsigned int channel);
|
||||
QMidiMessage* setPitch(unsigned int pitch);
|
||||
QMidiMessage* setVelocity(unsigned int velocity);
|
||||
QMidiMessage* setControl(unsigned int control);
|
||||
QMidiMessage* setValue(unsigned int value);
|
||||
QMidiMessage* setDeltaTime(double deltaTime);
|
||||
QMidiMessage* setRawMessage(std::vector<unsigned char> rawMessage);
|
||||
|
||||
std::vector<unsigned char> getRawMessage();
|
||||
|
||||
public:
|
||||
QMidiStatus _status;
|
||||
unsigned int _channel;
|
||||
unsigned int _pitch;
|
||||
unsigned int _velocity;
|
||||
unsigned int _control;
|
||||
unsigned int _value;
|
||||
double _deltaTime;
|
||||
|
||||
std::vector<unsigned char> _rawMessage;
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
};
|
||||
|
||||
#endif // QMIDIMESSAGE_H
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
#include "qmidiout.h"
|
||||
#include <QDebug>
|
||||
QMidiOut::QMidiOut(QObject *parent) : QObject(parent),
|
||||
_midiOut(new RtMidiOut())
|
||||
{
|
||||
|
||||
}
|
||||
QStringList QMidiOut::getPorts()
|
||||
{
|
||||
//TODO: make this static
|
||||
QStringList ports;
|
||||
for(unsigned int i = 0; i < _midiOut->getPortCount(); i++)
|
||||
{
|
||||
ports.append(QString::fromStdString(_midiOut->getPortName(i)));
|
||||
}
|
||||
return ports;
|
||||
}
|
||||
void QMidiOut::openPort(unsigned int index)
|
||||
{
|
||||
_midiOut->openPort(index);
|
||||
}
|
||||
|
||||
void QMidiOut::openVirtualPort(QString name)
|
||||
{
|
||||
_midiOut->openVirtualPort(name.toStdString());
|
||||
}
|
||||
void QMidiOut::sendNoteOn(unsigned int channel, unsigned int pitch, unsigned int velocity)
|
||||
{
|
||||
std::vector<unsigned char> message;
|
||||
message.push_back(MIDI_NOTE_ON+channel-1);
|
||||
message.push_back(pitch);
|
||||
message.push_back(velocity);
|
||||
sendRawMessage(message);
|
||||
}
|
||||
void QMidiOut::sendNoteOff(unsigned int channel, unsigned int pitch, unsigned int velocity)
|
||||
{
|
||||
std::vector<unsigned char> message;
|
||||
message.push_back(MIDI_NOTE_OFF+(channel-1));
|
||||
message.push_back(pitch);
|
||||
message.push_back(velocity);
|
||||
sendRawMessage(message);
|
||||
}
|
||||
void QMidiOut::sendMessage(QMidiMessage *message)
|
||||
{
|
||||
std::vector<unsigned char> rawMessage = message->getRawMessage();
|
||||
qDebug()<<"send message"<<rawMessage.front();
|
||||
sendRawMessage(rawMessage);
|
||||
}
|
||||
|
||||
void QMidiOut::sendRawMessage(std::vector<unsigned char> &message)
|
||||
{
|
||||
_midiOut->sendMessage(&message);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
#ifndef QMIDIOUT_H
|
||||
#define QMIDIOUT_H
|
||||
|
||||
#include <QStringList>
|
||||
#include <QObject>
|
||||
#include "RtMidi.h"
|
||||
#include "qmidimessage.h"
|
||||
|
||||
class QMidiOut : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QMidiOut(QObject *parent = 0);
|
||||
void noteOn(unsigned int note, unsigned int value);
|
||||
QStringList getPorts();
|
||||
void sendNoteOn(unsigned int channel, unsigned int pitch, unsigned int velocity);
|
||||
void sendNoteOff(unsigned int channel, unsigned int pitch, unsigned int velocity);
|
||||
void sendMessage(QMidiMessage *message);
|
||||
void sendRawMessage(std::vector<unsigned char> &message);
|
||||
void openPort(unsigned int index);
|
||||
void openVirtualPort(QString name);
|
||||
private:
|
||||
RtMidiOut *_midiOut;
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
};
|
||||
|
||||
#endif // QMIDIOUT_H
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
#include "qmidipianoroll.h"
|
||||
#include <QPainter>
|
||||
#include <QGraphicsRectItem>
|
||||
QMidiPianoRoll::QMidiPianoRoll(QWidget *parent) :
|
||||
QGraphicsView(parent),
|
||||
_scene(new QGraphicsScene()),
|
||||
_keyWidth(10),
|
||||
_keyHeight(60)
|
||||
{
|
||||
float x = 0;
|
||||
for(int i = 0; i < 128; i++)
|
||||
{
|
||||
int position = i % 12;
|
||||
QGraphicsRectItem *rect;
|
||||
if(position == 0 || position == 2 || position == 4 || position == 5 || position == 7 || position == 9 || position == 11)
|
||||
{
|
||||
rect = new QGraphicsRectItem(x,0,_keyWidth,_keyHeight);
|
||||
_scene->addItem(rect);
|
||||
if(position != 4 && position != 11 )
|
||||
{
|
||||
x += _keyWidth/2+1;
|
||||
}
|
||||
else
|
||||
{
|
||||
x += _keyWidth+1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rect = new QGraphicsRectItem(x,0,_keyWidth,_keyHeight/2);
|
||||
rect->setZValue(2);
|
||||
QBrush brush;
|
||||
QPen pen;
|
||||
brush.setStyle(Qt::SolidPattern);
|
||||
pen.setColor(Qt::black);
|
||||
brush.setColor(Qt::black);
|
||||
rect->setBrush(brush);
|
||||
rect->setPen(pen);
|
||||
_scene->addItem(rect);
|
||||
x += _keyWidth/2+1;
|
||||
}
|
||||
_keys.push_back(rect);
|
||||
|
||||
}
|
||||
|
||||
setScene(_scene);
|
||||
}
|
||||
|
||||
bool QMidiPianoRoll::isSemiTone(int pitch)
|
||||
{
|
||||
int position = pitch %12;
|
||||
if(position == 0 || position == 2 || position == 4 || position == 5 || position == 7 || position == 9 || position == 11)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//void QMidiPianoRoll::paintEvent(QPaintEvent *event)
|
||||
//{
|
||||
//// QPainter painter(this);
|
||||
//}
|
||||
|
||||
void QMidiPianoRoll::onMidiReceive(QMidiMessage *message)
|
||||
{
|
||||
switch(message->getStatus())
|
||||
{
|
||||
case MIDI_NOTE_ON: {
|
||||
QBrush brush;
|
||||
brush.setStyle(Qt::SolidPattern);
|
||||
brush.setColor(QColor(0,0,200, message->getVelocity()*2));
|
||||
_keys[message->getPitch()]->setBrush(brush);
|
||||
break;
|
||||
}
|
||||
case MIDI_NOTE_OFF: {
|
||||
QBrush brush;
|
||||
brush.setStyle(Qt::SolidPattern);
|
||||
QColor color;
|
||||
if(isSemiTone(message->getPitch()))
|
||||
{
|
||||
color = QColor(Qt::black);
|
||||
}
|
||||
else
|
||||
{
|
||||
color = QColor(Qt::white);
|
||||
}
|
||||
brush.setColor(color);
|
||||
_keys[message->getPitch()]->setBrush(brush);
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
#ifndef QMIDIPIANOROLL_H
|
||||
#define QMIDIPIANOROLL_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QGraphicsView>
|
||||
#include <QGraphicsScene>
|
||||
|
||||
#include "qmidimessage.h"
|
||||
class QMidiPianoRoll :
|
||||
public QGraphicsView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QMidiPianoRoll(QWidget *parent = 0);
|
||||
protected:
|
||||
// void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
bool isSemiTone(int pitch);
|
||||
private:
|
||||
QGraphicsScene *_scene;
|
||||
int _keyWidth;
|
||||
int _keyHeight;
|
||||
QVector<QGraphicsRectItem*> _keys;
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void onMidiReceive(QMidiMessage *message);
|
||||
};
|
||||
|
||||
#endif // QMIDIPIANOROLL_H
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
set -ev
|
||||
|
||||
for dir in examples/example*/
|
||||
do
|
||||
(
|
||||
dir=${dir%*/} &&
|
||||
cd examples/${dir##*/} &&
|
||||
mkdir -p build &&
|
||||
cd build &&
|
||||
qmake ../*.pro &&
|
||||
make
|
||||
|
||||
)
|
||||
done
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
#!/bin/bash
|
||||
set -ev
|
||||
|
||||
sudo add-apt-repository --yes ppa:ubuntu-sdk-team/ppa
|
||||
sudo apt-get update -qq
|
||||
|
||||
sudo apt-get install qt5-default
|
||||
sudo apt-get install qt5-qmake
|
||||
sudo apt-get install qtbase5-dev-tools
|
||||
|
||||
sudo apt-get install libasound2-dev #run install_dependencies.sh instead
|
||||
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
set -ev
|
||||
|
||||
brew install qt5
|
||||
brew link --force qt5
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
set -ev
|
||||
|
||||
sudo apt-get install libasound2-dev
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
QApplication app(argc, argv);
|
||||
return app.exec();
|
||||
}
|
||||
Loading…
Reference in New Issue