OpenShot Audio Library | OpenShotAudio 0.4.0

Loading...
Searching...
No Matches
juce_UMPackets.h
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23#ifndef DOXYGEN
24
25 namespace juce::universal_midi_packets
26{
27
39 class Packets
40{
41 public:
49 void add (const View& v) { storage.insert (storage.end(), v.cbegin(), v.cend()); }
50
51 void add (const PacketX1& p) { addImpl (p); }
52 void add (const PacketX2& p) { addImpl (p); }
53 void add (const PacketX3& p) { addImpl (p); }
54 void add (const PacketX4& p) { addImpl (p); }
55
57 void reserve (size_t numWords) { storage.reserve (numWords); }
58
60 void clear() { storage.clear(); }
61
63 Iterator cbegin() const noexcept { return Iterator (data(), size()); }
64 Iterator begin() const noexcept { return cbegin(); }
65
67 Iterator cend() const noexcept { return Iterator (data() + size(), 0); }
68 Iterator end() const noexcept { return cend(); }
69
71 const uint32_t* data() const noexcept { return storage.data(); }
72
78 size_t size() const noexcept { return storage.size(); }
79
80 private:
81 template <size_t numWords>
82 void addImpl (const Packet<numWords>& p)
83 {
84 jassert (Utils::getNumWordsForMessageType (p[0]) == numWords);
85 add (View (p.data()));
86 }
87
88 std::vector<uint32_t> storage;
89};
90
91} // namespace juce::universal_midi_packets
92
93#endif
juce::universal_midi_packets::Iterator
Definition juce_UMPIterator.h:38
juce::universal_midi_packets::Packet
Definition juce_UMPacket.h:35
juce::universal_midi_packets::Packets
Definition juce_UMPackets.h:40
juce::universal_midi_packets::Packets::data
const uint32_t * data() const noexcept
Definition juce_UMPackets.h:71
juce::universal_midi_packets::Packets::add
void add(const View &v)
Definition juce_UMPackets.h:49
juce::universal_midi_packets::Packets::size
size_t size() const noexcept
Definition juce_UMPackets.h:78
juce::universal_midi_packets::Packets::reserve
void reserve(size_t numWords)
Definition juce_UMPackets.h:57
juce::universal_midi_packets::Packets::cbegin
Iterator cbegin() const noexcept
Definition juce_UMPackets.h:63
juce::universal_midi_packets::Packets::clear
void clear()
Definition juce_UMPackets.h:60
juce::universal_midi_packets::Packets::cend
Iterator cend() const noexcept
Definition juce_UMPackets.h:67
juce::universal_midi_packets::View
Definition juce_UMPView.h:44
juce::universal_midi_packets::Utils::getNumWordsForMessageType
static uint32_t getNumWordsForMessageType(uint32_t)
Definition juce_UMPUtils.cpp:26