├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── LabMuse └── imuse-technical.md ├── README.md ├── assets ├── 106-Grieg-InTheHallOfTheMountainKing.midi ├── 209-Tchaikovsky-RussianDance.midi ├── minute_waltz.midi ├── rachmaninov3.midi ├── venture.mid └── venture.txt ├── cmake └── LabMidiConfig.cmake.in ├── examples ├── MidiApp.cpp ├── MidiApp.h ├── MidiPlayerApp.cpp ├── MidiPlayerApp.h ├── MidiPortsApp.cpp ├── MidiPortsApp.h ├── OptionParser.cpp └── OptionParser.h ├── include └── LabMidi │ ├── LabMidi.h │ ├── MidiFile.h │ ├── MidiFilePlayer.h │ ├── MidiInOut.h │ ├── MusicTheory.h │ ├── Ports.h │ ├── SoftSynth.h │ └── Util.h ├── src ├── LabMidiIn.cpp ├── LabMidiMusicTheory.cpp ├── LabMidiOut.cpp ├── LabMidiPorts.cpp ├── LabMidiSoftSynth.cpp ├── LabMidiSong.cpp ├── LabMidiSongPlayer.cpp └── LabMidiUtil.cpp └── third-party └── rtmidi-1.0.15 ├── RtError.h ├── RtMidi.cpp ├── RtMidi.h ├── config ├── config.guess ├── config.sub └── install.sh ├── configure ├── configure.ac ├── doc ├── doxygen │ ├── Doxyfile │ ├── footer.html │ ├── header.html │ └── tutorial.txt ├── html │ ├── RtError_8h-source.html │ ├── RtError_8h_source.html │ ├── RtMidi_8h-source.html │ ├── RtMidi_8h_source.html │ ├── annotated.html │ ├── classRtError-members.html │ ├── classRtError.html │ ├── classRtMidi-members.html │ ├── classRtMidi.gif │ ├── classRtMidi.html │ ├── classRtMidi.png │ ├── classRtMidiIn-members.html │ ├── classRtMidiIn.gif │ ├── classRtMidiIn.html │ ├── classRtMidiIn.png │ ├── classRtMidiOut-members.html │ ├── classRtMidiOut.gif │ ├── classRtMidiOut.html │ ├── classRtMidiOut.png │ ├── classes.html │ ├── doxygen.css │ ├── doxygen.png │ ├── files.html │ ├── functions.html │ ├── functions_enum.html │ ├── functions_eval.html │ ├── functions_func.html │ ├── functions_type.html │ ├── hierarchy.html │ ├── index.html │ ├── structRtMidiIn_1_1MidiMessage-members.html │ ├── structRtMidiIn_1_1MidiMessage.html │ ├── structRtMidiIn_1_1MidiQueue-members.html │ ├── structRtMidiIn_1_1MidiQueue.html │ ├── structRtMidiIn_1_1RtMidiInData-members.html │ ├── structRtMidiIn_1_1RtMidiInData.html │ ├── tab_b.gif │ ├── tab_l.gif │ ├── tab_r.gif │ └── tabs.css ├── images │ ├── ccrma.gif │ └── mcgill.gif └── release.txt ├── readme └── tests ├── Makefile.in ├── RtMidi.dsw ├── cmidiin.cpp ├── cmidiin.dsp ├── midiout.cpp ├── midiout.dsp ├── midiprobe.cpp ├── midiprobe.dsp ├── qmidiin.cpp ├── qmidiin.dsp ├── sysextest.cpp └── sysextest.dsp /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | 6 | .DS_Store 7 | 8 | 9 | # Compiled Dynamic libraries 10 | *.so 11 | *.dylib 12 | 13 | # Compiled Static libraries 14 | *.lai 15 | *.la 16 | *.a 17 | 18 | # XCode stuff 19 | *.hmap 20 | *.xcuserstate 21 | 22 | # Vim stuff 23 | *.swp 24 | 25 | src/LabMidi.xcodeproj/xcuserdata/ 26 | src/obj/ 27 | build/ 28 | 29 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 2 | 3 | project(LabMidi 4 | VERSION 1.0.0 5 | DESCRIPTION "MIDI library for C++" 6 | LANGUAGES CXX) 7 | 8 | # set c++ to 17 9 | set(CMAKE_CXX_STANDARD 17) 10 | 11 | set(LABMIDI_ROOT ${CMAKE_CURRENT_SOURCE_DIR}) 12 | 13 | 14 | option(LABMIDI_USE_RTMIDI6 "Enable RtMidi 6 support" ON) 15 | 16 | if(LABMIDI_USE_RTMIDI6) 17 | find_package(RtMidi 6.0.0 QUIET) 18 | 19 | if (NOT RtMidi_FOUND) 20 | message(STATUS "Using FetchContent to manage RtMidi") 21 | include(FetchContent) 22 | 23 | FetchContent_Declare( 24 | rtmidi 25 | GIT_REPOSITORY https://github.com/thestk/rtmidi.git 26 | GIT_TAG 6.0.0 27 | ) 28 | 29 | set(BUILD_SHARED_LIBS_OLD "${BUILD_SHARED_LIBS}") 30 | set(BUILD_SHARED_LIBS OFF) 31 | FetchContent_MakeAvailable(rtmidi) 32 | set(BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS_OLD}") 33 | endif() 34 | 35 | if(NOT TARGET rtmidi) 36 | message(FATAL_ERROR "RtMidi not found") 37 | endif() 38 | endif() 39 | 40 | # Sources and Headers 41 | set(LABMIDI_HEADERS 42 | include/LabMidi/LabMidi.h 43 | include/LabMidi/MidiFile.h 44 | include/LabMidi/MidiFilePlayer.h 45 | include/LabMidi/MidiInOut.h 46 | include/LabMidi/MusicTheory.h 47 | include/LabMidi/Ports.h 48 | include/LabMidi/SoftSynth.h 49 | include/LabMidi/Util.h 50 | ) 51 | 52 | set(LABMIDI_SOURCES 53 | src/LabMidiIn.cpp 54 | src/LabMidiMusicTheory.cpp 55 | src/LabMidiOut.cpp 56 | src/LabMidiPorts.cpp 57 | src/LabMidiSoftSynth.cpp 58 | src/LabMidiSong.cpp 59 | src/LabMidiSongPlayer.cpp 60 | src/LabMidiUtil.cpp 61 | ) 62 | 63 | # Build the library 64 | add_library(LabMidi ${LABMIDI_SOURCES} ${LABMIDI_HEADERS}) 65 | target_include_directories(LabMidi PUBLIC include) 66 | target_link_libraries(LabMidi PRIVATE rtmidi) 67 | add_library(Lab::Midi ALIAS LabMidi) 68 | 69 | set_target_properties( 70 | LabMidi 71 | PROPERTIES 72 | FOLDER "LabMidi" 73 | POSITION_INDEPENDENT_CODE ON 74 | PUBLIC_HEADER "${LABMIDI_HEADERS}" 75 | OUTPUT_NAME "LabMidi" 76 | OUTPUT_NAME_DEBUG "LabMidi_d" 77 | INTERFACE_INCLUDE_DIRECTORIES ${LABMIDI_ROOT}/include 78 | ) 79 | 80 | # Create configuration file for CMake package config 81 | configure_file(cmake/LabMidiConfig.cmake.in "${PROJECT_BINARY_DIR}/LabMidiConfig.cmake" @ONLY) 82 | install(TARGETS LabMidi 83 | EXPORT LabMidi 84 | LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" 85 | ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" 86 | RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" 87 | PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_PREFIX}/include") 88 | 89 | install(FILES 90 | "${PROJECT_BINARY_DIR}/LabMidiConfig.cmake" DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/cmake" 91 | ) 92 | 93 | option(LABMIDI_BUILD_EXAMPLES "Build example applications" OFF) 94 | 95 | if(LABMIDI_BUILD_EXAMPLES) 96 | add_executable(LabMidiApp examples/MidiApp.cpp) 97 | target_link_libraries(LabMidiApp PRIVATE LabMidi) 98 | 99 | add_executable(LabMidiPlayerApp examples/MidiPlayerApp.cpp examples/OptionParser.cpp) 100 | target_link_libraries(LabMidiPlayerApp PRIVATE LabMidi) 101 | 102 | add_executable(LabMidiPortsApp examples/MidiPortsApp.cpp examples/OptionParser.cpp) 103 | target_link_libraries(LabMidiPortsApp PRIVATE LabMidi) 104 | 105 | # Install examples 106 | install(TARGETS LabMidiApp LabMidiPlayerApp LabMidiPortsApp 107 | RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" 108 | ) 109 | endif() 110 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This project incorporates third-party code under BSD 2 and 3 clause licenses. 2 | 3 | 2 Clause BSD 4 | =============================================================================== 5 | Copyright (c) 2015+, Nick Porcino. All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | LabMidi 2 | ======= 3 | 4 | Cross platform MIDI related utilities. 5 | 6 | class MidiIn 7 | Can read from a MIDI input port, typically provided by a keyboard 8 | 9 | class MidiOut 10 | Outputs to a MIDI port, typically consumed by a synthesizer 11 | 12 | class MidiSoftSynth : public MidiOutBase 13 | A software synthesizer that can be used as a MIDI output. Currently 14 | only implemented for OSX (and presumably it would work for iOS as well). 15 | 16 | class MidiSong 17 | A song is a collection of tracks, which are a list of MIDI events. A song can 18 | be parsed from a Standard MIDI file, or from a base64 encoded Standard MIDI file 19 | with an appropriate header. MML (Music Macro Language) data may also be parsed, 20 | passed in as either an MML string, or a file path. The version parsed is a restricted 21 | form of Modern MML, and not nearly as sophisticated as what mml2mid can currently 22 | process. 23 | 24 | class MidiSongPlayer 25 | Can play a single MidiSong. The class is initialized with a pointer 26 | to a MidiSong. The data in the MidiSong is not retained in any way, 27 | so after a MidiSongPlayer is instantiated it is fine to discard the 28 | MidiSong object. 29 | 30 | LabMidiUtil.h 31 | Contains various routines to convert between note names, note numbers, 32 | and frequency, as well as routines to fetch standard General MIDI names 33 | for instruments. 34 | 35 | Like ofxMidi, I'm thinking of using PGMidi to implement the MidiIn and MidiOUt classes on iOS. 36 | 37 | Building 38 | -------- 39 | CMake 3.15 or greater is required for building. Building in the usual way should work out of the box, as LabMidi 40 | has no external dependencies. 41 | 42 | Build Options: 43 | - LABMIDI_BUILD_EXAMPLES (ON/OFF): Build example applications (default: ON) 44 | - LABMIDI_BUILD_SHARED_LIBS (ON/OFF): Build as shared libraries (default: OFF) 45 | - LABMIDI_INSTALL (ON/OFF): Generate installation target (default: ON) 46 | 47 | Example: 48 | ```cmake 49 | cmake -B build -DLABMIDI_BUILD_EXAMPLES=ON 50 | cmake --build build 51 | ``` 52 | 53 | Usage 54 | ----- 55 | LabMidi can be used in other CMake projects either via find_package() or FetchContent: 56 | 57 | ```cmake 58 | # Option 1: Using find_package 59 | find_package(LabMidi REQUIRED) 60 | target_link_libraries(your_target PRIVATE Lab::Midi) 61 | 62 | # Option 2: Using FetchContent 63 | include(FetchContent) 64 | FetchContent_Declare( 65 | labmidi 66 | GIT_REPOSITORY your_repo_url 67 | GIT_TAG your_tag 68 | ) 69 | FetchContent_MakeAvailable(labmidi) 70 | target_link_libraries(your_target PRIVATE Lab::Midi) 71 | ``` 72 | 73 | See the MidiApp source for examples of usage. Note that MidiApp.cpp currently has hard coded paths to the midi sample files. 74 | You'll need to make sure you've set your working directory to the folder containing the resources folder. In XCode, under the Product menu, select Edit Schemes..., then the Options tab, then the target you want to run, and click the Use Custom Working Directory box. Fill in the path appropriately. 75 | 76 | MidiPlayer 77 | ---------- 78 | 79 | MidiPlayerApp -o 0 -f path/to/file.midi 80 | 81 | Will play file.midi on the 0th port. 82 | 83 | License 84 | ------- 85 | BSD 3-clause. 86 | 87 | Note that the sample midi files in the assets directory were obtained from the jasmid 88 | distribution on github, and they contain their own internal copyright notices. 89 | 90 | Thanks 91 | ------ 92 | Thanks to ofxMidi for inspiration, and jasmid for a clean implementation of a standard midi file reader, which I 93 | used as a jumping off point for the LabMidi midi file parser. Thanks to RtMidi for providing a robust platform abstraction. 94 | LabMidi is quite different from jasmid and ofxMidi because the focus is playing midi files, and providing basic routing functionality. 95 | 96 | Thanks to qiao for posting lots of base64 encoded MIDI tracks at . 97 | 98 | Thanks to for posting a very cool web utility that calculates scales and chords. 99 | It's dual licensed GPL and CC-0. I used the tables in that utility, choosing the CC-0 license for this usage. 100 | 101 | There's 9,310 piano MIDI files here: 102 | 103 | Thanks to arle for publishing mml2mid , 104 | and to g200kg for an MML player. 105 | 106 | Thanks to Andre Mazzone and Josh Fillstrup for helping get LabMidi up and running on Linux. 107 | -------------------------------------------------------------------------------- /assets/minute_waltz.midi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meshula/LabMidi/45c449bf77013c10cfed9389b69595b30e856e5d/assets/minute_waltz.midi -------------------------------------------------------------------------------- /assets/rachmaninov3.midi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meshula/LabMidi/45c449bf77013c10cfed9389b69595b30e856e5d/assets/rachmaninov3.midi -------------------------------------------------------------------------------- /assets/venture.mid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meshula/LabMidi/45c449bf77013c10cfed9389b69595b30e856e5d/assets/venture.mid -------------------------------------------------------------------------------- /assets/venture.txt: -------------------------------------------------------------------------------- 1 | //Venture (Original WIP) by Ximon 2 | //https://musescore.com/user/2391686/scores/841451 3 | //License: Creative Commons copyright waiver (CC0) 4 | -------------------------------------------------------------------------------- /cmake/LabMidiConfig.cmake.in: -------------------------------------------------------------------------------- 1 | add_library(LabMidi SHARED IMPORTED) 2 | set_property(TARGET LabMidi APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) 3 | set_property(TARGET LabMidi APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) 4 | set_target_properties(LabMidi PROPERTIES IMPORTED_IMPLIB_RELEASE @CMAKE_INSTALL_PREFIX@/lib/LabMidi.lib) 5 | set_target_properties(LabMidi PROPERTIES IMPORTED_IMPLIB_DEBUG @CMAKE_INSTALL_PREFIX@/lib/LabMidi_d.lib) 6 | set_property(TARGET LabMidi APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES @CMAKE_INSTALL_PREFIX@/include) 7 | add_library(Lab::Midi ALIAS LabMidi) 8 | -------------------------------------------------------------------------------- /examples/MidiApp.h: -------------------------------------------------------------------------------- 1 | // 2 | // MidiApp.h 3 | // 4 | 5 | /* 6 | Copyright (c) 2012, Nick Porcino 7 | All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions are met: 11 | 12 | * Redistributions of source code must retain the above copyright notice, this 13 | list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | * The names of its contributors may not be used to endorse or promote products 18 | derived from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 24 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 27 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | 33 | #pragma once 34 | 35 | 36 | class MidiApp 37 | { 38 | public: 39 | MidiApp(); 40 | ~MidiApp(); 41 | 42 | void setup(); 43 | void update(); 44 | 45 | double getElapsedSeconds(); 46 | bool running(); 47 | 48 | private: 49 | class Detail; 50 | Detail* _detail; 51 | }; 52 | 53 | -------------------------------------------------------------------------------- /examples/MidiPlayerApp.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright (c) 2012, Nick Porcino 3 | // All rights reserved. 4 | // SPDX-License-Identifier: BSD-2-Clause 5 | 6 | #include "MidiPlayerApp.h" 7 | #include "OptionParser.h" 8 | 9 | #include 10 | 11 | #include 12 | 13 | #ifdef _MSC_VER 14 | #define WIN32_LEAN_AND_MEAN 15 | #include 16 | #else 17 | #include 18 | #include 19 | #include 20 | #endif 21 | 22 | 23 | 24 | class MidiPlayerApp::Detail 25 | { 26 | public: 27 | Lab::MidiPorts* midiPorts = nullptr; 28 | Lab::MidiSongPlayer* midiSongPlayer = nullptr; 29 | double startTime = 0; 30 | 31 | Detail() 32 | : midiPorts(new Lab::MidiPorts()) 33 | , midiSongPlayer(0) 34 | { 35 | } 36 | 37 | ~Detail() 38 | { 39 | delete midiPorts; 40 | } 41 | 42 | void listPorts() 43 | { 44 | midiPorts->refreshPortList(); 45 | int c = midiPorts->inPorts(); 46 | if (c == 0) 47 | std::cout << "No MIDI input ports found\n\n"; 48 | else { 49 | std::cout << "MIDI input ports:" << std::endl; 50 | for (int i = 0; i < c; ++i) 51 | std::cout << " " << i << ": " << midiPorts->inPort(i) << std::endl; 52 | std::cout << std::endl; 53 | } 54 | 55 | c = midiPorts->outPorts(); 56 | if (c == 0) 57 | std::cout << "No MIDI output ports found\n\n"; 58 | else { 59 | std::cout << "MIDI output ports:" << std::endl; 60 | for (int i = 0; i < c; ++i) 61 | std::cout << " " << i << ": " << midiPorts->outPort(i) << std::endl; 62 | std::cout << std::endl; 63 | } 64 | } 65 | }; 66 | 67 | MidiPlayerApp::MidiPlayerApp 68 | () 69 | : _detail(new Detail()) 70 | { 71 | _detail->listPorts(); 72 | } 73 | 74 | MidiPlayerApp::~MidiPlayerApp 75 | () 76 | { 77 | delete _detail; 78 | } 79 | 80 | double MidiPlayerApp::getElapsedSeconds() 81 | { 82 | #ifdef _MSC_VER 83 | static double freq; 84 | static LARGE_INTEGER start; 85 | static bool init = true; 86 | if (init) { 87 | LARGE_INTEGER lFreq; 88 | QueryPerformanceFrequency(&lFreq); 89 | freq = double(lFreq.QuadPart); 90 | QueryPerformanceCounter(&start); 91 | init = false; 92 | } 93 | LARGE_INTEGER now; 94 | QueryPerformanceCounter(&now); 95 | return double(now.QuadPart - start.QuadPart) / freq; 96 | #else 97 | timeval t; 98 | gettimeofday(&t, 0); 99 | return double(t.tv_sec) + double(t.tv_usec) * 1.0e-6f; 100 | #endif 101 | } 102 | 103 | void MidiPlayerApp::setup() 104 | { 105 | } 106 | 107 | void MidiPlayerApp::update(double t) 108 | { 109 | _detail->midiSongPlayer->update(static_cast(t)); 110 | } 111 | 112 | bool MidiPlayerApp::running(double t) 113 | { 114 | if (!_detail->midiSongPlayer) 115 | return false; 116 | 117 | return t <= (_detail->midiSongPlayer->length() + 0.5f); 118 | } 119 | 120 | int main(int argc, char** argv) 121 | { 122 | MidiPlayerApp app; 123 | 124 | OptionParser op("MidiPlayer"); 125 | int port = -1; 126 | std::string path; 127 | op.AddIntOption("o", "outport", port, "A valid MIDI output port number"); 128 | op.AddStringOption("f", "file", path, "Path to the file to play"); 129 | if (op.Parse(argc, argv)) { 130 | if (port == -1 || !path.length()) 131 | op.Usage(); 132 | else { 133 | Lab::MidiOut* midiOut = new Lab::MidiOut(); 134 | midiOut->openPort(port); 135 | Lab::MidiSong* midiSong = new Lab::MidiSong(); 136 | midiSong->parse(path.c_str(), true); 137 | app._detail->midiSongPlayer = new Lab::MidiSongPlayer(midiSong); 138 | app._detail->midiSongPlayer->addCallback(Lab::MidiOut::playerCallback, midiOut); 139 | app._detail->midiSongPlayer->play(0); 140 | 141 | double startTime = app.getElapsedSeconds(); 142 | 143 | while (app.running(app.getElapsedSeconds() - startTime)) { 144 | #ifdef _MSC_VER 145 | Sleep(1); // 1ms delay --- to do - shouldn't sleep this long 146 | #else 147 | usleep(100); // 0.1ms delay 148 | #endif 149 | app.update(app.getElapsedSeconds() - startTime); 150 | } 151 | delete midiOut; 152 | } 153 | } 154 | 155 | return 1; 156 | } 157 | 158 | -------------------------------------------------------------------------------- /examples/MidiPlayerApp.h: -------------------------------------------------------------------------------- 1 | // 2 | // MidiApp.h 3 | // 4 | 5 | /* 6 | Copyright (c) 2012, Nick Porcino 7 | All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions are met: 11 | 12 | * Redistributions of source code must retain the above copyright notice, this 13 | list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | * The names of its contributors may not be used to endorse or promote products 18 | derived from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 24 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 27 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | 33 | #pragma once 34 | 35 | 36 | class MidiPlayerApp 37 | 38 | { 39 | public: 40 | MidiPlayerApp(); 41 | ~MidiPlayerApp(); 42 | 43 | void setup(); 44 | void update(double t); 45 | 46 | double getElapsedSeconds(); 47 | bool running(double t); 48 | 49 | //private: 50 | class Detail; 51 | Detail* _detail; 52 | }; 53 | 54 | -------------------------------------------------------------------------------- /examples/MidiPortsApp.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MidiApp.cpp 3 | * 4 | */ 5 | 6 | /* 7 | Copyright (c) 2012, Nick Porcino 8 | All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | 13 | * Redistributions of source code must retain the above copyright notice, this 14 | list of conditions and the following disclaimer. 15 | * Redistributions in binary form must reproduce the above copyright notice, 16 | this list of conditions and the following disclaimer in the documentation 17 | and/or other materials provided with the distribution. 18 | * The names of its contributors may not be used to endorse or promote products 19 | derived from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 25 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 28 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | // Note that the sample midi files were obtained from the jasmid 34 | // distribution on github, and they contain their own internal 35 | // copyright notices. 36 | 37 | #include "MidiPortsApp.h" 38 | #include "LabMidi/Ports.h" 39 | 40 | #include 41 | 42 | #ifdef _MSC_VER 43 | #define WIN32_LEAN_AND_MEAN 44 | #include 45 | #else 46 | #include 47 | #include 48 | #include 49 | #endif 50 | 51 | class MidiPortsApp::Detail 52 | { 53 | public: 54 | Detail() 55 | : midiPorts(new Lab::MidiPorts()) 56 | { 57 | } 58 | 59 | ~Detail() 60 | { 61 | delete midiPorts; 62 | } 63 | 64 | void listPorts() 65 | { 66 | midiPorts->refreshPortList(); 67 | int c = midiPorts->inPorts(); 68 | if (c == 0) 69 | std::cout << "No MIDI input ports found" << std::endl; 70 | else { 71 | std::cout << "MIDI input ports:" << std::endl; 72 | for (int i = 0; i < c; ++i) 73 | std::cout << " " << i << ": " << midiPorts->inPort(i) << std::endl; 74 | std::cout << std::endl; 75 | } 76 | 77 | c = midiPorts->outPorts(); 78 | if (c == 0) 79 | std::cout << "No MIDI output ports found" << std::endl; 80 | else { 81 | std::cout << "MIDI output ports:" << std::endl; 82 | for (int i = 0; i < c; ++i) 83 | std::cout << " " << i << ": " << midiPorts->outPort(i) << std::endl; 84 | std::cout << std::endl; 85 | } 86 | } 87 | 88 | Lab::MidiPorts* midiPorts; 89 | double startTime; 90 | }; 91 | 92 | MidiPortsApp::MidiPortsApp() 93 | : _detail(new Detail()) 94 | { 95 | _detail->listPorts(); 96 | } 97 | 98 | MidiPortsApp::~MidiPortsApp() 99 | { 100 | delete _detail; 101 | } 102 | 103 | double MidiPortsApp::getElapsedSeconds() 104 | { 105 | #ifdef _MSC_VER 106 | static double freq; 107 | static LARGE_INTEGER start; 108 | static bool init = true; 109 | if (init) { 110 | LARGE_INTEGER lFreq; 111 | QueryPerformanceFrequency(&lFreq); 112 | freq = double(lFreq.QuadPart); 113 | QueryPerformanceCounter(&lStart); 114 | init = false; 115 | } 116 | LARGE_INTEGER now; 117 | QueryPerformanceCounter(&now); 118 | return double(now.QuadPart - start.QuadPart) / freq; 119 | #else 120 | timeval t; 121 | gettimeofday(&t, 0); 122 | return double(t.tv_sec) + double(t.tv_usec) * 1.0e-6f; 123 | #endif 124 | } 125 | 126 | void MidiPortsApp::setup() 127 | { 128 | } 129 | 130 | void MidiPortsApp::update() 131 | { 132 | } 133 | 134 | bool MidiPortsApp::running() 135 | { 136 | return false; 137 | } 138 | 139 | int main(int argc, char** argv) 140 | { 141 | MidiPortsApp* app = new MidiPortsApp(); 142 | 143 | while (app->running()) { 144 | #ifdef _MSC_VER 145 | Sleep(1); // 1ms delay --- to do - shouldn't sleep this long 146 | #else 147 | usleep(100); // 0.1ms delay 148 | #endif 149 | app->update(); 150 | } 151 | 152 | delete app; 153 | return 1; 154 | } 155 | 156 | -------------------------------------------------------------------------------- /examples/MidiPortsApp.h: -------------------------------------------------------------------------------- 1 | // 2 | // MidiApp.h 3 | // 4 | 5 | /* 6 | Copyright (c) 2012, Nick Porcino 7 | All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions are met: 11 | 12 | * Redistributions of source code must retain the above copyright notice, this 13 | list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | * The names of its contributors may not be used to endorse or promote products 18 | derived from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 24 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 27 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | 33 | #pragma once 34 | 35 | 36 | class MidiPortsApp 37 | { 38 | public: 39 | MidiPortsApp(); 40 | ~MidiPortsApp(); 41 | 42 | void setup(); 43 | void update(); 44 | 45 | double getElapsedSeconds(); 46 | bool running(); 47 | 48 | private: 49 | class Detail; 50 | Detail* _detail; 51 | }; 52 | 53 | -------------------------------------------------------------------------------- /include/LabMidi/LabMidi.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, Nick Porcino 2 | // All rights reserved. 3 | // SPDX-License-Identifier: BSD-2-Clause 4 | 5 | #pragma once 6 | #ifndef included_labmidi_h 7 | #define included_labmidi_h 8 | 9 | #include "LabMidi/MidiInOut.h" 10 | #include "LabMidi/MidiFile.h" 11 | #include "LabMidi/MidiFilePlayer.h" 12 | #include "LabMidi/Ports.h" 13 | #include "LabMidi/SoftSynth.h" 14 | #include "LabMidi/Util.h" 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /include/LabMidi/MidiFile.h: -------------------------------------------------------------------------------- 1 | // 2 | // LabMidiSong.h 3 | // 4 | 5 | /* 6 | Copyright (c) 2012, Nick Porcino 7 | All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions are met: 11 | 12 | * Redistributions of source code must retain the above copyright notice, this 13 | list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | * The names of its contributors may not be used to endorse or promote products 18 | derived from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 24 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 27 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #pragma once 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | namespace Lab { 40 | 41 | class MidiOutBase; 42 | 43 | ////////////////////////// 44 | // (Meta) Message Type // 45 | ////////////////////////// 46 | 47 | enum class Midi_MetaEventType : uint8_t 48 | { 49 | SEQUENCE_NUMBER = 0x00, 50 | TEXT = 0x01, 51 | COPYRIGHT = 0x02, 52 | TRACK_NAME = 0x03, 53 | INSTRUMENT = 0x04, 54 | LYRIC = 0x05, 55 | MARKER = 0x06, 56 | CUE = 0x07, 57 | PATCH_NAME = 0x08, 58 | DEVICE_NAME = 0x09, 59 | MIDI_CHANNEL_PREFIX = 0x20, 60 | WHAT_is_THIS = 0x21, 61 | END_OF_TRACK = 0x2F, 62 | TEMPO_CHANGE = 0x51, 63 | SMPTE_OFFSET = 0x54, 64 | TIME_SIGNATURE = 0x58, 65 | KEY_SIGNATURE = 0x59, 66 | PROPRIETARY = 0x7F, 67 | SYSTEM_EXCLUSIVE = 0xF0, 68 | END_OF_EXCLUSIVE = 0xF7, 69 | LABMIDI_CHANNEL_EVENT = 0xFE, 70 | UNKNOWN = 0xFF 71 | }; 72 | 73 | constexpr inline uint8_t clamp(uint8_t val, uint8_t min, uint8_t max) 74 | { 75 | return std::max(std::min(val, max), min); 76 | } 77 | 78 | struct MidiEvent { 79 | MidiEvent(Midi_MetaEventType s) : eventType(s), tick(0) { } 80 | ~MidiEvent() = default; 81 | 82 | Midi_MetaEventType eventType; 83 | int tick; 84 | std::vector data; 85 | }; 86 | 87 | struct Event_SequenceNumber : public MidiEvent { 88 | Event_SequenceNumber() : MidiEvent(Midi_MetaEventType::SEQUENCE_NUMBER) {} uint16_t number = 0; }; 89 | struct Event_Text : public MidiEvent { 90 | Event_Text() : MidiEvent(Midi_MetaEventType::TEXT) {} }; 91 | struct Event_CopyrightNotice : public MidiEvent { 92 | Event_CopyrightNotice() : MidiEvent(Midi_MetaEventType::COPYRIGHT) {} }; 93 | struct Event_TrackName : public MidiEvent { 94 | Event_TrackName() : MidiEvent(Midi_MetaEventType::TRACK_NAME) {} }; 95 | struct Event_InstrumentName : public MidiEvent { 96 | Event_InstrumentName() : MidiEvent(Midi_MetaEventType::INSTRUMENT) {} }; 97 | struct Event_Lyrics : public MidiEvent { 98 | Event_Lyrics() : MidiEvent(Midi_MetaEventType::LYRIC) {} }; 99 | struct Event_Marker : public MidiEvent { 100 | Event_Marker() : MidiEvent(Midi_MetaEventType::MARKER) {} }; 101 | struct Event_Cue : public MidiEvent { 102 | Event_Cue() : MidiEvent(Midi_MetaEventType::CUE) {} }; 103 | struct Event_MidiChannelPrefix : public MidiEvent { 104 | Event_MidiChannelPrefix() : MidiEvent(Midi_MetaEventType::MIDI_CHANNEL_PREFIX) {} uint8_t channel = 0; }; 105 | struct Event_EndOfTrack : public MidiEvent { 106 | Event_EndOfTrack() : MidiEvent(Midi_MetaEventType::END_OF_TRACK) {} }; 107 | struct Event_SetTempo : public MidiEvent { 108 | Event_SetTempo() : MidiEvent(Midi_MetaEventType::TEMPO_CHANGE) {} int microsecondsPerBeat = 125000; }; 109 | struct Event_SmpteOffset : public MidiEvent { 110 | Event_SmpteOffset() : MidiEvent(Midi_MetaEventType::SMPTE_OFFSET) {} uint8_t framerate = 0; uint8_t hour = 0; uint8_t min = 0; uint8_t sec = 0; uint8_t frame = 0; uint8_t subframe = 0; }; 111 | struct Event_TimeSignature : public MidiEvent { 112 | Event_TimeSignature() : MidiEvent(Midi_MetaEventType::TIME_SIGNATURE) {} double timeSignature = 120.; uint8_t metronome = 0; uint8_t thirtyseconds = 0; }; 113 | struct Event_KeySignature : public MidiEvent { 114 | Event_KeySignature() : MidiEvent(Midi_MetaEventType::KEY_SIGNATURE) {} uint8_t key = 0; uint8_t scale = 0; }; 115 | struct Event_SequencerSpecific : public MidiEvent { 116 | Event_SequencerSpecific() : MidiEvent(Midi_MetaEventType::PROPRIETARY) {} }; 117 | struct Event_Unknown : public MidiEvent { 118 | Event_Unknown() : MidiEvent(Midi_MetaEventType::UNKNOWN) {} }; 119 | struct Event_SysEx : public MidiEvent { 120 | Event_SysEx() : MidiEvent(Midi_MetaEventType::SYSTEM_EXCLUSIVE) {} }; 121 | struct Event_DividedSysEx : public MidiEvent { 122 | Event_DividedSysEx() : MidiEvent(Midi_MetaEventType::END_OF_EXCLUSIVE) {} }; 123 | 124 | struct Event_Channel : public MidiEvent { 125 | Event_Channel() : MidiEvent(Midi_MetaEventType::LABMIDI_CHANNEL_EVENT) {} }; 126 | 127 | class MidiTrack { 128 | public: 129 | ~MidiTrack() 130 | { 131 | for (auto e : events) 132 | delete e; 133 | } 134 | std::vector events; 135 | }; 136 | 137 | class MidiSong { 138 | public: 139 | MidiSong(); 140 | ~MidiSong(); 141 | 142 | void parse(uint8_t const*const midifiledata, size_t length, bool verbose); 143 | void parse(char const*const midifilePath, bool verbose); 144 | 145 | void writeMidi(std::ostream& out); 146 | 147 | // Converts MML to Midi 148 | void parseMML(char const*const mmlStr, size_t length, bool verbose); 149 | void parseMML(char const*const midifilePath, bool verbose); 150 | 151 | void clearTracks(); 152 | 153 | float ticksPerBeat = 1; // precision (number of ticks distinguishable per second) 154 | float startingTempo = 120; 155 | std::vector> tracks; 156 | }; 157 | 158 | } // Lab 159 | 160 | -------------------------------------------------------------------------------- /include/LabMidi/MidiFilePlayer.h: -------------------------------------------------------------------------------- 1 | // 2 | // LabMidiSongPlayer.h 3 | // 4 | 5 | /* 6 | Copyright (c) 2012, Nick Porcino 7 | All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions are met: 11 | 12 | * Redistributions of source code must retain the above copyright notice, this 13 | list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | * The names of its contributors may not be used to endorse or promote products 18 | derived from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 24 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 27 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #pragma once 33 | 34 | #include "LabMidi/MidiInOut.h" 35 | 36 | namespace Lab { 37 | 38 | class MidiSong; 39 | 40 | struct MidiRtEvent; 41 | 42 | typedef void (*MidiEventCallbackFn)(void* userData, MidiRtEvent*); 43 | 44 | class MidiSongPlayer { 45 | public: 46 | MidiSongPlayer(MidiSong*); 47 | ~MidiSongPlayer(); 48 | 49 | void play(float wallClockTime); 50 | void update(float wallClockTime); 51 | 52 | float length() const; // length of the contained song 53 | 54 | void addCallback(MidiEventCallbackFn, void* userData); 55 | void removeCallback(void* userData); 56 | 57 | private: 58 | class Detail; 59 | Detail* _detail; 60 | }; 61 | 62 | } // Lab 63 | 64 | -------------------------------------------------------------------------------- /include/LabMidi/MidiInOut.h: -------------------------------------------------------------------------------- 1 | // 2 | // LabMidiIn.h 3 | // 4 | // CoreAudio, CoreMidi, and CoreFoundation frameworks are required on OSX/iOS 5 | // 6 | /* 7 | Copyright (c) 2012, Nick Porcino 8 | All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | 13 | * Redistributions of source code must retain the above copyright notice, this 14 | list of conditions and the following disclaimer. 15 | * Redistributions in binary form must reproduce the above copyright notice, 16 | this list of conditions and the following disclaimer in the documentation 17 | and/or other materials provided with the distribution. 18 | * The names of its contributors may not be used to endorse or promote products 19 | derived from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 25 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 28 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #pragma once 34 | 35 | #include 36 | #include 37 | 38 | class RtMidiIn; 39 | 40 | namespace Lab { 41 | 42 | /* 43 | http://www.midi.org/techspecs/midimessages.php 44 | Command Meaning # parameters param 1 param 2 45 | 0x8c Note-off 2 key velocity 46 | 0x9c Note-on 2 key velocity 47 | 0xAc Aftertouch 2 key touch 48 | 0xBc Continuous controller (pedals, levers, etc) 49 | 2 controller # controller value 50 | 0xCc Patch change 2 instrument # 51 | 0xDc Channel Pressure 1 pressure 52 | 0xEc Pitch bend (center is 0x2000) 53 | 2 lsb (7 bits) msb (7 bits) 54 | 55 | where c is the channel number 56 | 57 | 0xF0 0iiiiiii (7 bit manufacturer ID) 0ddddddd (message, listened to if iiiiiii corresponds to receiving device) 58 | 0xF1 0nnndddd Time code quarter frame. nnn = message type, dddd = values 59 | 0xF2 0iiiiiii LSB of 14 bit song position pointer, 0mmmmmmm MSB of 14 bit song position pointer 60 | 0xF3 0sssssss Song to be played 61 | 0xF6 upon reception, all analog synthesizers should tune their oscillators 62 | 0xF7 end of excclusive, used to terminate system exclusive dump. 63 | */ 64 | 65 | // channel info (MSN=command LSN=channel) 66 | #define MIDI_NOTE_OFF 0x80 67 | #define MIDI_NOTE_ON 0x90 68 | #define MIDI_POLY_PRESSURE 0xA0 69 | #define MIDI_CONTROL_CHANGE 0xB0 70 | #define MIDI_PROGRAM_CHANGE 0xC0 71 | #define MIDI_CHANNEL_PRESSURE 0xD0 72 | #define MIDI_PITCH_BEND 0xE0 73 | 74 | // system common 75 | #define MIDI_SYSTEM_EXCLUSIVE 0xF0 76 | #define MIDI_TIME_CODE 0xF1 77 | #define MIDI_SONG_POS_POINTER 0xF2 78 | #define MIDI_SONG_SELECT 0xF3 79 | #define MIDI_RESERVED1 0xF4 80 | #define MIDI_RESERVED2 0xF5 81 | #define MIDI_TUNE_REQUEST 0xF6 82 | #define MIDI_EOX 0xF7 83 | 84 | // system realtime 85 | #define MIDI_TIME_CLOCK 0xF8 86 | #define MIDI_RESERVED3 0xF9 87 | #define MIDI_START 0xFA 88 | #define MIDI_CONTINUE 0xFB 89 | #define MIDI_STOP 0xFC 90 | #define MIDI_RESERVED4 0xFD 91 | #define MIDI_ACTIVE_SENSING 0xFE 92 | #define MIDI_SYSTEM_RESET 0xFF 93 | 94 | struct MidiCommand { 95 | MidiCommand() = default; 96 | MidiCommand(uint8_t command, uint8_t byte1, uint8_t byte2) 97 | : command(command), byte1(byte1), byte2(byte2) { } 98 | MidiCommand(const MidiCommand& rhs) { 99 | *this = rhs; 100 | } 101 | MidiCommand& operator=(const MidiCommand& rhs) { 102 | command = rhs.command; 103 | byte1 = rhs.byte1; 104 | byte2 = rhs.byte2; 105 | return *this; 106 | } 107 | uint8_t command = 0; 108 | uint8_t byte1 = 0; 109 | uint8_t byte2 = 0; 110 | }; 111 | 112 | struct MidiRtEvent 113 | { 114 | MidiRtEvent(float t, uint8_t b1, uint8_t b2, uint8_t b3) 115 | : time(t) 116 | { 117 | command.command = b1; 118 | command.byte1 = b2; 119 | command.byte2 = b3; 120 | } 121 | 122 | MidiRtEvent& operator=(const MidiRtEvent& rhs) 123 | { 124 | time = rhs.time; 125 | command = rhs.command; 126 | return *this; 127 | } 128 | 129 | float time; 130 | MidiCommand command; 131 | }; 132 | 133 | 134 | typedef void (*MidiCallbackFn)(void* userData, MidiCommand*); 135 | 136 | //---------------------------------------------------------------------------- 137 | 138 | class MidiIn { 139 | public: 140 | MidiIn(); 141 | ~MidiIn(); 142 | 143 | void setVerbose(bool verbose); 144 | 145 | // [OSX and ALSA] createVirtualPort creates a software MIDI port that 146 | // other software can connect to. portName is the user facing name that 147 | // will appear if MIDI devices are enumerated. 148 | // 149 | bool createVirtualPort(const std::string& portName) noexcept; 150 | 151 | // Opens a numbered midi port corresponding to a MIDI source available 152 | // on the MIDI system. 153 | // 154 | bool openPort(unsigned int port); 155 | 156 | void closePort(); 157 | unsigned int getPort() const; 158 | 159 | void addCallback(MidiCallbackFn, void* userData); 160 | void removeCallback(void* userData); 161 | 162 | private: 163 | class Detail; 164 | Detail* _detail; 165 | }; 166 | 167 | class MidiOutBase { 168 | public: 169 | virtual ~MidiOutBase() { } 170 | virtual void command(const MidiCommand*) = 0; 171 | }; 172 | 173 | class MidiOut : public MidiOutBase { 174 | public: 175 | MidiOut(); 176 | virtual ~MidiOut(); 177 | 178 | // createVirtualPort is available on MacOSX and ALSA for allowing other software to connect 179 | bool createVirtualPort(const std::string& port) noexcept; 180 | 181 | bool openPort(unsigned int port); 182 | void closePort(); 183 | unsigned int getPort() const; 184 | 185 | // channels are 0-0xF (not 1-16) 186 | void sendNoteOn(int channel, int id, int value); 187 | void sendNoteOff(int channel, int id, int value); 188 | void sendControlChange(int channel, int id, int value); 189 | void sendProgramChange(int channel, int value); 190 | void sendPitchBend(int channel, int lsb, int msb); 191 | 192 | virtual void command(const MidiCommand*); 193 | 194 | // user data will be a MidiSoftSynth pointer 195 | static void playerCallback(void* userData, MidiRtEvent*); 196 | 197 | private: 198 | class Detail; 199 | Detail* _detail; 200 | }; 201 | 202 | 203 | } // Lab 204 | 205 | -------------------------------------------------------------------------------- /include/LabMidi/MusicTheory.h: -------------------------------------------------------------------------------- 1 | // 2 | // LabMidiMusicTheory.h 3 | // MidiApp 4 | // 5 | /* 6 | Copyright (c) 2012, Nick Porcino 7 | All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions are met: 11 | 12 | * Redistributions of source code must retain the above copyright notice, this 13 | list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | * The names of its contributors may not be used to endorse or promote products 18 | derived from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 24 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 27 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #pragma once 33 | 34 | #include 35 | #include 36 | 37 | namespace Lab { 38 | 39 | // The number of scales encoded in this module 40 | // 41 | int scaleCount(); 42 | 43 | // The name of the indexed scale. If out of range, "Unknown" is returned. 44 | // 45 | char const*const scaleName(int scale); 46 | 47 | // The notes of the indexed scale. If out of range, all the notes will 48 | // be written to 0xff. The return value is the number of notes in the scale 49 | // 50 | // Notes will be zero based. The user should add the tonic note to get 51 | // a scale to play. For example, to play a scale in the key of C, add 60 52 | // to the values in the notes array. 53 | // 54 | // If the base note is >= 115, be careful not to play out of range notes. 55 | // MIDI notes range from 0 to 127. 56 | // 57 | int scale(int index, uint8_t notes[9]); 58 | 59 | 60 | // The number of chords encoded in this module 61 | // 62 | int chordsCount(); 63 | 64 | // The name of the indexed chords. If out of range, "Unknown" is returned. 65 | // 66 | char const*const chordName(int scale); 67 | 68 | // The notes of the indexed chord. If out of range, all the notes will 69 | // be written to 0xff. The return value is the number of notes in the chord 70 | // 71 | // inversion is the amount (positive or negative) to invert the chord by 72 | // 73 | // Notes will be zero based. The user should add the tonic note to get 74 | // a scale to play. For example, to play a scale in the key of C, add 60 75 | // to the values in the notes array. 76 | // 77 | // If inversion was non-zero, be careful that the adjusted notes are not out 78 | // of range. MIDI notes range from 0 to 127. 79 | // 80 | int chord(int index, uint8_t notes[9]); 81 | int chord(int index, uint8_t notes[9], int inversion); 82 | 83 | // Returns a reference to an array containing the circle of fifths 84 | // 85 | // Notes are zero based. The usual MIDI range caveats apply. 86 | // 87 | uint8_t (&cirlceOfFifths())[12]; 88 | 89 | // Returns a reference to an array containing bools indicating where 90 | // the black keys are on a piano keyboard. The 0th index indicates C. 91 | // blackKeys()[n % 12] answers the question for any note. 92 | // 93 | bool (&blackKeys())[12]; 94 | 95 | // Given a number of steps, and the number of beats that occurs during those 96 | // steps, fill in the result array with a pattern where those beats are 97 | // evenly distributed according to Bjorklund's algorithm. 98 | // 99 | void rhythm(int steps, int beats, std::vector& result); 100 | 101 | } // Lab 102 | -------------------------------------------------------------------------------- /include/LabMidi/Ports.h: -------------------------------------------------------------------------------- 1 | // 2 | // LabMidiPorts.h 3 | // 4 | // CoreAudio, CoreMidi, and CoreFoundation frameworks are required on OSX/iOS 5 | // 6 | // 7 | 8 | /* 9 | Copyright (c) 2012, Nick Porcino 10 | All rights reserved. 11 | 12 | Redistribution and use in source and binary forms, with or without 13 | modification, are permitted provided that the following conditions are met: 14 | 15 | * Redistributions of source code must retain the above copyright notice, this 16 | list of conditions and the following disclaimer. 17 | * Redistributions in binary form must reproduce the above copyright notice, 18 | this list of conditions and the following disclaimer in the documentation 19 | and/or other materials provided with the distribution. 20 | * The names of its contributors may not be used to endorse or promote products 21 | derived from this software without specific prior written permission. 22 | 23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 27 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 30 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #pragma once 36 | 37 | #include 38 | 39 | namespace Lab { 40 | 41 | class MidiPorts 42 | { 43 | public: 44 | MidiPorts(); 45 | ~MidiPorts(); 46 | 47 | public: 48 | // Manage a list of ports 49 | void refreshPortList(); 50 | 51 | int inPorts() const; 52 | int outPorts() const; 53 | const std::string& inPort(int i) const; 54 | const std::string& outPort(int i) const; 55 | char const*const inPortCStr(int i) const; 56 | char const*const outPortCStr(int i) const; 57 | 58 | private: 59 | class Detail; 60 | Detail* _detail; 61 | }; 62 | 63 | } // Lab 64 | 65 | -------------------------------------------------------------------------------- /include/LabMidi/SoftSynth.h: -------------------------------------------------------------------------------- 1 | // 2 | // LabMidiSoftSynth.h 3 | // 4 | // CoreAudio, CoreMidi, and CoreFoundation frameworks are required on OSX/iOS 5 | // 6 | // 7 | 8 | /* 9 | Copyright (c) 2012, Nick Porcino 10 | All rights reserved. 11 | 12 | Redistribution and use in source and binary forms, with or without 13 | modification, are permitted provided that the following conditions are met: 14 | 15 | * Redistributions of source code must retain the above copyright notice, this 16 | list of conditions and the following disclaimer. 17 | * Redistributions in binary form must reproduce the above copyright notice, 18 | this list of conditions and the following disclaimer in the documentation 19 | and/or other materials provided with the distribution. 20 | * The names of its contributors may not be used to endorse or promote products 21 | derived from this software without specific prior written permission. 22 | 23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 27 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 30 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #pragma once 36 | 37 | #include "LabMidi/MidiInOut.h" 38 | 39 | namespace Lab { 40 | 41 | struct MidiCommand; 42 | 43 | class MidiSoftSynth : public MidiOutBase { 44 | public: 45 | MidiSoftSynth(); 46 | ~MidiSoftSynth(); 47 | 48 | void initialize(int midiChannel, char const*const bankPath); 49 | virtual void command(const MidiCommand*); 50 | 51 | // user data will be a MidiSoftSynth pointer 52 | static void playerCallback(void* userData, MidiRtEvent*); 53 | 54 | private: 55 | class Detail; 56 | Detail* _detail; 57 | }; 58 | 59 | } // Lab 60 | -------------------------------------------------------------------------------- /include/LabMidi/Util.h: -------------------------------------------------------------------------------- 1 | // 2 | // LabMidiUtil.h 3 | // 4 | // CoreAudio, CoreMidi, and CoreFoundation frameworks are required on OSX/iOS 5 | // 6 | // 7 | 8 | /* 9 | Copyright (c) 2012, Nick Porcino 10 | All rights reserved. 11 | 12 | Redistribution and use in source and binary forms, with or without 13 | modification, are permitted provided that the following conditions are met: 14 | 15 | * Redistributions of source code must retain the above copyright notice, this 16 | list of conditions and the following disclaimer. 17 | * Redistributions in binary form must reproduce the above copyright notice, 18 | this list of conditions and the following disclaimer in the documentation 19 | and/or other materials provided with the distribution. 20 | * The names of its contributors may not be used to endorse or promote products 21 | derived from this software without specific prior written permission. 22 | 23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 27 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 30 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #pragma once 36 | 37 | #include 38 | 39 | namespace Lab { 40 | 41 | // Convert a MIDI command byte into a descriptive string 42 | // 43 | const char* commandName(uint8_t command); 44 | 45 | // Convert an instrument number, 0 based, into a group name. The names 46 | // correspond to those in the General MIDI specification. 47 | // 48 | const char* instrumentGroupName(uint8_t instrument); 49 | 50 | // Convert an instrument number, 0 based, into a name. The names 51 | // correspond to those in the General MIDI specification. 52 | // 53 | const char* instrumentName(uint8_t instrument); 54 | 55 | // Convert a channel 10 note number into a percussive instrument name. 56 | // The names correspond to those in the General MIDI specification. 57 | // 58 | const char* percussionName(uint8_t channel10noteNumber); 59 | 60 | // Convert a MIDI note to a name in standard format. 61 | // The result can be round tripped through noteNameToNoteNum. 62 | // 63 | const char* noteName(uint8_t note); 64 | 65 | // Convert a MIDI note to a name in standard format, unless the note 66 | // is on channel 10. On Channel 10, the name of the percussive instrument 67 | // will be returned. 68 | // 69 | // The result cannot be round tripped through noteNameToNoteNum. 70 | // 71 | const char* noteName(uint8_t note, uint8_t channel); 72 | 73 | // Convert a note name to a MIDI note number 74 | // 75 | // name has the form nmo, and does not need to be null terminated. 76 | // where n is note name in upper or lower case (a-g) 77 | // m is modifier - b for flat # for sharp 78 | // o is octave from -1 to 9 79 | // 80 | // len is the number of characters consumed by the note name 81 | // 82 | // If the note number cannot be converted, 0xff is returned. 83 | // Does not convert percussion names from channel 10, so 0xff will be 84 | // returned in that case. 85 | // 86 | uint8_t noteNameToNoteNum(char const*const name); 87 | uint8_t noteNameToNoteNum(char const*const name, int& len); 88 | 89 | // Convert a note number to frequency 90 | // 91 | // The default value for A is 440.0. A different tuning value 92 | // can be provided. 93 | // 94 | float noteToFrequency(uint8_t note); 95 | float noteToFrequency(uint8_t, float A); 96 | 97 | // Convert a frequency to a note number 98 | // 99 | // The default value for A is 440.0. A different tuning value 100 | // can be provided. 101 | // 102 | uint8_t frequencyToNote(float freq); 103 | uint8_t frequencyToNote(float freq, float A); 104 | 105 | // Convert a bpm value to a named tempo such as Largo 106 | // 107 | char const*const bpmToTempoName(int bpm); 108 | 109 | } // Lab 110 | 111 | -------------------------------------------------------------------------------- /src/LabMidiIn.cpp: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // LabMidiIn.cpp 4 | // 5 | /* 6 | Copyright (c) 2012, Nick Porcino 7 | All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions are met: 11 | 12 | * Redistributions of source code must retain the above copyright notice, this 13 | list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | * The names of its contributors may not be used to endorse or promote products 18 | derived from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 24 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 27 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #include "LabMidi/MidiInOut.h" 33 | 34 | #include "RtMidi.h" 35 | #include 36 | 37 | namespace Lab { 38 | 39 | 40 | class MidiIn::Detail { 41 | public: 42 | Detail() 43 | : verbose(false) 44 | , port(-1) 45 | { 46 | try { 47 | midiIn = new RtMidiIn(); 48 | } 49 | catch (RtMidiError& rterr) { 50 | midiIn = 0; 51 | rterr.printMessage(); 52 | } 53 | } 54 | 55 | ~Detail() 56 | { 57 | closePort(); 58 | delete midiIn; 59 | } 60 | 61 | static void midiInCallback(double deltatime, std::vector *message, void* userData) 62 | { 63 | ((MidiIn::Detail*)userData)->manageNewMessage(deltatime, message); 64 | } 65 | 66 | bool openPort(int port) 67 | { 68 | if (port != -1) 69 | closePort(); 70 | 71 | try { 72 | midiIn->openPort(port); 73 | midiIn->setCallback(&midiInCallback, this); 74 | 75 | // Don't ignore sysex, timing, or active sensing messages. 76 | midiIn->ignoreTypes(false, false, false); 77 | port = port; 78 | } 79 | catch(RtMidiError& rterr) { 80 | port = -1; 81 | rterr.printMessage(); 82 | } 83 | 84 | return port != -1; 85 | } 86 | 87 | void closePort() 88 | { 89 | midiIn->closePort(); 90 | port = -1; 91 | } 92 | 93 | bool createVirtualPort(const std::string& port) noexcept 94 | { 95 | try { 96 | midiIn->openVirtualPort(port); 97 | midiIn->setCallback(&midiInCallback, this); 98 | } 99 | catch(const RtMidiError&) { 100 | return false; 101 | } 102 | return true; 103 | } 104 | 105 | // RtMidi compatible callback function 106 | void manageNewMessage(double deltatime, std::vector* message) 107 | { 108 | size_t nBytes = message->size(); 109 | if (verbose) { 110 | std::cout << "num bytes: " << nBytes; 111 | for (unsigned int i = 0; i < nBytes; i++) 112 | std::cout << " Byte " << i << " = " << (int)message->at(i) << ", "; 113 | if (nBytes > 0) 114 | std::cout << "stamp = " << deltatime << '\n'; 115 | } 116 | 117 | if (nBytes > 0) { 118 | MidiCommand mc; 119 | mc.command = message->at(0); 120 | mc.byte1 = 0; 121 | mc.byte2 = 0; 122 | 123 | if (nBytes > 1) 124 | mc.byte1 = int(message->at(1)); 125 | if (nBytes > 2) 126 | mc.byte2 = int(message->at(2)); 127 | 128 | for (auto i = callbacks.begin(); i != callbacks.end(); ++i) 129 | (*i).second((*i).first, &mc); 130 | } 131 | } 132 | 133 | 134 | RtMidiIn* midiIn; 135 | unsigned int port; 136 | bool verbose; 137 | 138 | std::vector > callbacks; 139 | }; 140 | 141 | MidiIn::MidiIn() 142 | : _detail(new Detail()) 143 | { 144 | } 145 | 146 | MidiIn::~MidiIn() 147 | { 148 | delete _detail; 149 | } 150 | 151 | bool MidiIn::openPort(unsigned int port) 152 | { 153 | return _detail->openPort(port); 154 | } 155 | 156 | bool MidiIn::createVirtualPort(const std::string& port) noexcept 157 | { 158 | return _detail->createVirtualPort(port); 159 | } 160 | 161 | unsigned int MidiIn::getPort() const 162 | { 163 | return _detail->port; 164 | } 165 | 166 | void MidiIn::closePort() 167 | { 168 | _detail->closePort(); 169 | } 170 | 171 | void MidiIn::addCallback(MidiCallbackFn f, void* userData) 172 | { 173 | _detail->callbacks.push_back(std::pair(userData, f)); 174 | } 175 | 176 | void MidiIn::removeCallback(void* userData) 177 | { 178 | std::vector >::iterator i = _detail->callbacks.begin(); 179 | while (i != _detail->callbacks.end()) { 180 | if (userData == (*i).first) { 181 | _detail->callbacks.erase(i); 182 | i = _detail->callbacks.begin(); 183 | } 184 | else 185 | ++i; 186 | } 187 | } 188 | 189 | void MidiIn::setVerbose(bool verbose) 190 | { 191 | _detail->verbose = verbose; 192 | } 193 | 194 | } // Lab 195 | -------------------------------------------------------------------------------- /src/LabMidiOut.cpp: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // LabMidiOut.cpp 4 | // 5 | /* 6 | Copyright (c) 2012, Nick Porcino 7 | All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions are met: 11 | 12 | * Redistributions of source code must retain the above copyright notice, this 13 | list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | * The names of its contributors may not be used to endorse or promote products 18 | derived from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 24 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 27 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #include "LabMidi/MidiInOut.h" 33 | 34 | #include "RtMidi.h" 35 | 36 | namespace Lab { 37 | 38 | class MidiOut::Detail 39 | { 40 | public: 41 | Detail() 42 | : port(-1) 43 | { 44 | try { 45 | midiOut = new RtMidiOut(); 46 | } 47 | catch(RtMidiError& error) { 48 | midiOut = 0; 49 | error.printMessage(); 50 | } 51 | } 52 | 53 | ~Detail() 54 | { 55 | closePort(); 56 | } 57 | 58 | void closePort() 59 | { 60 | if (midiOut) { 61 | midiOut->closePort(); 62 | delete midiOut; 63 | } 64 | } 65 | 66 | bool openPort(unsigned int p) 67 | { 68 | if (port != -1) 69 | closePort(); 70 | 71 | try { 72 | midiOut->openPort(p, "MidiOut"); 73 | port = p; 74 | } 75 | catch(RtMidiError& rterr) { 76 | port = -1; 77 | rterr.printMessage(); 78 | } 79 | 80 | return port != -1; 81 | } 82 | 83 | RtMidiOut* midiOut; 84 | unsigned int port; 85 | }; 86 | 87 | MidiOut::MidiOut() 88 | : _detail(new Detail()) 89 | { 90 | } 91 | 92 | MidiOut::~MidiOut() 93 | { 94 | delete _detail; 95 | } 96 | 97 | bool MidiOut::openPort(unsigned int port) 98 | { 99 | return _detail->openPort(port); 100 | } 101 | 102 | bool MidiOut::createVirtualPort(const std::string& _port) noexcept 103 | { 104 | try { 105 | _detail->midiOut->openVirtualPort(_port); 106 | } 107 | catch(const RtMidiError&) { 108 | return false; 109 | } 110 | return true; 111 | } 112 | 113 | void MidiOut::closePort() 114 | { 115 | _detail->closePort(); 116 | } 117 | 118 | unsigned int MidiOut::getPort() const 119 | { 120 | return _detail->port; 121 | } 122 | 123 | void MidiOut::sendNoteOn(int channel, int id, int value) 124 | { 125 | std::vector message; 126 | message.push_back(MIDI_NOTE_ON | channel); 127 | message.push_back(id); 128 | message.push_back(value); 129 | _detail->midiOut->sendMessage(&message); 130 | } 131 | 132 | void MidiOut::sendNoteOff(int channel, int id, int value) 133 | { 134 | std::vector message; 135 | message.push_back(MIDI_NOTE_OFF | channel); 136 | message.push_back(id); 137 | message.push_back(value); 138 | _detail->midiOut->sendMessage(&message); 139 | } 140 | 141 | void MidiOut::sendControlChange(int channel, int id, int value) 142 | { 143 | std::vector message; 144 | message.push_back(MIDI_CONTROL_CHANGE | channel); 145 | message.push_back(id); 146 | message.push_back(value); 147 | _detail->midiOut->sendMessage(&message); 148 | } 149 | 150 | void MidiOut::sendProgramChange(int channel, int value) 151 | { 152 | std::vector message; 153 | message.push_back(MIDI_PROGRAM_CHANGE | channel); 154 | message.push_back(value); 155 | _detail->midiOut->sendMessage(&message); 156 | } 157 | 158 | void MidiOut::sendPitchBend(int channel, int lsb, int msb) 159 | { 160 | std::vector message; 161 | message.push_back(MIDI_PITCH_BEND | channel); 162 | message.push_back(lsb); 163 | message.push_back(msb); 164 | _detail->midiOut->sendMessage(&message); 165 | } 166 | 167 | void MidiOut::command(const MidiCommand* mc) 168 | { 169 | std::vector message; 170 | message.push_back(mc->command); 171 | message.push_back(mc->byte1); 172 | uint8_t c = mc->command >> 4; 173 | if ((c != 0xc) && (c != 0xd)) 174 | message.push_back(mc->byte2); 175 | _detail->midiOut->sendMessage(&message); 176 | } 177 | 178 | void MidiOut::playerCallback(void* userData, MidiRtEvent* ev) 179 | { 180 | MidiOut* mo = static_cast(userData); 181 | if (mo) 182 | mo->command(&ev->command); 183 | } 184 | 185 | 186 | } // Lab 187 | -------------------------------------------------------------------------------- /src/LabMidiPorts.cpp: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // LabMidiUtil.cpp 4 | // 5 | 6 | /* 7 | Copyright (c) 2012, Nick Porcino 8 | All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | 13 | * Redistributions of source code must retain the above copyright notice, this 14 | list of conditions and the following disclaimer. 15 | * Redistributions in binary form must reproduce the above copyright notice, 16 | this list of conditions and the following disclaimer in the documentation 17 | and/or other materials provided with the distribution. 18 | * The names of its contributors may not be used to endorse or promote products 19 | derived from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 25 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 28 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #include "LabMidi/Ports.h" 34 | #include "RtMidi.h" 35 | 36 | namespace Lab { 37 | 38 | class MidiPorts::Detail 39 | { 40 | public: 41 | Detail() 42 | : inProbe(new RtMidiIn()) 43 | , outProbe(new RtMidiOut()) 44 | { 45 | refreshPortList(); 46 | } 47 | 48 | ~Detail() 49 | { 50 | delete inProbe; 51 | delete outProbe; 52 | } 53 | 54 | void refreshPortList() 55 | { 56 | inPorts = inProbe->getPortCount(); 57 | inPortNames.clear(); 58 | for (unsigned int i = 0; i < inPorts; ++i) 59 | inPortNames.push_back(inProbe->getPortName(i)); 60 | 61 | outPorts = outProbe->getPortCount(); 62 | outPortNames.clear(); 63 | for (unsigned int i = 0; i < outPorts; ++i) 64 | outPortNames.push_back(outProbe->getPortName(i)); 65 | } 66 | 67 | RtMidiIn* inProbe; 68 | RtMidiOut* outProbe; 69 | unsigned int inPorts; 70 | unsigned int outPorts; 71 | std::vector inPortNames; 72 | std::vector outPortNames; 73 | }; 74 | 75 | MidiPorts::MidiPorts() 76 | : _detail(new Detail()) 77 | { 78 | } 79 | 80 | MidiPorts::~MidiPorts() 81 | { 82 | delete _detail; 83 | } 84 | 85 | void MidiPorts::refreshPortList() 86 | { 87 | _detail->refreshPortList(); 88 | } 89 | 90 | int MidiPorts::inPorts() const 91 | { 92 | return _detail->inPorts; 93 | } 94 | 95 | int MidiPorts::outPorts() const 96 | { 97 | return _detail->outPorts; 98 | } 99 | 100 | const std::string& MidiPorts::inPort(int i) const 101 | { 102 | static std::string emptyString; 103 | if (i < 0 || i >= _detail->inPortNames.size()) 104 | return emptyString; 105 | return _detail->inPortNames[i]; 106 | } 107 | 108 | const std::string& MidiPorts::outPort(int i) const 109 | { 110 | static std::string emptyString; 111 | if (i < 0 || i >= _detail->outPortNames.size()) 112 | return emptyString; 113 | return _detail->outPortNames[i]; 114 | } 115 | 116 | char const*const MidiPorts::inPortCStr(int i) const 117 | { 118 | static const char emptyString[1] = {'\0'}; 119 | if (i < 0 || i >= _detail->inPortNames.size()) 120 | return emptyString; 121 | return _detail->inPortNames[i].c_str(); 122 | } 123 | 124 | char const*const MidiPorts::outPortCStr(int i) const 125 | { 126 | static const char emptyString[1] = {'\0'}; 127 | if (i < 0 || i >= _detail->outPortNames.size()) 128 | return emptyString; 129 | return _detail->outPortNames[i].c_str(); 130 | } 131 | 132 | 133 | } // Lab 134 | -------------------------------------------------------------------------------- /src/LabMidiSongPlayer.cpp: -------------------------------------------------------------------------------- 1 | ;// 2 | // LabMidiSongPlayer.cpp 3 | // 4 | 5 | /* 6 | Copyright (c) 2012, Nick Porcino 7 | All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions are met: 11 | 12 | * Redistributions of source code must retain the above copyright notice, this 13 | list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | * The names of its contributors may not be used to endorse or promote products 18 | derived from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 24 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 27 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #include "LabMidi/MidiFile.h" 33 | #include "LabMidi/MidiFilePlayer.h" 34 | #include "LabMidi/MidiInOut.h" 35 | #include "LabMidi/Util.h" 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | namespace Lab { 42 | 43 | class MidiSongPlayer::Detail 44 | { 45 | public: 46 | 47 | Detail(MidiSong* s) 48 | : song(s) 49 | , startTime(0) 50 | , eventCursor(0) 51 | { 52 | beatsPerMinute = s ? s->startingTempo : 120.0f; // 120 is the standard default value 53 | ticksPerBeat = s ? s->ticksPerBeat : 100.0f; // 100 is an arbitrary safe value 54 | events.reserve(10000); // arbritrarily large to avoid push_back delays 55 | } 56 | 57 | void update(float wallclockTime) 58 | { 59 | if (eventCursor >= events.size()) 60 | return; 61 | 62 | float newTime = wallclockTime - startTime; 63 | while (eventCursor < events.size() && events[eventCursor].time <= newTime) { 64 | 65 | MidiRtEvent& ev = events[eventCursor]; 66 | 67 | for (auto i = callbacks.begin(); i != callbacks.end(); ++i) 68 | (*i).second((*i).first, &ev); 69 | 70 | ++eventCursor; 71 | } 72 | } 73 | 74 | double ticksToSeconds(int ticks) 75 | { 76 | double beats = double(ticks) / ticksPerBeat; 77 | double seconds = beats / (beatsPerMinute / 60.f); 78 | return seconds; 79 | } 80 | 81 | double secondsToTicks(float seconds) 82 | { 83 | double ticksPerSecond = (beatsPerMinute * ticksPerBeat) / 60.f; 84 | double ticks = ticksPerSecond * seconds; 85 | return (int)ticks; 86 | } 87 | 88 | void recordEvent(double now, MidiEvent* ev) 89 | { 90 | if (ev->eventType == Midi_MetaEventType::TEMPO_CHANGE) { 91 | Event_SetTempo* ste = (Event_SetTempo*) ev; 92 | beatsPerMinute = 60000000.0f / float(ste->microsecondsPerBeat); 93 | } 94 | else if (ev->eventType == Midi_MetaEventType::LABMIDI_CHANNEL_EVENT && ev->data.size() >= 2) { 95 | events.push_back(MidiRtEvent(float(now), ev->data[0], ev->data[1], ev->data[2])); 96 | } 97 | } 98 | 99 | std::vector events; 100 | 101 | MidiSong* song; 102 | 103 | float startTime; 104 | float beatsPerMinute; 105 | double ticksPerBeat; 106 | int eventCursor; 107 | 108 | std::vector > callbacks; 109 | }; 110 | 111 | MidiSongPlayer::MidiSongPlayer(MidiSong* s) 112 | : _detail(new Detail(s)) 113 | { 114 | if (s) { 115 | size_t tc = s->tracks.size(); 116 | 117 | // double, because don't want to introduce sync slip during rendering 118 | std::vector nextTime; 119 | nextTime.resize(tc); 120 | std::vector nextIndex; 121 | nextIndex.resize(tc); 122 | 123 | int i = 0; 124 | for (auto t = s->tracks.begin(); t != s->tracks.end(); ++t, ++i) { 125 | size_t ec = (*t)->events.size(); 126 | nextTime[i] = ec ? (*t)->events[0]->tick : std::numeric_limits::max(); 127 | nextIndex[i] = ec ? 0 : -1; 128 | } 129 | 130 | do { 131 | double nextEventT = std::numeric_limits::max(); 132 | int nt = -1; 133 | for (int i = 0; i < tc; ++i) { 134 | if (nextIndex[i] >= s->tracks[i]->events.size()) 135 | continue; 136 | if (nextTime[i] < nextEventT) { 137 | nt = i; 138 | nextEventT = nextTime[i]; 139 | } 140 | } 141 | if (nt == -1) 142 | break; 143 | 144 | MidiEvent* ev = s->tracks[nt]->events[nextIndex[nt]]; 145 | _detail->recordEvent(nextTime[nt], ev); 146 | ++nextIndex[nt]; 147 | int n = nextIndex[nt]; 148 | if (n < s->tracks[nt]->events.size()) 149 | nextTime[nt] += _detail->ticksToSeconds(s->tracks[nt]->events[n]->tick); 150 | } while (true); 151 | } 152 | } 153 | 154 | MidiSongPlayer::~MidiSongPlayer() 155 | { 156 | delete _detail; 157 | } 158 | 159 | void MidiSongPlayer::play(float wallclockTime) 160 | { 161 | _detail->startTime = wallclockTime; 162 | } 163 | 164 | void MidiSongPlayer::update(float wallclockTime) 165 | { 166 | _detail->update(wallclockTime); 167 | } 168 | 169 | float MidiSongPlayer::length() const 170 | { 171 | return _detail->events.back().time; 172 | } 173 | 174 | void MidiSongPlayer::addCallback(MidiEventCallbackFn f, void* userData) 175 | { 176 | _detail->callbacks.push_back(std::pair(userData, f)); 177 | } 178 | 179 | void MidiSongPlayer::removeCallback(void* userData) 180 | { 181 | std::vector >::iterator i = _detail->callbacks.begin(); 182 | while (i != _detail->callbacks.end()) { 183 | if (userData == (*i).first) { 184 | _detail->callbacks.erase(i); 185 | i = _detail->callbacks.begin(); 186 | } 187 | else 188 | ++i; 189 | } 190 | } 191 | 192 | } // Lab 193 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/RtError.h: -------------------------------------------------------------------------------- 1 | /************************************************************************/ 2 | /*! \class RtError 3 | \brief Exception handling class for RtAudio & RtMidi. 4 | 5 | The RtError class is quite simple but it does allow errors to be 6 | "caught" by RtError::Type. See the RtAudio and RtMidi 7 | documentation to know which methods can throw an RtError. 8 | 9 | */ 10 | /************************************************************************/ 11 | 12 | #ifndef RTERROR_H 13 | #define RTERROR_H 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | class RtError : public std::exception 20 | { 21 | public: 22 | //! Defined RtError types. 23 | enum Type { 24 | WARNING, /*!< A non-critical error. */ 25 | DEBUG_WARNING, /*!< A non-critical error which might be useful for debugging. */ 26 | UNSPECIFIED, /*!< The default, unspecified error type. */ 27 | NO_DEVICES_FOUND, /*!< No devices found on system. */ 28 | INVALID_DEVICE, /*!< An invalid device ID was specified. */ 29 | MEMORY_ERROR, /*!< An error occured during memory allocation. */ 30 | INVALID_PARAMETER, /*!< An invalid parameter was specified to a function. */ 31 | INVALID_USE, /*!< The function was called incorrectly. */ 32 | DRIVER_ERROR, /*!< A system driver error occured. */ 33 | SYSTEM_ERROR, /*!< A system error occured. */ 34 | THREAD_ERROR /*!< A thread error occured. */ 35 | }; 36 | 37 | //! The constructor. 38 | RtError( const std::string& message, Type type = RtError::UNSPECIFIED ) throw() : message_(message), type_(type) {} 39 | 40 | //! The destructor. 41 | virtual ~RtError( void ) throw() {} 42 | 43 | //! Prints thrown error message to stderr. 44 | virtual void printMessage( void ) const throw() { std::cerr << '\n' << message_ << "\n\n"; } 45 | 46 | //! Returns the thrown error message type. 47 | virtual const Type& getType(void) const throw() { return type_; } 48 | 49 | //! Returns the thrown error message string. 50 | virtual const std::string& getMessage(void) const throw() { return message_; } 51 | 52 | //! Returns the thrown error message as a c-style string. 53 | virtual const char* what( void ) const throw() { return message_.c_str(); } 54 | 55 | protected: 56 | std::string message_; 57 | Type type_; 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/config/install.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meshula/LabMidi/45c449bf77013c10cfed9389b69595b30e856e5d/third-party/rtmidi-1.0.15/config/install.sh -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/configure.ac: -------------------------------------------------------------------------------- 1 | # Process this file with autoconf to produce a configure script. 2 | AC_INIT(RtMidi, 1.0, gary@music.mcgill.ca, rtmidi) 3 | AC_CONFIG_AUX_DIR(config) 4 | AC_CONFIG_SRCDIR(RtMidi.cpp) 5 | AC_CONFIG_FILES(tests/Makefile) 6 | 7 | # Fill GXX with something before test. 8 | AC_SUBST( GXX, ["no"] ) 9 | 10 | # Checks for programs. 11 | AC_PROG_CXX(g++ CC c++ cxx) 12 | 13 | # Checks for header files. 14 | AC_HEADER_STDC 15 | #AC_CHECK_HEADERS(sys/ioctl.h unistd.h) 16 | 17 | # Check for debug 18 | AC_MSG_CHECKING(whether to compile debug version) 19 | AC_ARG_ENABLE(debug, 20 | [ --enable-debug = enable various debug output], 21 | [AC_SUBST( cppflag, [-D__RTMIDI_DEBUG__] ) AC_SUBST( cxxflag, [-g] ) AC_SUBST( object_path, [Debug] ) AC_MSG_RESULT(yes)], 22 | [AC_SUBST( cppflag, [] ) AC_SUBST( cxxflag, [-O3] ) AC_SUBST( object_path, [Release] ) AC_MSG_RESULT(no)]) 23 | 24 | # For -I and -D flags 25 | CPPFLAGS="$CPPFLAGS $cppflag" 26 | 27 | # For debugging and optimization ... overwrite default because it has both -g and -O2 28 | #CXXFLAGS="$CXXFLAGS $cxxflag" 29 | CXXFLAGS="$cxxflag" 30 | 31 | # Check compiler and use -Wall if gnu. 32 | if [test $GXX = "yes" ;] then 33 | AC_SUBST( cxxflag, [-Wall] ) 34 | fi 35 | 36 | CXXFLAGS="$CXXFLAGS $cxxflag" 37 | 38 | # Checks for package options and external software 39 | AC_CANONICAL_HOST 40 | AC_MSG_CHECKING(for MIDI API) 41 | case $host in 42 | *-*-linux*) 43 | AC_SUBST( api, [""] ) 44 | AC_ARG_WITH(jack, [ --with-jack = choose JACK server support (linux only)], [ 45 | AC_SUBST( api, [-D__LINUX_JACK__] ) 46 | AC_MSG_RESULT(using JACK) 47 | AC_CHECK_LIB(jack, jack_client_open, , AC_MSG_ERROR(JACK support requires the jack library!))], ) 48 | 49 | if [test "$api" == "";] then 50 | AC_SUBST( api, [-D__LINUX_ALSASEQ__] ) 51 | AC_CHECK_LIB(asound, snd_seq_open, , AC_MSG_ERROR(RtMidi in Linux requires the ALSA asound library!)) 52 | # Checks for pthread library. 53 | AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtMidi requires the pthread library!)) 54 | fi 55 | 56 | ;; 57 | 58 | *-sgi*) 59 | AC_SUBST( api, ["-D__IRIX_MD__ -LANG:std -w"] ) 60 | AC_MSG_RESULT(using IRIX MD) 61 | AC_CHECK_LIB(md, mdInit, , AC_MSG_ERROR(IRIX MIDI support requires the md library!) ) 62 | # Checks for pthread library. 63 | AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtMidi requires the pthread library!)) 64 | ;; 65 | 66 | *-apple*) 67 | # Check for CoreAudio framework 68 | AC_CHECK_HEADER(CoreMIDI/CoreMIDI.h, [AC_SUBST( api, [-D__MACOSX_CORE__] )], [AC_MSG_ERROR(CoreMIDI header files not found!)] ) 69 | AC_SUBST( LIBS, ["-framework CoreMIDI -framework CoreFoundation -framework CoreAudio"] ) 70 | ;; 71 | 72 | *-mingw32*) 73 | # Use WinMM library 74 | AC_SUBST( api, [-D__WINDOWS_MM__] ) 75 | # I can't get the following check to work so just manually add the library 76 | # AC_CHECK_LIB(winmm, midiInGetNumDevs, , AC_MSG_ERROR(Windows MIDI support requires the winmm library!) ) 77 | AC_SUBST( LIBS, [-lwinmm] ) 78 | ;; 79 | 80 | *) 81 | # Default case for unknown realtime systems. 82 | AC_MSG_ERROR(Unknown system type for MIDI support!) 83 | ;; 84 | esac 85 | 86 | CPPFLAGS="$CPPFLAGS $api" 87 | 88 | AC_OUTPUT 89 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/doxygen/footer.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 6 |
©2003-2011 Gary P. Scavone, McGill University. All Rights Reserved.
5 | Maintained by Gary P. Scavone, gary at music.mcgill.ca
7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/doxygen/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | The RtMidi Tutorial 4 | 5 | 6 | 7 |
8 | Tutorial   Class/Enum List   File List   Compound Members  
9 |
10 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/RtError_8h-source.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | The RtMidi Tutorial 4 | 5 | 6 | 7 |
8 | Tutorial   Class/Enum List   File List   Compound Members  
9 |
10 | 11 |

