25namespace juce::universal_midi_packets
33 struct ToUMP1Converter
35 template <
typename Fn>
36 void convert (
const BytestreamMidiView& m,
Fn&& fn)
41 template <
typename Fn>
54 struct ToUMP2Converter
56 template <
typename Fn>
57 void convert (
const BytestreamMidiView& m,
Fn&& fn)
59 Conversion::toMidi1 (m, [&] (
const View& v)
61 translator.dispatch (v, fn);
65 template <
typename Fn>
76 Midi1ToMidi2DefaultTranslator translator;
87 class GenericUMPConverter
89 template <
typename This,
typename... Args>
90 static void visit (This& t, Args&&... args)
92 if (t.mode == PacketProtocol::MIDI_1_0)
99 explicit GenericUMPConverter (PacketProtocol m)
107 template <
typename Converter,
typename Fn>
108 static void convertImpl (Converter& converter,
const BytestreamMidiView& m,
Fn&& fn)
113 template <
typename Converter,
typename Fn>
114 static void convertImpl (Converter& converter,
const View& m,
Fn&& fn)
119 template <
typename Converter,
typename Fn>
120 static void convertImpl (Converter& converter, Iterator b, Iterator e,
Fn&& fn)
124 convertImpl (converter, v, fn);
128 template <
typename Fn>
129 void convert (
const BytestreamMidiView& m,
Fn&& fn)
134 template <
typename Fn>
140 template <
typename Fn>
141 void convert (Iterator begin, Iterator end,
Fn&& fn)
146 PacketProtocol getProtocol() const noexcept {
return mode; }
150 const PacketProtocol mode{};
159 struct ToBytestreamConverter
161 explicit ToBytestreamConverter (
int storageSize)
162 : translator (storageSize) {}
164 template <
typename Fn>
165 void convert (
const MidiMessage& m,
Fn&& fn)
170 template <
typename Fn>
171 void convert (
const View& v,
double time,
Fn&& fn)
173 Conversion::midi2ToMidi1DefaultTranslation (v, [&] (
const View& midi1)
175 translator.dispatch (midi1, time, fn);
179 void reset() { translator.reset(); }
181 Midi1ToBytestreamTranslator translator;
std::u16string convert(const std::string &utf8Str)
convert an UTF-8 string to an UTF-16 string