адаптация s13bby/osc под vst и gui. (вайбкод)

вайбкод потому что мне в моменте стало понятно. что проще было сразу писать на фреймворке JUCE, чем адаптировать консольное приложение на MiniAudio.
обновляться данный репозиторий не будет. СmakeLists адаптирован онли под linux.
This commit is contained in:
2026-11-20 14:52:33 +06:00
parent 8384123f87
commit b0a75e98db
10387 changed files with 4025195 additions and 0 deletions
@@ -0,0 +1,49 @@
/*
==============================================================================
This file is part of the JUCE framework.
Copyright (c) Raw Material Software Limited
JUCE is an open source framework subject to commercial or open source
licensing.
By downloading, installing, or using the JUCE framework, or combining the
JUCE framework with any other source code, object code, content or any other
copyrightable work, you agree to the terms of the JUCE End User Licence
Agreement, and all incorporated terms including the JUCE Privacy Policy and
the JUCE Website Terms of Service, as applicable, which will bind you. If you
do not agree to the terms of these agreements, we will not license the JUCE
framework to you, and you must discontinue the installation or download
process and cease use of the JUCE framework.
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
Or:
You may also use this code under the terms of the AGPLv3:
https://www.gnu.org/licenses/agpl-3.0.en.html
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
namespace juce::universal_midi_packets
{
bool Block::operator== (const Block& other) const
{
const auto tie = [] (auto& x) { return std::tuple (x.info, x.name); };
return tie (*this) == tie (other);
}
bool Block::operator!= (const Block& other) const
{
return ! operator== (other);
}
}
@@ -0,0 +1,151 @@
/*
==============================================================================
This file is part of the JUCE framework.
Copyright (c) Raw Material Software Limited
JUCE is an open source framework subject to commercial or open source
licensing.
By downloading, installing, or using the JUCE framework, or combining the
JUCE framework with any other source code, object code, content or any other
copyrightable work, you agree to the terms of the JUCE End User Licence
Agreement, and all incorporated terms including the JUCE Privacy Policy and
the JUCE Website Terms of Service, as applicable, which will bind you. If you
do not agree to the terms of these agreements, we will not license the JUCE
framework to you, and you must discontinue the installation or download
process and cease use of the JUCE framework.
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
Or:
You may also use this code under the terms of the AGPLv3:
https://www.gnu.org/licenses/agpl-3.0.en.html
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
namespace juce::universal_midi_packets
{
//==============================================================================
/**
Represents a Function Block (FB) or Group Terminal Block (GTB).
GTBs are only available in USB MIDI, so devices on non-USB transports will not expose GTB
information. In the case that a device only exposes GTBs and not FBs, default values will
be used for any fields that are unavailable in the GTB definition.
@see BlockInfo
@tags{Audio}
*/
class Block
{
public:
Block() = default;
[[nodiscard]] Block withName (const String& x) const { return withMember (*this, &Block::name, x); }
[[nodiscard]] Block withFirstGroup (uint8_t x) const { return withMember (*this, &Block::info, info.withFirstGroup (x)); }
[[nodiscard]] Block withNumGroups (uint8_t x) const { return withMember (*this, &Block::info, info.withNumGroups (x)); }
[[nodiscard]] Block withMaxSysex8Streams (uint8_t x) const { return withMember (*this, &Block::info, info.withMaxSysex8Streams (x)); }
[[nodiscard]] Block withEnabled (bool x = true) const { return withMember (*this, &Block::info, info.withEnabled (x)); }
[[nodiscard]] Block withUiHint (BlockUiHint x) const
{
return withMember (*this, &Block::info, info.withUiHint (x));
}
[[nodiscard]] Block withMIDI1ProxyKind (BlockMIDI1ProxyKind x) const
{
return withMember (*this, &Block::info, info.withMIDI1ProxyKind (x));
}
[[nodiscard]] Block withDirection (BlockDirection x) const
{
return withMember (*this, &Block::info, info.withDirection (x));
}
/** The name of the block, if any. */
String getName() const { return name; }
/** All info relating to this block. */
BlockInfo getInfo() const { return info; }
/** In the range 0x0 to 0xF inclusive. */
uint8_t getFirstGroup() const
{
return info.getFirstGroup();
}
/** In the range 0x01 to 0x10 inclusive. */
uint8_t getNumGroups() const
{
return info.getNumGroups();
}
/** The number of simultaneous Sysex8 streams that are supported. */
uint8_t getMaxSysex8Streams() const
{
return info.getMaxSysex8Streams();
}
/** Some blocks may support bidirectional communication (e.g. for CI) but function predominantly
as a sender or receiver. The direction returned here is a hint to the user that doesn't
necessarily reflect the hardware capabilities.
*/
BlockUiHint getUiHint() const
{
return info.getUiHint();
}
/** If this block is a proxy for a MIDI 1.0 stream, describes the capabilities of that stream. */
BlockMIDI1ProxyKind getMIDI1ProxyKind() const
{
return info.getMIDI1ProxyKind();
}
/** Returns the message transmission directions that are supported by this block.
Use this to determine block capabilities.
For information that will be displayed to the user, prefer getUIHint().
*/
BlockDirection getDirection() const
{
return info.getDirection();
}
/** True if this block is enabled. */
bool isEnabled() const
{
return info.isEnabled();
}
/** True if the names of the two blocks match. */
bool nameMatches (const Block& other) const
{
return name == other.name;
}
/** True if the BlockInfo of the two blocks match. */
bool infoMatches (const Block& other) const
{
return info == other.info;
}
bool operator== (const Block& other) const;
bool operator!= (const Block& other) const;
private:
BlockInfo info;
String name;
};
}
@@ -0,0 +1,60 @@
/*
==============================================================================
This file is part of the JUCE framework.
Copyright (c) Raw Material Software Limited
JUCE is an open source framework subject to commercial or open source
licensing.
By downloading, installing, or using the JUCE framework, or combining the
JUCE framework with any other source code, object code, content or any other
copyrightable work, you agree to the terms of the JUCE End User Licence
Agreement, and all incorporated terms including the JUCE Privacy Policy and
the JUCE Website Terms of Service, as applicable, which will bind you. If you
do not agree to the terms of these agreements, we will not license the JUCE
framework to you, and you must discontinue the installation or download
process and cease use of the JUCE framework.
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
Or:
You may also use this code under the terms of the AGPLv3:
https://www.gnu.org/licenses/agpl-3.0.en.html
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
namespace juce::universal_midi_packets
{
//==============================================================================
/**
An interface class for entities that are interested in disconnection notifications.
@tags{Audio}
*/
struct JUCE_API DisconnectionListener
{
DisconnectionListener() = default;
DisconnectionListener (const DisconnectionListener&) = default;
DisconnectionListener (DisconnectionListener&&) noexcept = default;
DisconnectionListener& operator= (const DisconnectionListener&) = default;
DisconnectionListener& operator= (DisconnectionListener&&) noexcept = default;
virtual ~DisconnectionListener() = default;
/** Called to notify that the system has destroyed/disconnected a resource. */
virtual void disconnected() = 0;
};
}
@@ -0,0 +1,51 @@
/*
==============================================================================
This file is part of the JUCE framework.
Copyright (c) Raw Material Software Limited
JUCE is an open source framework subject to commercial or open source
licensing.
By downloading, installing, or using the JUCE framework, or combining the
JUCE framework with any other source code, object code, content or any other
copyrightable work, you agree to the terms of the JUCE End User Licence
Agreement, and all incorporated terms including the JUCE Privacy Policy and
the JUCE Website Terms of Service, as applicable, which will bind you. If you
do not agree to the terms of these agreements, we will not license the JUCE
framework to you, and you must discontinue the installation or download
process and cease use of the JUCE framework.
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
Or:
You may also use this code under the terms of the AGPLv3:
https://www.gnu.org/licenses/agpl-3.0.en.html
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
namespace juce::universal_midi_packets
{
bool Endpoint::operator== (const Endpoint& other) const
{
const auto selfBlocks = getBlocks();
const auto otherBlocks = other.getBlocks();
return std::equal (selfBlocks.begin(), selfBlocks.end(), otherBlocks.begin(), otherBlocks.end())
&& other.name == name
&& other.productInstanceId == productInstanceId
&& other.endpointInfo == endpointInfo
&& other.deviceInfo == deviceInfo
&& other.streamConfig == streamConfig;
}
}
@@ -0,0 +1,190 @@
/*
==============================================================================
This file is part of the JUCE framework.
Copyright (c) Raw Material Software Limited
JUCE is an open source framework subject to commercial or open source
licensing.
By downloading, installing, or using the JUCE framework, or combining the
JUCE framework with any other source code, object code, content or any other
copyrightable work, you agree to the terms of the JUCE End User Licence
Agreement, and all incorporated terms including the JUCE Privacy Policy and
the JUCE Website Terms of Service, as applicable, which will bind you. If you
do not agree to the terms of these agreements, we will not license the JUCE
framework to you, and you must discontinue the installation or download
process and cease use of the JUCE framework.
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
Or:
You may also use this code under the terms of the AGPLv3:
https://www.gnu.org/licenses/agpl-3.0.en.html
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
namespace juce::universal_midi_packets
{
//==============================================================================
/**
Represents a single MIDI endpoint, which may have up to one input and up to one output.
An Endpoint object just holds a snapshot of the physical endpoint's last known state at the
point when the Endpoint instance was created.
Instead of storing Endpoint instances, it's a better idea to store an EndpointId, and to call
Endpoints::getEndpoint() to get an up-to-date snapshot.
To connect to an endpoint, use Session::connectInput() or Session::connectOutput() to create
a connection in the context of a particular session.
@tags{Audio}
*/
class Endpoint
{
public:
Endpoint() = default;
[[nodiscard]] Endpoint withName (String x) const { return withMember (*this, &Endpoint::name, x); }
[[nodiscard]] Endpoint withProtocol (std::optional<PacketProtocol> x) const { return withMember (*this, &Endpoint::streamConfig, StreamConfigFlags ((streamConfig & ~maskProtocol) | asFlags (x))); }
[[nodiscard]] Endpoint withDeviceInfo (DeviceInfo x) const { return withMember (*this, &Endpoint::deviceInfo, std::move (x)); }
[[nodiscard]] Endpoint withProductInstanceId (String x) const { return withMember (*this, &Endpoint::productInstanceId, std::move (x)); }
[[nodiscard]] Endpoint withUMPVersion (uint8_t major, uint8_t minor) const { return withMember (*this, &Endpoint::endpointInfo, endpointInfo.withVersion (major, minor)); }
[[nodiscard]] Endpoint withStaticBlocks (bool x = true) const { return withMember (*this, &Endpoint::endpointInfo, endpointInfo.withStaticFunctionBlocks (x)); }
[[nodiscard]] Endpoint withMidi1Support (bool x = true) const { return withMember (*this, &Endpoint::endpointInfo, endpointInfo.withMidi1Support (x)); }
[[nodiscard]] Endpoint withMidi2Support (bool x = true) const { return withMember (*this, &Endpoint::endpointInfo, endpointInfo.withMidi2Support (x)); }
[[nodiscard]] Endpoint withReceiveJRSupport (bool x = true) const { return withMember (*this, &Endpoint::endpointInfo, endpointInfo.withReceiveJRSupport (x)); }
[[nodiscard]] Endpoint withTransmitJRSupport (bool x = true) const { return withMember (*this, &Endpoint::endpointInfo, endpointInfo.withTransmitJRSupport (x)); }
[[nodiscard]] Endpoint withReceiveJREnabled (bool x = true) const { return withMember (*this, &Endpoint::streamConfig, StreamConfigFlags (x ? (streamConfig | maskRxjr) : (streamConfig & ~maskRxjr))); }
[[nodiscard]] Endpoint withTransmitJREnabled (bool x = true) const { return withMember (*this, &Endpoint::streamConfig, StreamConfigFlags (x ? (streamConfig | maskTxjr) : (streamConfig & ~maskTxjr))); }
/** The block index is used to uniquely identify the block, so be sure to always declare
blocks in a consistent order.
*/
[[nodiscard]] Endpoint withBlocks (Span<const Block> x) const
{
auto result = withNumBlocks (x.size());
std::copy (x.begin(), x.end(), result.blocks.begin());
return result;
}
/** The number of blocks on this endpoint. */
[[nodiscard]] Endpoint withNumBlocks (size_t x) const
{
jassert (x <= blocks.size());
auto result = *this;
result.endpointInfo = result.endpointInfo.withNumFunctionBlocks ((uint8_t) std::min (blocks.size(), x));
return result;
}
/** Returns the name of this endpoint. */
String getName() const { return name; }
/** Returns properties of the device that owns the endpoint. */
DeviceInfo getDeviceInfo() const
{
return deviceInfo;
}
/** Returns the product instance ID if available, or an empty string otherwise.
The product instance ID should match the device serial number, and should be unique per
manufacturer, family, and model.
This ID can be used to distinguish between separate devices that have the same DeviceInfo.
It can also be used to determine whether separate endpoints are associated with the same
device.
*/
String getProductInstanceId() const
{
return productInstanceId;
}
/** The protocol that the endpoint currently expects to send and receive; endpoints are allowed
to switch protocols, so this won't always return the same value.
May return nullopt if the protocol is unknown, perhaps because negotiation has not taken place.
*/
std::optional<PacketProtocol> getProtocol() const
{
switch (streamConfig & maskProtocol)
{
case 1: return PacketProtocol::MIDI_1_0;
case 2: return PacketProtocol::MIDI_2_0;
}
return {};
}
uint8_t getUMPVersionMajor() const { return endpointInfo.getVersionMajor(); }
uint8_t getUMPVersionMinor() const { return endpointInfo.getVersionMinor(); }
bool hasStaticBlocks() const { return endpointInfo.hasStaticFunctionBlocks(); }
bool hasMidi1Support() const { return endpointInfo.hasMidi1Support(); }
bool hasMidi2Support() const { return endpointInfo.hasMidi2Support(); }
bool hasReceiveJRSupport() const { return endpointInfo.hasReceiveJRSupport(); }
bool hasTransmitJRSupport() const { return endpointInfo.hasTransmitJRSupport(); }
bool isReceiveJREnabled() const { return streamConfig & maskRxjr; }
bool isTransmitJREnabled() const { return streamConfig & maskTxjr; }
/** There can be a maximum of 32 blocks.
This may return an empty span if the endpoint has neither function blocks nor group terminal
blocks.
*/
Span<const Block> getBlocks() const&
{
return { blocks.data(), endpointInfo.getNumFunctionBlocks() };
}
/** Returns a mutable view over the blocks in this endpoint. */
Span<Block> getBlocks() &
{
return { blocks.data(), endpointInfo.getNumFunctionBlocks() };
}
// These are deleted because it's probably not a good idea to create a span over a temporary
Span<const Block> getBlocks() const&& = delete;
Span<Block> getBlocks() && = delete;
bool operator== (const Endpoint&) const;
bool operator!= (const Endpoint& other) { return ! operator== (other); }
private:
enum StreamConfigFlags : uint16_t
{
maskProtocol = 0x00ff,
maskTxjr = 0x0100,
maskRxjr = 0x0200,
};
static StreamConfigFlags asFlags (std::optional<PacketProtocol> p)
{
if (! p.has_value())
return {};
switch (*p)
{
case PacketProtocol::MIDI_1_0: return StreamConfigFlags (1);
case PacketProtocol::MIDI_2_0: return StreamConfigFlags (2);
}
return {};
}
std::array<Block, 32> blocks;
String name;
String productInstanceId;
EndpointInfo endpointInfo;
DeviceInfo deviceInfo;
StreamConfigFlags streamConfig{};
};
}
@@ -0,0 +1,46 @@
/*
==============================================================================
This file is part of the JUCE framework.
Copyright (c) Raw Material Software Limited
JUCE is an open source framework subject to commercial or open source
licensing.
By downloading, installing, or using the JUCE framework, or combining the
JUCE framework with any other source code, object code, content or any other
copyrightable work, you agree to the terms of the JUCE End User Licence
Agreement, and all incorporated terms including the JUCE Privacy Policy and
the JUCE Website Terms of Service, as applicable, which will bind you. If you
do not agree to the terms of these agreements, we will not license the JUCE
framework to you, and you must discontinue the installation or download
process and cease use of the JUCE framework.
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
Or:
You may also use this code under the terms of the AGPLv3:
https://www.gnu.org/licenses/agpl-3.0.en.html
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
namespace juce::universal_midi_packets
{
auto EndpointId::tie() const { return std::tuple (src, dst); }
bool EndpointId::operator== (const EndpointId& x) const { return tie() == x.tie(); }
bool EndpointId::operator!= (const EndpointId& x) const { return tie() != x.tie(); }
bool EndpointId::operator< (const EndpointId& x) const { return tie() < x.tie(); }
bool EndpointId::operator<= (const EndpointId& x) const { return tie() <= x.tie(); }
bool EndpointId::operator> (const EndpointId& x) const { return tie() > x.tie(); }
bool EndpointId::operator>= (const EndpointId& x) const { return tie() >= x.tie(); }
}
@@ -0,0 +1,96 @@
/*
==============================================================================
This file is part of the JUCE framework.
Copyright (c) Raw Material Software Limited
JUCE is an open source framework subject to commercial or open source
licensing.
By downloading, installing, or using the JUCE framework, or combining the
JUCE framework with any other source code, object code, content or any other
copyrightable work, you agree to the terms of the JUCE End User Licence
Agreement, and all incorporated terms including the JUCE Privacy Policy and
the JUCE Website Terms of Service, as applicable, which will bind you. If you
do not agree to the terms of these agreements, we will not license the JUCE
framework to you, and you must discontinue the installation or download
process and cease use of the JUCE framework.
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
Or:
You may also use this code under the terms of the AGPLv3:
https://www.gnu.org/licenses/agpl-3.0.en.html
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
namespace juce::universal_midi_packets
{
/** Directional properties of a MIDI endpoint. */
enum class IOKind : uint8_t
{
src, ///< A source of MIDI events
dst, ///< A destination for MIDI events
};
/** All possible MIDI directions. */
constexpr IOKind ioKinds[] { IOKind::src, IOKind::dst };
//==============================================================================
/**
Identifies a MIDI endpoint. This is intended to be an opaque type that can only be compared with
other instances.
For backwards compatibility, we need to ensure that port identifier strings that used to work
with MidiInput and MidiOutput continue to function in the same way. However, the old identifiers
weren't necessarily unique between inputs and outputs (a MIDI 1.0 input and output could have
the same ID), which means that a single id string isn't enough to uniquely identify an input
or output port.
@tags{Audio}
*/
class EndpointId
{
auto tie() const;
public:
/** @internal */
class Impl;
EndpointId() = default;
bool operator== (const EndpointId& x) const;
bool operator!= (const EndpointId& x) const;
bool operator< (const EndpointId& x) const;
bool operator<= (const EndpointId& x) const;
bool operator> (const EndpointId& x) const;
bool operator>= (const EndpointId& x) const;
String get (IOKind k) const { return k == IOKind::src ? src : dst; }
static EndpointId make (IOKind dir, const String& id)
{
return dir == IOKind::src ? makeSrcDst (id, {}) : makeSrcDst ({}, id);
}
static EndpointId makeSrcDst (const String& s, const String& d)
{
return { s, d };
}
String src, dst;
private:
EndpointId (const String& s, const String& d) : src (s), dst (d) {}
};
}
@@ -0,0 +1,243 @@
/*
==============================================================================
This file is part of the JUCE framework.
Copyright (c) Raw Material Software Limited
JUCE is an open source framework subject to commercial or open source
licensing.
By downloading, installing, or using the JUCE framework, or combining the
JUCE framework with any other source code, object code, content or any other
copyrightable work, you agree to the terms of the JUCE End User Licence
Agreement, and all incorporated terms including the JUCE Privacy Policy and
the JUCE Website Terms of Service, as applicable, which will bind you. If you
do not agree to the terms of these agreements, we will not license the JUCE
framework to you, and you must discontinue the installation or download
process and cease use of the JUCE framework.
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
Or:
You may also use this code under the terms of the AGPLv3:
https://www.gnu.org/licenses/agpl-3.0.en.html
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
namespace juce::universal_midi_packets
{
class Endpoints::Impl : private EndpointsListener
{
public:
class Native
{
public:
virtual ~Native() = default;
virtual Backend getBackend() const = 0;
virtual bool isVirtualMidiBytestreamServiceActive() const = 0;
virtual bool isVirtualMidiUmpServiceActive() const = 0;
virtual void setVirtualMidiBytestreamServiceActive (bool) {}
virtual void setVirtualMidiUmpServiceActive (bool) {}
virtual void getEndpoints (std::vector<EndpointId>&) const = 0;
virtual std::optional<Endpoint> getEndpoint (const EndpointId&) const = 0;
virtual std::optional<StaticDeviceInfo> getStaticDeviceInfo (const EndpointId&) const = 0;
virtual std::unique_ptr<Session::Impl::Native> makeSession (const String&) = 0;
static std::unique_ptr<Native> make (EndpointsListener&);
};
Backend getBackend() const
{
return native->getBackend();
}
bool isVirtualMidiBytestreamServiceActive() const
{
return native->isVirtualMidiBytestreamServiceActive();
}
bool isVirtualMidiUmpServiceActive() const
{
return native->isVirtualMidiUmpServiceActive();
}
void setVirtualMidiBytestreamServiceActive (bool x)
{
native->setVirtualMidiBytestreamServiceActive (x);
}
void setVirtualMidiUmpServiceActive (bool x)
{
native->setVirtualMidiUmpServiceActive (x);
}
void getEndpoints (std::vector<EndpointId>& x) const
{
native->getEndpoints (x);
}
std::optional<Endpoint> getEndpoint (const EndpointId& x) const
{
return native->getEndpoint (x);
}
std::optional<StaticDeviceInfo> getStaticDeviceInfo (const EndpointId& x) const
{
return native->getStaticDeviceInfo (x);
}
std::unique_ptr<Session::Impl::Native> makeSession (const String& x)
{
return native->makeSession (x);
}
void addListener (EndpointsListener& x)
{
listeners.add (&x);
}
void removeListener (EndpointsListener& x)
{
listeners.remove (&x);
}
static std::unique_ptr<Impl> make()
{
auto result = rawToUniquePtr (new Impl);
result->native = Native::make (*result);
if (result->native == nullptr)
return {};
return result;
}
static String getGlobalMidiClientName()
{
if (auto* app = JUCEApplicationBase::getInstance())
return app->getApplicationName();
return "JUCE";
}
private:
void endpointsChanged() override
{
listeners.call ([] (auto& l) { l.endpointsChanged(); });
}
void virtualMidiServiceActiveChanged() override
{
listeners.call ([] (auto& l) { l.virtualMidiServiceActiveChanged(); });
}
Impl() = default;
ListenerList<EndpointsListener> listeners;
std::unique_ptr<Native> native;
};
void Endpoints::getEndpoints (std::vector<EndpointId>& x) const
{
x.clear();
if (impl != nullptr)
impl->getEndpoints (x);
}
std::vector<EndpointId> Endpoints::getEndpoints() const
{
std::vector<EndpointId> result;
getEndpoints (result);
return result;
}
std::optional<Endpoint> Endpoints::getEndpoint (const EndpointId& x) const
{
if (impl != nullptr)
return impl->getEndpoint (x);
return {};
}
std::optional<StaticDeviceInfo> Endpoints::getStaticDeviceInfo (const EndpointId& x) const
{
if (impl != nullptr)
return impl->getStaticDeviceInfo (x);
return {};
}
void Endpoints::addListener (EndpointsListener& x)
{
if (impl != nullptr)
impl->addListener (x);
}
void Endpoints::removeListener (EndpointsListener& x)
{
if (impl != nullptr)
impl->removeListener (x);
}
Session Endpoints::makeSession (const String& x) const
{
return Session::Impl::makeSession (impl != nullptr ? impl->makeSession (x) : nullptr);
}
std::optional<Backend> Endpoints::getBackend() const
{
if (impl != nullptr)
return impl->getBackend();
return {};
}
bool Endpoints::isVirtualMidiBytestreamServiceActive() const
{
if (impl != nullptr)
return impl->isVirtualMidiBytestreamServiceActive();
return false;
}
bool Endpoints::isVirtualMidiUmpServiceActive() const
{
if (impl != nullptr)
return impl->isVirtualMidiUmpServiceActive();
return false;
}
void Endpoints::setVirtualMidiBytestreamServiceActive (bool x)
{
if (impl != nullptr)
impl->setVirtualMidiBytestreamServiceActive (x);
}
void Endpoints::setVirtualMidiUmpServiceActive (bool x)
{
if (impl != nullptr)
impl->setVirtualMidiUmpServiceActive (x);
}
Endpoints::Endpoints()
: impl (Impl::make())
{
}
Endpoints::~Endpoints()
{
clearSingletonInstance();
}
}
@@ -0,0 +1,208 @@
/*
==============================================================================
This file is part of the JUCE framework.
Copyright (c) Raw Material Software Limited
JUCE is an open source framework subject to commercial or open source
licensing.
By downloading, installing, or using the JUCE framework, or combining the
JUCE framework with any other source code, object code, content or any other
copyrightable work, you agree to the terms of the JUCE End User Licence
Agreement, and all incorporated terms including the JUCE Privacy Policy and
the JUCE Website Terms of Service, as applicable, which will bind you. If you
do not agree to the terms of these agreements, we will not license the JUCE
framework to you, and you must discontinue the installation or download
process and cease use of the JUCE framework.
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
Or:
You may also use this code under the terms of the AGPLv3:
https://www.gnu.org/licenses/agpl-3.0.en.html
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
namespace juce::universal_midi_packets
{
/**
An interface class for types that are interested in receiving updates
about changes to available MIDI endpoints.
@tags{Audio}
*/
struct EndpointsListener
{
EndpointsListener() = default;
EndpointsListener (const EndpointsListener&) = default;
EndpointsListener (EndpointsListener&&) noexcept = default;
EndpointsListener& operator= (const EndpointsListener&) = default;
EndpointsListener& operator= (EndpointsListener&&) noexcept = default;
virtual ~EndpointsListener() = default;
/** Called on each platform to notify listeners that some aspect of the MIDI configuration
has changed, including device connection, disconnection, and property changes.
*/
virtual void endpointsChanged() = 0;
/** Called on Android to indicate that the service managing the virtual MIDI ports
was started or stopped.
Creating a virtual endpoint will fail if the service is not running, so you may wish to
listen for this event, and to create the virtual ports after this function has been called.
You can query the current state of the service using Endpoints::isVirtualUmpServiceActive()
and Endpoints::isVirtualBytestreamServiceActive().
*/
virtual void virtualMidiServiceActiveChanged() {}
};
/** MIDI implementation technologies
@tags{Audio}
*/
enum class Backend
{
alsa, ///< linux
android, ///< android
coremidi, ///< macOS, iOS
winmm, ///< classic Windows MIDI
winrt, ///< Windows WinRT MIDI 1.0 (experimental)
wms, ///< Windows MIDI Services (experimental)
};
/**
Endpoints known to the system.
Use this to locate hardware and software devices that are capable of sending and
receiving MIDI messages.
Call makeSession() to create a session that manages connections to those devices.
@tags{Audio}
*/
class Endpoints : public DeletedAtShutdown
{
public:
/** Fetch endpoint ids. */
std::vector<EndpointId> getEndpoints() const;
/** Fetch endpoint ids into the provided buffer. */
void getEndpoints (std::vector<EndpointId>&) const;
/** Fetches information about a particular endpoint, or nullopt if the information
is unavailable.
Currently, this function may return nullopt on Android for UMP devices that are
connected but not opened.
If you're displaying endpoint names in a user-facing list, it's probably a good idea to
use the Endpoint name if getEndpoint() returns a value. Otherwise, you can use the
StaticDeviceInformation name if getStaticDeviceInformation() returns a value. If both
functions return nullopt, this implies that the device is unknown/disconnected.
*/
std::optional<Endpoint> getEndpoint (const EndpointId&) const;
/** Fetches static information about a particular endpoint, or nullopt if the endpoint is
unavailable, which might happen if the endpoint has been disconnected.
*/
std::optional<StaticDeviceInfo> getStaticDeviceInfo (const EndpointId&) const;
/** Adds a listener that will receive notifications when endpoints are added, removed,
or otherwise changed.
*/
void addListener (EndpointsListener&);
/** Removes a listener that was previously added with addListener().
*/
void removeListener (EndpointsListener&);
/** Creates a session to manage connections to endpoints.
It's possible for this function to fail, in which case Session::isAlive() will return false.
*/
Session makeSession (const String& name) const;
/** Returns the technology that is being used to communicate with MIDI devices on this platform.
This is mainly relevant on Windows, where there are several different MIDI implementations.
The intended use of this getter is to allow programs to detect whether the Windows MIDI
Services (WMS) are active and running. If initialisation of WMS failed, the implementation
will fall back to an earlier, more limited implementation. Programs may wish to detect this
situation so that they can direct users to install the WMS SDK.
If no MIDI technology is available, this returns nullopt.
*/
std::optional<Backend> getBackend() const;
/** Creating a virtual legacy port will only succeed if this function returns true.
On platforms that support virtual MIDI connections (macOS, iOS, ALSA, Windows MIDI Services),
this will normally return true.
On platforms that don't support virtual MIDI (older Windows MIDI APIs), this will always
return false.
On Android, this will return false until the virtual MIDI service has started, and will
return true while the service is running.
You can listen for virtualMidiServiceActiveChanged() to take actions (e.g. creating or
destroying virtual ports) when the service status changes.
*/
bool isVirtualMidiBytestreamServiceActive() const;
/** Creating a virtual UMP endpoint will only succeed if this function returns true.
On recent platforms that support virtual MIDI connections (recent macOS and iOS, recent ALSA,
Windows MIDI Services), this will normally return true.
On platforms that don't support virtual MIDI (older Windows MIDI APIs), this will always
return false.
On Android, this will return false until the virtual MIDI service has started, and will
return true while the service is running.
You can listen for virtualMidiServiceActiveChanged() to take actions (e.g. creating or
destroying virtual ports) when the service status changes.
*/
bool isVirtualMidiUmpServiceActive() const;
/** By default, Android MIDI services are initially disabled, but can be enabled by calling
this function, passing true.
This function is *not synchronous*, so the service will start or stop at some point after
this function has returned.
To find out when the service state changes, listen for virtualMidiServiceActiveChanged()
and check the result of isVirtualMidiBytestreamServiceActive().
On platforms other than Android, this call does nothing.
*/
void setVirtualMidiBytestreamServiceActive (bool);
/** By default, Android MIDI services are initially disabled, but can be enabled by calling
this function, passing true.
This function is *not synchronous*, so the service will start or stop at some point after
this function has returned.
To find out when the service state changes, listen for virtualMidiServiceActiveChanged()
and check the result of isVirtualMidiUmpServiceActive().
On Android versions that don't support virtual UMP (API level < 35), this call does nothing.
On platforms other than Android, this call does nothing.
*/
void setVirtualMidiUmpServiceActive (bool);
JUCE_DECLARE_SINGLETON_INLINE (Endpoints, false)
~Endpoints() override;
/** @internal */
class Impl;
private:
Endpoints();
std::unique_ptr<Impl> impl;
};
}
@@ -0,0 +1,131 @@
/*
==============================================================================
This file is part of the JUCE framework.
Copyright (c) Raw Material Software Limited
JUCE is an open source framework subject to commercial or open source
licensing.
By downloading, installing, or using the JUCE framework, or combining the
JUCE framework with any other source code, object code, content or any other
copyrightable work, you agree to the terms of the JUCE End User Licence
Agreement, and all incorporated terms including the JUCE Privacy Policy and
the JUCE Website Terms of Service, as applicable, which will bind you. If you
do not agree to the terms of these agreements, we will not license the JUCE
framework to you, and you must discontinue the installation or download
process and cease use of the JUCE framework.
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
Or:
You may also use this code under the terms of the AGPLv3:
https://www.gnu.org/licenses/agpl-3.0.en.html
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
namespace juce::universal_midi_packets
{
struct EndpointAndStaticInfo
{
Endpoint endpoint;
StaticDeviceInfo info;
EndpointId id;
auto tie() const { return std::tuple (endpoint, info, id); }
bool operator== (const EndpointAndStaticInfo& other) const { return tie() == other.tie(); }
bool operator!= (const EndpointAndStaticInfo& other) const { return tie() != other.tie(); }
};
class IOHelpers
{
public:
IOHelpers() = delete;
static Block makeLegacyBlock (bool isInput)
{
const auto direction = isInput ? BlockDirection::receiver : BlockDirection::sender;
const auto hint = isInput ? BlockUiHint::receiver : BlockUiHint::sender;
return Block{}.withName ("Legacy MIDI 1.0")
.withEnabled (true)
.withFirstGroup (0)
.withNumGroups (1)
.withMIDI1ProxyKind (BlockMIDI1ProxyKind::unrestrictedBandwidth)
.withDirection (direction)
.withUiHint (hint);
}
static EndpointAndStaticInfo makeProxyEndpoint (const MidiDeviceInfo& info, BlockDirection direction)
{
jassert (direction != BlockDirection::unknown);
const auto hint = std::invoke ([&]
{
switch (direction)
{
case BlockDirection::bidirectional: return BlockUiHint::bidirectional;
case BlockDirection::sender: return BlockUiHint::sender;
case BlockDirection::receiver: return BlockUiHint::receiver;
case BlockDirection::unknown: break;
}
return BlockUiHint::unknown;
});
const auto block = Block{}.withDirection (direction)
.withUiHint (hint)
.withEnabled (true)
.withFirstGroup (0)
.withNumGroups (1)
.withMIDI1ProxyKind (BlockMIDI1ProxyKind::unrestrictedBandwidth);
const auto id = std::invoke ([&]
{
switch (direction)
{
case BlockDirection::bidirectional:
return EndpointId::makeSrcDst (info.identifier, info.identifier);
case BlockDirection::receiver:
return EndpointId::make (IOKind::dst, info.identifier);
case BlockDirection::sender:
return EndpointId::make (IOKind::src, info.identifier);
case BlockDirection::unknown: break;
}
return EndpointId{};
});
const auto srcId = direction != BlockDirection::receiver ? info.identifier : "";
const auto dstId = direction != BlockDirection::sender ? info.identifier : "";
std::array<String, 16> srcIds { srcId };
std::array<String, 16> dstIds { dstId };
const auto baseEndpoint = Endpoint{}.withName (info.name)
.withProtocol (PacketProtocol::MIDI_1_0)
.withUMPVersion (1, 1)
.withMidi1Support (true)
.withStaticBlocks (true)
.withBlocks (std::array { block });
const auto staticInfo = StaticDeviceInfo{}.withLegacyIdentifiersSrc (srcIds)
.withLegacyIdentifiersDst (dstIds)
.withHasSource (direction == BlockDirection::sender)
.withHasDestination (direction == BlockDirection::receiver)
.withName (info.name)
.withTransport (Transport::bytestream);
return { baseEndpoint, staticInfo, id };
}
};
}
@@ -0,0 +1,209 @@
/*
==============================================================================
This file is part of the JUCE framework.
Copyright (c) Raw Material Software Limited
JUCE is an open source framework subject to commercial or open source
licensing.
By downloading, installing, or using the JUCE framework, or combining the
JUCE framework with any other source code, object code, content or any other
copyrightable work, you agree to the terms of the JUCE End User Licence
Agreement, and all incorporated terms including the JUCE Privacy Policy and
the JUCE Website Terms of Service, as applicable, which will bind you. If you
do not agree to the terms of these agreements, we will not license the JUCE
framework to you, and you must discontinue the installation or download
process and cease use of the JUCE framework.
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
Or:
You may also use this code under the terms of the AGPLv3:
https://www.gnu.org/licenses/agpl-3.0.en.html
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
namespace juce::universal_midi_packets
{
class Input::Impl final : private Consumer,
private DisconnectionListener
{
public:
class Native
{
public:
virtual ~Native() = default;
/* Returns the ID of the endpoint to which this connection is connected. */
virtual EndpointId getEndpointId() const = 0;
/* The protocol to which incoming messages are converted. */
virtual PacketProtocol getProtocol() const = 0;
};
~Impl() override
{
JUCE_ASSERT_MESSAGE_THREAD
}
EndpointId getEndpointId() const
{
return identifier;
}
PacketProtocol getProtocol() const
{
return protocol;
}
void addConsumer (Consumer& x)
{
consumers.add (x);
}
void removeConsumer (Consumer& x)
{
consumers.remove (x);
}
void addDisconnectionListener (DisconnectionListener& x)
{
disconnectListeners.add (&x);
}
void removeDisconnectionListener (DisconnectionListener& x)
{
disconnectListeners.remove (&x);
}
bool isAlive() const
{
return connected && native != nullptr;
}
template <typename Callback>
static Input makeInput (Callback&& callback)
{
auto impl = rawToUniquePtr (new Impl);
impl->native = callback (static_cast<DisconnectionListener&> (*impl), static_cast<Consumer&> (*impl));
if (impl->native == nullptr)
return {};
impl->identifier = impl->native->getEndpointId();
impl->protocol = impl->native->getProtocol();
return Input { std::move (impl) };
}
private:
Impl()
{
JUCE_ASSERT_MESSAGE_THREAD
}
void consume (Iterator b, Iterator e, double t) override
{
consumers.call ([&] (auto& l) { l.consume (b, e, t); });
}
void disconnected() override
{
JUCE_ASSERT_MESSAGE_THREAD
connected = false;
disconnectListeners.call ([] (auto& x) { x.disconnected(); });
}
ListenerList<DisconnectionListener> disconnectListeners;
WaitFreeListeners<Consumer> consumers;
EndpointId identifier;
PacketProtocol protocol;
std::unique_ptr<Native> native;
std::atomic<bool> connected { true };
};
Input::Input() = default;
Input::~Input() = default;
Input::Input (std::unique_ptr<Impl> x) : impl (std::move (x)) {}
Input::Input (Input&&) noexcept = default;
Input& Input::operator= (Input&&) noexcept = default;
EndpointId Input::getEndpointId() const
{
if (impl != nullptr)
return impl->getEndpointId();
return {};
}
PacketProtocol Input::getProtocol() const
{
// You should ensure that isAlive() returns true before calling other member functions!
jassert (isAlive());
if (impl != nullptr)
return impl->getProtocol();
return {};
}
void Input::addConsumer (Consumer& x)
{
// You should ensure that isAlive() returns true before calling other member functions!
jassert (isAlive());
// This function should only be called on the main thread!
JUCE_ASSERT_MESSAGE_THREAD
if (impl != nullptr)
impl->addConsumer (x);
}
void Input::removeConsumer (Consumer& x)
{
// This function should only be called on the main thread!
JUCE_ASSERT_MESSAGE_THREAD
if (impl != nullptr)
impl->removeConsumer (x);
}
void Input::addDisconnectionListener (DisconnectionListener& x)
{
// You should ensure that isAlive() returns true before calling other member functions!
jassert (isAlive());
// This function should only be called on the main thread!
JUCE_ASSERT_MESSAGE_THREAD
if (impl != nullptr)
impl->addDisconnectionListener (x);
}
void Input::removeDisconnectionListener (DisconnectionListener& x)
{
// This function should only be called on the main thread!
JUCE_ASSERT_MESSAGE_THREAD
if (impl != nullptr)
impl->removeDisconnectionListener (x);
}
bool Input::isAlive() const
{
if (impl != nullptr)
return impl->isAlive();
return false;
}
}
@@ -0,0 +1,175 @@
/*
==============================================================================
This file is part of the JUCE framework.
Copyright (c) Raw Material Software Limited
JUCE is an open source framework subject to commercial or open source
licensing.
By downloading, installing, or using the JUCE framework, or combining the
JUCE framework with any other source code, object code, content or any other
copyrightable work, you agree to the terms of the JUCE End User Licence
Agreement, and all incorporated terms including the JUCE Privacy Policy and
the JUCE Website Terms of Service, as applicable, which will bind you. If you
do not agree to the terms of these agreements, we will not license the JUCE
framework to you, and you must discontinue the installation or download
process and cease use of the JUCE framework.
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
Or:
You may also use this code under the terms of the AGPLv3:
https://www.gnu.org/licenses/agpl-3.0.en.html
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
namespace juce::universal_midi_packets
{
//==============================================================================
/**
An interface class for entities that consume Universal MIDI Packets from some producer.
@tags{Audio}
*/
struct Consumer
{
Consumer() = default;
Consumer (const Consumer&) = default;
Consumer (Consumer&&) noexcept = default;
Consumer& operator= (const Consumer&) = default;
Consumer& operator= (Consumer&&) noexcept = default;
virtual ~Consumer() noexcept = default;
/** This will be called each time a new packet is ready for processing. */
virtual void consume (Iterator b, Iterator e, double time) = 0;
};
//==============================================================================
/**
An input (from the JUCE project's perspective) that receives messages sent by an endpoint.
An Input is conceptually similar to a unique_ptr, in that it's a nullable move-only type.
You can check the null state of an instance by calling isAlive().
isAlive() will return true for an Input that's currently connected, or false otherwise.
In particular, isAlive() will return false for a default-constructed Input.
If isAlive() returns false, you should avoid calling other member functions:
although this won't result in undefined behaviour, none of the functions will produce useful
results in this state.
In the case that the device connected to the Input becomes unavailable (e.g. it is unplugged or
the bluetooth connection is dropped), the Input will null itself, and calls to isAlive() will
return false. You can register a callback to handle this event by calling
addDisconnectionListener().
A particular pitfall to watch out for is calling addConsumer(), removeConsumer(),
addDisconnectionListener(), and removeDisconnectionListener() on a default-constructed Input
or other Input for which isAlive() returns false. This will have no effect. Instead, if you want
to attach listeners to an Input, you should use Session::connectInput() to create an Input,
and ensure that isAlive() returns true on that Input before attaching listeners.
@tags{Audio}
*/
class Input
{
public:
/** Creates a disconnected input.
A default-constructed input will never receive any messages.
Instances should only be created on the main thread.
*/
Input();
/** Destructor.
Instances should only be destroyed on the main thread in order to avoid potential races
with disconnection callbacks, which also happen on the main thread.
*/
~Input();
Input (Input&&) noexcept;
Input& operator= (Input&&) noexcept;
Input (const Input&) = delete;
Input& operator= (const Input&) = delete;
/** Returns this connection's endpoint. */
EndpointId getEndpointId() const;
/** Returns the protocol that was requested when creating this connection. */
PacketProtocol getProtocol() const;
/** Attaches a receiver that will receive MIDI messages from this input.
Incoming messages will be converted to the protocol that was requested when
opening the Input.
If isAlive() returns false at the point where this function is called, this function
will have no effect. This can commonly happen when attempting to add listeners to a
default-constructed Input, or if the input device got disconnected.
It is an error to add or remove a consumer from within the consumer callback.
This will cause deadlocks, so be careful!
You should only add and remove consumers from the main thread.
Calls to Consumer::consume() will happen on a separate thread, often with high
or even realtime priority.
*/
void addConsumer (Consumer& r);
/** Detaches the receiver so that it will no longer receive MIDI messages from this
Input.
It is an error to add or remove a consumer from within the consumer callback.
This will cause deadlocks, so be careful!
@see addConsumer()
*/
void removeConsumer (Consumer& r);
/** Attaches a listener that will be notified when this endpoint is disconnected.
Disconnection notifications will be sent on the main thread, and listeners should
only be added or removed on the main thread in order to avoid potential data races.
Calling this function on an instance for which isAlive() returns false has no effect.
*/
void addDisconnectionListener (DisconnectionListener& r);
/** Removes a disconnection listener.
@see addDisconnectionListener()
*/
void removeDisconnectionListener (DisconnectionListener& r);
/** True if this connection is currently active.
This function returns false for a default-constructed instance.
*/
bool isAlive() const;
explicit operator bool() const { return isAlive(); }
/** @internal */
class Impl;
private:
explicit Input (std::unique_ptr<Impl>);
std::unique_ptr<Impl> impl;
};
}
@@ -0,0 +1,100 @@
/*
==============================================================================
This file is part of the JUCE framework.
Copyright (c) Raw Material Software Limited
JUCE is an open source framework subject to commercial or open source
licensing.
By downloading, installing, or using the JUCE framework, or combining the
JUCE framework with any other source code, object code, content or any other
copyrightable work, you agree to the terms of the JUCE End User Licence
Agreement, and all incorporated terms including the JUCE Privacy Policy and
the JUCE Website Terms of Service, as applicable, which will bind you. If you
do not agree to the terms of these agreements, we will not license the JUCE
framework to you, and you must discontinue the installation or download
process and cease use of the JUCE framework.
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
Or:
You may also use this code under the terms of the AGPLv3:
https://www.gnu.org/licenses/agpl-3.0.en.html
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
namespace juce::universal_midi_packets
{
class LegacyVirtualInput::Impl final
{
public:
class Native
{
public:
virtual ~Native() = default;
virtual EndpointId getId() const = 0;
};
EndpointId getId() const
{
return identifier;
}
bool isAlive() const
{
return native != nullptr;
}
static LegacyVirtualInput makeLegacyVirtualInput (std::unique_ptr<Native> x)
{
if (x != nullptr)
return LegacyVirtualInput { rawToUniquePtr (new Impl (std::move (x))) };
return {};
}
private:
explicit Impl (std::unique_ptr<Native> n)
: native (std::move (n)),
identifier (native->getId())
{
}
std::unique_ptr<Native> native;
EndpointId identifier;
};
LegacyVirtualInput::LegacyVirtualInput() = default;
LegacyVirtualInput::~LegacyVirtualInput() = default;
LegacyVirtualInput::LegacyVirtualInput (std::unique_ptr<Impl> x) : impl (std::move (x)) {}
LegacyVirtualInput::LegacyVirtualInput (LegacyVirtualInput&&) noexcept = default;
LegacyVirtualInput& LegacyVirtualInput::operator= (LegacyVirtualInput&&) noexcept = default;
EndpointId LegacyVirtualInput::getId() const
{
if (impl != nullptr)
return impl->getId();
return {};
}
bool LegacyVirtualInput::isAlive() const
{
if (impl != nullptr)
return impl->isAlive();
return false;
}
}
@@ -0,0 +1,81 @@
/*
==============================================================================
This file is part of the JUCE framework.
Copyright (c) Raw Material Software Limited
JUCE is an open source framework subject to commercial or open source
licensing.
By downloading, installing, or using the JUCE framework, or combining the
JUCE framework with any other source code, object code, content or any other
copyrightable work, you agree to the terms of the JUCE End User Licence
Agreement, and all incorporated terms including the JUCE Privacy Policy and
the JUCE Website Terms of Service, as applicable, which will bind you. If you
do not agree to the terms of these agreements, we will not license the JUCE
framework to you, and you must discontinue the installation or download
process and cease use of the JUCE framework.
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
Or:
You may also use this code under the terms of the AGPLv3:
https://www.gnu.org/licenses/agpl-3.0.en.html
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
namespace juce::universal_midi_packets
{
/**
Represents a virtual MIDI 1.0 input port.
@tags{Audio}
*/
class LegacyVirtualInput
{
public:
/** Creates an invalid virtual port that doesn't correspond to any virtual device. */
LegacyVirtualInput();
~LegacyVirtualInput();
LegacyVirtualInput (LegacyVirtualInput&&) noexcept;
LegacyVirtualInput& operator= (LegacyVirtualInput&&) noexcept;
LegacyVirtualInput (const LegacyVirtualInput&) = delete;
LegacyVirtualInput& operator= (const LegacyVirtualInput&) = delete;
/** Retrieves the unique id of this input.
You can pass this ID to Session::connectInput() in order to receive messages sent to this
input.
Note that this ID is *not* guaranteed to be stable - creating the 'same' virtual device
across several program invocations may produce a different ID each time.
To fetch the current details of this device, you can pass this ID to Endpoints::getEndpoint().
*/
EndpointId getId() const;
bool isAlive() const;
explicit operator bool() const { return isAlive(); }
/** @internal */
class Impl;
private:
explicit LegacyVirtualInput (std::unique_ptr<Impl>);
std::unique_ptr<Impl> impl;
};
}
@@ -0,0 +1,100 @@
/*
==============================================================================
This file is part of the JUCE framework.
Copyright (c) Raw Material Software Limited
JUCE is an open source framework subject to commercial or open source
licensing.
By downloading, installing, or using the JUCE framework, or combining the
JUCE framework with any other source code, object code, content or any other
copyrightable work, you agree to the terms of the JUCE End User Licence
Agreement, and all incorporated terms including the JUCE Privacy Policy and
the JUCE Website Terms of Service, as applicable, which will bind you. If you
do not agree to the terms of these agreements, we will not license the JUCE
framework to you, and you must discontinue the installation or download
process and cease use of the JUCE framework.
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
Or:
You may also use this code under the terms of the AGPLv3:
https://www.gnu.org/licenses/agpl-3.0.en.html
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
namespace juce::universal_midi_packets
{
class LegacyVirtualOutput::Impl final
{
public:
class Native
{
public:
virtual ~Native() = default;
virtual EndpointId getId() const = 0;
};
EndpointId getId() const
{
return identifier;
}
bool isAlive() const
{
return native != nullptr;
}
static LegacyVirtualOutput makeLegacyVirtualOutput (std::unique_ptr<Native> x)
{
if (x != nullptr)
return LegacyVirtualOutput { rawToUniquePtr (new Impl (std::move (x))) };
return {};
}
private:
explicit Impl (std::unique_ptr<Native> n)
: native (std::move (n)),
identifier (native->getId())
{
}
std::unique_ptr<Native> native;
EndpointId identifier;
};
LegacyVirtualOutput::LegacyVirtualOutput() = default;
LegacyVirtualOutput::~LegacyVirtualOutput() = default;
LegacyVirtualOutput::LegacyVirtualOutput (std::unique_ptr<Impl> x) : impl (std::move (x)) {}
LegacyVirtualOutput::LegacyVirtualOutput (LegacyVirtualOutput&&) noexcept = default;
LegacyVirtualOutput& LegacyVirtualOutput::operator= (LegacyVirtualOutput&&) noexcept = default;
EndpointId LegacyVirtualOutput::getId() const
{
if (impl != nullptr)
return impl->getId();
return {};
}
bool LegacyVirtualOutput::isAlive() const
{
if (impl != nullptr)
return impl->isAlive();
return false;
}
}
@@ -0,0 +1,80 @@
/*
==============================================================================
This file is part of the JUCE framework.
Copyright (c) Raw Material Software Limited
JUCE is an open source framework subject to commercial or open source
licensing.
By downloading, installing, or using the JUCE framework, or combining the
JUCE framework with any other source code, object code, content or any other
copyrightable work, you agree to the terms of the JUCE End User Licence
Agreement, and all incorporated terms including the JUCE Privacy Policy and
the JUCE Website Terms of Service, as applicable, which will bind you. If you
do not agree to the terms of these agreements, we will not license the JUCE
framework to you, and you must discontinue the installation or download
process and cease use of the JUCE framework.
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
Or:
You may also use this code under the terms of the AGPLv3:
https://www.gnu.org/licenses/agpl-3.0.en.html
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
namespace juce::universal_midi_packets
{
/**
Represents a virtual MIDI 1.0 output port.
@tags{Audio}
*/
class LegacyVirtualOutput
{
public:
/** Creates an invalid virtual port that doesn't correspond to any virtual device. */
LegacyVirtualOutput();
~LegacyVirtualOutput();
LegacyVirtualOutput (LegacyVirtualOutput&&) noexcept;
LegacyVirtualOutput& operator= (LegacyVirtualOutput&&) noexcept;
LegacyVirtualOutput (const LegacyVirtualOutput&) = delete;
LegacyVirtualOutput& operator= (const LegacyVirtualOutput&) = delete;
/** Retrieves the unique id of this input.
You can pass this ID to Session::connectOutput() in order to send messages to this output.
Note that this ID is *not* guaranteed to be stable - creating the 'same' virtual device
across several program invocations may produce a different ID each time.
To fetch the current details of this device, you can pass this ID to Endpoints::getEndpoint().
*/
EndpointId getId() const;
bool isAlive() const;
explicit operator bool() const { return isAlive(); }
/** @internal */
class Impl;
private:
explicit LegacyVirtualOutput (std::unique_ptr<Impl>);
std::unique_ptr<Impl> impl;
};
}
@@ -0,0 +1,170 @@
/*
==============================================================================
This file is part of the JUCE framework.
Copyright (c) Raw Material Software Limited
JUCE is an open source framework subject to commercial or open source
licensing.
By downloading, installing, or using the JUCE framework, or combining the
JUCE framework with any other source code, object code, content or any other
copyrightable work, you agree to the terms of the JUCE End User Licence
Agreement, and all incorporated terms including the JUCE Privacy Policy and
the JUCE Website Terms of Service, as applicable, which will bind you. If you
do not agree to the terms of these agreements, we will not license the JUCE
framework to you, and you must discontinue the installation or download
process and cease use of the JUCE framework.
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
Or:
You may also use this code under the terms of the AGPLv3:
https://www.gnu.org/licenses/agpl-3.0.en.html
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
namespace juce::universal_midi_packets
{
class Output::Impl final : private DisconnectionListener
{
public:
class Native
{
public:
virtual ~Native() = default;
virtual EndpointId getEndpointId() const = 0;
virtual bool send (Iterator b, Iterator e) = 0;
};
~Impl() override
{
JUCE_ASSERT_MESSAGE_THREAD
}
EndpointId getEndpointId() const
{
return identifier;
}
bool send (Iterator beginIterator, Iterator endIterator)
{
return isAlive() && native->send (beginIterator, endIterator);
}
void addDisconnectionListener (DisconnectionListener& x)
{
disconnectListeners.add (&x);
}
void removeDisconnectionListener (DisconnectionListener& x)
{
disconnectListeners.remove (&x);
}
bool isAlive() const
{
return connected && native != nullptr;
}
template <typename Callback>
static Output makeOutput (Callback&& callback)
{
auto impl = rawToUniquePtr (new Impl);
impl->native = callback (static_cast<DisconnectionListener&> (*impl));
if (impl->native == nullptr)
return {};
impl->identifier = impl->native->getEndpointId();
return Output { std::move (impl) };
}
private:
Impl()
{
JUCE_ASSERT_MESSAGE_THREAD
}
void disconnected() override
{
JUCE_ASSERT_MESSAGE_THREAD
connected = false;
disconnectListeners.call ([] (auto& x) { x.disconnected(); });
}
ListenerList<DisconnectionListener> disconnectListeners;
std::unique_ptr<Native> native;
EndpointId identifier;
std::atomic<bool> connected { true };
};
Output::Output() = default;
Output::~Output() = default;
Output::Output (std::unique_ptr<Impl> x) : impl (std::move (x)) {}
Output::Output (Output&&) noexcept = default;
Output& Output::operator= (Output&&) noexcept = default;
EndpointId Output::getEndpointId() const
{
// You should ensure that isAlive() returns true before calling other member functions!
jassert (isAlive());
if (impl != nullptr)
return impl->getEndpointId();
return {};
}
bool Output::send (Iterator beginIterator, Iterator endIterator)
{
// You should ensure that isAlive() returns true before calling other member functions!
jassert (isAlive());
if (impl != nullptr)
return impl->send (beginIterator, endIterator);
return false;
}
void Output::addDisconnectionListener (DisconnectionListener& x)
{
// You should ensure that isAlive() returns true before calling other member functions!
jassert (isAlive());
// This function should only be called on the main thread!
JUCE_ASSERT_MESSAGE_THREAD
if (impl != nullptr)
impl->addDisconnectionListener (x);
}
void Output::removeDisconnectionListener (DisconnectionListener& x)
{
// This function should only be called on the main thread!
JUCE_ASSERT_MESSAGE_THREAD
if (impl != nullptr)
impl->removeDisconnectionListener (x);
}
bool Output::isAlive() const
{
if (impl != nullptr)
return impl->isAlive();
return false;
}
}
@@ -0,0 +1,133 @@
/*
==============================================================================
This file is part of the JUCE framework.
Copyright (c) Raw Material Software Limited
JUCE is an open source framework subject to commercial or open source
licensing.
By downloading, installing, or using the JUCE framework, or combining the
JUCE framework with any other source code, object code, content or any other
copyrightable work, you agree to the terms of the JUCE End User Licence
Agreement, and all incorporated terms including the JUCE Privacy Policy and
the JUCE Website Terms of Service, as applicable, which will bind you. If you
do not agree to the terms of these agreements, we will not license the JUCE
framework to you, and you must discontinue the installation or download
process and cease use of the JUCE framework.
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
Or:
You may also use this code under the terms of the AGPLv3:
https://www.gnu.org/licenses/agpl-3.0.en.html
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
namespace juce::universal_midi_packets
{
/**
An output (from the JUCE project's perspective) that sends messages to an endpoint.
An Output is conceptually similar to a unique_ptr, in that it's a nullable move-only type.
You can check the null state of an instance by calling isAlive().
isAlive() will return true for an Output that's currently connected, or false otherwise.
In particular, isAlive() will return false for a default-constructed Output.
If isAlive() returns false, you should avoid calling other member functions:
although this won't result in undefined behaviour, none of the functions will produce useful
results in this state.
In the case that the device connected to the Output becomes unavailable (e.g. it is unplugged or
the bluetooth connection is dropped), the Output will null itself, and calls to isAlive() will
return false. You can register a callback to handle this event by calling
addDisconnectionListener().
A particular pitfall to watch out for is calling addDisconnectionListener() and
removeDisconnectionListener() on a default-constructed Output or other Output for which
isAlive() returns false. This will have no effect. Instead, if you want
to attach listeners to an Output, you should use Session::connectOutput() to create an Output,
and ensure that isAlive() returns true on that Output before attaching listeners.
@tags{Audio}
*/
class Output
{
public:
/** Creates a disconnected output.
Sending messages to a default-constructed output won't do anything.
Instances should only be created on the main thread.
*/
Output();
/** Destructor.
Instances should only be destroyed on the main thread in order to avoid potential races
with disconnection callbacks, which also happen on the main thread.
*/
~Output();
Output (Output&&) noexcept;
Output& operator= (Output&&) noexcept;
Output (const Output&) = delete;
Output& operator= (const Output&) = delete;
/** Returns this connection's endpoint. */
EndpointId getEndpointId() const;
/** Sends a range of messages to this endpoint.
If isAlive() returns false at the point where this function is called, then this
function has no effect.
Returns true on success, false on failure.
You may send messages using any protocol, and they will be converted automatically
to the protocol expected by the receiver.
This function may be called from a background thread (i.e. not the main thread).
*/
bool send (Iterator beginIterator, Iterator endIterator);
/** Attaches a listener that will be notified when this endpoint is disconnected.
Disconnection notifications will be sent on the main thread, and listeners should
only be added or removed on the main thread in order to avoid potential data races.
Calling this function on an instance for which isAlive() returns false has no effect.
*/
void addDisconnectionListener (DisconnectionListener& r);
/** Removes a disconnection listener.
@see addDisconnectionListener()
*/
void removeDisconnectionListener (DisconnectionListener& r);
/** True if this connection is currently active.
This function returns false for a default-constructed instance.
*/
bool isAlive() const;
explicit operator bool() const { return isAlive(); }
/** @internal */
class Impl;
private:
explicit Output (std::unique_ptr<Impl>);
std::unique_ptr<Impl> impl;
};
}
@@ -0,0 +1,310 @@
/*
==============================================================================
This file is part of the JUCE framework.
Copyright (c) Raw Material Software Limited
JUCE is an open source framework subject to commercial or open source
licensing.
By downloading, installing, or using the JUCE framework, or combining the
JUCE framework with any other source code, object code, content or any other
copyrightable work, you agree to the terms of the JUCE End User Licence
Agreement, and all incorporated terms including the JUCE Privacy Policy and
the JUCE Website Terms of Service, as applicable, which will bind you. If you
do not agree to the terms of these agreements, we will not license the JUCE
framework to you, and you must discontinue the installation or download
process and cease use of the JUCE framework.
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
Or:
You may also use this code under the terms of the AGPLv3:
https://www.gnu.org/licenses/agpl-3.0.en.html
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
namespace juce::universal_midi_packets
{
class Session::Impl
{
public:
class Native
{
public:
virtual ~Native() = default;
virtual String getName() const = 0;
virtual std::unique_ptr<Input::Impl::Native> connectInput (DisconnectionListener&,
const EndpointId&,
PacketProtocol,
Consumer&) = 0;
virtual std::unique_ptr<Output::Impl::Native> connectOutput (DisconnectionListener&,
const EndpointId&) = 0;
/* Creates a full MIDI 2.0 UMP endpoint, or returns nullptr on failure. */
virtual std::unique_ptr<VirtualEndpoint::Impl::Native> createNativeVirtualEndpoint (const String&,
const DeviceInfo&,
const String&,
PacketProtocol,
Span<const Block>,
BlocksAreStatic)
{
// If this is hit, you're trying to create a virtual (app-to-app) MIDI 2.0 endpoint, but
// the current MIDI backend does not implement this feature.
jassertfalse;
return {};
}
/* Creates a virtual MIDI 1.0 port. This is intended for use on platforms that don't
support virtual MIDI 2.0.
*/
virtual std::unique_ptr<LegacyVirtualInput::Impl::Native> createLegacyVirtualInput (const String&)
{
// If this is hit, you're trying to create a virtual (app-to-app) MIDI 1.0 endpoint, but
// the current MIDI backend does not implement this feature.
jassertfalse;
return {};
}
/* Creates a virtual MIDI 1.0 port. This is intended for use on platforms that don't
support virtual MIDI 2.0.
*/
virtual std::unique_ptr<LegacyVirtualOutput::Impl::Native> createLegacyVirtualOutput (const String&)
{
// If this is hit, you're trying to create a virtual (app-to-app) MIDI 1.0 endpoint, but
// the current MIDI backend does not implement this feature.
jassertfalse;
return {};
}
};
String getName() const
{
return native->getName();
}
Input makeInput (const EndpointId& endpointId, PacketProtocol protocol)
{
return Input::Impl::makeInput ([&] (DisconnectionListener& d, Consumer& c)
{
return native->connectInput (d, endpointId, protocol, c);
});
}
Output makeOutput (const EndpointId& endpointId)
{
return Output::Impl::makeOutput ([&] (DisconnectionListener& d)
{
return native->connectOutput (d, endpointId);
});
}
VirtualEndpoint createVirtualEndpoint (const String& name,
const DeviceInfo& info,
const String& productInstance,
PacketProtocol protocol,
Span<const Block> blocks,
BlocksAreStatic areStatic)
{
if (blocks.size() > 32)
{
// UMP endpoints support a maximum of 32 function blocks
jassertfalse;
return {};
}
if (name.getNumBytesAsUTF8() > 98)
{
// Per the spec, there's a length restriction on endpoint names
jassertfalse;
return {};
}
const auto isBlockNameTooLong = [] (const Block& b)
{
return b.getName().getNumBytesAsUTF8() > 91;
};
if (std::any_of (blocks.begin(), blocks.end(), isBlockNameTooLong))
{
// Per the spec, there's a length restriction on block names
jassertfalse;
return {};
}
const auto isBlockDisabled = [] (const Block& b) { return ! b.isEnabled(); };
if (areStatic == BlocksAreStatic::yes && std::any_of (blocks.begin(), blocks.end(), isBlockDisabled))
{
// You may not request a disabled function block if the function block topology is static
jassertfalse;
return {};
}
auto umpEndpointNative = native->createNativeVirtualEndpoint (name,
info,
productInstance,
protocol,
blocks,
areStatic);
if (umpEndpointNative == nullptr)
return {};
auto result = VirtualEndpoint::Impl::makeVirtualEndpoint (std::move (umpEndpointNative));
if (! result)
return {};
#if JUCE_ASSERTIONS_ENABLED_OR_LOGGED
if (const auto endpoint = Endpoints::getInstance()->getEndpoint (result.getId()))
{
jassert (endpoint->getName() == name);
jassert (endpoint->getProductInstanceId() == productInstance);
jassert (endpoint->getProtocol() == protocol);
jassert (endpoint->hasStaticBlocks() == (areStatic == BlocksAreStatic::yes));
jassert (std::equal (blocks.begin(),
blocks.end(),
endpoint->getBlocks().begin(),
endpoint->getBlocks().end()));
}
else
{
// Unable to find this endpoint, even though we just created it!
jassertfalse;
}
if (const auto staticInfo = Endpoints::getInstance()->getStaticDeviceInfo (result.getId()))
{
jassert (staticInfo->getTransport() == Transport::ump);
}
else
{
jassertfalse;
}
#endif
return result;
}
LegacyVirtualInput createLegacyVirtualInput (const String& name)
{
if (auto result = native->createLegacyVirtualInput (name))
{
[[maybe_unused]] const auto id = result->getId();
jassert (id.dst.isNotEmpty());
return LegacyVirtualInput::Impl::makeLegacyVirtualInput (std::move (result));
}
return {};
}
LegacyVirtualOutput createLegacyVirtualOutput (const String& name)
{
if (auto result = native->createLegacyVirtualOutput (name))
{
[[maybe_unused]] const auto id = result->getId();
jassert (id.src.isNotEmpty());
return LegacyVirtualOutput::Impl::makeLegacyVirtualOutput (std::move (result));
}
return {};
}
static Session makeSession (std::unique_ptr<Native> x)
{
if (x == nullptr)
return Session { nullptr };
return Session { rawToUniquePtr (new Impl (std::move (x))) };
}
private:
explicit Impl (std::unique_ptr<Native> n) : native (std::move (n)) {}
// Order of data members is important to ensure that all inputs+outputs are destroyed before the
// native session
std::unique_ptr<Native> native;
};
String Session::getName() const
{
if (impl != nullptr)
return impl->getName();
return {};
}
Input Session::connectInput (const EndpointId& x, PacketProtocol p)
{
if (impl != nullptr)
return impl->makeInput (x, p);
return {};
}
Output Session::connectOutput (const EndpointId& x)
{
if (impl != nullptr)
return impl->makeOutput (x);
return {};
}
VirtualEndpoint Session::createVirtualEndpoint (const String& name,
const DeviceInfo& deviceInfo,
const String& productInstanceID,
PacketProtocol protocol,
Span<const Block> initialBlocks,
BlocksAreStatic areStatic)
{
if (impl == nullptr)
return {};
return impl->createVirtualEndpoint (name,
deviceInfo,
productInstanceID,
protocol,
initialBlocks,
areStatic);
}
LegacyVirtualInput Session::createLegacyVirtualInput (const juce::String& name)
{
if (impl == nullptr)
return {};
return impl->createLegacyVirtualInput (name);
}
LegacyVirtualOutput Session::createLegacyVirtualOutput (const juce::String& name)
{
if (impl == nullptr)
return {};
return impl->createLegacyVirtualOutput (name);
}
bool Session::isAlive() const
{
return impl != nullptr;
}
Session::Session (std::shared_ptr<Impl> x) : impl (std::move (x)) {}
Session::Session (const Session&) = default;
Session::Session (Session&&) noexcept = default;
Session& Session::operator= (const Session&) = default;
Session& Session::operator= (Session&&) noexcept = default;
Session::~Session() = default;
}
@@ -0,0 +1,189 @@
/*
==============================================================================
This file is part of the JUCE framework.
Copyright (c) Raw Material Software Limited
JUCE is an open source framework subject to commercial or open source
licensing.
By downloading, installing, or using the JUCE framework, or combining the
JUCE framework with any other source code, object code, content or any other
copyrightable work, you agree to the terms of the JUCE End User Licence
Agreement, and all incorporated terms including the JUCE Privacy Policy and
the JUCE Website Terms of Service, as applicable, which will bind you. If you
do not agree to the terms of these agreements, we will not license the JUCE
framework to you, and you must discontinue the installation or download
process and cease use of the JUCE framework.
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
Or:
You may also use this code under the terms of the AGPLv3:
https://www.gnu.org/licenses/agpl-3.0.en.html
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
namespace juce::universal_midi_packets
{
/** This type is passed when creating a virtual endpoint to request static or dynamic blocks. */
enum class BlocksAreStatic : uint8_t
{
no, ///< Indicates that block layouts will not change after construction.
yes, ///< Indicates that the block layout may be modified after construction.
};
/**
Allows creating new connections to endpoints, and also creating new virtual endpoints.
The session is internally reference counted, meaning that the system resources represented
by the session won't be released until the Session object, along with every Input, Output,
VirtualEndpoint, LegacyVirtualInput, and LegacyVirtualOutput that it created has been
destroyed.
Internally, sessions cache open connections, so that multiple Inputs
or Outputs to the same endpoint will share resources associated with that connection.
Therefore, in order to minimise resource usage, you should create as few sessions as possible,
and re-use them when creating new connections. It may still make sense to have a separate
session for logically discrete components of your project, e.g. a multi-window application
where each window has its own document with an associated MIDI configuration.
@tags{Audio}
*/
class Session
{
public:
/** Returns the name that was provided when creating this session, or an empty string
if the session is not alive.
*/
String getName() const;
/** Creates a connection to a particular endpoint.
On failure, returns a disconnected connection (i.e. isAlive() returns false).
Passing an EndpointId denoting an endpoint that can only receive messages will fail.
Incoming messages will be automatically converted to the specified protocol, regardless
of their actual protocol 'on the wire'.
If the session is not alive, this will always fail and return an Input that is not alive.
*/
Input connectInput (const EndpointId&, PacketProtocol);
/** Creates a connection to a particular endpoint.
On failure, returns a disconnected connection (i.e. isAlive() returns false).
Passing an EndpointId denoting an endpoint that can only send messages will fail.
If the session is not alive, this will always fail and return an Output that is not alive.
*/
Output connectOutput (const EndpointId&);
/** Returns a new VirtualEndpoint if virtual endpoints are supported and the configuration is
valid. If creating the endpoint fails, this will return an invalid VirtualEndpoint.
To actually send and receive messages through this endpoint, use connectInput()
and connectOutput(), passing the result of VirtualEndpoint::getId(). This will create
an Input or Output that can be used in the same way as for any other kind of device.
If the function blocks are static, all blocks must be marked as active.
If the function blocks are not static, then blocks may be initially inactive.
The number of declared function blocks may not change while the device is active,
so if you need a dynamic number of blocks, mark the block layout as non-static
and mark any initially unused blocks as inactive.
Only a maximum of 32 blocks are allowed on an endpoint. If you pass more than 32
blocks, this function will fail.
This function may also fail if virtual devices are not available on the current platform.
Some platforms (older macOS, older Linux) support virtual MIDI 1.0 devices but not
virtual UMP devices. On such platforms, this function will fail. You may wish to check
for this case, and to call createLegacyVirtualInput() and/or createLegacyVirtualOutput()
as a fall-back.
If the session is not alive, this will always fail and return a VirtualEndpoint that is not
alive.
On Android, this function will only ever succeed on newer platforms (API level >= 35).
You may need to call Endpoints::setVirtualMidiUmpServiceActive() to make the virtual UMP
service available. You can listen for state changes in the virtual MIDI service using
EndpointsListener::virtualMidiServiceActiveChanged(). A maximum of one VirtualEndpoint may
be alive at any time on Android, and attempting to create additional virtual endpoints will
fail.
*/
VirtualEndpoint createVirtualEndpoint (const String& name,
const DeviceInfo& deviceInfo,
const String& productInstanceID,
PacketProtocol protocol,
Span<const Block> initialBlocks,
BlocksAreStatic);
/** Creates a MIDI 1.0-compatible input port.
Where supported by platform APIs, this will explicitly create a single-group MIDI 1.0 port.
To use the input, pass the result of LegacyVirtualInput::getId() to connectInput().
There are some special cases to keep in mind:
- Windows MIDI Services only allows creation of UMP endpoints, not MIDI 1.0 ports, so on
that platform we create an endpoint with a single MIDI 1.0 Block.
- Android requires that virtual ports are declared in the app manifest. JUCE declares a
virtual bytestream device with a single input and output, and a virtual UMP device with
a single bidirectional port. By default, these virtual devices are disabled, but they
can be enabled by calling Endpoints::setVirtualMidiBytestreamServiceActive() and
Endpoints::setVirtualMidiUmpServiceActive(). After each service becomes available, you
may create exactly one VirtualEndpoint, one LegacyVirtualInput, and/or one
LegacyVirtualOutput. Additional virtual ports are not supported.
*/
LegacyVirtualInput createLegacyVirtualInput (const String& name);
/** Creates a MIDI 1.0-compatible output port.
Where supported by platform APIs, this will explicitly create a single-group MIDI 1.0 port.
To use the output, pass the result of LegacyVirtualOutput::getId() to connectOutput().
There are some special cases to keep in mind:
- Windows MIDI Services only allows creation of UMP endpoints, not MIDI 1.0 ports, so on
that platform we create an endpoint with a single MIDI 1.0 Block.
- Android requires that virtual ports are declared in the app manifest. JUCE declares a
virtual bytestream device with a single input and output, and a virtual UMP device with
a single bidirectional port. By default, these virtual devices are disabled, but they
can be enabled by calling Endpoints::setVirtualMidiBytestreamServiceActive() and
Endpoints::setVirtualMidiUmpServiceActive(). After each service becomes available, you
may create exactly one VirtualEndpoint, one LegacyVirtualInput, and/or one
LegacyVirtualOutput. Additional virtual ports are not supported.
*/
LegacyVirtualOutput createLegacyVirtualOutput (const String& name);
/** True if this session was created successfully and is currently alive. */
bool isAlive() const;
explicit operator bool() const { return isAlive(); }
Session (const Session&);
Session (Session&&) noexcept;
Session& operator= (const Session&);
Session& operator= (Session&&) noexcept;
~Session();
/** @internal */
class Impl;
private:
explicit Session (std::shared_ptr<Impl>);
std::shared_ptr<Impl> impl;
};
}
@@ -0,0 +1,48 @@
/*
==============================================================================
This file is part of the JUCE framework.
Copyright (c) Raw Material Software Limited
JUCE is an open source framework subject to commercial or open source
licensing.
By downloading, installing, or using the JUCE framework, or combining the
JUCE framework with any other source code, object code, content or any other
copyrightable work, you agree to the terms of the JUCE End User Licence
Agreement, and all incorporated terms including the JUCE Privacy Policy and
the JUCE Website Terms of Service, as applicable, which will bind you. If you
do not agree to the terms of these agreements, we will not license the JUCE
framework to you, and you must discontinue the installation or download
process and cease use of the JUCE framework.
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
Or:
You may also use this code under the terms of the AGPLv3:
https://www.gnu.org/licenses/agpl-3.0.en.html
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
namespace juce::universal_midi_packets
{
auto StaticDeviceInfo::tie() const
{
return std::tie (identifierSrc, identifierDst, name, manufacturer, product, transport, source, destination);
}
bool StaticDeviceInfo::operator== (const StaticDeviceInfo& other) const
{
return tie() == other.tie();
}
}
@@ -0,0 +1,114 @@
/*
==============================================================================
This file is part of the JUCE framework.
Copyright (c) Raw Material Software Limited
JUCE is an open source framework subject to commercial or open source
licensing.
By downloading, installing, or using the JUCE framework, or combining the
JUCE framework with any other source code, object code, content or any other
copyrightable work, you agree to the terms of the JUCE End User Licence
Agreement, and all incorporated terms including the JUCE Privacy Policy and
the JUCE Website Terms of Service, as applicable, which will bind you. If you
do not agree to the terms of these agreements, we will not license the JUCE
framework to you, and you must discontinue the installation or download
process and cease use of the JUCE framework.
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
Or:
You may also use this code under the terms of the AGPLv3:
https://www.gnu.org/licenses/agpl-3.0.en.html
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
namespace juce::universal_midi_packets
{
/**
Static information about a particular MIDI device that can be queried without opening a
connection to the device.
This information differs from the detailed information in the Endpoint struct, in that
the StaticDeviceInformation is communicated out-of-band, whereas Endpoint information is
communicated in-band, i.e. it is sent as MIDI messages after establishing a connection to the
device.
@tags{Audio}
*/
class StaticDeviceInfo
{
public:
[[nodiscard]] StaticDeviceInfo withName (const String& x) const { return withMember (*this, &StaticDeviceInfo::name, x); }
[[nodiscard]] StaticDeviceInfo withManufacturer (const String& x) const { return withMember (*this, &StaticDeviceInfo::manufacturer, x); }
[[nodiscard]] StaticDeviceInfo withProduct (const String& x) const { return withMember (*this, &StaticDeviceInfo::product, x); }
[[nodiscard]] StaticDeviceInfo withHasSource (bool x) const { return withMember (*this, &StaticDeviceInfo::source, x); }
[[nodiscard]] StaticDeviceInfo withHasDestination (bool x) const { return withMember (*this, &StaticDeviceInfo::destination, x); }
[[nodiscard]] StaticDeviceInfo withTransport (Transport x) const { return withMember (*this, &StaticDeviceInfo::transport, x); }
[[nodiscard]] StaticDeviceInfo withLegacyIdentifiersSrc (Span<const String, 16> x) const
{
auto copy = *this;
std::copy (x.begin(), x.end(), copy.identifierSrc.begin());
return copy;
}
[[nodiscard]] StaticDeviceInfo withLegacyIdentifiersDst (Span<const String, 16> x) const
{
auto copy = *this;
std::copy (x.begin(), x.end(), copy.identifierDst.begin());
return copy;
}
[[nodiscard]] StaticDeviceInfo withLegacyIdentifiers (IOKind k, Span<const String, 16> x) const
{
return k == IOKind::src ? withLegacyIdentifiersSrc (x) : withLegacyIdentifiersDst (x);
}
String getName() const { return name; }
String getManufacturer() const { return manufacturer; }
String getProduct() const { return product; }
bool hasSource() const { return source; }
bool hasDestination() const { return destination; }
Transport getTransport() const { return transport; }
/** Returns an identifier to uniquely identify each group, for use with the legacy MIDI API. */
Span<const String, 16> getLegacyIdentifiersSrc() const& { return identifierSrc; }
/** Returns an identifier to uniquely identify each group, for use with the legacy MIDI API. */
Span<const String, 16> getLegacyIdentifiersDst() const& { return identifierDst; }
Span<const String, 16> getLegacyIdentifiers (IOKind k) const&
{
return k == IOKind::src ? getLegacyIdentifiersSrc() : getLegacyIdentifiersDst();
}
Span<const String, 16> getLegacyIdentifiersSrc() const&& = delete;
Span<const String, 16> getLegacyIdentifiersDst() const&& = delete;
Span<const String, 16> getLegacyIdentifiers (IOKind) const&& = delete;
bool operator== (const StaticDeviceInfo&) const;
bool operator!= (const StaticDeviceInfo& other) const { return ! operator== (other); }
private:
auto tie() const;
std::array<String, 16> identifierSrc, identifierDst;
String name; ///< The full human-readable name of this device
String manufacturer; ///< The name of the organisation that produced this device
String product; ///< The human-readable product name
Transport transport{}; ///< The format used for MIDI messages in transit
uint8_t source = false; ///< True if the device can send messages
uint8_t destination = false; ///< True if the device can receive messages
};
}
@@ -0,0 +1,134 @@
/*
==============================================================================
This file is part of the JUCE framework.
Copyright (c) Raw Material Software Limited
JUCE is an open source framework subject to commercial or open source
licensing.
By downloading, installing, or using the JUCE framework, or combining the
JUCE framework with any other source code, object code, content or any other
copyrightable work, you agree to the terms of the JUCE End User Licence
Agreement, and all incorporated terms including the JUCE Privacy Policy and
the JUCE Website Terms of Service, as applicable, which will bind you. If you
do not agree to the terms of these agreements, we will not license the JUCE
framework to you, and you must discontinue the installation or download
process and cease use of the JUCE framework.
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
Or:
You may also use this code under the terms of the AGPLv3:
https://www.gnu.org/licenses/agpl-3.0.en.html
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
namespace juce::universal_midi_packets
{
class VirtualEndpoint::Impl final
{
public:
class Native
{
public:
virtual ~Native() = default;
virtual EndpointId getId() const = 0;
virtual bool setBlock (uint8_t, const Block&) = 0;
virtual bool setName (const String&) = 0;
};
EndpointId getId() const
{
return identifier;
}
bool setBlock (uint8_t i, const Block& b)
{
if (native != nullptr)
return native->setBlock (i, b);
return false;
}
bool setName (const String& n)
{
if (native != nullptr)
return native->setName (n);
return false;
}
bool isAlive() const
{
return native != nullptr;
}
static VirtualEndpoint makeVirtualEndpoint (std::unique_ptr<Native> x)
{
if (x != nullptr)
return VirtualEndpoint { rawToUniquePtr (new Impl (std::move (x))) };
return {};
}
private:
explicit Impl (std::unique_ptr<Native> n)
: native (std::move (n)),
identifier (native->getId())
{
}
std::unique_ptr<Native> native;
EndpointId identifier;
};
VirtualEndpoint::VirtualEndpoint() = default;
VirtualEndpoint::~VirtualEndpoint() = default;
VirtualEndpoint::VirtualEndpoint (std::unique_ptr<Impl> x) : impl (std::move (x)) {}
VirtualEndpoint::VirtualEndpoint (VirtualEndpoint&&) noexcept = default;
VirtualEndpoint& VirtualEndpoint::operator= (VirtualEndpoint&&) noexcept = default;
EndpointId VirtualEndpoint::getId() const
{
if (impl != nullptr)
return impl->getId();
return {};
}
bool VirtualEndpoint::setBlock (uint8_t i, const Block& b)
{
if (impl != nullptr)
return impl->setBlock (i, b);
return false;
}
bool VirtualEndpoint::setName (const String& x)
{
if (impl != nullptr)
return impl->setName (x);
return false;
}
bool VirtualEndpoint::isAlive() const
{
if (impl != nullptr)
return impl->isAlive();
return false;
}
}
@@ -0,0 +1,118 @@
/*
==============================================================================
This file is part of the JUCE framework.
Copyright (c) Raw Material Software Limited
JUCE is an open source framework subject to commercial or open source
licensing.
By downloading, installing, or using the JUCE framework, or combining the
JUCE framework with any other source code, object code, content or any other
copyrightable work, you agree to the terms of the JUCE End User Licence
Agreement, and all incorporated terms including the JUCE Privacy Policy and
the JUCE Website Terms of Service, as applicable, which will bind you. If you
do not agree to the terms of these agreements, we will not license the JUCE
framework to you, and you must discontinue the installation or download
process and cease use of the JUCE framework.
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
Or:
You may also use this code under the terms of the AGPLv3:
https://www.gnu.org/licenses/agpl-3.0.en.html
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
namespace juce::universal_midi_packets
{
/**
Represents a virtual device that allows this program to advertise itself to other MIDI-aware
applications on the system.
Creating a VirtualEndpoint will install a new endpoint on the system. This endpoint will
be visible when enumerating endpoints using the Endpoints singleton. If you're displaying
a list of endpoints in your UI, it's probably a good idea to omit any virtual endpoints
created by the current application in order to avoid confusion.
After creating a VirtualEndpoint, it can be opened like any other connection, by calling
Session::connectInput() and Session::connectOutput(), passing the EndpointId for the
virtual endpoint.
@tags{Audio}
*/
class VirtualEndpoint
{
public:
/** Creates an invalid virtual endpoint that doesn't correspond to any virtual device.
isAlive() will return false for a default-constructed VirtualEndpoint.
*/
VirtualEndpoint();
~VirtualEndpoint();
VirtualEndpoint (VirtualEndpoint&&) noexcept;
VirtualEndpoint& operator= (VirtualEndpoint&&) noexcept;
VirtualEndpoint (const VirtualEndpoint&) = delete;
VirtualEndpoint& operator= (const VirtualEndpoint&) = delete;
/** Retrieves the unique id of this endpoint.
Pass this ID to Session::connectInput() and/or Session::connectOutput in order to send and
receive messages through the virtual endpoint.
Note that this ID is *not* guaranteed to be stable - creating the 'same' virtual device
across several program invocations may produce a different ID each time.
To fetch the current details of this device, you can pass this ID to Endpoints::getEndpoint().
*/
EndpointId getId() const;
/** Sets new properties for the block at the given zero-based index. The number of function
blocks on an endpoint may not change.
Returns true on success, or false otherwise.
This may fail for several reasons, including:
- attempting to modify an endpoint with static function blocks
- attempting to update a block index that doesn't exist on this endpoint
- attempting to set a block with invalid properties, e.g. the sum of the start index and
number of included groups is greater than 16
- platform-specific reasons, e.g. macOS doesn't currently allow changing the number of
spanned groups in a block
*/
bool setBlock (uint8_t index, const Block& newBlock);
/** Assigns a new name to this endpoint, and sends a notification to connected endpoints. */
bool setName (const String&);
/** Returns true if this object represents an endpoint that is currently alive, or false if
the endpoint is not alive. This can happen because the endpoint failed to open, or
if the session holding the endpoint was closed.
This function returns false for a default-constructed instance.
*/
bool isAlive() const;
explicit operator bool() const { return isAlive(); }
/** @internal */
class Impl;
private:
explicit VirtualEndpoint (std::unique_ptr<Impl>);
std::unique_ptr<Impl> impl;
};
}