Use normal Processor run_in_place interface on Meter.
[ardour.git] / libs / ardour / base_midi_port.cc
1 /*
2     Copyright (C) 2006 Paul Davis 
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19 #include <cassert>
20 #include <iostream>
21 #include <glib.h>
22 #include <ardour/base_midi_port.h>
23 #include <ardour/data_type.h>
24
25 using namespace ARDOUR;
26 using namespace std;
27
28 BaseMidiPort::BaseMidiPort (const std::string& name, Flags flags)
29         : Port (name, flags)
30         , _buffer (0) 
31         , _own_buffer (false)
32 {
33         _type = DataType::MIDI;
34         _mixdown = default_mixdown;
35 }
36
37 BaseMidiPort::~BaseMidiPort()
38 {
39         if (_own_buffer && _buffer) {
40                 delete _buffer;
41         }
42 }
43
44 void
45 BaseMidiPort::default_mixdown (const set<Port*>& ports, MidiBuffer* dest, nframes_t cnt, nframes_t offset, bool first_overwrite)
46 {
47         set<Port*>::const_iterator p = ports.begin();
48
49         if (first_overwrite) {
50                 cout << "first overwrite" << endl;
51                 dest->read_from ((dynamic_cast<BaseMidiPort*>(*p))->get_midi_buffer(), cnt, offset);
52                 p++;
53         }
54
55         // XXX DAVE: this is just a guess
56
57         for (; p != ports.end(); ++p) {
58                 cout << "merge" << endl;
59                 dest->merge (*dest, (dynamic_cast<BaseMidiPort*>(*p))->get_midi_buffer());
60         }
61 }
62
63 void 
64 BaseMidiPort::set_mixdown_function (void (*func)(const set<Port*>&, MidiBuffer*, nframes_t, nframes_t, bool))
65 {
66         g_atomic_pointer_set(&_mixdown, func);
67 }