RtError.h

00001 /************************************************************************/
12 | 00010 /************************************************************************/
13 | 00011 
14 | 00012 #ifndef RTERROR_H
15 | 00013 #define RTERROR_H
16 | 00014 
17 | 00015 #include <iostream>
18 | 00016 #include <string>
19 | 00017 
20 | 00018 class RtError
21 | 00019 {
22 | 00020 public:
23 | 00022   enum Type {
24 | 00023     WARNING,           
25 | 00024     DEBUG_WARNING,     
26 | 00025     UNSPECIFIED,       
27 | 00026     NO_DEVICES_FOUND,  
28 | 00027     INVALID_DEVICE,    
29 | 00028     INVALID_STREAM,    
30 | 00029     MEMORY_ERROR,      
31 | 00030     INVALID_PARAMETER, 
32 | 00031     DRIVER_ERROR,      
33 | 00032     SYSTEM_ERROR,      
34 | 00033     THREAD_ERROR       
35 | 00034   };
36 | 00035 
37 | 00036 protected:
38 | 00037   std::string message_;
39 | 00038   Type type_;
40 | 00039 
41 | 00040 public:
42 | 00042   RtError(const std::string& message, Type type = RtError::UNSPECIFIED) : message_(message), type_(type) {}
43 | 00043 
44 | 00045   virtual ~RtError(void) {};
45 | 00046 
46 | 00048   virtual void printMessage(void) { std::cerr << '\n' << message_ << "\n\n"; }
47 | 00049 
48 | 00051   virtual const Type& getType(void) { return type_; }
49 | 00052 
50 | 00054   virtual const std::string& getMessage(void) { return message_; }
51 | 00055 
52 | 00057   virtual const char *getMessageString(void) { return message_.c_str(); }
53 | 00058 };
54 | 00059 
55 | 00060 #endif
56 | 
57 |
58 | 59 | 60 | 62 |
©2003-2009 Gary P. Scavone, McGill University. All Rights Reserved.
61 | Maintained by Gary P. Scavone, gary at music.mcgill.ca
63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/RtError_8h_source.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | The RtMidi Tutorial 4 | 5 | 6 | 7 |
8 | Tutorial   Class/Enum List   File List   Compound Members  
9 |
10 | 11 |

