1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Documentation: Add doxygen guards to UMP namespace

This commit is contained in:
reuk 2021-12-08 14:13:44 +00:00
parent bf32f0dba9
commit d5099ecf4d
17 changed files with 162 additions and 94 deletions

View file

@ -37,7 +37,11 @@
#include "juce_UMPDispatcher.h" #include "juce_UMPDispatcher.h"
#include "juce_UMPReceiver.h" #include "juce_UMPReceiver.h"
#ifndef DOXYGEN
namespace juce namespace juce
{ {
namespace ump = universal_midi_packets; namespace ump = universal_midi_packets;
} }
#endif

View file

@ -20,12 +20,14 @@
============================================================================== ==============================================================================
*/ */
#ifndef DOXYGEN
namespace juce namespace juce
{ {
namespace universal_midi_packets namespace universal_midi_packets
{ {
/* /**
Functions to assist conversion of UMP messages to/from other formats, Functions to assist conversion of UMP messages to/from other formats,
especially older 'bytestream' formatted MidiMessages. especially older 'bytestream' formatted MidiMessages.
@ -33,7 +35,7 @@ namespace universal_midi_packets
*/ */
struct Conversion struct Conversion
{ {
/* Converts from a MIDI 1 bytestream to MIDI 1 on Universal MIDI Packets. /** Converts from a MIDI 1 bytestream to MIDI 1 on Universal MIDI Packets.
`callback` is a function which accepts a single View argument. `callback` is a function which accepts a single View argument.
*/ */
@ -97,7 +99,7 @@ struct Conversion
} }
} }
/* Converts a MidiMessage to one or more messages in UMP format, using /** Converts a MidiMessage to one or more messages in UMP format, using
the MIDI 1.0 Protocol. the MIDI 1.0 Protocol.
`packets` is an out-param to allow the caller to control `packets` is an out-param to allow the caller to control
@ -111,7 +113,7 @@ struct Conversion
toMidi1 (m, [&] (const View& view) { packets.add (view); }); toMidi1 (m, [&] (const View& view) { packets.add (view); });
} }
/* Widens a 7-bit MIDI 1.0 value to a 8-bit MIDI 2.0 value. */ /** Widens a 7-bit MIDI 1.0 value to a 8-bit MIDI 2.0 value. */
static uint8_t scaleTo8 (uint8_t word7Bit) static uint8_t scaleTo8 (uint8_t word7Bit)
{ {
const auto shifted = (uint8_t) (word7Bit << 0x1); const auto shifted = (uint8_t) (word7Bit << 0x1);
@ -120,7 +122,7 @@ struct Conversion
return (uint8_t) (shifted | ((repeat >> 5) & mask)); return (uint8_t) (shifted | ((repeat >> 5) & mask));
} }
/* Widens a 7-bit MIDI 1.0 value to a 16-bit MIDI 2.0 value. */ /** Widens a 7-bit MIDI 1.0 value to a 16-bit MIDI 2.0 value. */
static uint16_t scaleTo16 (uint8_t word7Bit) static uint16_t scaleTo16 (uint8_t word7Bit)
{ {
const auto shifted = (uint16_t) (word7Bit << 0x9); const auto shifted = (uint16_t) (word7Bit << 0x9);
@ -129,7 +131,7 @@ struct Conversion
return (uint16_t) (shifted | (((repeat << 3) | (repeat >> 3)) & mask)); return (uint16_t) (shifted | (((repeat << 3) | (repeat >> 3)) & mask));
} }
/* Widens a 14-bit MIDI 1.0 value to a 16-bit MIDI 2.0 value. */ /** Widens a 14-bit MIDI 1.0 value to a 16-bit MIDI 2.0 value. */
static uint16_t scaleTo16 (uint16_t word14Bit) static uint16_t scaleTo16 (uint16_t word14Bit)
{ {
const auto shifted = (uint16_t) (word14Bit << 0x2); const auto shifted = (uint16_t) (word14Bit << 0x2);
@ -138,7 +140,7 @@ struct Conversion
return (uint16_t) (shifted | ((repeat >> 11) & mask)); return (uint16_t) (shifted | ((repeat >> 11) & mask));
} }
/* Widens a 7-bit MIDI 1.0 value to a 32-bit MIDI 2.0 value. */ /** Widens a 7-bit MIDI 1.0 value to a 32-bit MIDI 2.0 value. */
static uint32_t scaleTo32 (uint8_t word7Bit) static uint32_t scaleTo32 (uint8_t word7Bit)
{ {
const auto shifted = (uint32_t) (word7Bit << 0x19); const auto shifted = (uint32_t) (word7Bit << 0x19);
@ -151,7 +153,7 @@ struct Conversion
| (repeat >> 5)) & mask)); | (repeat >> 5)) & mask));
} }
/* Widens a 14-bit MIDI 1.0 value to a 32-bit MIDI 2.0 value. */ /** Widens a 14-bit MIDI 1.0 value to a 32-bit MIDI 2.0 value. */
static uint32_t scaleTo32 (uint16_t word14Bit) static uint32_t scaleTo32 (uint16_t word14Bit)
{ {
const auto shifted = (uint32_t) (word14Bit << 0x12); const auto shifted = (uint32_t) (word14Bit << 0x12);
@ -160,22 +162,22 @@ struct Conversion
return (uint32_t) (shifted | (((repeat << 5) | (repeat >> 8)) & mask)); return (uint32_t) (shifted | (((repeat << 5) | (repeat >> 8)) & mask));
} }
/* Narrows a 16-bit MIDI 2.0 value to a 7-bit MIDI 1.0 value. */ /** Narrows a 16-bit MIDI 2.0 value to a 7-bit MIDI 1.0 value. */
static uint8_t scaleTo7 (uint8_t word8Bit) { return (uint8_t) (word8Bit >> 1); } static uint8_t scaleTo7 (uint8_t word8Bit) { return (uint8_t) (word8Bit >> 1); }
/* Narrows a 16-bit MIDI 2.0 value to a 7-bit MIDI 1.0 value. */ /** Narrows a 16-bit MIDI 2.0 value to a 7-bit MIDI 1.0 value. */
static uint8_t scaleTo7 (uint16_t word16Bit) { return (uint8_t) (word16Bit >> 9); } static uint8_t scaleTo7 (uint16_t word16Bit) { return (uint8_t) (word16Bit >> 9); }
/* Narrows a 32-bit MIDI 2.0 value to a 7-bit MIDI 1.0 value. */ /** Narrows a 32-bit MIDI 2.0 value to a 7-bit MIDI 1.0 value. */
static uint8_t scaleTo7 (uint32_t word32Bit) { return (uint8_t) (word32Bit >> 25); } static uint8_t scaleTo7 (uint32_t word32Bit) { return (uint8_t) (word32Bit >> 25); }
/* Narrows a 32-bit MIDI 2.0 value to a 14-bit MIDI 1.0 value. */ /** Narrows a 32-bit MIDI 2.0 value to a 14-bit MIDI 1.0 value. */
static uint16_t scaleTo14 (uint16_t word16Bit) { return (uint16_t) (word16Bit >> 2); } static uint16_t scaleTo14 (uint16_t word16Bit) { return (uint16_t) (word16Bit >> 2); }
/* Narrows a 32-bit MIDI 2.0 value to a 14-bit MIDI 1.0 value. */ /** Narrows a 32-bit MIDI 2.0 value to a 14-bit MIDI 1.0 value. */
static uint16_t scaleTo14 (uint32_t word32Bit) { return (uint16_t) (word32Bit >> 18); } static uint16_t scaleTo14 (uint32_t word32Bit) { return (uint16_t) (word32Bit >> 18); }
/* Converts UMP messages which may include MIDI 2.0 channel voice messages into /** Converts UMP messages which may include MIDI 2.0 channel voice messages into
equivalent MIDI 1.0 messages (still in UMP format). equivalent MIDI 1.0 messages (still in UMP format).
`callback` is a function that accepts a single View argument and will be `callback` is a function that accepts a single View argument and will be
@ -324,3 +326,5 @@ struct Conversion
} }
} }
#endif

View file

@ -20,11 +20,13 @@
============================================================================== ==============================================================================
*/ */
#ifndef DOXYGEN
namespace juce namespace juce
{ {
namespace universal_midi_packets namespace universal_midi_packets
{ {
/* /**
Allows conversion from bytestream- or Universal MIDI Packet-formatted Allows conversion from bytestream- or Universal MIDI Packet-formatted
messages to MIDI 1.0 messages in UMP format. messages to MIDI 1.0 messages in UMP format.
@ -45,7 +47,7 @@ namespace universal_midi_packets
} }
}; };
/* /**
Allows conversion from bytestream- or Universal MIDI Packet-formatted Allows conversion from bytestream- or Universal MIDI Packet-formatted
messages to MIDI 2.0 messages in UMP format. messages to MIDI 2.0 messages in UMP format.
@ -76,7 +78,7 @@ namespace universal_midi_packets
Midi1ToMidi2DefaultTranslator translator; Midi1ToMidi2DefaultTranslator translator;
}; };
/* /**
Allows conversion from bytestream- or Universal MIDI Packet-formatted Allows conversion from bytestream- or Universal MIDI Packet-formatted
messages to UMP format. messages to UMP format.
@ -131,7 +133,7 @@ namespace universal_midi_packets
const PacketProtocol mode{}; const PacketProtocol mode{};
}; };
/* /**
Allows conversion from bytestream- or Universal MIDI Packet-formatted Allows conversion from bytestream- or Universal MIDI Packet-formatted
messages to bytestream format. messages to bytestream format.
@ -163,3 +165,5 @@ namespace universal_midi_packets
}; };
} }
} }
#endif

View file

@ -20,12 +20,14 @@
============================================================================== ==============================================================================
*/ */
#ifndef DOXYGEN
namespace juce namespace juce
{ {
namespace universal_midi_packets namespace universal_midi_packets
{ {
/* /**
Parses a raw stream of uint32_t, and calls a user-provided callback every time Parses a raw stream of uint32_t, and calls a user-provided callback every time
a full Universal MIDI Packet is encountered. a full Universal MIDI Packet is encountered.
@ -34,10 +36,10 @@ namespace universal_midi_packets
class Dispatcher class Dispatcher
{ {
public: public:
/* Clears the dispatcher. */ /** Clears the dispatcher. */
void reset() { currentPacketLen = 0; } void reset() { currentPacketLen = 0; }
/* Calls `callback` with a View of each packet encountered in the range delimited /** Calls `callback` with a View of each packet encountered in the range delimited
by `begin` and `end`. by `begin` and `end`.
If the range ends part-way through a packet, the next call to `dispatch` will If the range ends part-way through a packet, the next call to `dispatch` will
@ -67,7 +69,7 @@ private:
}; };
//============================================================================== //==============================================================================
/* /**
Parses a stream of bytes representing a sequence of bytestream-encoded MIDI 1.0 messages, Parses a stream of bytes representing a sequence of bytestream-encoded MIDI 1.0 messages,
converting the messages to UMP format and passing the packets to a user-provided callback converting the messages to UMP format and passing the packets to a user-provided callback
as they become ready. as they become ready.
@ -77,7 +79,7 @@ private:
class BytestreamToUMPDispatcher class BytestreamToUMPDispatcher
{ {
public: public:
/* Initialises the dispatcher. /** Initialises the dispatcher.
Channel messages will be converted to the requested protocol format `pp`. Channel messages will be converted to the requested protocol format `pp`.
`storageSize` bytes will be allocated to store incomplete messages. `storageSize` bytes will be allocated to store incomplete messages.
@ -93,7 +95,7 @@ public:
converter.reset(); converter.reset();
} }
/* Calls `callback` with a View of each converted packet as it becomes ready. /** Calls `callback` with a View of each converted packet as it becomes ready.
@param begin the first byte in a range of bytes representing bytestream-encoded MIDI messages. @param begin the first byte in a range of bytes representing bytestream-encoded MIDI messages.
@param end one-past the last byte in a range of bytes representing bytestream-encoded MIDI messages. @param end one-past the last byte in a range of bytes representing bytestream-encoded MIDI messages.
@ -145,7 +147,7 @@ private:
}; };
//============================================================================== //==============================================================================
/* /**
Parses a stream of 32-bit words representing a sequence of UMP-encoded MIDI messages, Parses a stream of 32-bit words representing a sequence of UMP-encoded MIDI messages,
converting the messages to MIDI 1.0 bytestream format and passing them to a user-provided converting the messages to MIDI 1.0 bytestream format and passing them to a user-provided
callback as they become ready. callback as they become ready.
@ -155,21 +157,21 @@ private:
class ToBytestreamDispatcher class ToBytestreamDispatcher
{ {
public: public:
/* Initialises the dispatcher. /** Initialises the dispatcher.
`storageSize` bytes will be allocated to store incomplete messages. `storageSize` bytes will be allocated to store incomplete messages.
*/ */
explicit ToBytestreamDispatcher (int storageSize) explicit ToBytestreamDispatcher (int storageSize)
: converter (storageSize) {} : converter (storageSize) {}
/* Clears the dispatcher. */ /** Clears the dispatcher. */
void reset() void reset()
{ {
dispatcher.reset(); dispatcher.reset();
converter.reset(); converter.reset();
} }
/* Calls `callback` with converted bytestream-formatted MidiMessage whenever /** Calls `callback` with converted bytestream-formatted MidiMessage whenever
a new message becomes available. a new message becomes available.
@param begin the first word in a stream of words representing UMP-encoded MIDI packets. @param begin the first word in a stream of words representing UMP-encoded MIDI packets.
@ -196,3 +198,5 @@ private:
} }
} }
#endif

View file

@ -20,12 +20,14 @@
============================================================================== ==============================================================================
*/ */
#ifndef DOXYGEN
namespace juce namespace juce
{ {
namespace universal_midi_packets namespace universal_midi_packets
{ {
/* /**
This struct holds functions that can be used to create different kinds This struct holds functions that can be used to create different kinds
of Universal MIDI Packet. of Universal MIDI Packet.
@ -33,7 +35,7 @@ namespace universal_midi_packets
*/ */
struct Factory struct Factory
{ {
/* @internal */ /** @internal */
struct Detail struct Detail
{ {
static PacketX1 makeSystem() { return PacketX1{}.withMessageType (1); } static PacketX1 makeSystem() { return PacketX1{}.withMessageType (1); }
@ -532,3 +534,5 @@ struct Factory
} }
} }
#endif

View file

@ -20,12 +20,14 @@
============================================================================== ==============================================================================
*/ */
#ifndef DOXYGEN
namespace juce namespace juce
{ {
namespace universal_midi_packets namespace universal_midi_packets
{ {
/* /**
Enables iteration over a collection of Universal MIDI Packets stored as Enables iteration over a collection of Universal MIDI Packets stored as
a contiguous range of 32-bit words. a contiguous range of 32-bit words.
@ -37,10 +39,10 @@ namespace universal_midi_packets
class Iterator class Iterator
{ {
public: public:
/* Creates an invalid (singular) iterator. */ /** Creates an invalid (singular) iterator. */
Iterator() noexcept = default; Iterator() noexcept = default;
/* Creates an iterator pointing at `ptr`. */ /** Creates an iterator pointing at `ptr`. */
explicit Iterator (const uint32_t* ptr, size_t bytes) noexcept explicit Iterator (const uint32_t* ptr, size_t bytes) noexcept
: view (ptr) : view (ptr)
#if JUCE_DEBUG #if JUCE_DEBUG
@ -56,7 +58,7 @@ public:
using pointer = const View*; using pointer = const View*;
using iterator_category = std::forward_iterator_tag; using iterator_category = std::forward_iterator_tag;
/* Moves this iterator to the next packet in the range. */ /** Moves this iterator to the next packet in the range. */
Iterator& operator++() noexcept Iterator& operator++() noexcept
{ {
const auto increment = view.size(); const auto increment = view.size();
@ -73,7 +75,7 @@ public:
return *this; return *this;
} }
/* Moves this iterator to the next packet in the range, /** Moves this iterator to the next packet in the range,
returning the value of the iterator before it was returning the value of the iterator before it was
incremented. incremented.
*/ */
@ -84,7 +86,7 @@ public:
return copy; return copy;
} }
/* Returns true if this iterator points to the same address /** Returns true if this iterator points to the same address
as another iterator. as another iterator.
*/ */
bool operator== (const Iterator& other) const noexcept bool operator== (const Iterator& other) const noexcept
@ -92,7 +94,7 @@ public:
return view == other.view; return view == other.view;
} }
/* Returns false if this iterator points to the same address /** Returns false if this iterator points to the same address
as another iterator. as another iterator.
*/ */
bool operator!= (const Iterator& other) const noexcept bool operator!= (const Iterator& other) const noexcept
@ -100,14 +102,14 @@ public:
return ! operator== (other); return ! operator== (other);
} }
/* Returns a reference to a View of the packet currently /** Returns a reference to a View of the packet currently
pointed-to by this iterator. pointed-to by this iterator.
The View can be queried for its size and content. The View can be queried for its size and content.
*/ */
reference operator*() noexcept { return view; } reference operator*() noexcept { return view; }
/* Returns a pointer to a View of the packet currently /** Returns a pointer to a View of the packet currently
pointed-to by this iterator. pointed-to by this iterator.
The View can be queried for its size and content. The View can be queried for its size and content.
@ -124,3 +126,5 @@ private:
} }
} }
#endif

View file

@ -20,12 +20,14 @@
============================================================================== ==============================================================================
*/ */
#ifndef DOXYGEN
namespace juce namespace juce
{ {
namespace universal_midi_packets namespace universal_midi_packets
{ {
/* /**
Parses a raw stream of uint32_t holding a series of Universal MIDI Packets using Parses a raw stream of uint32_t holding a series of Universal MIDI Packets using
the MIDI 1.0 Protocol, converting to plain (non-UMP) MidiMessages. the MIDI 1.0 Protocol, converting to plain (non-UMP) MidiMessages.
@ -34,7 +36,7 @@ namespace universal_midi_packets
class Midi1ToBytestreamTranslator class Midi1ToBytestreamTranslator
{ {
public: public:
/* Ensures that there is room in the internal buffer for a sysex message of at least /** Ensures that there is room in the internal buffer for a sysex message of at least
`initialBufferSize` bytes. `initialBufferSize` bytes.
*/ */
explicit Midi1ToBytestreamTranslator (int initialBufferSize) explicit Midi1ToBytestreamTranslator (int initialBufferSize)
@ -42,14 +44,14 @@ public:
pendingSysExData.reserve (size_t (initialBufferSize)); pendingSysExData.reserve (size_t (initialBufferSize));
} }
/* Clears the concatenator. */ /** Clears the concatenator. */
void reset() void reset()
{ {
pendingSysExData.clear(); pendingSysExData.clear();
pendingSysExTime = 0.0; pendingSysExTime = 0.0;
} }
/* Converts a Universal MIDI Packet using the MIDI 1.0 Protocol to /** Converts a Universal MIDI Packet using the MIDI 1.0 Protocol to
an equivalent MidiMessage. Accumulates SysEx packets into a single an equivalent MidiMessage. Accumulates SysEx packets into a single
MidiMessage, as appropriate. MidiMessage, as appropriate.
@ -91,7 +93,7 @@ public:
} }
} }
/* Converts from a Universal MIDI Packet to MIDI 1 bytestream format. /** Converts from a Universal MIDI Packet to MIDI 1 bytestream format.
This is only capable of converting a single Universal MIDI Packet to This is only capable of converting a single Universal MIDI Packet to
an equivalent bytestream MIDI message. This function cannot understand an equivalent bytestream MIDI message. This function cannot understand
@ -211,3 +213,5 @@ private:
} }
} }
#endif

View file

@ -20,12 +20,14 @@
============================================================================== ==============================================================================
*/ */
#ifndef DOXYGEN
namespace juce namespace juce
{ {
namespace universal_midi_packets namespace universal_midi_packets
{ {
/* /**
Translates a series of MIDI 1 Universal MIDI Packets to corresponding MIDI 2 Translates a series of MIDI 1 Universal MIDI Packets to corresponding MIDI 2
packets. packets.
@ -36,7 +38,7 @@ class Midi1ToMidi2DefaultTranslator
public: public:
Midi1ToMidi2DefaultTranslator() = default; Midi1ToMidi2DefaultTranslator() = default;
/* Converts MIDI 1 Universal MIDI Packets to corresponding MIDI 2 packets, /** Converts MIDI 1 Universal MIDI Packets to corresponding MIDI 2 packets,
calling `callback` with each converted packet. calling `callback` with each converted packet.
In some cases (such as RPN/NRPN messages) multiple MIDI 1 packets will In some cases (such as RPN/NRPN messages) multiple MIDI 1 packets will
@ -185,3 +187,5 @@ private:
} }
} }
#endif

View file

@ -20,19 +20,21 @@
============================================================================== ==============================================================================
*/ */
#ifndef DOXYGEN
namespace juce namespace juce
{ {
namespace universal_midi_packets namespace universal_midi_packets
{ {
/* The kinds of MIDI protocol that can be formatted into Universal MIDI Packets. */ /** The kinds of MIDI protocol that can be formatted into Universal MIDI Packets. */
enum class PacketProtocol enum class PacketProtocol
{ {
MIDI_1_0, MIDI_1_0,
MIDI_2_0, MIDI_2_0,
}; };
/* All kinds of MIDI protocol understood by JUCE. */ /** All kinds of MIDI protocol understood by JUCE. */
enum class MidiProtocol enum class MidiProtocol
{ {
bytestream, bytestream,
@ -42,3 +44,5 @@ enum class MidiProtocol
} }
} }
#endif

View file

@ -20,12 +20,14 @@
============================================================================== ==============================================================================
*/ */
#ifndef DOXYGEN
namespace juce namespace juce
{ {
namespace universal_midi_packets namespace universal_midi_packets
{ {
/* /**
A base class for classes which receive Universal MIDI Packets from an input. A base class for classes which receive Universal MIDI Packets from an input.
@tags{Audio} @tags{Audio}
@ -34,9 +36,11 @@ struct Receiver
{ {
virtual ~Receiver() noexcept = default; virtual ~Receiver() noexcept = default;
/* This will be called each time a new packet is ready for processing. */ /** This will be called each time a new packet is ready for processing. */
virtual void packetReceived (const View& packet, double time) = 0; virtual void packetReceived (const View& packet, double time) = 0;
}; };
} }
} }
#endif

View file

@ -20,12 +20,14 @@
============================================================================== ==============================================================================
*/ */
#ifndef DOXYGEN
namespace juce namespace juce
{ {
namespace universal_midi_packets namespace universal_midi_packets
{ {
/* /**
This struct acts as a single-file namespace for Univeral MIDI Packet This struct acts as a single-file namespace for Univeral MIDI Packet
functionality related to 7-bit SysEx. functionality related to 7-bit SysEx.
@ -33,7 +35,7 @@ namespace universal_midi_packets
*/ */
struct SysEx7 struct SysEx7
{ {
/* Returns the number of 64-bit packets required to hold a series of /** Returns the number of 64-bit packets required to hold a series of
SysEx bytes. SysEx bytes.
The number passed to this function should exclude the leading/trailing The number passed to this function should exclude the leading/trailing
@ -42,32 +44,34 @@ struct SysEx7
*/ */
static uint32_t getNumPacketsRequiredForDataSize (uint32_t); static uint32_t getNumPacketsRequiredForDataSize (uint32_t);
/* The different kinds of UMP SysEx-7 message. */ /** The different kinds of UMP SysEx-7 message. */
enum class Kind : uint8_t enum class Kind : uint8_t
{ {
/* The whole message fits in a single 2-word packet. */ /** The whole message fits in a single 2-word packet. */
complete = 0, complete = 0,
/* The packet begins a SysEx message that will continue in subsequent packets. */ /** The packet begins a SysEx message that will continue in subsequent packets. */
begin = 1, begin = 1,
/* The packet is a continuation of an ongoing SysEx message. */ /** The packet is a continuation of an ongoing SysEx message. */
continuation = 2, continuation = 2,
/* The packet terminates an ongoing SysEx message. */ /** The packet terminates an ongoing SysEx message. */
end = 3 end = 3
}; };
/* Holds the bytes from a single SysEx-7 packet. */ /** Holds the bytes from a single SysEx-7 packet. */
struct PacketBytes struct PacketBytes
{ {
std::array<uint8_t, 6> data; std::array<uint8_t, 6> data;
uint8_t size; uint8_t size;
}; };
/* Extracts the data bytes from a 64-bit data message. */ /** Extracts the data bytes from a 64-bit data message. */
static PacketBytes getDataBytes (const PacketX2& packet); static PacketBytes getDataBytes (const PacketX2& packet);
}; };
} }
} }
#endif

View file

@ -20,25 +20,27 @@
============================================================================== ==============================================================================
*/ */
#ifndef DOXYGEN
namespace juce namespace juce
{ {
namespace universal_midi_packets namespace universal_midi_packets
{ {
/* /**
Helpful types and functions for interacting with Universal MIDI Packets. Helpful types and functions for interacting with Universal MIDI Packets.
@tags{Audio} @tags{Audio}
*/ */
struct Utils struct Utils
{ {
/* Joins 4 bytes into a single 32-bit word. */ /** Joins 4 bytes into a single 32-bit word. */
static constexpr uint32_t bytesToWord (uint8_t a, uint8_t b, uint8_t c, uint8_t d) static constexpr uint32_t bytesToWord (uint8_t a, uint8_t b, uint8_t c, uint8_t d)
{ {
return uint32_t (a << 0x18 | b << 0x10 | c << 0x08 | d << 0x00); return uint32_t (a << 0x18 | b << 0x10 | c << 0x08 | d << 0x00);
} }
/* Returns the expected number of 32-bit words in a Universal MIDI Packet, given /** Returns the expected number of 32-bit words in a Universal MIDI Packet, given
the first word of the packet. the first word of the packet.
The result will be between 1 and 4 inclusive. The result will be between 1 and 4 inclusive.
@ -46,7 +48,7 @@ struct Utils
*/ */
static uint32_t getNumWordsForMessageType (uint32_t); static uint32_t getNumWordsForMessageType (uint32_t);
/* /**
Helper functions for setting/getting 4-bit ranges inside a 32-bit word. Helper functions for setting/getting 4-bit ranges inside a 32-bit word.
*/ */
template <size_t Index> template <size_t Index>
@ -65,7 +67,7 @@ struct Utils
} }
}; };
/* /**
Helper functions for setting/getting 8-bit ranges inside a 32-bit word. Helper functions for setting/getting 8-bit ranges inside a 32-bit word.
*/ */
template <size_t Index> template <size_t Index>
@ -84,7 +86,7 @@ struct Utils
} }
}; };
/* /**
Helper functions for setting/getting 16-bit ranges inside a 32-bit word. Helper functions for setting/getting 16-bit ranges inside a 32-bit word.
*/ */
template <size_t Index> template <size_t Index>
@ -111,3 +113,5 @@ struct Utils
} }
} }
#endif

View file

@ -20,12 +20,14 @@
============================================================================== ==============================================================================
*/ */
#ifndef DOXYGEN
namespace juce namespace juce
{ {
namespace universal_midi_packets namespace universal_midi_packets
{ {
/* /**
Points to a single Universal MIDI Packet. Points to a single Universal MIDI Packet.
The packet must be well-formed for member functions to work correctly. The packet must be well-formed for member functions to work correctly.
@ -43,41 +45,41 @@ namespace universal_midi_packets
class View class View
{ {
public: public:
/* Create an invalid view. */ /** Create an invalid view. */
View() noexcept = default; View() noexcept = default;
/* Create a view of the packet starting at address `d`. */ /** Create a view of the packet starting at address `d`. */
explicit View (const uint32_t* data) noexcept : ptr (data) {} explicit View (const uint32_t* data) noexcept : ptr (data) {}
/* Get a pointer to the first word in the Universal MIDI Packet currently /** Get a pointer to the first word in the Universal MIDI Packet currently
pointed-to by this view. pointed-to by this view.
*/ */
const uint32_t* data() const noexcept { return ptr; } const uint32_t* data() const noexcept { return ptr; }
/* Get the number of 32-words (between 1 and 4 inclusive) in the Universal /** Get the number of 32-words (between 1 and 4 inclusive) in the Universal
MIDI Packet currently pointed-to by this view. MIDI Packet currently pointed-to by this view.
*/ */
uint32_t size() const noexcept; uint32_t size() const noexcept;
/* Get a specific word from this packet. /** Get a specific word from this packet.
Passing an `index` that is greater than or equal to the result of `size` Passing an `index` that is greater than or equal to the result of `size`
will cause undefined behaviour. will cause undefined behaviour.
*/ */
const uint32_t& operator[] (size_t index) const noexcept { return ptr[index]; } const uint32_t& operator[] (size_t index) const noexcept { return ptr[index]; }
/* Get an iterator pointing to the first word in the packet. */ /** Get an iterator pointing to the first word in the packet. */
const uint32_t* begin() const noexcept { return ptr; } const uint32_t* begin() const noexcept { return ptr; }
const uint32_t* cbegin() const noexcept { return ptr; } const uint32_t* cbegin() const noexcept { return ptr; }
/* Get an iterator pointing one-past the last word in the packet. */ /** Get an iterator pointing one-past the last word in the packet. */
const uint32_t* end() const noexcept { return ptr + size(); } const uint32_t* end() const noexcept { return ptr + size(); }
const uint32_t* cend() const noexcept { return ptr + size(); } const uint32_t* cend() const noexcept { return ptr + size(); }
/* Return true if this view is pointing to the same address as another view. */ /** Return true if this view is pointing to the same address as another view. */
bool operator== (const View& other) const noexcept { return ptr == other.ptr; } bool operator== (const View& other) const noexcept { return ptr == other.ptr; }
/* Return false if this view is pointing to the same address as another view. */ /** Return false if this view is pointing to the same address as another view. */
bool operator!= (const View& other) const noexcept { return ! operator== (other); } bool operator!= (const View& other) const noexcept { return ! operator== (other); }
private: private:
@ -86,3 +88,5 @@ private:
} }
} }
#endif

View file

@ -20,12 +20,14 @@
============================================================================== ==============================================================================
*/ */
#ifndef DOXYGEN
namespace juce namespace juce
{ {
namespace universal_midi_packets namespace universal_midi_packets
{ {
/* /**
Holds a single Universal MIDI Packet. Holds a single Universal MIDI Packet.
@tags{Audio} @tags{Audio}
@ -187,3 +189,5 @@ using PacketX4 = Packet<4>;
} }
} }
#endif

View file

@ -20,12 +20,14 @@
============================================================================== ==============================================================================
*/ */
#ifndef DOXYGEN
namespace juce namespace juce
{ {
namespace universal_midi_packets namespace universal_midi_packets
{ {
/* /**
Holds a collection of Universal MIDI Packets. Holds a collection of Universal MIDI Packets.
Unlike MidiBuffer, this collection does not store any additional information Unlike MidiBuffer, this collection does not store any additional information
@ -39,7 +41,7 @@ namespace universal_midi_packets
class Packets class Packets
{ {
public: public:
/* Adds a single packet to the collection. /** Adds a single packet to the collection.
The View must be valid for this to work. If the view The View must be valid for this to work. If the view
points to a malformed message, or if the view points to a region points to a malformed message, or if the view points to a region
@ -53,24 +55,24 @@ public:
void add (const PacketX3& p) { addImpl (p); } void add (const PacketX3& p) { addImpl (p); }
void add (const PacketX4& p) { addImpl (p); } void add (const PacketX4& p) { addImpl (p); }
/* Pre-allocates space for at least `numWords` 32-bit words in this collection. */ /** Pre-allocates space for at least `numWords` 32-bit words in this collection. */
void reserve (size_t numWords) { storage.reserve (numWords); } void reserve (size_t numWords) { storage.reserve (numWords); }
/* Removes all previously-added packets from this collection. */ /** Removes all previously-added packets from this collection. */
void clear() { storage.clear(); } void clear() { storage.clear(); }
/* Gets an iterator pointing to the first packet in this collection. */ /** Gets an iterator pointing to the first packet in this collection. */
Iterator cbegin() const noexcept { return Iterator (data(), size()); } Iterator cbegin() const noexcept { return Iterator (data(), size()); }
Iterator begin() const noexcept { return cbegin(); } Iterator begin() const noexcept { return cbegin(); }
/* Gets an iterator pointing one-past the last packet in this collection. */ /** Gets an iterator pointing one-past the last packet in this collection. */
Iterator cend() const noexcept { return Iterator (data() + size(), 0); } Iterator cend() const noexcept { return Iterator (data() + size(), 0); }
Iterator end() const noexcept { return cend(); } Iterator end() const noexcept { return cend(); }
/* Gets a pointer to the contents of the collection as a range of raw 32-bit words. */ /** Gets a pointer to the contents of the collection as a range of raw 32-bit words. */
const uint32_t* data() const noexcept { return storage.data(); } const uint32_t* data() const noexcept { return storage.data(); }
/* Returns the number of uint32_t words in storage. /** Returns the number of uint32_t words in storage.
Note that this is likely to be larger than the number of packets Note that this is likely to be larger than the number of packets
currently being stored, as some packets span multiple words. currently being stored, as some packets span multiple words.
@ -90,3 +92,5 @@ private:
} }
} }
#endif

View file

@ -20,12 +20,14 @@
============================================================================== ==============================================================================
*/ */
#ifndef DOXYGEN
namespace juce namespace juce
{ {
namespace universal_midi_packets namespace universal_midi_packets
{ {
/* /**
A base class for classes which convert bytestream midi to other formats. A base class for classes which convert bytestream midi to other formats.
@tags{Audio} @tags{Audio}
@ -38,7 +40,7 @@ struct BytestreamInputHandler
virtual void pushMidiData (const void* data, int bytes, double time) = 0; virtual void pushMidiData (const void* data, int bytes, double time) = 0;
}; };
/* /**
Parses a continuous bytestream and emits complete MidiMessages whenever a full Parses a continuous bytestream and emits complete MidiMessages whenever a full
message is received. message is received.
@ -49,7 +51,7 @@ struct BytestreamToBytestreamHandler : public BytestreamInputHandler
BytestreamToBytestreamHandler (MidiInput& i, MidiInputCallback& c) BytestreamToBytestreamHandler (MidiInput& i, MidiInputCallback& c)
: input (i), callback (c), concatenator (2048) {} : input (i), callback (c), concatenator (2048) {}
/* /**
Provides an `operator()` which can create an input handler for a given Provides an `operator()` which can create an input handler for a given
MidiInput. MidiInput.
@ -87,7 +89,7 @@ struct BytestreamToBytestreamHandler : public BytestreamInputHandler
MidiDataConcatenator concatenator; MidiDataConcatenator concatenator;
}; };
/* /**
Parses a continuous MIDI 1.0 bytestream, and emits full messages in the requested Parses a continuous MIDI 1.0 bytestream, and emits full messages in the requested
UMP format. UMP format.
@ -98,7 +100,7 @@ struct BytestreamToUMPHandler : public BytestreamInputHandler
BytestreamToUMPHandler (PacketProtocol protocol, Receiver& c) BytestreamToUMPHandler (PacketProtocol protocol, Receiver& c)
: recipient (c), dispatcher (protocol, 2048) {} : recipient (c), dispatcher (protocol, 2048) {}
/* /**
Provides an `operator()` which can create an input handler for a given Provides an `operator()` which can create an input handler for a given
MidiInput. MidiInput.
@ -138,3 +140,5 @@ struct BytestreamToUMPHandler : public BytestreamInputHandler
} }
} }
#endif

View file

@ -20,12 +20,14 @@
============================================================================== ==============================================================================
*/ */
#ifndef DOXYGEN
namespace juce namespace juce
{ {
namespace universal_midi_packets namespace universal_midi_packets
{ {
/* /**
A base class for classes which convert Universal MIDI Packets to other A base class for classes which convert Universal MIDI Packets to other
formats. formats.
@ -39,7 +41,7 @@ struct U32InputHandler
virtual void pushMidiData (const uint32_t* begin, const uint32_t* end, double time) = 0; virtual void pushMidiData (const uint32_t* begin, const uint32_t* end, double time) = 0;
}; };
/* /**
Parses a continuous stream of U32 words and emits complete MidiMessages whenever a full Parses a continuous stream of U32 words and emits complete MidiMessages whenever a full
message is received. message is received.
@ -50,7 +52,7 @@ struct U32ToBytestreamHandler : public U32InputHandler
U32ToBytestreamHandler (MidiInput& i, MidiInputCallback& c) U32ToBytestreamHandler (MidiInput& i, MidiInputCallback& c)
: input (i), callback (c), dispatcher (2048) {} : input (i), callback (c), dispatcher (2048) {}
/* /**
Provides an `operator()` which can create an input handler for a given Provides an `operator()` which can create an input handler for a given
MidiInput. MidiInput.
@ -91,7 +93,7 @@ struct U32ToBytestreamHandler : public U32InputHandler
ToBytestreamDispatcher dispatcher; ToBytestreamDispatcher dispatcher;
}; };
/* /**
Parses a continuous stream of U32 words and emits full messages in the requested Parses a continuous stream of U32 words and emits full messages in the requested
UMP format. UMP format.
@ -102,7 +104,7 @@ struct U32ToUMPHandler : public U32InputHandler
U32ToUMPHandler (PacketProtocol protocol, Receiver& c) U32ToUMPHandler (PacketProtocol protocol, Receiver& c)
: recipient (c), converter (protocol) {} : recipient (c), converter (protocol) {}
/* /**
Provides an `operator()` which can create an input handler for a given Provides an `operator()` which can create an input handler for a given
MidiInput. MidiInput.
@ -149,3 +151,5 @@ struct U32ToUMPHandler : public U32InputHandler
} }
} }
#endif