mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
MIDI: Add span getters for MidiMessage and MidiMessageMetadata
This commit is contained in:
parent
85191fa50a
commit
fb4f04e4d1
3 changed files with 16 additions and 4 deletions
|
|
@ -60,6 +60,13 @@ struct MidiMessageMetadata
|
|||
*/
|
||||
MidiMessage getMessage() const { return MidiMessage (data, numBytes, samplePosition); }
|
||||
|
||||
Span<const std::byte> asSpan() const&
|
||||
{
|
||||
return { reinterpret_cast<const std::byte*> (data), (size_t) numBytes };
|
||||
}
|
||||
|
||||
Span<const std::byte> asSpan() const&& = delete;
|
||||
|
||||
/** Pointer to the first byte of a MIDI message. */
|
||||
const uint8* data = nullptr;
|
||||
|
||||
|
|
|
|||
|
|
@ -987,6 +987,13 @@ public:
|
|||
static uint16 pitchbendToPitchwheelPos (float pitchbendInSemitones,
|
||||
float pitchbendRangeInSemitones) noexcept;
|
||||
|
||||
Span<const std::byte> asSpan() const&
|
||||
{
|
||||
return { reinterpret_cast<const std::byte*> (getRawData()), (size_t) getRawDataSize() };
|
||||
}
|
||||
|
||||
Span<const std::byte> asSpan() const&& = delete;
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
/** @cond */
|
||||
|
|
|
|||
|
|
@ -51,13 +51,11 @@ struct BytestreamMidiView
|
|||
to a temporary.
|
||||
*/
|
||||
explicit BytestreamMidiView (const MidiMessage* msg)
|
||||
: bytes (unalignedPointerCast<const std::byte*> (msg->getRawData()),
|
||||
static_cast<size_t> (msg->getRawDataSize())),
|
||||
: bytes (msg->asSpan()),
|
||||
timestamp (msg->getTimeStamp()) {}
|
||||
|
||||
explicit BytestreamMidiView (const MidiMessageMetadata msg)
|
||||
: bytes (unalignedPointerCast<const std::byte*> (msg.data),
|
||||
static_cast<size_t> (msg.numBytes)),
|
||||
: bytes (msg.asSpan()),
|
||||
timestamp (msg.samplePosition) {}
|
||||
|
||||
MidiMessage getMessage() const
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue