LMMS
Loading...
Searching...
No Matches
juce_UMPConverters.h
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23#ifndef DOXYGEN
24
25namespace juce
26{
28{
36 {
37 template <typename Fn>
38 void convert (const MidiMessage& m, Fn&& fn)
39 {
40 Conversion::toMidi1 (m, std::forward<Fn> (fn));
41 }
42
43 template <typename Fn>
44 void convert (const View& v, Fn&& fn)
45 {
47 }
48 };
49
57 {
58 template <typename Fn>
59 void convert (const MidiMessage& m, Fn&& fn)
60 {
61 Conversion::toMidi1 (m, [&] (const View& v)
62 {
63 translator.dispatch (v, fn);
64 });
65 }
66
67 template <typename Fn>
68 void convert (const View& v, Fn&& fn)
69 {
70 translator.dispatch (v, std::forward<Fn> (fn));
71 }
72
73 void reset()
74 {
75 translator.reset();
76 }
77
79 };
80
90 {
91 public:
94
95 void reset()
96 {
97 std::get<1> (converters).reset();
98 }
99
100 template <typename Fn>
101 void convert (const MidiMessage& m, Fn&& fn)
102 {
103 switch (mode)
104 {
105 case PacketProtocol::MIDI_1_0: return std::get<0> (converters).convert (m, std::forward<Fn> (fn));
106 case PacketProtocol::MIDI_2_0: return std::get<1> (converters).convert (m, std::forward<Fn> (fn));
107 }
108 }
109
110 template <typename Fn>
111 void convert (const View& v, Fn&& fn)
112 {
113 switch (mode)
114 {
115 case PacketProtocol::MIDI_1_0: return std::get<0> (converters).convert (v, std::forward<Fn> (fn));
116 case PacketProtocol::MIDI_2_0: return std::get<1> (converters).convert (v, std::forward<Fn> (fn));
117 }
118 }
119
120 template <typename Fn>
122 {
123 std::for_each (begin, end, [&] (const View& v)
124 {
125 convert (v, fn);
126 });
127 }
128
130
131 private:
132 std::tuple<ToUMP1Converter, ToUMP2Converter> converters;
134 };
135
143 {
144 explicit ToBytestreamConverter (int storageSize)
145 : translator (storageSize) {}
146
147 template <typename Fn>
148 void convert (const MidiMessage& m, Fn&& fn)
149 {
150 fn (m);
151 }
152
153 template <typename Fn>
154 void convert (const View& v, double time, Fn&& fn)
155 {
157 {
158 translator.dispatch (midi1, time, fn);
159 });
160 }
161
162 void reset() { translator.reset(); }
163
165 };
166}
167}
168
169#endif
#define noexcept
Definition DistrhoDefines.h:72
Definition juce_MidiMessage.h:35
PacketProtocol getProtocol() const noexcept
Definition juce_UMPConverters.h:129
GenericUMPConverter(PacketProtocol m)
Definition juce_UMPConverters.h:92
void convert(Iterator begin, Iterator end, Fn &&fn)
Definition juce_UMPConverters.h:121
void reset()
Definition juce_UMPConverters.h:95
void convert(const View &v, Fn &&fn)
Definition juce_UMPConverters.h:111
std::tuple< ToUMP1Converter, ToUMP2Converter > converters
Definition juce_UMPConverters.h:132
const PacketProtocol mode
Definition juce_UMPConverters.h:133
void convert(const MidiMessage &m, Fn &&fn)
Definition juce_UMPConverters.h:101
Definition juce_UMPIterator.h:40
Definition juce_UMPMidi1ToBytestreamTranslator.h:37
Definition juce_UMPMidi1ToMidi2DefaultTranslator.h:37
Definition juce_UMPView.h:46
unsigned * m
Definition inflate.c:1559
unsigned v[N_MAX]
Definition inflate.c:1584
Definition juce_UMP_test.cpp:26
PacketProtocol
Definition juce_UMPProtocols.h:32
@ MIDI_1_0
Definition juce_UMPProtocols.h:33
@ MIDI_2_0
Definition juce_UMPProtocols.h:34
Definition carla_juce.cpp:31
RangedDirectoryIterator end(const RangedDirectoryIterator &)
Definition juce_RangedDirectoryIterator.h:184
RangedDirectoryIterator begin(const RangedDirectoryIterator &it)
Definition juce_RangedDirectoryIterator.h:179
static void midi2ToMidi1DefaultTranslation(const View &v, Callback &&callback)
Definition juce_UMPConversion.h:190
static void toMidi1(const MidiMessage &m, PacketCallbackFunction &&callback)
Definition juce_UMPConversion.h:43
void reset()
Definition juce_UMPConverters.h:162
Midi1ToBytestreamTranslator translator
Definition juce_UMPConverters.h:164
void convert(const View &v, double time, Fn &&fn)
Definition juce_UMPConverters.h:154
void convert(const MidiMessage &m, Fn &&fn)
Definition juce_UMPConverters.h:148
ToBytestreamConverter(int storageSize)
Definition juce_UMPConverters.h:144
Definition juce_UMPConverters.h:36
void convert(const MidiMessage &m, Fn &&fn)
Definition juce_UMPConverters.h:38
void convert(const View &v, Fn &&fn)
Definition juce_UMPConverters.h:44
Definition juce_UMPConverters.h:57
void convert(const MidiMessage &m, Fn &&fn)
Definition juce_UMPConverters.h:59
void reset()
Definition juce_UMPConverters.h:73
void convert(const View &v, Fn &&fn)
Definition juce_UMPConverters.h:68
Midi1ToMidi2DefaultTranslator translator
Definition juce_UMPConverters.h:78
const char const char const char const char char * fn
Definition swell-functions.h:168
#define const
Definition zconf.h:137