2 * Copyright (C) 2014 Robin Gareus <robin@gareus.org>
3 * Copyright (C) 2013 Paul Davis
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
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include "dummy_audiobackend.h"
24 #include "pbd/error.h"
27 using namespace ARDOUR;
29 static std::string s_instance_name;
30 size_t DummyAudioBackend::_max_buffer_size = 8192;
32 DummyAudioBackend::DummyAudioBackend (AudioEngine& e)
35 , _freewheeling (false)
37 , _audio_buffersize (1024)
41 , _systemic_input_latency (0)
42 , _systemic_output_latency (0)
43 , _processed_samples (0)
45 _instance_name = s_instance_name;
48 DummyAudioBackend::~DummyAudioBackend ()
52 /* AUDIOBACKEND API */
55 DummyAudioBackend::name () const
61 DummyAudioBackend::is_realtime () const
66 std::vector<AudioBackend::DeviceStatus>
67 DummyAudioBackend::enumerate_devices () const
69 std::vector<AudioBackend::DeviceStatus> s;
70 s.push_back (DeviceStatus (_("Dummy"), true));
75 DummyAudioBackend::available_sample_rates (const std::string&) const
77 std::vector<float> sr;
78 sr.push_back (8000.0);
79 sr.push_back (22050.0);
80 sr.push_back (24000.0);
81 sr.push_back (44100.0);
82 sr.push_back (48000.0);
83 sr.push_back (88200.0);
84 sr.push_back (96000.0);
85 sr.push_back (176400.0);
86 sr.push_back (192000.0);
91 DummyAudioBackend::available_buffer_sizes (const std::string&) const
93 std::vector<uint32_t> bs;
110 DummyAudioBackend::available_input_channel_count (const std::string&) const
116 DummyAudioBackend::available_output_channel_count (const std::string&) const
122 DummyAudioBackend::can_change_sample_rate_when_running () const
128 DummyAudioBackend::can_change_buffer_size_when_running () const
134 DummyAudioBackend::set_device_name (const std::string&)
140 DummyAudioBackend::set_sample_rate (float sr)
142 if (sr <= 0) { return -1; }
144 engine.sample_rate_change (sr);
149 DummyAudioBackend::set_buffer_size (uint32_t bs)
151 if (bs <= 0 || bs >= _max_buffer_size) {
154 _audio_buffersize = bs;
155 engine.buffer_size_change (bs);
160 DummyAudioBackend::set_interleaved (bool yn)
162 if (!yn) { return 0; }
167 DummyAudioBackend::set_input_channels (uint32_t cc)
174 DummyAudioBackend::set_output_channels (uint32_t cc)
181 DummyAudioBackend::set_systemic_input_latency (uint32_t sl)
183 _systemic_input_latency = sl;
188 DummyAudioBackend::set_systemic_output_latency (uint32_t sl)
190 _systemic_output_latency = sl;
194 /* Retrieving parameters */
196 DummyAudioBackend::device_name () const
198 return _("Dummy Device");
202 DummyAudioBackend::sample_rate () const
208 DummyAudioBackend::buffer_size () const
210 return _audio_buffersize;
214 DummyAudioBackend::interleaved () const
220 DummyAudioBackend::input_channels () const
226 DummyAudioBackend::output_channels () const
232 DummyAudioBackend::systemic_input_latency () const
234 return _systemic_input_latency;
238 DummyAudioBackend::systemic_output_latency () const
240 return _systemic_output_latency;
244 std::vector<std::string>
245 DummyAudioBackend::enumerate_midi_options () const
247 std::vector<std::string> m;
248 m.push_back (_("None"));
253 DummyAudioBackend::set_midi_option (const std::string&)
259 DummyAudioBackend::midi_option () const
266 static void * pthread_process (void *arg)
268 DummyAudioBackend *d = static_cast<DummyAudioBackend *>(arg);
269 d->main_process_thread ();
275 DummyAudioBackend::_start (bool /*for_latency_measurement*/)
278 PBD::error << _("DummyAudioBackend: already active.") << endmsg;
281 if (pthread_create (&_main_thread, NULL, pthread_process, this)) {
282 PBD::error << _("DummyAudioBackend: cannot start.") << endmsg;
286 while (!_running && --timeout > 0) { usleep (1000); }
288 if (timeout == 0 || !_running) {
289 PBD::error << _("DummyAudioBackend: failed to start process thread.") << endmsg;
293 if (engine.reestablish_ports ()) {
294 PBD::error << _("DummyAudioBackend: Could not re-establish ports.") << endmsg;
299 engine.reconnect_ports ();
304 DummyAudioBackend::stop ()
312 if (pthread_join (_main_thread, &status)) {
313 PBD::error << _("DummyAudioBackend: failed to terminate.") << endmsg;
320 DummyAudioBackend::freewheel (bool onoff)
322 if (onoff != _freewheeling) {
325 _freewheeling = onoff;
326 engine.freewheel_callback (onoff);
331 DummyAudioBackend::dsp_load () const
333 return 100.f * _dsp_load;
337 DummyAudioBackend::raw_buffer_size (DataType t)
340 case DataType::AUDIO:
341 return _max_buffer_size * sizeof(Sample);
343 return _max_buffer_size; // XXX not really limited
350 DummyAudioBackend::sample_time ()
352 return _processed_samples;
356 DummyAudioBackend::sample_time_at_cycle_start ()
358 return _processed_samples;
362 DummyAudioBackend::samples_since_cycle_start ()
369 DummyAudioBackend::dummy_process_thread (void *arg)
371 ThreadData* td = reinterpret_cast<ThreadData*> (arg);
372 boost::function<void ()> f = td->f;
379 DummyAudioBackend::create_process_thread (boost::function<void()> func)
383 size_t stacksize = 100000;
385 pthread_attr_init (&attr);
386 pthread_attr_setstacksize (&attr, stacksize);
387 ThreadData* td = new ThreadData (this, func, stacksize);
389 if (pthread_create (&thread_id, &attr, dummy_process_thread, td)) {
390 PBD::error << _("AudioEngine: cannot create process thread.") << endmsg;
394 _threads.push_back (thread_id);
399 DummyAudioBackend::join_process_threads ()
403 for (std::vector<pthread_t>::const_iterator i = _threads.begin (); i != _threads.end (); ++i)
406 if (pthread_join (*i, &status)) {
407 PBD::error << _("AudioEngine: cannot terminate process thread.") << endmsg;
416 DummyAudioBackend::in_process_thread ()
418 for (std::vector<pthread_t>::const_iterator i = _threads.begin (); i != _threads.end (); ++i)
420 #ifdef COMPILER_MINGW
421 if (*i == GetCurrentThread ()) {
425 if (pthread_equal (*i, pthread_self ()) != 0) {
434 DummyAudioBackend::process_thread_count ()
436 return _threads.size ();
440 DummyAudioBackend::update_latencies ()
447 DummyAudioBackend::private_handle () const
453 DummyAudioBackend::my_name () const
455 return _instance_name;
459 DummyAudioBackend::available () const
465 DummyAudioBackend::port_name_size () const
471 DummyAudioBackend::set_port_name (PortEngine::PortHandle port, const std::string& name)
473 if (!valid_port (port)) {
474 PBD::error << _("DummyBackend::set_port_name: Invalid Port(s)") << endmsg;
477 return static_cast<DummyPort*>(port)->set_name (_instance_name + ":" + name);
481 DummyAudioBackend::get_port_name (PortEngine::PortHandle port) const
483 if (!valid_port (port)) {
484 PBD::error << _("DummyBackend::get_port_name: Invalid Port(s)") << endmsg;
485 return std::string ();
487 return static_cast<DummyPort*>(port)->name ();
490 PortEngine::PortHandle
491 DummyAudioBackend::get_port_by_name (const std::string& name) const
493 PortHandle port = (PortHandle) find_port (name);
498 DummyAudioBackend::get_ports (
499 const std::string& port_name_pattern,
500 DataType type, PortFlags flags,
501 std::vector<std::string>& port_names) const
505 bool use_regexp = false;
506 if (port_name_pattern.size () > 0) {
507 if (!regcomp (&port_regex, port_name_pattern.c_str (), REG_EXTENDED|REG_NOSUB)) {
511 for (size_t i = 0; i < _ports.size (); ++i) {
512 DummyPort* port = _ports[i];
513 if ((port->type () == type) && (port->flags () & flags)) {
514 if (!use_regexp || !regexec (&port_regex, port->name ().c_str (), 0, NULL, 0)) {
515 port_names.push_back (port->name ());
521 regfree (&port_regex);
527 DummyAudioBackend::port_data_type (PortEngine::PortHandle port) const
529 if (!valid_port (port)) {
530 return DataType::NIL;
532 return static_cast<DummyPort*>(port)->type ();
535 PortEngine::PortHandle
536 DummyAudioBackend::register_port (
537 const std::string& name,
538 ARDOUR::DataType type,
539 ARDOUR::PortFlags flags)
541 if (name.size () == 0) { return 0; }
542 if (flags & IsPhysical) { return 0; }
543 if (find_port (_instance_name + ":" + name) != NULL) {
544 PBD::error << _("DummyBackend::register_port: Port already exists.") << endmsg;
548 DummyPort* port = NULL;
550 case DataType::AUDIO:
551 port = new DummyAudioPort (_instance_name + ":" + name, flags);
554 port = new DummyMidiPort (_instance_name + ":" + name, flags);
557 PBD::error << _("DummyBackend::register_port: Invalid Data Type.") << endmsg;
561 _ports.push_back (port);
567 DummyAudioBackend::unregister_port (PortEngine::PortHandle port_handle)
569 if (!valid_port (port_handle)) {
570 PBD::error << _("DummyBackend::unregister_port: Invalid Port.") << endmsg;
572 DummyPort* port = (DummyPort*)port_handle;
573 std::vector<DummyPort*>::iterator i = std::find (_ports.begin (), _ports.end (), (DummyPort*)port_handle);
574 if (i == _ports.end ()) {
575 PBD::error << _("DummyBackend::unregister_port: Failed to find port") << endmsg;
583 DummyAudioBackend::connect (const std::string& src, const std::string& dst)
585 DummyPort* src_port = find_port (src);
586 DummyPort* dst_port = find_port (dst);
589 PBD::error << _("DummyBackend::connect: Invalid Source port:")
590 << " (" << src <<")" << endmsg;
594 PBD::error << _("DummyBackend::connect: Invalid Destination port:")
595 << " (" << dst <<")" << endmsg;
598 return src_port->connect (dst_port);
602 DummyAudioBackend::disconnect (const std::string& src, const std::string& dst)
604 DummyPort* src_port = find_port (src);
605 DummyPort* dst_port = find_port (dst);
607 if (!src_port || !dst_port) {
608 PBD::error << _("DummyBackend::disconnect: Invalid Port(s)") << endmsg;
611 return src_port->disconnect (dst_port);
615 DummyAudioBackend::connect (PortEngine::PortHandle src, const std::string& dst)
617 DummyPort* dst_port = find_port (dst);
618 if (!valid_port (src)) {
619 PBD::error << _("DummyBackend::connect: Invalid Source Port Handle") << endmsg;
623 PBD::error << _("DummyBackend::connect: Invalid Destination Port")
624 << " (" << dst << ")" << endmsg;
627 return static_cast<DummyPort*>(src)->connect (dst_port);
631 DummyAudioBackend::disconnect (PortEngine::PortHandle src, const std::string& dst)
633 DummyPort* dst_port = find_port (dst);
634 if (!valid_port (src) || !dst_port) {
635 PBD::error << _("DummyBackend::disconnect: Invalid Port(s)") << endmsg;
638 return static_cast<DummyPort*>(src)->disconnect (dst_port);
642 DummyAudioBackend::disconnect_all (PortEngine::PortHandle port)
644 if (!valid_port (port)) {
645 PBD::error << _("DummyBackend::disconnect_all: Invalid Port") << endmsg;
648 static_cast<DummyPort*>(port)->disconnect_all ();
653 DummyAudioBackend::connected (PortEngine::PortHandle port, bool /* process_callback_safe*/)
655 if (!valid_port (port)) {
656 PBD::error << _("DummyBackend::disconnect_all: Invalid Port") << endmsg;
659 return static_cast<DummyPort*>(port)->is_connected ();
663 DummyAudioBackend::connected_to (PortEngine::PortHandle src, const std::string& dst, bool /*process_callback_safe*/)
665 DummyPort* dst_port = find_port (dst);
666 if (!valid_port (src) || !dst_port) {
667 PBD::error << _("DummyBackend::connected_to: Invalid Port") << endmsg;
670 return static_cast<DummyPort*>(src)->is_connected (dst_port);
674 DummyAudioBackend::physically_connected (PortEngine::PortHandle port, bool /*process_callback_safe*/)
676 if (!valid_port (port)) {
677 PBD::error << _("DummyBackend::physically_connected: Invalid Port") << endmsg;
680 return static_cast<DummyPort*>(port)->is_physically_connected ();
684 DummyAudioBackend::get_connections (PortEngine::PortHandle port, std::vector<std::string>& names, bool /*process_callback_safe*/)
686 if (!valid_port (port)) {
687 PBD::error << _("DummyBackend::get_connections: Invalid Port") << endmsg;
691 assert (0 == names.size ());
693 const std::vector<DummyPort*>& connected_ports = static_cast<DummyPort*>(port)->get_connections ();
695 for (std::vector<DummyPort*>::const_iterator i = connected_ports.begin (); i != connected_ports.end (); ++i) {
696 names.push_back ((*i)->name ());
699 return (int)names.size ();
704 DummyAudioBackend::midi_event_get (
705 pframes_t& timestamp,
706 size_t& size, uint8_t** buf, void* port_buffer,
707 uint32_t event_index)
709 assert (buf && port_buffer);
710 DummyMidiBuffer& source = * (DummyMidiBuffer*)port_buffer;
711 if (event_index >= source.size ()) {
714 DummyMidiEvent * const event = source[event_index].get ();
716 timestamp = event->timestamp ();
717 size = event->size ();
718 *buf = event->data ();
723 DummyAudioBackend::midi_event_put (
726 const uint8_t* buffer, size_t size)
728 assert (buffer && port_buffer);
729 DummyMidiBuffer& dst = * (DummyMidiBuffer*)port_buffer;
730 if (dst.size () && (pframes_t)dst.back ()->timestamp () > timestamp) {
731 fprintf (stderr, "DummyMidiBuffer: it's too late for this event.\n");
734 dst.push_back (boost::shared_ptr<DummyMidiEvent>(new DummyMidiEvent (timestamp, buffer, size)));
739 DummyAudioBackend::get_midi_event_count (void* port_buffer)
741 assert (port_buffer);
742 return static_cast<DummyMidiBuffer*>(port_buffer)->size ();
746 DummyAudioBackend::midi_clear (void* port_buffer)
748 assert (port_buffer);
749 DummyMidiBuffer * buf = static_cast<DummyMidiBuffer*>(port_buffer);
757 DummyAudioBackend::can_monitor_input () const
763 DummyAudioBackend::request_input_monitoring (PortEngine::PortHandle, bool)
769 DummyAudioBackend::ensure_input_monitoring (PortEngine::PortHandle, bool)
775 DummyAudioBackend::monitoring_input (PortEngine::PortHandle)
780 /* Latency management */
783 DummyAudioBackend::set_latency_range (PortEngine::PortHandle port, bool for_playback, LatencyRange latency_range)
785 if (!valid_port (port)) {
786 PBD::error << _("DummyPort::set_latency_range (): invalid port.") << endmsg;
788 static_cast<DummyPort*>(port)->set_latency_range (latency_range, for_playback);
792 DummyAudioBackend::get_latency_range (PortEngine::PortHandle port, bool for_playback)
794 if (!valid_port (port)) {
795 PBD::error << _("DummyPort::get_latency_range (): invalid port.") << endmsg;
801 return static_cast<DummyPort*>(port)->latency_range (for_playback);
804 /* Discovering physical ports */
807 DummyAudioBackend::port_is_physical (PortEngine::PortHandle port) const
809 if (!valid_port (port)) {
810 PBD::error << _("DummyPort::port_is_physical (): invalid port.") << endmsg;
813 return static_cast<DummyPort*>(port)->is_physical ();
817 DummyAudioBackend::get_physical_outputs (DataType type, std::vector<std::string>& port_names)
819 for (size_t i = 0; i < _ports.size (); ++i) {
820 DummyPort* port = _ports[i];
821 if ((port->type () == type) && port->is_output () && port->is_physical ()) {
822 port_names.push_back (port->name ());
828 DummyAudioBackend::get_physical_inputs (DataType type, std::vector<std::string>& port_names)
830 for (size_t i = 0; i < _ports.size (); ++i) {
831 DummyPort* port = _ports[i];
832 if ((port->type () == type) && port->is_input () && port->is_physical ()) {
833 port_names.push_back (port->name ());
839 DummyAudioBackend::n_physical_outputs () const
843 for (size_t i = 0; i < _ports.size (); ++i) {
844 DummyPort* port = _ports[i];
845 if (port->is_output () && port->is_physical ()) {
846 switch (port->type ()) {
847 case DataType::AUDIO: ++n_audio; break;
848 case DataType::MIDI: ++n_midi; break;
854 cc.set (DataType::AUDIO, n_audio);
855 cc.set (DataType::MIDI, n_midi);
860 DummyAudioBackend::n_physical_inputs () const
864 for (size_t i = 0; i < _ports.size (); ++i) {
865 DummyPort* port = _ports[i];
866 if (port->is_input () && port->is_physical ()) {
867 switch (port->type ()) {
868 case DataType::AUDIO: ++n_audio; break;
869 case DataType::MIDI: ++n_midi; break;
875 cc.set (DataType::AUDIO, n_audio);
876 cc.set (DataType::MIDI, n_midi);
880 /* Getting access to the data buffer for a port */
883 DummyAudioBackend::get_buffer (PortEngine::PortHandle port, pframes_t nframes)
886 assert (valid_port (port));
887 return static_cast<DummyPort*>(port)->get_buffer (nframes);
892 DummyAudioBackend::main_process_thread ()
894 AudioEngine::thread_init_callback (this);
896 _processed_samples = 0;
898 struct timeval clock1, clock2;
899 ::gettimeofday (&clock1, NULL);
901 if (engine.process_callback (_audio_buffersize)) {
904 _processed_samples += _audio_buffersize;
905 if (!_freewheeling) {
906 ::gettimeofday (&clock2, NULL);
907 const int elapsed_time = (clock2.tv_sec - clock1.tv_sec) * 1000000 + (clock2.tv_usec - clock1.tv_usec);
908 const int nomial_time = 1000000 * _audio_buffersize / _samplerate;
909 _dsp_load = elapsed_time / (float) nomial_time;
910 if (elapsed_time < nomial_time) {
911 ::usleep (nomial_time - elapsed_time);
913 ::usleep (100); // don't hog cpu
917 ::usleep (100); // don't hog cpu
919 ::gettimeofday (&clock1, NULL);
926 /******************************************************************************/
928 static boost::shared_ptr<DummyAudioBackend> _instance;
930 static boost::shared_ptr<AudioBackend>
931 backend_factory (AudioEngine& e)
934 _instance.reset (new DummyAudioBackend (e));
940 instantiate (const std::string& arg1, const std::string& /* arg2 */)
942 s_instance_name = arg1;
954 already_configured ()
959 static ARDOUR::AudioBackendInfo _descriptor = {
967 extern "C" ARDOURBACKEND_API ARDOUR::AudioBackendInfo* descriptor ()
973 /******************************************************************************/
974 DummyPort::DummyPort (const std::string& name, PortFlags flags)
978 _capture_latency_range.min = 0;
979 _capture_latency_range.max = 0;
980 _playback_latency_range.min = 0;
981 _playback_latency_range.max = 0;
984 DummyPort::~DummyPort () {
989 int DummyPort::connect (DummyPort *port)
992 PBD::error << _("DummyPort::connect (): invalid (null) port") << endmsg;
996 if (type () != port->type ()) {
997 PBD::error << _("DummyPort::connect (): wrong port-type") << endmsg;
1001 if (is_output () && port->is_output ()) {
1002 PBD::error << _("DummyPort::connect (): cannot inter-connect output ports.") << endmsg;
1006 if (is_input () && port->is_input ()) {
1007 PBD::error << _("DummyPort::connect (): cannot inter-connect input ports.") << endmsg;
1012 PBD::error << _("DummyPort::connect (): cannot self-connect ports.") << endmsg;
1016 if (is_connected (port)) {
1017 PBD::error << _("DummyPort::connect (): ports are already connected:")
1018 << " (" << name () << ") -> (" << port->name () << ")"
1023 _connect (port, true);
1028 void DummyPort::_connect (DummyPort *port, bool callback)
1030 _connections.push_back (port);
1032 port->_connect (this, false);
1036 int DummyPort::disconnect (DummyPort *port)
1039 PBD::error << _("DummyPort::disconnect (): invalid (null) port") << endmsg;
1043 if (!is_connected (port)) {
1044 PBD::error << _("DummyPort::disconnect (): ports are not connected:")
1045 << " (" << name () << ") -> (" << port->name () << ")"
1049 _disconnect (port, true);
1053 void DummyPort::_disconnect (DummyPort *port, bool callback)
1055 std::vector<DummyPort*>::iterator it = std::find (_connections.begin (), _connections.end (), port);
1057 assert (it != _connections.end ());
1059 _connections.erase (it);
1062 port->_disconnect (this, false);
1067 void DummyPort::disconnect_all ()
1069 while (!_connections.empty ()) {
1070 _connections.back ()->_disconnect (this, false);
1071 _connections.pop_back ();
1076 DummyPort::is_connected (const DummyPort *port) const
1078 return std::find (_connections.begin (), _connections.end (), port) != _connections.end ();
1081 bool DummyPort::is_physically_connected () const
1083 for (std::vector<DummyPort*>::const_iterator it = _connections.begin (); it != _connections.end (); ++it) {
1084 if ((*it)->is_physical ()) {
1091 /******************************************************************************/
1093 DummyAudioPort::DummyAudioPort (const std::string& name, PortFlags flags)
1094 : DummyPort (name, flags)
1096 memset (_buffer, 0, sizeof (_buffer));
1099 DummyAudioPort::~DummyAudioPort () { }
1101 void* DummyAudioPort::get_buffer (pframes_t n_samples)
1104 std::vector<DummyPort*>::const_iterator it = get_connections ().begin ();
1105 if (it == get_connections ().end ()) {
1106 memset (_buffer, 0, n_samples * sizeof (Sample));
1108 DummyAudioPort const * source = static_cast<const DummyAudioPort*>(*it);
1109 assert (source && source->is_output ());
1110 memcpy (_buffer, source->const_buffer (), n_samples * sizeof (Sample));
1111 while (++it != get_connections ().end ()) {
1112 source = static_cast<const DummyAudioPort*>(*it);
1113 assert (source && source->is_output ());
1114 Sample* dst = buffer ();
1115 const Sample* src = source->const_buffer ();
1116 for (uint32_t s = 0; s < n_samples; ++s, ++dst, ++src) {
1126 DummyMidiPort::DummyMidiPort (const std::string& name, PortFlags flags)
1127 : DummyPort (name, flags)
1132 DummyMidiPort::~DummyMidiPort () { }
1134 void* DummyMidiPort::get_buffer (pframes_t /* nframes */)
1138 for (std::vector<DummyPort*>::const_iterator i = get_connections ().begin ();
1139 i != get_connections ().end ();
1141 const DummyMidiBuffer src = static_cast<const DummyMidiPort*>(*i)->const_buffer ();
1142 for (DummyMidiBuffer::const_iterator it = src.begin (); it != src.end (); ++it) {
1143 _buffer.push_back (boost::shared_ptr<DummyMidiEvent>(new DummyMidiEvent (**it)));
1146 std::sort (_buffer.begin (), _buffer.end ());
1151 DummyMidiEvent::DummyMidiEvent (const pframes_t timestamp, const uint8_t* data, size_t size)
1153 , _timestamp (timestamp)
1157 _data = (uint8_t*) malloc (size);
1158 memcpy (_data, data, size);
1162 DummyMidiEvent::DummyMidiEvent (const DummyMidiEvent& other)
1163 : _size (other.size ())
1164 , _timestamp (other.timestamp ())
1167 if (other.size () && other.const_data ()) {
1168 _data = (uint8_t*) malloc (other.size ());
1169 memcpy (_data, other.const_data (), other.size ());
1173 DummyMidiEvent::~DummyMidiEvent () {