along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include <cmath>
+
+#ifdef COMPILER_MSVC
+#include <float.h>
+
+// 'std::isinf()' and 'std::isnan()' are not available in MSVC.
+#define isinf_local(val) !((bool)_finite((double)val))
+#define isnan_local(val) (bool)_isnan((double)val)
+#else
+#define isinf_local std::isinf
+#define isnan_local std::isnan
+#endif
#include "pbd/ffs.h"
#include "pbd/enumwriter.h"
#include "ardour/buffer_set.h"
#include "ardour/debug.h"
#include "ardour/delivery.h"
+#include "ardour/event_type_map.h"
#include "ardour/meter.h"
#include "ardour/midi_diskstream.h"
#include "ardour/midi_playlist.h"
}
int
-MidiTrack::export_stuff (BufferSet& /*bufs*/, framepos_t /*start_frame*/, framecnt_t /*nframes*/,
- boost::shared_ptr<Processor> /*endpoint*/, bool /*include_endpoint*/, bool /*for_export*/, bool /*for_freeze*/)
-{
- return -1;
+MidiTrack::export_stuff (BufferSet& buffers,
+ framepos_t start,
+ framecnt_t nframes,
+ boost::shared_ptr<Processor> endpoint,
+ bool include_endpoint,
+ bool for_export,
+ bool for_freeze)
+{
+ if (buffers.count().n_midi() == 0) {
+ return -1;
+ }
+
+ boost::shared_ptr<MidiDiskstream> diskstream = midi_diskstream();
+
+ Glib::Threads::RWLock::ReaderLock rlock (_processor_lock);
+
+ boost::shared_ptr<MidiPlaylist> mpl = boost::dynamic_pointer_cast<MidiPlaylist>(diskstream->playlist());
+ if (!mpl) {
+ return -2;
+ }
+
+ buffers.get_midi(0).clear();
+ if (mpl->read(buffers.get_midi(0), start, nframes, 0) != nframes) {
+ return -1;
+ }
+
+ //bounce_process (buffers, start, nframes, endpoint, include_endpoint, for_export, for_freeze);
+
+ return 0;
}
boost::shared_ptr<Region>
-MidiTrack::bounce (InterThreadInfo& /*itt*/)
+MidiTrack::bounce (InterThreadInfo& itt)
{
- std::cerr << "MIDI bounce currently unsupported" << std::endl;
- return boost::shared_ptr<Region> ();
+ return bounce_range (_session.current_start_frame(), _session.current_end_frame(), itt, main_outs(), false);
}
-
boost::shared_ptr<Region>
-MidiTrack::bounce_range (framepos_t /*start*/, framepos_t /*end*/, InterThreadInfo& /*itt*/,
- boost::shared_ptr<Processor> /*endpoint*/, bool /*include_endpoint*/)
+MidiTrack::bounce_range (framepos_t start,
+ framepos_t end,
+ InterThreadInfo& itt,
+ boost::shared_ptr<Processor> endpoint,
+ bool include_endpoint)
{
- std::cerr << "MIDI bounce range currently unsupported" << std::endl;
- return boost::shared_ptr<Region> ();
+ vector<boost::shared_ptr<Source> > srcs;
+ return _session.write_one_track (*this, start, end, false, srcs, itt, endpoint, include_endpoint, false, false);
}
void
MidiTrack::MidiControl::set_value(double val)
{
const Evoral::Parameter ¶meter = _list ? _list->parameter() : Control::parameter();
+ const Evoral::ParameterDescriptor &desc = EventTypeMap::instance().descriptor(parameter);
bool valid = false;
- if (isinf(val)) {
+ if (isinf_local(val)) {
cerr << "MIDIControl value is infinity" << endl;
- } else if (isnan(val)) {
+ } else if (isnan_local(val)) {
cerr << "MIDIControl value is NaN" << endl;
- } else if (val < parameter.min()) {
- cerr << "MIDIControl value is < " << parameter.min() << endl;
- } else if (val > parameter.max()) {
- cerr << "MIDIControl value is > " << parameter.max() << endl;
+ } else if (val < desc.lower) {
+ cerr << "MIDIControl value is < " << desc.lower << endl;
+ } else if (val > desc.upper) {
+ cerr << "MIDIControl value is > " << desc.upper << endl;
} else {
valid = true;
}
return;
}
- assert(val <= parameter.max());
+ assert(val <= desc.upper);
if ( ! _list || ! automation_playback()) {
size_t size = 3;
uint8_t ev[3] = { parameter.channel(), uint8_t (val), 0 };