RtError.h

00001 /************************************************************************/
12 | 00010 /************************************************************************/
13 | 00011 
14 | 00012 #ifndef RTERROR_H
15 | 00013 #define RTERROR_H
16 | 00014 
17 | 00015 #include <exception>
18 | 00016 #include <iostream>
19 | 00017 #include <string>
20 | 00018 
21 | 00019 class RtError : public std::exception
22 | 00020 {
23 | 00021  public:
24 | 00023   enum Type {
25 | 00024     WARNING,           
26 | 00025     DEBUG_WARNING,     
27 | 00026     UNSPECIFIED,       
28 | 00027     NO_DEVICES_FOUND,  
29 | 00028     INVALID_DEVICE,    
30 | 00029     MEMORY_ERROR,      
31 | 00030     INVALID_PARAMETER, 
32 | 00031     INVALID_USE,       
33 | 00032     DRIVER_ERROR,      
34 | 00033     SYSTEM_ERROR,      
35 | 00034     THREAD_ERROR       
36 | 00035   };
37 | 00036 
38 | 00038   RtError( const std::string& message, Type type = RtError::UNSPECIFIED ) throw() : message_(message), type_(type) {}
39 | 00039  
40 | 00041   virtual ~RtError( void ) throw() {}
41 | 00042 
42 | 00044   virtual void printMessage( void ) const throw() { std::cerr << '\n' << message_ << "\n\n"; }
43 | 00045 
44 | 00047   virtual const Type& getType(void) const throw() { return type_; }
45 | 00048 
46 | 00050   virtual const std::string& getMessage(void) const throw() { return message_; }
47 | 00051 
48 | 00053   virtual const char* what( void ) const throw() { return message_.c_str(); }
49 | 00054 
50 | 00055  protected:
51 | 00056   std::string message_;
52 | 00057   Type type_;
53 | 00058 };
54 | 00059 
55 | 00060 #endif
56 | 
57 |
58 | 59 | 60 | 62 |
©2003-2011 Gary P. Scavone, McGill University. All Rights Reserved.
61 | Maintained by Gary P. Scavone, gary at music.mcgill.ca
63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/annotated.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | The RtMidi Tutorial 4 | 5 | 6 | 7 |
8 | Tutorial   Class/Enum List   File List   Compound Members  
9 |
10 | 11 |
12 |

