OpenShot Audio Library | OpenShotAudio  0.3.0
juce_MidiBuffer.h
1 /*
2  ==============================================================================
3 
4  This file is part of the JUCE library.
5  Copyright (c) 2017 - ROLI Ltd.
6 
7  JUCE is an open source library subject to commercial or open-source
8  licensing.
9 
10  The code included in this file is provided under the terms of the ISC license
11  http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12  To use, copy, modify, and/or distribute this software for any purpose with or
13  without fee is hereby granted provided that the above copyright notice and
14  this permission notice appear in all copies.
15 
16  JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17  EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18  DISCLAIMED.
19 
20  ==============================================================================
21 */
22 
23 namespace juce
24 {
25 
26 //==============================================================================
42 class JUCE_API MidiBuffer
43 {
44 public:
45  //==============================================================================
47  MidiBuffer() noexcept;
48 
50  explicit MidiBuffer (const MidiMessage& message) noexcept;
51 
53  MidiBuffer (const MidiBuffer&) noexcept;
54 
56  MidiBuffer& operator= (const MidiBuffer&) noexcept;
57 
59  ~MidiBuffer();
60 
61  //==============================================================================
63  void clear() noexcept;
64 
70  void clear (int start, int numSamples);
71 
75  bool isEmpty() const noexcept;
76 
83  int getNumEvents() const noexcept;
84 
96  void addEvent (const MidiMessage& midiMessage, int sampleNumber);
97 
114  void addEvent (const void* rawMidiData,
115  int maxBytesOfMidiData,
116  int sampleNumber);
117 
132  void addEvents (const MidiBuffer& otherBuffer,
133  int startSample,
134  int numSamples,
135  int sampleDeltaToAdd);
136 
140  int getFirstEventTime() const noexcept;
141 
145  int getLastEventTime() const noexcept;
146 
147  //==============================================================================
153  void swapWith (MidiBuffer&) noexcept;
154 
159  void ensureSize (size_t minimumNumBytes);
160 
161  //==============================================================================
170  class JUCE_API Iterator
171  {
172  public:
173  //==============================================================================
175  Iterator (const MidiBuffer&) noexcept;
176 
178  Iterator (const Iterator&) = default;
179 
181  ~Iterator() noexcept;
182 
183  //==============================================================================
187  void setNextSamplePosition (int samplePosition) noexcept;
188 
198  bool getNextEvent (MidiMessage& result,
199  int& samplePosition) noexcept;
200 
214  bool getNextEvent (const uint8* &midiData,
215  int& numBytesOfMidiData,
216  int& samplePosition) noexcept;
217 
218  private:
219  //==============================================================================
220  const MidiBuffer& buffer;
221  const uint8* data;
222  };
223 
229 
230 private:
231  JUCE_LEAK_DETECTOR (MidiBuffer)
232 };
233 
234 } // namespace juce
Array< uint8 > data