Skip to content

Commit d78052b

Browse files
committed
Doxygen comments.
1 parent 51bb12c commit d78052b

File tree

1 file changed

+64
-5
lines changed

1 file changed

+64
-5
lines changed

include/midi2/ump_to_midi1.hpp

+64-5
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,32 @@
2222

2323
namespace midi2 {
2424

25+
/// \brief Converts MIDI 2.0 UMP (Universal MIDI Packet) messages to MIDI 1.0 UMP.
26+
///
27+
/// This class provides functionality to convert UMP messages to MIDI 1.0 messages.
28+
/// It maintains a context that includes a cache for per-note controllers and a FIFO
29+
/// for output messages.
2530
class ump_to_midi1 {
2631
public:
32+
/// \brief The type of input UMP message.
2733
using input_type = std::uint32_t;
34+
/// \brief The type of output MIDI 1.0 message.
2835
using output_type = std::uint32_t;
2936

30-
/// Checks if the output is empty
37+
/// \brief Checks if the output is empty
38+
/// \return True if the output FIFO is empty, false otherwise.
3139
[[nodiscard]] constexpr bool empty() const { return context_.output.empty(); }
40+
41+
/// \brief Pops the front message from the output FIFO.
42+
/// \return The first message in the output FIFO.
43+
/// \note This method asserts that the output FIFO is not empty.
3244
[[nodiscard]] constexpr output_type pop() {
3345
assert(!empty());
3446
return context_.output.pop_front();
3547
}
3648

49+
/// \brief Pushes an input UMP message for processing.
50+
/// \param ump The input UMP message.
3751
void push(input_type const ump) { p_.process_ump(ump); }
3852

3953
private:
@@ -47,11 +61,16 @@ class ump_to_midi1 {
4761
});
4862
}
4963

64+
/// \brief Represents a key for the per-note controller cache.
5065
struct pn_cache_key {
5166
constexpr bool operator==(pn_cache_key const &) const noexcept = default;
5267

68+
/// The group number
5369
std::uint8_t group : 4 = 0;
70+
/// The channel number
5471
std::uint8_t channel : 4 = 0;
72+
/// true if the controller is RPN (Registered Parameter Number), false if it represents an NRPN (Non-Registered
73+
/// Parameter Number).
5574
bool is_rpn = false;
5675
};
5776

@@ -123,16 +142,43 @@ class ump_to_midi1 {
123142
}
124143
static constexpr void sysex7_end(context_type *const ctxt, ump::data64::sysex7_end const &in) { ctxt->push(in); }
125144
};
126-
// m2cvm messages are translated to m1cvm messages.
145+
146+
/// \brief Translated MIDI 2.0 Channel Voice Messages (m2cvm) and translates them to m1cvm messages.
127147
class m2cvm {
128148
public:
149+
/// \brief Translates a MIDI 2.0 note off message to a MIDI 1.0 note off message.
150+
/// \param ctxt The context for the conversion process.
151+
/// \param in The input MIDI 2.0 note off message.
129152
static void note_off(context_type *ctxt, ump::m2cvm::note_off const &in);
153+
154+
/// \brief Translates a MIDI 2.0 note on message to a MIDI 1.0 note on message.
155+
/// \param ctxt The context for the conversion process.
156+
/// \param in The input MIDI 2.0 note on message.
130157
static void note_on(context_type *ctxt, ump::m2cvm::note_on const &in);
158+
159+
/// \brief Translates a MIDI 2.0 poly pressure message to a MIDI 1.0 poly pressure message.
160+
/// \param ctxt The context for the conversion process.
161+
/// \param in The input MIDI 2.0 poly pressure message.
131162
static void poly_pressure(context_type *ctxt, ump::m2cvm::poly_pressure const &in);
163+
164+
/// \brief Translates a MIDI 2.0 program change message to a MIDI 1.0 program change message.
165+
/// \param ctxt The context for the conversion process.
166+
/// \param in The input MIDI 2.0 program change message.
132167
static void program_change(context_type *ctxt, ump::m2cvm::program_change const &in);
133-
static void channel_pressure(context_type *ctxt, ump::m2cvm::channel_pressure const &);
134168

169+
/// \brief Translates a MIDI 2.0 channel pressure message to a MIDI 1.0 channel pressure message.
170+
/// \param ctxt The context for the conversion process.
171+
/// \param in The input MIDI 2.0 channel pressure message.
172+
static void channel_pressure(context_type *ctxt, ump::m2cvm::channel_pressure const &in);
173+
174+
/// \brief Translates a MIDI 2.0 RPN controller message to a MIDI 1.0 controller message.
175+
/// \param ctxt The context for the conversion process.
176+
/// \param in The input MIDI 2.0 RPN controller message.
135177
static void rpn_controller(context_type *ctxt, ump::m2cvm::rpn_controller const &in);
178+
179+
/// \brief Translates a MIDI 2.0 NRPN controller message to a MIDI 1.0 controller message.
180+
/// \param ctxt The context for the conversion process.
181+
/// \param in The input MIDI 2.0 NRPN controller message.
136182
static void nrpn_controller(context_type *ctxt, ump::m2cvm::nrpn_controller const &in);
137183

138184
static constexpr void rpn_per_note_controller(context_type const *,
@@ -154,14 +200,27 @@ class ump_to_midi1 {
154200
static constexpr void per_note_management(context_type const *, ump::m2cvm::per_note_management const &) {
155201
// do nothing: cannot be translated to MIDI 1
156202
}
157-
static void control_change(context_type *ctxt, ump::m2cvm::control_change const &);
158-
static void pitch_bend(context_type *ctxt, ump::m2cvm::pitch_bend const &);
203+
204+
/// \brief Translates a MIDI 2.0 control change message to a MIDI 1.0 control change message.
205+
/// \param ctxt The context for the conversion process.
206+
/// \param in The input MIDI 2.0 control change message.
207+
static void control_change(context_type *ctxt, ump::m2cvm::control_change const &in);
208+
209+
/// @brief Translates a MIDI 2.0 pitch bend message to a MIDI 1.0 pitch bend message.
210+
/// @param ctxt The context for the conversion process.
211+
/// @param in The input MIDI 2.0 pitch bend message.
212+
static void pitch_bend(context_type *ctxt, ump::m2cvm::pitch_bend const &in);
159213

160214
static constexpr void per_note_pitch_bend(context_type const *, ump::m2cvm::per_note_pitch_bend const &) {
161215
// do nothing: cannot be translated to MIDI 1
162216
}
163217

164218
private:
219+
/// \brief Handles per-note controller messages.
220+
/// \param ctxt The context for the conversion process.
221+
/// \param key The key for the per-note controller cache.
222+
/// \param controller_number The controller number.
223+
/// \param value The value of the controller.
165224
static void pn_message(context_type *ctxt, context_type::pn_cache_key const &key,
166225
std::pair<std::uint8_t, std::uint8_t> const &controller_number, std::uint32_t value);
167226
};

0 commit comments

Comments
 (0)