Class List

Here are the classes, structs, unions and interfaces with brief descriptions: 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
RtMidiIn::MidiMessage
RtMidiIn::MidiQueue
RtErrorException handling class for RtAudio & RtMidi
RtMidiAn abstract base class for realtime MIDI input/output
RtMidiInA realtime MIDI input class
RtMidiIn::RtMidiInData
RtMidiOutA realtime MIDI output class
21 |
22 |
23 | 24 | 25 | 27 |
©2003-2011 Gary P. Scavone, McGill University. All Rights Reserved.
26 | Maintained by Gary P. Scavone, gary at music.mcgill.ca
28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/classRtError-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | The RtMidi Tutorial 4 | 5 | 6 | 7 |
8 | Tutorial   Class/Enum List   File List   Compound Members  
9 |
10 | 11 |
12 |

RtError Member List

This is the complete list of members for RtError, including all inherited members. 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
DEBUG_WARNING enum valueRtError
DRIVER_ERROR enum valueRtError
getMessage(void) const RtError [inline, virtual]
getType(void) const RtError [inline, virtual]
INVALID_DEVICE enum valueRtError
INVALID_PARAMETER enum valueRtError
INVALID_USE enum valueRtError
MEMORY_ERROR enum valueRtError
NO_DEVICES_FOUND enum valueRtError
printMessage(void) const RtError [inline, virtual]
RtError(const std::string &message, Type type=RtError::UNSPECIFIED)RtError [inline]
SYSTEM_ERROR enum valueRtError
THREAD_ERROR enum valueRtError
Type enum nameRtError
UNSPECIFIED enum valueRtError
WARNING enum valueRtError
what(void) const RtError [inline, virtual]
~RtError(void)RtError [inline, virtual]
32 |
33 | 34 | 35 | 37 |
©2003-2011 Gary P. Scavone, McGill University. All Rights Reserved.
36 | Maintained by Gary P. Scavone, gary at music.mcgill.ca
38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/classRtMidi-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | The RtMidi Tutorial 4 | 5 | 6 | 7 |
8 | Tutorial   Class/Enum List   File List   Compound Members  
9 |
10 | 11 |
12 |

