JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_MidiBuffer.h
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23namespace juce
24{
25
26//==============================================================================
37{
38 MidiMessageMetadata() noexcept = default;
39
40 MidiMessageMetadata (const uint8* dataIn, int numBytesIn, int positionIn) noexcept
42 {
43 }
44
50
52 const uint8* data = nullptr;
53
55 int numBytes = 0;
56
59};
60
61//==============================================================================
78class JUCE_API MidiBufferIterator
79{
80 using Ptr = const uint8*;
81
82public:
83 MidiBufferIterator() = default;
84
90 explicit MidiBufferIterator (const uint8* dataIn) noexcept
91 : data (dataIn)
92 {
93 }
94
95 using difference_type = std::iterator_traits<Ptr>::difference_type;
96 using value_type = MidiMessageMetadata;
97 using reference = MidiMessageMetadata;
98 using pointer = void;
99 using iterator_category = std::input_iterator_tag;
100
102 MidiBufferIterator& operator++() noexcept;
103
107 MidiBufferIterator operator++ (int) noexcept;
108
112 bool operator== (const MidiBufferIterator& other) const noexcept { return data == other.data; }
113
117 bool operator!= (const MidiBufferIterator& other) const noexcept { return ! operator== (other); }
118
122 reference operator*() const noexcept;
123
124private:
125 Ptr data = nullptr;
126};
127
128//==============================================================================
144class JUCE_API MidiBuffer
145{
146public:
147 //==============================================================================
149 MidiBuffer() noexcept = default;
150
152 explicit MidiBuffer (const MidiMessage& message) noexcept;
153
154 //==============================================================================
156 void clear() noexcept;
157
163 void clear (int start, int numSamples);
164
168 bool isEmpty() const noexcept;
169
176 int getNumEvents() const noexcept;
177
191 bool addEvent (const MidiMessage& midiMessage, int sampleNumber);
192
211 bool addEvent (const void* rawMidiData,
212 int maxBytesOfMidiData,
213 int sampleNumber);
214
229 void addEvents (const MidiBuffer& otherBuffer,
230 int startSample,
231 int numSamples,
232 int sampleDeltaToAdd);
233
237 int getFirstEventTime() const noexcept;
238
242 int getLastEventTime() const noexcept;
243
244 //==============================================================================
250 void swapWith (MidiBuffer&) noexcept;
251
256 void ensureSize (size_t minimumNumBytes);
257
259 MidiBufferIterator begin() const noexcept { return cbegin(); }
260
262 MidiBufferIterator end() const noexcept { return cend(); }
263
265 MidiBufferIterator cbegin() const noexcept { return MidiBufferIterator (data.begin()); }
266
268 MidiBufferIterator cend() const noexcept { return MidiBufferIterator (data.end()); }
269
273 MidiBufferIterator findNextSamplePosition (int samplePosition) const noexcept;
274
275 //==============================================================================
276 #ifndef DOXYGEN
286 class [[deprecated]] JUCE_API Iterator
287 {
288 public:
289 //==============================================================================
291 Iterator (const MidiBuffer& b) noexcept;
292
293 //==============================================================================
297 void setNextSamplePosition (int samplePosition) noexcept;
298
308 bool getNextEvent (MidiMessage& result,
309 int& samplePosition) noexcept;
310
324 bool getNextEvent (const uint8* &midiData,
325 int& numBytesOfMidiData,
326 int& samplePosition) noexcept;
327
328 private:
329 //==============================================================================
330 const MidiBuffer& buffer;
331 MidiBufferIterator iterator;
332 };
333 #endif
334
340
341private:
343};
344
345} // namespace juce
Holds a resizable array of primitive or copy-by-value objects.
Definition juce_Array.h:56
An iterator to move over contiguous raw MIDI data, which Allows iterating over a MidiBuffer using C++...
MidiBufferIterator(const uint8 *dataIn) noexcept
Constructs an iterator pointing at the message starting at the byte dataIn.
Holds a sequence of time-stamped midi events.
MidiBufferIterator cbegin() const noexcept
Get a read-only iterator pointing to the beginning of this buffer.
MidiBufferIterator cend() const noexcept
Get a read-only iterator pointing one past the end of this buffer.
MidiBuffer() noexcept=default
Creates an empty MidiBuffer.
Array< uint8 > data
The raw data holding this buffer.
MidiBufferIterator end() const noexcept
Get a read-only iterator pointing one past the end of this buffer.
Encapsulates a MIDI message.
#define JUCE_LEAK_DETECTOR(OwnerClass)
This macro lets you embed a leak-detecting object inside a class.
JUCE Namespace.
const DirectoryEntry & operator*(const DirectoryEntry &e) noexcept
A convenience operator so that the expression *it++ works correctly when it is an instance of RangedD...
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88
unsigned char uint8
A platform-independent 8-bit unsigned integer type.
A view of MIDI message data stored in a contiguous buffer.
const uint8 * data
Pointer to the first byte of a MIDI message.
int samplePosition
The MIDI message's timestamp.
int numBytes
The number of bytes in the MIDI message.
MidiMessage getMessage() const
Constructs a new MidiMessage instance from the data that this object is viewing.