Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ option(RTMIDI_API_AMIDI "Compile with Android support." ${ANDROID})

# Module options
option(RTMIDI_BUILD_MODULES "Build C++ modules for RtMidi" OFF)
option(RTMIDI_USE_NAMESPACE "Use namespace rtmidi for module" ON)
option(RTMIDI_USE_NAMESPACE "Force usage of namespace rt::midi for modules" ON)

# Add -Wall if possible
if (CMAKE_COMPILER_IS_GNUCXX)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ RtMidi is a set of C++ classes (`RtMidiIn`, `RtMidiOut`, and API specific classe

MIDI input and output functionality are separated into two classes, `RtMidiIn` and `RtMidiOut`. Each class instance supports only a single MIDI connection. RtMidi does not provide timing functionality (i.e., output messages are sent immediately). Input messages are timestamped with delta times in seconds (via a `double` floating point type). MIDI data is passed to the user as raw bytes using an `std::vector<unsigned char>`.

RtMidi is also offered as a module, which is enabled with `RTMIDI_BUILD_MODULES`, and is accessed with `import rtmidi;`. Namespaces are inlined, so classes can be accessed through namespace `rtmidi` or through the global namespace (for example, `rtmidi::MidiApi` and `::MidiApi` are both valid).
RtMidi is also offered as a module, which is enabled with `RTMIDI_BUILD_MODULES`, and is accessed with `import rt.midi;`. Namespaces are inlined, so classes can be accessed through namespace `rt::midi` or through the global namespace (for example, `rt::midi::MidiApi` and `::MidiApi` are both valid).

## Windows

Expand Down
4 changes: 3 additions & 1 deletion RtMidi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
#include "RtMidi.h"
#include <sstream>

inline namespace rtmidi {
inline namespace rt {
inline namespace midi {

#if defined(__APPLE__)
#include <TargetConditionals.h>
Expand Down Expand Up @@ -5275,3 +5276,4 @@ void MidiOutAndroid :: sendMessage( const unsigned char *message, size_t size )
#endif // __AMIDI__

}
}
4 changes: 3 additions & 1 deletion RtMidi.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@
#include <string>
#include <vector>

inline namespace rtmidi {
inline namespace rt {
inline namespace midi {

/************************************************************************/
/*! \class RtMidiError
Expand Down Expand Up @@ -675,6 +676,7 @@ inline void RtMidiOut :: sendMessage( const std::vector<unsigned char> *message
inline void RtMidiOut :: sendMessage( const unsigned char *message, size_t size ) { static_cast<MidiOutApi *>(rtapi_)->sendMessage( message, size ); }
inline void RtMidiOut :: setErrorCallback( RtMidiErrorCallback errorCallback, void *userData ) { rtapi_->setErrorCallback(errorCallback, userData); }

}
}

#endif
4 changes: 4 additions & 0 deletions modules/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ if(NOT COMMAND configure_cpp_module_target)
endfunction()
endif()

if(RTMIDI_USE_NAMESPACE)
target_compile_definitions(rtmidi_modules PRIVATE RTMIDI_USE_NAMESPACE)
endif()

configure_cpp_module_target(rtmidi_modules)

target_link_libraries(rtmidi_modules
Expand Down
29 changes: 19 additions & 10 deletions modules/RtMidi.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,24 @@ module;

#include "RtMidi.h"

export module rtmidi;
export module rt.midi;

export inline namespace rtmidi {
using rtmidi::RtMidiError;
using rtmidi::RtMidiErrorCallback;
using rtmidi::RtMidi;
using rtmidi::RtMidiIn;
using rtmidi::RtMidiOut;
using rtmidi::MidiApi;
using rtmidi::MidiInApi;
using rtmidi::MidiOutApi;
export
#ifdef RTMIDI_USE_NAMESPACE
inline namespace rt {
inline namespace midi {
#else
namespace rt::midi {
#endif
using rt::midi::RtMidiError;
using rt::midi::RtMidiErrorCallback;
using rt::midi::RtMidi;
using rt::midi::RtMidiIn;
using rt::midi::RtMidiOut;
using rt::midi::MidiApi;
using rt::midi::MidiInApi;
using rt::midi::MidiOutApi;
}
#ifdef RTMIDI_USE_NAMESPACE
}
#endif
Loading