RtMidi Member List

This is the complete list of members for RtMidi, including all inherited members. 13 | 14 | 15 | 16 | 17 | 18 |
closePort(void)=0RtMidi [pure virtual]
getPortCount()=0RtMidi [pure virtual]
getPortName(unsigned int portNumber=0)=0RtMidi [pure virtual]
openPort(unsigned int portNumber=0, const std::string portName=std::string("RtMidi"))=0RtMidi [pure virtual]
openVirtualPort(const std::string portName=std::string("RtMidi"))=0RtMidi [pure virtual]
19 |
20 | 21 | 22 | 24 |
©2003-2011 Gary P. Scavone, McGill University. All Rights Reserved.
23 | Maintained by Gary P. Scavone, gary at music.mcgill.ca
25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/classRtMidi.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meshula/LabMidi/45c449bf77013c10cfed9389b69595b30e856e5d/third-party/rtmidi-1.0.15/doc/html/classRtMidi.gif -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/classRtMidi.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | The RtMidi Tutorial 4 | 5 | 6 | 7 |
8 | Tutorial   Class/Enum List   File List   Compound Members  
9 |
10 | 11 |
12 |

RtMidi Class Reference

13 |

An abstract base class for realtime MIDI input/output. 14 | More...

15 | 16 |

#include <RtMidi.h>

17 |
18 | Inheritance diagram for RtMidi:
19 |
20 |
21 | 22 | 23 | RtMidiIn 24 | RtMidiOut 25 | 26 |
27 |
28 | 29 |

List of all members.

30 | 31 | 32 | 34 | 35 | 37 | 38 | 40 | 41 | 43 | 44 | 46 | 47 |

Public Member Functions

33 | virtual void openPort (unsigned int portNumber=0, const std::string portName=std::string("RtMidi"))=0
 Pure virtual openPort() function.
36 | virtual void openVirtualPort (const std::string portName=std::string("RtMidi"))=0
 Pure virtual openVirtualPort() function.
39 | virtual unsigned int getPortCount ()=0
 Pure virtual getPortCount() function.
42 | virtual std::string getPortName (unsigned int portNumber=0)=0
 Pure virtual getPortName() function.
45 | virtual void closePort (void)=0
 Pure virtual closePort() function.
48 |

Detailed Description

49 |

An abstract base class for realtime MIDI input/output.

50 |

This class implements some common functionality for the realtime MIDI input/output subclasses RtMidiIn and RtMidiOut.

51 |

RtMidi WWW site: http://music.mcgill.ca/~gary/rtmidi/

52 |

RtMidi: realtime MIDI i/o C++ classes Copyright (c) 2003-2011 Gary P. Scavone

53 |

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:

54 |

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

55 |

Any person wishing to distribute modifications to the Software is requested to send the modifications to the original developer so that they can be incorporated into the canonical version.

56 |

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.

57 |
The documentation for this class was generated from the following file: 60 |
61 |
62 | 63 | 64 | 66 |
©2003-2011 Gary P. Scavone, McGill University. All Rights Reserved.
65 | Maintained by Gary P. Scavone, gary at music.mcgill.ca
67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/classRtMidi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meshula/LabMidi/45c449bf77013c10cfed9389b69595b30e856e5d/third-party/rtmidi-1.0.15/doc/html/classRtMidi.png -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/classRtMidiIn-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | The RtMidi Tutorial 4 | 5 | 6 | 7 |
8 | Tutorial   Class/Enum List   File List   Compound Members  
9 |
10 | 11 |
12 |

RtMidiIn Member List

This is the complete list of members for RtMidiIn, including all inherited members. 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 |
cancelCallback()RtMidiIn
closePort(void)RtMidiIn [virtual]
getMessage(std::vector< unsigned char > *message)RtMidiIn
getPortCount()RtMidiIn [virtual]
getPortName(unsigned int portNumber=0)RtMidiIn [virtual]
ignoreTypes(bool midiSysex=true, bool midiTime=true, bool midiSense=true)RtMidiIn
openPort(unsigned int portNumber=0, const std::string Portname=std::string("RtMidi Input"))RtMidiIn [virtual]
openVirtualPort(const std::string portName=std::string("RtMidi Input"))RtMidiIn [virtual]
RtMidiCallback typedefRtMidiIn
RtMidiIn(const std::string clientName=std::string("RtMidi Input Client"), unsigned int queueSizeLimit=100)RtMidiIn
setCallback(RtMidiCallback callback, void *userData=0)RtMidiIn
~RtMidiIn()RtMidiIn
26 |
27 | 28 | 29 | 31 |
©2003-2011 Gary P. Scavone, McGill University. All Rights Reserved.
30 | Maintained by Gary P. Scavone, gary at music.mcgill.ca
32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/classRtMidiIn.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meshula/LabMidi/45c449bf77013c10cfed9389b69595b30e856e5d/third-party/rtmidi-1.0.15/doc/html/classRtMidiIn.gif -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/classRtMidiIn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meshula/LabMidi/45c449bf77013c10cfed9389b69595b30e856e5d/third-party/rtmidi-1.0.15/doc/html/classRtMidiIn.png -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/classRtMidiOut-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | The RtMidi Tutorial 4 | 5 | 6 | 7 |
8 | Tutorial   Class/Enum List   File List   Compound Members  
9 |
10 | 11 |
12 |

RtMidiOut Member List

This is the complete list of members for RtMidiOut, including all inherited members. 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
closePort()RtMidiOut [virtual]
getPortCount()RtMidiOut [virtual]
getPortName(unsigned int portNumber=0)RtMidiOut [virtual]
openPort(unsigned int portNumber=0, const std::string portName=std::string("RtMidi Output"))RtMidiOut [virtual]
openVirtualPort(const std::string portName=std::string("RtMidi Output"))RtMidiOut [virtual]
RtMidiOut(const std::string clientName=std::string("RtMidi Output Client"))RtMidiOut
sendMessage(std::vector< unsigned char > *message)RtMidiOut
~RtMidiOut()RtMidiOut
22 |
23 | 24 | 25 | 27 |
©2003-2011 Gary P. Scavone, McGill University. All Rights Reserved.
26 | Maintained by Gary P. Scavone, gary at music.mcgill.ca
28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/classRtMidiOut.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meshula/LabMidi/45c449bf77013c10cfed9389b69595b30e856e5d/third-party/rtmidi-1.0.15/doc/html/classRtMidiOut.gif -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/classRtMidiOut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meshula/LabMidi/45c449bf77013c10cfed9389b69595b30e856e5d/third-party/rtmidi-1.0.15/doc/html/classRtMidiOut.png -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/classes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | The RtMidi Tutorial 4 | 5 | 6 | 7 |
8 | Tutorial   Class/Enum List   File List   Compound Members  
9 |
10 | 11 |
12 |

Class Index

M | R
13 | 14 |
  M  
15 |
RtMidiIn::MidiQueue   RtError   RtMidiIn   RtMidiOut   
RtMidiIn::MidiMessage   
  R  
16 |
RtMidi   RtMidiIn::RtMidiInData   
M | R
17 |
18 |
19 | 20 | 21 | 23 |
©2003-2011 Gary P. Scavone, McGill University. All Rights Reserved.
22 | Maintained by Gary P. Scavone, gary at music.mcgill.ca
24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/doxygen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meshula/LabMidi/45c449bf77013c10cfed9389b69595b30e856e5d/third-party/rtmidi-1.0.15/doc/html/doxygen.png -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/files.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | The RtMidi Tutorial 4 | 5 | 6 | 7 |
8 | Tutorial   Class/Enum List   File List   Compound Members  
9 |
10 | 11 |
12 |

File List

Here is a list of all documented files with brief descriptions: 13 | 14 | 15 |
RtError.h [code]
RtMidi.h [code]
16 |
17 |
18 | 19 | 20 | 22 |
©2003-2011 Gary P. Scavone, McGill University. All Rights Reserved.
21 | Maintained by Gary P. Scavone, gary at music.mcgill.ca
23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/functions.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | The RtMidi Tutorial 4 | 5 | 6 | 7 |
8 | Tutorial   Class/Enum List   File List   Compound Members  
9 |
10 | 11 |
12 | 19 |
20 |
21 |
    22 |
  • c
  • 23 |
  • d
  • 24 |
  • g
  • 25 |
  • i
  • 26 |
  • m
  • 27 |
  • n
  • 28 |
  • o
  • 29 |
  • p
  • 30 |
  • r
  • 31 |
  • s
  • 32 |
  • t
  • 33 |
  • u
  • 34 |
  • w
  • 35 |
  • ~
  • 36 |
37 |
38 |
39 | Here is a list of all documented class members with links to the class documentation for each member: 40 | 41 |

- c -

51 | 52 | 53 |

- d -

    54 |
  • DEBUG_WARNING 55 | : RtError 56 |
  • 57 |
  • DRIVER_ERROR 58 | : RtError 59 |
  • 60 |
61 | 62 | 63 |

- g -

82 | 83 | 84 |

