mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
CoreMidi: Never convert messages to MIDI 2.0 protocol
This commit is contained in:
parent
a24be991fa
commit
fd69d347b4
2 changed files with 54 additions and 63 deletions
|
|
@ -88,6 +88,15 @@ namespace universal_midi_packets
|
|||
*/
|
||||
class GenericUMPConverter
|
||||
{
|
||||
template <typename This, typename... Args>
|
||||
static void visit (This& t, Args&&... args)
|
||||
{
|
||||
if (t.mode == PacketProtocol::MIDI_1_0)
|
||||
convertImpl (std::get<0> (t.converters), std::forward<Args> (args)...);
|
||||
else
|
||||
convertImpl (std::get<1> (t.converters), std::forward<Args> (args)...);
|
||||
}
|
||||
|
||||
public:
|
||||
explicit GenericUMPConverter (PacketProtocol m)
|
||||
: mode (m) {}
|
||||
|
|
@ -97,33 +106,43 @@ namespace universal_midi_packets
|
|||
std::get<1> (converters).reset();
|
||||
}
|
||||
|
||||
template <typename Converter, typename Fn>
|
||||
static void convertImpl (Converter& converter, const BytestreamMidiView& m, Fn&& fn)
|
||||
{
|
||||
converter.convert (m, std::forward<Fn> (fn));
|
||||
}
|
||||
|
||||
template <typename Converter, typename Fn>
|
||||
static void convertImpl (Converter& converter, const View& m, Fn&& fn)
|
||||
{
|
||||
converter.convert (m, std::forward<Fn> (fn));
|
||||
}
|
||||
|
||||
template <typename Converter, typename Fn>
|
||||
static void convertImpl (Converter& converter, Iterator b, Iterator e, Fn&& fn)
|
||||
{
|
||||
std::for_each (b, e, [&] (const auto& v)
|
||||
{
|
||||
convertImpl (converter, v, fn);
|
||||
});
|
||||
}
|
||||
|
||||
template <typename Fn>
|
||||
void convert (const BytestreamMidiView& m, Fn&& fn)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case PacketProtocol::MIDI_1_0: return std::get<0> (converters).convert (m, std::forward<Fn> (fn));
|
||||
case PacketProtocol::MIDI_2_0: return std::get<1> (converters).convert (m, std::forward<Fn> (fn));
|
||||
}
|
||||
visit (*this, m, std::forward<Fn> (fn));
|
||||
}
|
||||
|
||||
template <typename Fn>
|
||||
void convert (const View& v, Fn&& fn)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case PacketProtocol::MIDI_1_0: return std::get<0> (converters).convert (v, std::forward<Fn> (fn));
|
||||
case PacketProtocol::MIDI_2_0: return std::get<1> (converters).convert (v, std::forward<Fn> (fn));
|
||||
}
|
||||
visit (*this, v, std::forward<Fn> (fn));
|
||||
}
|
||||
|
||||
template <typename Fn>
|
||||
void convert (Iterator begin, Iterator end, Fn&& fn)
|
||||
{
|
||||
std::for_each (begin, end, [&] (const View& v)
|
||||
{
|
||||
convert (v, fn);
|
||||
});
|
||||
visit (*this, begin, end, std::forward<Fn> (fn));
|
||||
}
|
||||
|
||||
PacketProtocol getProtocol() const noexcept { return mode; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue