2 * Copyright (C) 2006-2007 John Anderson
3 * Copyright (C) 2008-2012 Paul Davis <paul@linuxaudiosystems.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #ifndef midi_byte_array_h
20 #define midi_byte_array_h
25 #include <boost/shared_array.hpp>
27 //#include <midi++/types.h>
29 typedef unsigned char byte;
33 To make building arrays of bytes easier. Thusly:
36 mba << 0xf0 << 0x00 << 0xf7;
41 MidiByteArray direct( 3, 0xf0, 0x00, 0xf7 );
45 cout << direct << endl;
47 will all result in "f0 00 f7" being output to stdout
49 class MidiByteArray : public std::vector<MIDI::byte>
52 MidiByteArray() : std::vector<MIDI::byte>() {}
54 MidiByteArray( size_t count, MIDI::byte array[] );
57 Accepts a preceding count, and then a list of bytes
59 MidiByteArray( size_t count, MIDI::byte first, ... );
61 /// copy the given number of bytes from the given array
62 void copy( size_t count, MIDI::byte arr[] );
65 /// append the given byte to the end of the array
66 MidiByteArray & operator << ( MidiByteArray & mba, const MIDI::byte & b );
68 /// append the given string to the end of the array
69 MidiByteArray & operator << ( MidiByteArray & mba, const std::string & );
71 /// append the given array to the end of this array
72 MidiByteArray & operator << ( MidiByteArray & mba, const MidiByteArray & barr );
74 /// output the bytes as hex to the given stream
75 std::ostream & operator << ( std::ostream & os, const MidiByteArray & mba );