- i -

    85 |
  • ignoreTypes() 86 | : RtMidiIn 87 |
  • 88 |
  • INVALID_DEVICE 89 | : RtError 90 |
  • 91 |
  • INVALID_PARAMETER 92 | : RtError 93 |
  • 94 |
  • INVALID_USE 95 | : RtError 96 |
  • 97 |
98 | 99 | 100 |

- m -

    101 |
  • MEMORY_ERROR 102 | : RtError 103 |
  • 104 |
105 | 106 | 107 |

- n -

    108 |
  • NO_DEVICES_FOUND 109 | : RtError 110 |
  • 111 |
112 | 113 | 114 |

- o -

126 | 127 | 128 |

- p -

    129 |
  • printMessage() 130 | : RtError 131 |
  • 132 |
133 | 134 | 135 |

- r -

    136 |
  • RtError() 137 | : RtError 138 |
  • 139 |
  • RtMidiCallback 140 | : RtMidiIn 141 |
  • 142 |
  • RtMidiIn() 143 | : RtMidiIn 144 |
  • 145 |
  • RtMidiOut() 146 | : RtMidiOut 147 |
  • 148 |
149 | 150 | 151 |

- s -

    152 |
  • sendMessage() 153 | : RtMidiOut 154 |
  • 155 |
  • setCallback() 156 | : RtMidiIn 157 |
  • 158 |
  • SYSTEM_ERROR 159 | : RtError 160 |
  • 161 |
162 | 163 | 164 |

- t -

    165 |
  • THREAD_ERROR 166 | : RtError 167 |
  • 168 |
  • Type 169 | : RtError 170 |
  • 171 |
172 | 173 | 174 |

- u -

    175 |
  • UNSPECIFIED 176 | : RtError 177 |
  • 178 |
179 | 180 | 181 |

- w -

    182 |
  • WARNING 183 | : RtError 184 |
  • 185 |
  • what() 186 | : RtError 187 |
  • 188 |
189 | 190 | 191 |

- ~ -

    192 |
  • ~RtError() 193 | : RtError 194 |
  • 195 |
  • ~RtMidiIn() 196 | : RtMidiIn 197 |
  • 198 |
  • ~RtMidiOut() 199 | : RtMidiOut 200 |
  • 201 |
202 |
203 |
204 | 205 | 206 | 208 |
©2003-2011 Gary P. Scavone, McGill University. All Rights Reserved.
207 | Maintained by Gary P. Scavone, gary at music.mcgill.ca
209 | 210 | 211 | 212 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/functions_enum.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | The RtMidi Tutorial 4 | 5 | 6 | 7 |
8 | Tutorial   Class/Enum List   File List   Compound Members  
9 |
10 | 11 |
12 | 19 |
20 |
21 |  
    22 |
  • Type 23 | : RtError 24 |
  • 25 |
26 |
27 |
28 | 29 | 30 | 32 |
©2003-2011 Gary P. Scavone, McGill University. All Rights Reserved.
31 | Maintained by Gary P. Scavone, gary at music.mcgill.ca
33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/functions_eval.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | The RtMidi Tutorial 4 | 5 | 6 | 7 |
8 | Tutorial   Class/Enum List   File List   Compound Members  
9 |
10 | 11 |
12 | 19 |
20 |
21 |  
    22 |
  • DEBUG_WARNING 23 | : RtError 24 |
  • 25 |
  • DRIVER_ERROR 26 | : RtError 27 |
  • 28 |
  • INVALID_DEVICE 29 | : RtError 30 |
  • 31 |
  • INVALID_PARAMETER 32 | : RtError 33 |
  • 34 |
  • INVALID_USE 35 | : RtError 36 |
  • 37 |
  • MEMORY_ERROR 38 | : RtError 39 |
  • 40 |
  • NO_DEVICES_FOUND 41 | : RtError 42 |
  • 43 |
  • SYSTEM_ERROR 44 | : RtError 45 |
  • 46 |
  • THREAD_ERROR 47 | : RtError 48 |
  • 49 |
  • UNSPECIFIED 50 | : RtError 51 |
  • 52 |
  • WARNING 53 | : RtError 54 |
  • 55 |
56 |
57 |
58 | 59 | 60 | 62 |
©2003-2011 Gary P. Scavone, McGill University. All Rights Reserved.
61 | Maintained by Gary P. Scavone, gary at music.mcgill.ca
63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/functions_func.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | The RtMidi Tutorial 4 | 5 | 6 | 7 |
8 | Tutorial   Class/Enum List   File List   Compound Members  
9 |
10 | 11 |
12 | 19 |
20 |
21 |   91 |
92 |
93 | 94 | 95 | 97 |
©2003-2011 Gary P. Scavone, McGill University. All Rights Reserved.
96 | Maintained by Gary P. Scavone, gary at music.mcgill.ca
98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/functions_type.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | The RtMidi Tutorial 4 | 5 | 6 | 7 |
8 | Tutorial   Class/Enum List   File List   Compound Members  
9 |
10 | 11 |
12 | 19 |
20 |
21 |  
    22 |
  • RtMidiCallback 23 | : RtMidiIn 24 |
  • 25 |
26 |
27 |
28 | 29 | 30 | 32 |
©2003-2011 Gary P. Scavone, McGill University. All Rights Reserved.
31 | Maintained by Gary P. Scavone, gary at music.mcgill.ca
33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/hierarchy.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | The RtMidi Tutorial 4 | 5 | 6 | 7 |
8 | Tutorial   Class/Enum List   File List   Compound Members  
9 |
10 | 11 |
12 |

Class Hierarchy

This inheritance list is sorted roughly, but not completely, alphabetically: 23 |
24 |
25 | 26 | 27 | 29 |
©2003-2011 Gary P. Scavone, McGill University. All Rights Reserved.
28 | Maintained by Gary P. Scavone, gary at music.mcgill.ca
30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/structRtMidiIn_1_1MidiMessage-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | The RtMidi Tutorial 4 | 5 | 6 | 7 |
8 | Tutorial   Class/Enum List   File List   Compound Members  
9 |
10 | 11 |
12 |

RtMidiIn::MidiMessage Member List

This is the complete list of members for RtMidiIn::MidiMessage, including all inherited members. 13 |
14 |
15 | 16 | 17 | 19 |
©2003-2011 Gary P. Scavone, McGill University. All Rights Reserved.
18 | Maintained by Gary P. Scavone, gary at music.mcgill.ca
20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/structRtMidiIn_1_1MidiMessage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | The RtMidi Tutorial 4 | 5 | 6 | 7 |
8 | Tutorial   Class/Enum List   File List   Compound Members  
9 |
10 | 11 | 13 |
14 |

RtMidiIn::MidiMessage Struct Reference

15 |

List of all members.

16 | 17 |
18 |
The documentation for this struct was generated from the following file: 21 |
22 |
23 | 24 | 25 | 27 |
©2003-2011 Gary P. Scavone, McGill University. All Rights Reserved.
26 | Maintained by Gary P. Scavone, gary at music.mcgill.ca
28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/structRtMidiIn_1_1MidiQueue-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | The RtMidi Tutorial 4 | 5 | 6 | 7 |
8 | Tutorial   Class/Enum List   File List   Compound Members  
9 |
10 | 11 |
12 |

RtMidiIn::MidiQueue Member List

This is the complete list of members for RtMidiIn::MidiQueue, including all inherited members. 13 |
14 |
15 | 16 | 17 | 19 |
©2003-2011 Gary P. Scavone, McGill University. All Rights Reserved.
18 | Maintained by Gary P. Scavone, gary at music.mcgill.ca
20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/structRtMidiIn_1_1MidiQueue.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | The RtMidi Tutorial 4 | 5 | 6 | 7 |
8 | Tutorial   Class/Enum List   File List   Compound Members  
9 |
10 | 11 | 13 |
14 |

RtMidiIn::MidiQueue Struct Reference

15 |

List of all members.

16 | 17 |
18 |
The documentation for this struct was generated from the following file: 21 |
22 |
23 | 24 | 25 | 27 |
©2003-2011 Gary P. Scavone, McGill University. All Rights Reserved.
26 | Maintained by Gary P. Scavone, gary at music.mcgill.ca
28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/structRtMidiIn_1_1RtMidiInData-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | The RtMidi Tutorial 4 | 5 | 6 | 7 |
8 | Tutorial   Class/Enum List   File List   Compound Members  
9 |
10 | 11 |
12 |

RtMidiIn::RtMidiInData Member List

This is the complete list of members for RtMidiIn::RtMidiInData, including all inherited members. 13 |
14 |
15 | 16 | 17 | 19 |
©2003-2011 Gary P. Scavone, McGill University. All Rights Reserved.
18 | Maintained by Gary P. Scavone, gary at music.mcgill.ca
20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/structRtMidiIn_1_1RtMidiInData.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | The RtMidi Tutorial 4 | 5 | 6 | 7 |
8 | Tutorial   Class/Enum List   File List   Compound Members  
9 |
10 | 11 | 13 |
14 |

RtMidiIn::RtMidiInData Struct Reference

15 |

List of all members.

16 | 17 |
18 |
The documentation for this struct was generated from the following file: 21 |
22 |
23 | 24 | 25 | 27 |
©2003-2011 Gary P. Scavone, McGill University. All Rights Reserved.
26 | Maintained by Gary P. Scavone, gary at music.mcgill.ca
28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/tab_b.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meshula/LabMidi/45c449bf77013c10cfed9389b69595b30e856e5d/third-party/rtmidi-1.0.15/doc/html/tab_b.gif -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/tab_l.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meshula/LabMidi/45c449bf77013c10cfed9389b69595b30e856e5d/third-party/rtmidi-1.0.15/doc/html/tab_l.gif -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/tab_r.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meshula/LabMidi/45c449bf77013c10cfed9389b69595b30e856e5d/third-party/rtmidi-1.0.15/doc/html/tab_r.gif -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/html/tabs.css: -------------------------------------------------------------------------------- 1 | /* tabs styles, based on http://www.alistapart.com/articles/slidingdoors */ 2 | 3 | DIV.tabs 4 | { 5 | float : left; 6 | width : 100%; 7 | background : url("tab_b.gif") repeat-x bottom; 8 | margin-bottom : 4px; 9 | } 10 | 11 | DIV.tabs UL 12 | { 13 | margin : 0px; 14 | padding-left : 10px; 15 | list-style : none; 16 | } 17 | 18 | DIV.tabs LI, DIV.tabs FORM 19 | { 20 | display : inline; 21 | margin : 0px; 22 | padding : 0px; 23 | } 24 | 25 | DIV.tabs FORM 26 | { 27 | float : right; 28 | } 29 | 30 | DIV.tabs A 31 | { 32 | float : left; 33 | background : url("tab_r.gif") no-repeat right top; 34 | border-bottom : 1px solid #84B0C7; 35 | font-size : 80%; 36 | font-weight : bold; 37 | text-decoration : none; 38 | } 39 | 40 | DIV.tabs A:hover 41 | { 42 | background-position: 100% -150px; 43 | } 44 | 45 | DIV.tabs A:link, DIV.tabs A:visited, 46 | DIV.tabs A:active, DIV.tabs A:hover 47 | { 48 | color: #1A419D; 49 | } 50 | 51 | DIV.tabs SPAN 52 | { 53 | float : left; 54 | display : block; 55 | background : url("tab_l.gif") no-repeat left top; 56 | padding : 5px 9px; 57 | white-space : nowrap; 58 | } 59 | 60 | DIV.tabs #MSearchBox 61 | { 62 | float : right; 63 | display : inline; 64 | font-size : 1em; 65 | } 66 | 67 | DIV.tabs TD 68 | { 69 | font-size : 80%; 70 | font-weight : bold; 71 | text-decoration : none; 72 | } 73 | 74 | 75 | 76 | /* Commented Backslash Hack hides rule from IE5-Mac \*/ 77 | DIV.tabs SPAN {float : none;} 78 | /* End IE5-Mac hack */ 79 | 80 | DIV.tabs A:hover SPAN 81 | { 82 | background-position: 0% -150px; 83 | } 84 | 85 | DIV.tabs LI.current A 86 | { 87 | background-position: 100% -150px; 88 | border-width : 0px; 89 | } 90 | 91 | DIV.tabs LI.current SPAN 92 | { 93 | background-position: 0% -150px; 94 | padding-bottom : 6px; 95 | } 96 | 97 | DIV.navpath 98 | { 99 | background : none; 100 | border : none; 101 | border-bottom : 1px solid #84B0C7; 102 | text-align : center; 103 | margin : 2px; 104 | padding : 2px; 105 | } 106 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/images/ccrma.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meshula/LabMidi/45c449bf77013c10cfed9389b69595b30e856e5d/third-party/rtmidi-1.0.15/doc/images/ccrma.gif -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/images/mcgill.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meshula/LabMidi/45c449bf77013c10cfed9389b69595b30e856e5d/third-party/rtmidi-1.0.15/doc/images/mcgill.gif -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/doc/release.txt: -------------------------------------------------------------------------------- 1 | RtMidi - a set of C++ classes that provides a common API for realtime MIDI input/output across Linux (ALSA & Jack), Macintosh OS X (CoreMidi), Windows (Multimedia), and SGI operating systems. 2 | 3 | By Gary P. Scavone, 2003-2011. 4 | 5 | v1.0.15: (11 August 2011) 6 | - updates for wide character support in Windows 7 | - stopped using std::queue and implemented internal MIDI ring buffer (for thread safety ... thanks to Michael Behrman) 8 | - removal of the setQueueSizeLimit() function ... queue size limit now an optional arguement to constructor 9 | 10 | v1.0.14: (17 April 2011) 11 | - bug fix to Jack MIDI support (thanks to Alexander Svetalkin and Pedro Lopez-Cabanillas) 12 | 13 | v1.0.13: (7 April 2011) 14 | - updated RtError.h to the same version as in RtAudio 15 | - new Jack MIDI support in Linux (thanks to Alexander Svetalkin) 16 | 17 | v1.0.12: (17 February 2011) 18 | - Windows 64-bit pointer fixes (thanks to Ward Kockelkorn) 19 | - removed possible exceptions from getPortName() functions 20 | - changed sysex sends in OS-X to use MIDISendSysex() function (thanks to Casey Tucker) 21 | - bug fixes to time code parsing in OS-X and ALSA (thanks to Greg) 22 | - added MSW project file to build as library (into lib/ directory ... thanks to Jason Champion) 23 | 24 | v1.0.11: (29 January 2010) 25 | - added CoreServices/CoreServices.h include for OS-X 10.6 and gcc4.2 compile (thanks to Jon McCormack) 26 | - various increment optimizations (thanks to Paul Dean) 27 | - fixed incorrectly located snd_seq_close() function in ALSA API (thanks to Pedro Lopez-Cabanillas) 28 | - updates to Windows sysex code to better deal with possible delivery problems (thanks to Bastiaan Verreijt) 29 | 30 | v1.0.10: (3 June 2009) 31 | - fix adding timestamp to OS-X sendMessage() function (thanks to John Dey) 32 | 33 | v1.0.9: (30 April 2009) 34 | - 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. 35 | - updated functionality in OSX_CORE for getting driver name (thanks to Casey Tucker) 36 | 37 | v1.0.8: (29 January 2009) 38 | - bug fixes for concatenating segmented sysex messages in ALSA (thanks to Christoph Eckert) 39 | - update to ALSA sequencer port enumeration (thanks to Pedro Lopez-Cabonillas) 40 | - bug fixes for concatenating segmented sysex messages in OS-X (thanks to Emmanuel Litzroth) 41 | - added functionality for naming clients (thanks to Pedro Lopez-Cabonillas and Axel Schmidt) 42 | - bug fix in Windows when receiving sysex messages if the ignore flag was set (thanks to Pedro Lopez-Cabonillas) 43 | 44 | v1.0.7: (7 December 2007) 45 | - configure and Makefile changes for MinGW 46 | - renamed midiinfo.cpp to midiprobe.cpp and updated VC++ project/workspace 47 | 48 | v1.0.6: (9 March 2006) 49 | - bug fix for timestamp problem in ALSA (thanks to Pedro Lopez-Cabanillas) 50 | 51 | v1.0.5: (18 November 2005) 52 | - added optional port name to openVirtualPort() functions 53 | - fixed UNICODE problem in Windows getting device names (thanks Eduardo Coutinho!). 54 | - fixed bug in Windows with respect to getting Sysex data (thanks Jean-Baptiste Berruchon!) 55 | 56 | v1.0.4: (14 October 2005) 57 | - added check for status byte == 0xF8 if ignoring timing messages 58 | - changed pthread attribute to SCHED_OTHER (from SCHED_RR) to avoid thread problem when realtime cababilities are not enabled. 59 | - now using ALSA sequencer time stamp information (thanks to Pedro Lopez-Cabanillas) 60 | - fixed memory leak in ALSA implementation 61 | - now concatenate segmented sysex messages in ALSA 62 | 63 | v1.0.3: (22 November 2004) 64 | - added common pure virtual functions to RtMidi abstract base class 65 | 66 | v1.0.2: (21 September 2004) 67 | - added warning messages to openVirtualPort() functions in Windows and Irix (where it can't be implemented) 68 | 69 | v1.0.1: (20 September 2004) 70 | - changed ALSA preprocessor definition to __LINUX_ALSASEQ__ 71 | 72 | v1.0.0: (17 September 2004) 73 | - first release of new independent class with both input and output functionality 74 | 75 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/readme: -------------------------------------------------------------------------------- 1 | RtMidi - a set of C++ classes that provide a common API for realtime MIDI input/output across Linux (ALSA & Jack), Macintosh OS X (CoreMidi), Windows (Multimedia) and SGI operating systems. 2 | 3 | By Gary P. Scavone, 2003-2011. 4 | 5 | This distribution of RtMidi contains the following: 6 | 7 | doc: RtMidi documentation (see doc/html/index.html) 8 | tests: example RtMidi programs 9 | 10 | 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. 11 | 12 | OVERVIEW: 13 | 14 | RtMidi is a set of C++ classes (RtMidiIn and RtMidiOut) that provide a common API (Application Programming Interface) for realtime MIDI input/output across Linux (ALSA), Macintosh OS X, SGI, 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: 15 | 16 | - object oriented C++ design 17 | - simple, common API across all supported platforms 18 | - only two header files and one source file for easy inclusion in programming projects 19 | - MIDI device enumeration 20 | 21 | 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. 22 | 23 | FURTHER READING: 24 | 25 | For complete documentation on RtMidi, see the doc directory of the distribution or surf to http://music.mcgill.ca/~gary/rtmidi/. 26 | 27 | 28 | LEGAL AND ETHICAL: 29 | 30 | The RtMidi license is similar to the the MIT License, with the added "feature" that modifications be sent to the developer. 31 | 32 | RtMidi: realtime MIDI i/o C++ classes 33 | Copyright (c) 2003-2011 Gary P. Scavone 34 | 35 | Permission is hereby granted, free of charge, to any person 36 | obtaining a copy of this software and associated documentation files 37 | (the "Software"), to deal in the Software without restriction, 38 | including without limitation the rights to use, copy, modify, merge, 39 | publish, distribute, sublicense, and/or sell copies of the Software, 40 | and to permit persons to whom the Software is furnished to do so, 41 | subject to the following conditions: 42 | 43 | The above copyright notice and this permission notice shall be 44 | included in all copies or substantial portions of the Software. 45 | 46 | Any person wishing to distribute modifications to the Software is 47 | requested to send the modifications to the original developer so that 48 | they can be incorporated into the canonical version. 49 | 50 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 51 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 52 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 53 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 54 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 55 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 56 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 57 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/tests/Makefile.in: -------------------------------------------------------------------------------- 1 | ### Do not edit -- Generated by 'configure --with-whatever' from Makefile.in 2 | ### RtMidi tests Makefile - for various flavors of unix 3 | 4 | PROGRAMS = midiprobe midiout qmidiin cmidiin sysextest 5 | RM = /bin/rm 6 | SRC_PATH = .. 7 | INCLUDE = .. 8 | OBJECT_PATH = @object_path@ 9 | vpath %.o $(OBJECT_PATH) 10 | 11 | OBJECTS = RtMidi.o 12 | 13 | CC = @CXX@ 14 | DEFS = @CPPFLAGS@ 15 | CFLAGS = @CXXFLAGS@ 16 | CFLAGS += -I$(INCLUDE) 17 | LIBRARY = @LIBS@ 18 | 19 | %.o : $(SRC_PATH)/%.cpp 20 | $(CC) $(CFLAGS) $(DEFS) -c $(<) -o $(OBJECT_PATH)/$@ 21 | 22 | all : $(PROGRAMS) 23 | 24 | midiprobe : midiprobe.cpp $(OBJECTS) 25 | $(CC) $(CFLAGS) $(DEFS) -o midiprobe midiprobe.cpp $(OBJECT_PATH)/RtMidi.o $(LIBRARY) 26 | 27 | midiout : midiout.cpp $(OBJECTS) 28 | $(CC) $(CFLAGS) $(DEFS) -o midiout midiout.cpp $(OBJECT_PATH)/RtMidi.o $(LIBRARY) 29 | 30 | qmidiin : qmidiin.cpp $(OBJECTS) 31 | $(CC) $(CFLAGS) $(DEFS) -o qmidiin qmidiin.cpp $(OBJECT_PATH)/RtMidi.o $(LIBRARY) 32 | 33 | cmidiin : cmidiin.cpp $(OBJECTS) 34 | $(CC) $(CFLAGS) $(DEFS) -o cmidiin cmidiin.cpp $(OBJECT_PATH)/RtMidi.o $(LIBRARY) 35 | 36 | sysextest : sysextest.cpp $(OBJECTS) 37 | $(CC) $(CFLAGS) $(DEFS) -o sysextest sysextest.cpp $(OBJECT_PATH)/RtMidi.o $(LIBRARY) 38 | 39 | clean : 40 | $(RM) -f $(OBJECT_PATH)/*.o 41 | $(RM) -f $(PROGRAMS) *.exe 42 | $(RM) -f *~ 43 | 44 | distclean: clean 45 | $(RM) -f Makefile 46 | 47 | strip : 48 | strip $(PROGRAMS) 49 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/tests/RtMidi.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "cmidiin"=".\cmidiin.dsp" - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Project: "midiout"=".\midiout.dsp" - Package Owner=<4> 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<4> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | Project: "midiprobe"=".\midiprobe.dsp" - Package Owner=<4> 31 | 32 | Package=<5> 33 | {{{ 34 | }}} 35 | 36 | Package=<4> 37 | {{{ 38 | }}} 39 | 40 | ############################################################################### 41 | 42 | Project: "qmidiin"=".\qmidiin.dsp" - Package Owner=<4> 43 | 44 | Package=<5> 45 | {{{ 46 | }}} 47 | 48 | Package=<4> 49 | {{{ 50 | }}} 51 | 52 | ############################################################################### 53 | 54 | Project: "sysextest"=".\sysextest.dsp" - Package Owner=<4> 55 | 56 | Package=<5> 57 | {{{ 58 | }}} 59 | 60 | Package=<4> 61 | {{{ 62 | }}} 63 | 64 | ############################################################################### 65 | 66 | Global: 67 | 68 | Package=<5> 69 | {{{ 70 | }}} 71 | 72 | Package=<3> 73 | {{{ 74 | }}} 75 | 76 | ############################################################################### 77 | 78 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/tests/cmidiin.cpp: -------------------------------------------------------------------------------- 1 | //*****************************************// 2 | // cmidiin.cpp 3 | // by Gary Scavone, 2003-2004. 4 | // 5 | // Simple program to test MIDI input and 6 | // use of a user callback function. 7 | // 8 | //*****************************************// 9 | 10 | #include 11 | #include 12 | #include "RtMidi.h" 13 | 14 | void usage( void ) { 15 | // Error function in case of incorrect command-line 16 | // argument specifications. 17 | std::cout << "\nuseage: cmidiin \n"; 18 | std::cout << " where port = the device to use (default = 0).\n\n"; 19 | exit( 0 ); 20 | } 21 | 22 | void mycallback( double deltatime, std::vector< unsigned char > *message, void *userData ) 23 | { 24 | unsigned int nBytes = message->size(); 25 | for ( unsigned int i=0; i 0 ) 28 | std::cout << "stamp = " << deltatime << std::endl; 29 | } 30 | 31 | // This function should be embedded in a try/catch block in case of 32 | // an exception. It offers the user a choice of MIDI ports to open. 33 | // It returns false if there are no ports available. 34 | bool chooseMidiPort( RtMidiIn *rtmidi ); 35 | 36 | int main( int argc, char *argv[] ) 37 | { 38 | RtMidiIn *midiin = 0; 39 | 40 | // Minimal command-line check. 41 | if ( argc > 2 ) usage(); 42 | 43 | try { 44 | 45 | // RtMidiIn constructor 46 | midiin = new RtMidiIn(); 47 | 48 | // Call function to select port. 49 | if ( chooseMidiPort( midiin ) == false ) goto cleanup; 50 | 51 | // Set our callback function. This should be done immediately after 52 | // opening the port to avoid having incoming messages written to the 53 | // queue instead of sent to the callback function. 54 | midiin->setCallback( &mycallback ); 55 | 56 | // Don't ignore sysex, timing, or active sensing messages. 57 | midiin->ignoreTypes( false, false, false ); 58 | 59 | std::cout << "\nReading MIDI input ... press to quit.\n"; 60 | char input; 61 | std::cin.get(input); 62 | 63 | } catch ( RtError &error ) { 64 | error.printMessage(); 65 | } 66 | 67 | cleanup: 68 | 69 | delete midiin; 70 | 71 | return 0; 72 | } 73 | 74 | bool chooseMidiPort( RtMidiIn *rtmidi ) 75 | { 76 | std::cout << "\nWould you like to open a virtual input port? [y/N] "; 77 | 78 | std::string keyHit; 79 | std::getline( std::cin, keyHit ); 80 | if ( keyHit == "y" ) { 81 | rtmidi->openVirtualPort(); 82 | return true; 83 | } 84 | 85 | std::string portName; 86 | unsigned int i = 0, nPorts = rtmidi->getPortCount(); 87 | if ( nPorts == 0 ) { 88 | std::cout << "No input ports available!" << std::endl; 89 | return false; 90 | } 91 | 92 | if ( nPorts == 1 ) { 93 | std::cout << "\nOpening " << rtmidi->getPortName() << std::endl; 94 | } 95 | else { 96 | for ( i=0; igetPortName(i); 98 | std::cout << " Input port #" << i << ": " << portName << '\n'; 99 | } 100 | 101 | do { 102 | std::cout << "\nChoose a port number: "; 103 | std::cin >> i; 104 | } while ( i >= nPorts ); 105 | } 106 | 107 | std::getline( std::cin, keyHit ); // used to clear out stdin 108 | rtmidi->openPort( i ); 109 | 110 | return true; 111 | } 112 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/tests/cmidiin.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="cmidiin" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Console Application" 0x0103 6 | 7 | CFG=cmidiin - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "cmidiin.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "cmidiin.mak" CFG="cmidiin - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "cmidiin - Win32 Release" (based on "Win32 (x86) Console Application") 21 | !MESSAGE "cmidiin - Win32 Debug" (based on "Win32 (x86) Console Application") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | RSC=rc.exe 30 | 31 | !IF "$(CFG)" == "cmidiin - Win32 Release" 32 | 33 | # PROP BASE Use_MFC 0 34 | # PROP BASE Use_Debug_Libraries 0 35 | # PROP BASE Output_Dir "cmidiin___Win32_Release" 36 | # PROP BASE Intermediate_Dir "cmidiin___Win32_Release" 37 | # PROP BASE Target_Dir "" 38 | # PROP Use_MFC 0 39 | # PROP Use_Debug_Libraries 0 40 | # PROP Output_Dir "" 41 | # PROP Intermediate_Dir "Release" 42 | # PROP Ignore_Export_Lib 0 43 | # PROP Target_Dir "" 44 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 45 | # ADD CPP /nologo /W3 /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_MM__" /YX /FD /c 46 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 47 | # ADD RSC /l 0x409 /d "NDEBUG" 48 | BSC32=bscmake.exe 49 | # ADD BASE BSC32 /nologo 50 | # ADD BSC32 /nologo 51 | LINK32=link.exe 52 | # 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 53 | # 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 54 | 55 | !ELSEIF "$(CFG)" == "cmidiin - Win32 Debug" 56 | 57 | # PROP BASE Use_MFC 0 58 | # PROP BASE Use_Debug_Libraries 1 59 | # PROP BASE Output_Dir "cmidiin___Win32_Debug" 60 | # PROP BASE Intermediate_Dir "cmidiin___Win32_Debug" 61 | # PROP BASE Target_Dir "" 62 | # PROP Use_MFC 0 63 | # PROP Use_Debug_Libraries 1 64 | # PROP Output_Dir "" 65 | # PROP Intermediate_Dir "Debug" 66 | # PROP Ignore_Export_Lib 0 67 | # PROP Target_Dir "" 68 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c 69 | # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_MM__" /YX /FD /GZ /c 70 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 71 | # ADD RSC /l 0x409 /d "_DEBUG" 72 | BSC32=bscmake.exe 73 | # ADD BASE BSC32 /nologo 74 | # ADD BSC32 /nologo 75 | LINK32=link.exe 76 | # 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 77 | # 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 78 | 79 | !ENDIF 80 | 81 | # Begin Target 82 | 83 | # Name "cmidiin - Win32 Release" 84 | # Name "cmidiin - Win32 Debug" 85 | # Begin Group "Source Files" 86 | 87 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 88 | # Begin Source File 89 | 90 | SOURCE=.\cmidiin.cpp 91 | # End Source File 92 | # Begin Source File 93 | 94 | SOURCE=..\RtMidi.cpp 95 | # End Source File 96 | # End Group 97 | # Begin Group "Header Files" 98 | 99 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 100 | # Begin Source File 101 | 102 | SOURCE=..\RtError.h 103 | # End Source File 104 | # Begin Source File 105 | 106 | SOURCE=..\RtMidi.h 107 | # End Source File 108 | # End Group 109 | # Begin Group "Resource Files" 110 | 111 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 112 | # End Group 113 | # End Target 114 | # End Project 115 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/tests/midiout.cpp: -------------------------------------------------------------------------------- 1 | //*****************************************// 2 | // midiout.cpp 3 | // by Gary Scavone, 2003-2004. 4 | // 5 | // Simple program to test MIDI output. 6 | // 7 | //*****************************************// 8 | 9 | #include 10 | #include 11 | #include "RtMidi.h" 12 | 13 | // Platform-dependent sleep routines. 14 | #if defined(__WINDOWS_MM__) 15 | #include 16 | #define SLEEP( milliseconds ) Sleep( (DWORD) milliseconds ) 17 | #else // Unix variants 18 | #include 19 | #define SLEEP( milliseconds ) usleep( (unsigned long) (milliseconds * 1000.0) ) 20 | #endif 21 | 22 | // This function should be embedded in a try/catch block in case of 23 | // an exception. It offers the user a choice of MIDI ports to open. 24 | // It returns false if there are no ports available. 25 | bool chooseMidiPort( RtMidiOut *rtmidi ); 26 | 27 | int main( int argc, char *argv[] ) 28 | { 29 | RtMidiOut *midiout = 0; 30 | std::vector message; 31 | 32 | // RtMidiOut constructor 33 | try { 34 | midiout = new RtMidiOut(); 35 | } 36 | catch ( RtError &error ) { 37 | error.printMessage(); 38 | exit( EXIT_FAILURE ); 39 | } 40 | 41 | // Call function to select port. 42 | try { 43 | if ( chooseMidiPort( midiout ) == false ) goto cleanup; 44 | } 45 | catch ( RtError &error ) { 46 | error.printMessage(); 47 | goto cleanup; 48 | } 49 | 50 | // Send out a series of MIDI messages. 51 | 52 | // Program change: 192, 5 53 | message.push_back( 192 ); 54 | message.push_back( 5 ); 55 | midiout->sendMessage( &message ); 56 | 57 | SLEEP( 500 ); 58 | 59 | message[0] = 0xF1; 60 | message[1] = 60; 61 | midiout->sendMessage( &message ); 62 | 63 | // Control Change: 176, 7, 100 (volume) 64 | message[0] = 176; 65 | message[1] = 7; 66 | message.push_back( 100 ); 67 | midiout->sendMessage( &message ); 68 | 69 | // Note On: 144, 64, 90 70 | message[0] = 144; 71 | message[1] = 64; 72 | message[2] = 90; 73 | midiout->sendMessage( &message ); 74 | 75 | SLEEP( 500 ); 76 | 77 | // Note Off: 128, 64, 40 78 | message[0] = 128; 79 | message[1] = 64; 80 | message[2] = 40; 81 | midiout->sendMessage( &message ); 82 | 83 | SLEEP( 500 ); 84 | 85 | // Control Change: 176, 7, 40 86 | message[0] = 176; 87 | message[1] = 7; 88 | message[2] = 40; 89 | midiout->sendMessage( &message ); 90 | 91 | SLEEP( 500 ); 92 | 93 | // Sysex: 240, 67, 4, 3, 2, 247 94 | message[0] = 240; 95 | message[1] = 67; 96 | message[2] = 4; 97 | message.push_back( 3 ); 98 | message.push_back( 2 ); 99 | message.push_back( 247 ); 100 | midiout->sendMessage( &message ); 101 | 102 | // Clean up 103 | cleanup: 104 | delete midiout; 105 | 106 | return 0; 107 | } 108 | 109 | bool chooseMidiPort( RtMidiOut *rtmidi ) 110 | { 111 | std::cout << "\nWould you like to open a virtual output port? [y/N] "; 112 | 113 | std::string keyHit; 114 | std::getline( std::cin, keyHit ); 115 | if ( keyHit == "y" ) { 116 | rtmidi->openVirtualPort(); 117 | return true; 118 | } 119 | 120 | std::string portName; 121 | unsigned int i = 0, nPorts = rtmidi->getPortCount(); 122 | if ( nPorts == 0 ) { 123 | std::cout << "No output ports available!" << std::endl; 124 | return false; 125 | } 126 | 127 | if ( nPorts == 1 ) { 128 | std::cout << "\nOpening " << rtmidi->getPortName() << std::endl; 129 | } 130 | else { 131 | for ( i=0; igetPortName(i); 133 | std::cout << " Output port #" << i << ": " << portName << '\n'; 134 | } 135 | 136 | do { 137 | std::cout << "\nChoose a port number: "; 138 | std::cin >> i; 139 | } while ( i >= nPorts ); 140 | } 141 | 142 | std::cout << "\n"; 143 | rtmidi->openPort( i ); 144 | 145 | return true; 146 | } 147 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/tests/midiout.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="midiout" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Console Application" 0x0103 6 | 7 | CFG=midiout - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "midiout.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "midiout.mak" CFG="midiout - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "midiout - Win32 Release" (based on "Win32 (x86) Console Application") 21 | !MESSAGE "midiout - Win32 Debug" (based on "Win32 (x86) Console Application") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | RSC=rc.exe 30 | 31 | !IF "$(CFG)" == "midiout - Win32 Release" 32 | 33 | # PROP BASE Use_MFC 0 34 | # PROP BASE Use_Debug_Libraries 0 35 | # PROP BASE Output_Dir "midiout___Win32_Release" 36 | # PROP BASE Intermediate_Dir "midiout___Win32_Release" 37 | # PROP BASE Target_Dir "" 38 | # PROP Use_MFC 0 39 | # PROP Use_Debug_Libraries 0 40 | # PROP Output_Dir "" 41 | # PROP Intermediate_Dir "Release" 42 | # PROP Ignore_Export_Lib 0 43 | # PROP Target_Dir "" 44 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 45 | # ADD CPP /nologo /W3 /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_MM__" /YX /FD /c 46 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 47 | # ADD RSC /l 0x409 /d "NDEBUG" 48 | BSC32=bscmake.exe 49 | # ADD BASE BSC32 /nologo 50 | # ADD BSC32 /nologo 51 | LINK32=link.exe 52 | # 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 53 | # 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 54 | 55 | !ELSEIF "$(CFG)" == "midiout - Win32 Debug" 56 | 57 | # PROP BASE Use_MFC 0 58 | # PROP BASE Use_Debug_Libraries 1 59 | # PROP BASE Output_Dir "midiout___Win32_Debug" 60 | # PROP BASE Intermediate_Dir "midiout___Win32_Debug" 61 | # PROP BASE Target_Dir "" 62 | # PROP Use_MFC 0 63 | # PROP Use_Debug_Libraries 1 64 | # PROP Output_Dir "" 65 | # PROP Intermediate_Dir "Debug" 66 | # PROP Ignore_Export_Lib 0 67 | # PROP Target_Dir "" 68 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c 69 | # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_MM__" /YX /FD /GZ /c 70 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 71 | # ADD RSC /l 0x409 /d "_DEBUG" 72 | BSC32=bscmake.exe 73 | # ADD BASE BSC32 /nologo 74 | # ADD BSC32 /nologo 75 | LINK32=link.exe 76 | # 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 77 | # 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 78 | 79 | !ENDIF 80 | 81 | # Begin Target 82 | 83 | # Name "midiout - Win32 Release" 84 | # Name "midiout - Win32 Debug" 85 | # Begin Group "Source Files" 86 | 87 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 88 | # Begin Source File 89 | 90 | SOURCE=.\midiout.cpp 91 | # End Source File 92 | # Begin Source File 93 | 94 | SOURCE=..\RtMidi.cpp 95 | # End Source File 96 | # End Group 97 | # Begin Group "Header Files" 98 | 99 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 100 | # Begin Source File 101 | 102 | SOURCE=..\RtError.h 103 | # End Source File 104 | # Begin Source File 105 | 106 | SOURCE=..\RtMidi.h 107 | # End Source File 108 | # End Group 109 | # Begin Group "Resource Files" 110 | 111 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 112 | # End Group 113 | # End Target 114 | # End Project 115 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/tests/midiprobe.cpp: -------------------------------------------------------------------------------- 1 | // midiprobe.cpp 2 | // 3 | // Simple program to check MIDI inputs and outputs. 4 | // 5 | // by Gary Scavone, 2003-2004. 6 | 7 | #include 8 | #include 9 | #include "RtMidi.h" 10 | 11 | int main() 12 | { 13 | RtMidiIn *midiin = 0; 14 | RtMidiOut *midiout = 0; 15 | 16 | try { 17 | 18 | // RtMidiIn constructor ... exception possible 19 | midiin = new RtMidiIn(); 20 | 21 | // Check inputs. 22 | unsigned int nPorts = midiin->getPortCount(); 23 | std::cout << "\nThere are " << nPorts << " MIDI input sources available.\n"; 24 | 25 | for ( unsigned i=0; igetPortName(i); 27 | std::cout << " Input Port #" << i+1 << ": " << portName << '\n'; 28 | } 29 | 30 | // RtMidiOut constructor ... exception possible 31 | midiout = new RtMidiOut(); 32 | 33 | // Check outputs. 34 | nPorts = midiout->getPortCount(); 35 | std::cout << "\nThere are " << nPorts << " MIDI output ports available.\n"; 36 | 37 | for ( unsigned i=0; igetPortName(i); 39 | std::cout << " Output Port #" << i+1 << ": " << portName << std::endl; 40 | } 41 | std::cout << std::endl; 42 | 43 | } catch ( RtError &error ) { 44 | error.printMessage(); 45 | } 46 | 47 | delete midiin; 48 | delete midiout; 49 | 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/tests/midiprobe.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="midiprobe" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Console Application" 0x0103 6 | 7 | CFG=midiprobe - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "midiprobe.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "midiprobe.mak" CFG="midiprobe - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "midiprobe - Win32 Release" (based on "Win32 (x86) Console Application") 21 | !MESSAGE "midiprobe - Win32 Debug" (based on "Win32 (x86) Console Application") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | RSC=rc.exe 30 | 31 | !IF "$(CFG)" == "midiprobe - Win32 Release" 32 | 33 | # PROP BASE Use_MFC 0 34 | # PROP BASE Use_Debug_Libraries 0 35 | # PROP BASE Output_Dir "midiprobe___Win32_Release" 36 | # PROP BASE Intermediate_Dir "midiprobe___Win32_Release" 37 | # PROP BASE Target_Dir "" 38 | # PROP Use_MFC 0 39 | # PROP Use_Debug_Libraries 0 40 | # PROP Output_Dir "" 41 | # PROP Intermediate_Dir "Release" 42 | # PROP Ignore_Export_Lib 0 43 | # PROP Target_Dir "" 44 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 45 | # ADD CPP /nologo /W3 /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_MM__" /YX /FD /c 46 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 47 | # ADD RSC /l 0x409 /d "NDEBUG" 48 | BSC32=bscmake.exe 49 | # ADD BASE BSC32 /nologo 50 | # ADD BSC32 /nologo 51 | LINK32=link.exe 52 | # 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 53 | # 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 54 | 55 | !ELSEIF "$(CFG)" == "midiprobe - Win32 Debug" 56 | 57 | # PROP BASE Use_MFC 0 58 | # PROP BASE Use_Debug_Libraries 1 59 | # PROP BASE Output_Dir "midiprobe___Win32_Debug" 60 | # PROP BASE Intermediate_Dir "midiprobe___Win32_Debug" 61 | # PROP BASE Target_Dir "" 62 | # PROP Use_MFC 0 63 | # PROP Use_Debug_Libraries 1 64 | # PROP Output_Dir "" 65 | # PROP Intermediate_Dir "Debug" 66 | # PROP Ignore_Export_Lib 0 67 | # PROP Target_Dir "" 68 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c 69 | # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_MM__" /YX /FD /GZ /c 70 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 71 | # ADD RSC /l 0x409 /d "_DEBUG" 72 | BSC32=bscmake.exe 73 | # ADD BASE BSC32 /nologo 74 | # ADD BSC32 /nologo 75 | LINK32=link.exe 76 | # 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 77 | # 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 78 | 79 | !ENDIF 80 | 81 | # Begin Target 82 | 83 | # Name "midiprobe - Win32 Release" 84 | # Name "midiprobe - Win32 Debug" 85 | # Begin Group "Source Files" 86 | 87 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 88 | # Begin Source File 89 | 90 | SOURCE=.\midiprobe.cpp 91 | # End Source File 92 | # Begin Source File 93 | 94 | SOURCE=..\RtMidi.cpp 95 | # End Source File 96 | # End Group 97 | # Begin Group "Header Files" 98 | 99 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 100 | # Begin Source File 101 | 102 | SOURCE=..\RtError.h 103 | # End Source File 104 | # Begin Source File 105 | 106 | SOURCE=..\RtMidi.h 107 | # End Source File 108 | # End Group 109 | # Begin Group "Resource Files" 110 | 111 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 112 | # End Group 113 | # End Target 114 | # End Project 115 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/tests/qmidiin.cpp: -------------------------------------------------------------------------------- 1 | //*****************************************// 2 | // qmidiin.cpp 3 | // by Gary Scavone, 2003-2004. 4 | // 5 | // Simple program to test MIDI input and 6 | // retrieval from the queue. 7 | // 8 | //*****************************************// 9 | 10 | #include 11 | #include 12 | #include 13 | #include "RtMidi.h" 14 | 15 | // Platform-dependent sleep routines. 16 | #if defined(__WINDOWS_MM__) 17 | #include 18 | #define SLEEP( milliseconds ) Sleep( (DWORD) milliseconds ) 19 | #else // Unix variants 20 | #include 21 | #define SLEEP( milliseconds ) usleep( (unsigned long) (milliseconds * 1000.0) ) 22 | #endif 23 | 24 | bool done; 25 | static void finish( int ignore ){ done = true; } 26 | 27 | void usage( void ) { 28 | // Error function in case of incorrect command-line 29 | // argument specifications. 30 | std::cout << "\nusage: qmidiin \n"; 31 | std::cout << " where port = the device to use (default = 0).\n\n"; 32 | exit( 0 ); 33 | } 34 | 35 | int main( int argc, char *argv[] ) 36 | { 37 | RtMidiIn *midiin = 0; 38 | std::vector message; 39 | int nBytes, i; 40 | double stamp; 41 | 42 | // Minimal command-line check. 43 | if ( argc > 2 ) usage(); 44 | 45 | // RtMidiIn constructor 46 | try { 47 | midiin = new RtMidiIn(); 48 | } 49 | catch ( RtError &error ) { 50 | error.printMessage(); 51 | exit( EXIT_FAILURE ); 52 | } 53 | 54 | // Check available ports vs. specified. 55 | unsigned int port = 0; 56 | unsigned int nPorts = midiin->getPortCount(); 57 | if ( argc == 2 ) port = (unsigned int) atoi( argv[1] ); 58 | if ( port >= nPorts ) { 59 | delete midiin; 60 | std::cout << "Invalid port specifier!\n"; 61 | usage(); 62 | } 63 | 64 | try { 65 | midiin->openPort( port ); 66 | } 67 | catch ( RtError &error ) { 68 | error.printMessage(); 69 | goto cleanup; 70 | } 71 | 72 | // Don't ignore sysex, timing, or active sensing messages. 73 | midiin->ignoreTypes( false, false, false ); 74 | 75 | // Install an interrupt handler function. 76 | done = false; 77 | (void) signal(SIGINT, finish); 78 | 79 | // Periodically check input queue. 80 | std::cout << "Reading MIDI from port ... quit with Ctrl-C.\n"; 81 | while ( !done ) { 82 | stamp = midiin->getMessage( &message ); 83 | nBytes = message.size(); 84 | for ( i=0; i 0 ) 87 | std::cout << "stamp = " << stamp << std::endl; 88 | 89 | // Sleep for 10 milliseconds. 90 | SLEEP( 10 ); 91 | } 92 | 93 | // Clean up 94 | cleanup: 95 | delete midiin; 96 | 97 | return 0; 98 | } 99 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/tests/qmidiin.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="qmidiin" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Console Application" 0x0103 6 | 7 | CFG=qmidiin - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "qmidiin.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "qmidiin.mak" CFG="qmidiin - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "qmidiin - Win32 Release" (based on "Win32 (x86) Console Application") 21 | !MESSAGE "qmidiin - Win32 Debug" (based on "Win32 (x86) Console Application") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | RSC=rc.exe 30 | 31 | !IF "$(CFG)" == "qmidiin - Win32 Release" 32 | 33 | # PROP BASE Use_MFC 0 34 | # PROP BASE Use_Debug_Libraries 0 35 | # PROP BASE Output_Dir "qmidiin___Win32_Release" 36 | # PROP BASE Intermediate_Dir "qmidiin___Win32_Release" 37 | # PROP BASE Target_Dir "" 38 | # PROP Use_MFC 0 39 | # PROP Use_Debug_Libraries 0 40 | # PROP Output_Dir "" 41 | # PROP Intermediate_Dir "Release" 42 | # PROP Ignore_Export_Lib 0 43 | # PROP Target_Dir "" 44 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 45 | # ADD CPP /nologo /W3 /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_MM__" /YX /FD /c 46 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 47 | # ADD RSC /l 0x409 /d "NDEBUG" 48 | BSC32=bscmake.exe 49 | # ADD BASE BSC32 /nologo 50 | # ADD BSC32 /nologo 51 | LINK32=link.exe 52 | # 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 53 | # 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 54 | 55 | !ELSEIF "$(CFG)" == "qmidiin - Win32 Debug" 56 | 57 | # PROP BASE Use_MFC 0 58 | # PROP BASE Use_Debug_Libraries 1 59 | # PROP BASE Output_Dir "qmidiin___Win32_Debug" 60 | # PROP BASE Intermediate_Dir "qmidiin___Win32_Debug" 61 | # PROP BASE Target_Dir "" 62 | # PROP Use_MFC 0 63 | # PROP Use_Debug_Libraries 1 64 | # PROP Output_Dir "" 65 | # PROP Intermediate_Dir "Debug" 66 | # PROP Ignore_Export_Lib 0 67 | # PROP Target_Dir "" 68 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c 69 | # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_MM__" /YX /FD /GZ /c 70 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 71 | # ADD RSC /l 0x409 /d "_DEBUG" 72 | BSC32=bscmake.exe 73 | # ADD BASE BSC32 /nologo 74 | # ADD BSC32 /nologo 75 | LINK32=link.exe 76 | # 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 77 | # 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 78 | 79 | !ENDIF 80 | 81 | # Begin Target 82 | 83 | # Name "qmidiin - Win32 Release" 84 | # Name "qmidiin - Win32 Debug" 85 | # Begin Group "Source Files" 86 | 87 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 88 | # Begin Source File 89 | 90 | SOURCE=.\qmidiin.cpp 91 | # End Source File 92 | # Begin Source File 93 | 94 | SOURCE=..\RtMidi.cpp 95 | # End Source File 96 | # End Group 97 | # Begin Group "Header Files" 98 | 99 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 100 | # Begin Source File 101 | 102 | SOURCE=..\RtError.h 103 | # End Source File 104 | # Begin Source File 105 | 106 | SOURCE=..\RtMidi.h 107 | # End Source File 108 | # End Group 109 | # Begin Group "Resource Files" 110 | 111 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 112 | # End Group 113 | # End Target 114 | # End Project 115 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/tests/sysextest.cpp: -------------------------------------------------------------------------------- 1 | //*****************************************// 2 | // sysextest.cpp 3 | // by Gary Scavone, 2003-2005. 4 | // 5 | // Simple program to test MIDI sysex sending and receiving. 6 | // 7 | //*****************************************// 8 | 9 | #include 10 | #include 11 | #include 12 | #include "RtMidi.h" 13 | 14 | void usage( void ) { 15 | std::cout << "\nuseage: sysextest N\n"; 16 | std::cout << " where N = length of sysex message to send / receive.\n\n"; 17 | exit( 0 ); 18 | } 19 | 20 | // Platform-dependent sleep routines. 21 | #if defined(__WINDOWS_MM__) 22 | #include 23 | #define SLEEP( milliseconds ) Sleep( (DWORD) milliseconds ) 24 | #else // Unix variants 25 | #include 26 | #define SLEEP( milliseconds ) usleep( (unsigned long) (milliseconds * 1000.0) ) 27 | #endif 28 | 29 | // This function should be embedded in a try/catch block in case of 30 | // an exception. It offers the user a choice of MIDI ports to open. 31 | // It returns false if there are no ports available. 32 | bool chooseMidiPort( RtMidi *rtmidi ); 33 | 34 | int main( int argc, char *argv[] ) 35 | { 36 | RtMidiOut *midiout = 0; 37 | RtMidiIn *midiin = 0; 38 | std::vector message; 39 | double stamp; 40 | unsigned int i, nBytes; 41 | 42 | // Minimal command-line check. 43 | if ( argc != 2 ) usage(); 44 | nBytes = (unsigned int) atoi( argv[1] ); 45 | 46 | // RtMidiOut and RtMidiIn constructors 47 | try { 48 | midiout = new RtMidiOut(); 49 | midiin = new RtMidiIn(); 50 | } 51 | catch ( RtError &error ) { 52 | error.printMessage(); 53 | goto cleanup; 54 | } 55 | 56 | // Don't ignore sysex, timing, or active sensing messages. 57 | midiin->ignoreTypes( false, true, true ); 58 | 59 | // Call function to select ports 60 | try { 61 | if ( chooseMidiPort( midiin ) == false ) goto cleanup; 62 | if ( chooseMidiPort( midiout ) == false ) goto cleanup; 63 | } 64 | catch ( RtError &error ) { 65 | error.printMessage(); 66 | goto cleanup; 67 | } 68 | 69 | // Create a long sysex messages of numbered bytes and send it out. 70 | message.push_back( 240 ); 71 | for ( i=0; isendMessage( &message ); 75 | 76 | SLEEP( 50 ); // pause a little 77 | 78 | // Look for one message (hopefully the previously sent sysex if the 79 | // ports were connected together) and print out the values. 80 | stamp = midiin->getMessage( &message ); 81 | nBytes = message.size(); 82 | for ( i=0; iopenVirtualPort(); 108 | return true; 109 | } 110 | 111 | std::string portName; 112 | unsigned int i = 0, nPorts = rtmidi->getPortCount(); 113 | if ( nPorts == 0 ) { 114 | if ( isInput ) 115 | std::cout << "No input ports available!" << std::endl; 116 | else 117 | std::cout << "No output ports available!" << std::endl; 118 | return false; 119 | } 120 | 121 | if ( nPorts == 1 ) { 122 | std::cout << "\nOpening " << rtmidi->getPortName() << std::endl; 123 | } 124 | else { 125 | for ( i=0; igetPortName(i); 127 | if ( isInput ) 128 | std::cout << " Input port #" << i << ": " << portName << '\n'; 129 | else 130 | std::cout << " Output port #" << i << ": " << portName << '\n'; 131 | } 132 | 133 | do { 134 | std::cout << "\nChoose a port number: "; 135 | std::cin >> i; 136 | } while ( i >= nPorts ); 137 | } 138 | 139 | std::cout << std::endl; 140 | rtmidi->openPort( i ); 141 | 142 | return true; 143 | } 144 | -------------------------------------------------------------------------------- /third-party/rtmidi-1.0.15/tests/sysextest.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="sysextest" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Console Application" 0x0103 6 | 7 | CFG=sysextest - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "sysextest.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "sysextest.mak" CFG="sysextest - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "sysextest - Win32 Release" (based on "Win32 (x86) Console Application") 21 | !MESSAGE "sysextest - Win32 Debug" (based on "Win32 (x86) Console Application") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | RSC=rc.exe 30 | 31 | !IF "$(CFG)" == "sysextest - Win32 Release" 32 | 33 | # PROP BASE Use_MFC 0 34 | # PROP BASE Use_Debug_Libraries 0 35 | # PROP BASE Output_Dir "sysextest___Win32_Release" 36 | # PROP BASE Intermediate_Dir "sysextest___Win32_Release" 37 | # PROP BASE Target_Dir "" 38 | # PROP Use_MFC 0 39 | # PROP Use_Debug_Libraries 0 40 | # PROP Output_Dir "" 41 | # PROP Intermediate_Dir "Release" 42 | # PROP Ignore_Export_Lib 0 43 | # PROP Target_Dir "" 44 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 45 | # ADD CPP /nologo /W3 /GR /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_MM__" /YX /FD /c 46 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 47 | # ADD RSC /l 0x409 /d "NDEBUG" 48 | BSC32=bscmake.exe 49 | # ADD BASE BSC32 /nologo 50 | # ADD BSC32 /nologo 51 | LINK32=link.exe 52 | # 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 53 | # 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 54 | 55 | !ELSEIF "$(CFG)" == "sysextest - Win32 Debug" 56 | 57 | # PROP BASE Use_MFC 0 58 | # PROP BASE Use_Debug_Libraries 1 59 | # PROP BASE Output_Dir "sysextest___Win32_Debug" 60 | # PROP BASE Intermediate_Dir "sysextest___Win32_Debug" 61 | # PROP BASE Target_Dir "" 62 | # PROP Use_MFC 0 63 | # PROP Use_Debug_Libraries 1 64 | # PROP Output_Dir "" 65 | # PROP Intermediate_Dir "Debug" 66 | # PROP Ignore_Export_Lib 0 67 | # PROP Target_Dir "" 68 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c 69 | # 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 70 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 71 | # ADD RSC /l 0x409 /d "_DEBUG" 72 | BSC32=bscmake.exe 73 | # ADD BASE BSC32 /nologo 74 | # ADD BSC32 /nologo 75 | LINK32=link.exe 76 | # 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 77 | # 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 78 | 79 | !ENDIF 80 | 81 | # Begin Target 82 | 83 | # Name "sysextest - Win32 Release" 84 | # Name "sysextest - Win32 Debug" 85 | # Begin Group "Source Files" 86 | 87 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 88 | # Begin Source File 89 | 90 | SOURCE=..\RtMidi.cpp 91 | # End Source File 92 | # Begin Source File 93 | 94 | SOURCE=.\sysextest.cpp 95 | # End Source File 96 | # End Group 97 | # Begin Group "Header Files" 98 | 99 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 100 | # Begin Source File 101 | 102 | SOURCE=..\RtError.h 103 | # End Source File 104 | # Begin Source File 105 | 106 | SOURCE=..\RtMidi.h 107 | # End Source File 108 | # End Group 109 | # Begin Group "Resource Files" 110 | 111 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 112 | # End Group 113 | # End Target 114 | # End Project 115 | --------------------------------------------------------------------------------