Lua bindings to access MIDI region/source note-events

This commit is contained in:
Robin Gareus 2017-03-18 18:37:19 +01:00
parent 940707e327
commit 6ceade76b3
3 changed files with 33 additions and 1 deletions

View File

@ -28,6 +28,7 @@
#include "ardour/libardour_visibility.h"
#include "ardour/midi_model.h"
#include "ardour/processor.h"
#include "ardour/session.h"
@ -300,6 +301,9 @@ namespace ARDOUR { namespace LuaAPI {
boost::shared_ptr<Evoral::Note<Evoral::Beats> >
new_noteptr (uint8_t, Evoral::Beats, Evoral::Beats, uint8_t, uint8_t);
std::list<boost::shared_ptr< Evoral::Note<Evoral::Beats> > >
note_list (boost::shared_ptr<ARDOUR::MidiModel>);
} } /* namespace */
namespace ARDOUR { namespace LuaOSC {

View File

@ -820,3 +820,17 @@ LuaAPI::new_noteptr (uint8_t chan, Evoral::Beats beat_time, Evoral::Beats length
{
return boost::shared_ptr<Evoral::Note<Evoral::Beats> > (new Evoral::Note<Evoral::Beats>(chan, beat_time, length, note, velocity));
}
std::list<boost::shared_ptr<Evoral::Note<Evoral::Beats> > >
LuaAPI::note_list (boost::shared_ptr<MidiModel> mm)
{
typedef typename boost::shared_ptr<Evoral::Note<Evoral::Beats> > NotePtr;
std::list<NotePtr> note_ptr_list;
const MidiModel::Notes& notes = mm->notes();
for (MidiModel::Notes::const_iterator i = notes.begin(); i != notes.end(); ++i) {
note_ptr_list.push_back (*i);
}
return note_ptr_list;
}

View File

@ -35,6 +35,7 @@
#include "ardour/audio_track.h"
#include "ardour/audioplaylist.h"
#include "ardour/buffer_set.h"
#include "ardour/beats_frames_converter.h"
#include "ardour/chan_mapping.h"
#include "ardour/dB.h"
#include "ardour/dsp_filter.h"
@ -165,6 +166,7 @@ CLASSKEYS(Selectable*);
CLASSKEYS(std::list<Selectable*>);
CLASSKEYS(ARDOUR::AudioEngine);
CLASSKEYS(ARDOUR::BeatsFramesConverter);
CLASSKEYS(ARDOUR::BufferSet);
CLASSKEYS(ARDOUR::ChanCount);
CLASSKEYS(ARDOUR::ChanMapping);
@ -1132,7 +1134,7 @@ LuaBindings::common (lua_State* L)
.deriveWSPtrClass <MidiRegion, Region> ("MidiRegion")
.addFunction ("do_export", &MidiRegion::do_export)
.addFunction ("midi_source", &MidiRegion::midi_source)
.addFunction ("model", (boost::shared_ptr<MidiModel> (MidiRegion::*)())&MidiRegion::midi_source)
.addFunction ("model", (boost::shared_ptr<MidiModel> (MidiRegion::*)())&MidiRegion::model)
.addFunction ("start_beats", &MidiRegion::start_beats)
.addFunction ("length_beats", &MidiRegion::length_beats)
.endClass ()
@ -1476,6 +1478,9 @@ LuaBindings::common (lua_State* L)
.addVoidPtrConstructor<std::list<boost::shared_ptr <AutomationControl> > > ()
.endClass ()
.beginStdList <boost::shared_ptr<Evoral::Note<Evoral::Beats> > > ("NotePtrList")
.endClass ()
#if 0 // depends on Evoal:: Note, Beats see note_fixer.h
// typedef Evoral::Note<Evoral::Beats> Note;
// std::set< boost::weak_ptr<Note> >
@ -1504,6 +1509,12 @@ LuaBindings::common (lua_State* L)
.addFunction ("frames_per_grid", &Meter::frames_per_grid)
.endClass ()
.beginClass <BeatsFramesConverter> ("BeatsFramesConverter")
.addConstructor <void (*) (const TempoMap&, framepos_t)> ()
.addFunction ("to", &BeatsFramesConverter::to)
.addFunction ("from", &BeatsFramesConverter::from)
.endClass ()
.beginClass <TempoMap> ("TempoMap")
.addFunction ("add_tempo", &TempoMap::add_tempo)
.addFunction ("add_meter", &TempoMap::add_meter)
@ -1514,6 +1525,8 @@ LuaBindings::common (lua_State* L)
.addFunction ("bbt_at_frame", &TempoMap::bbt_at_frame)
.addFunction ("exact_beat_at_frame", &TempoMap::exact_beat_at_frame)
.addFunction ("exact_qn_at_frame", &TempoMap::exact_qn_at_frame)
.addFunction ("framepos_plus_qn", &TempoMap::framepos_plus_qn)
.addFunction ("framewalk_to_qn", &TempoMap::framewalk_to_qn)
.endClass ()
.beginClass <MetricSection> ("MetricSection")
@ -1963,6 +1976,7 @@ LuaBindings::common (lua_State* L)
.addFunction ("monotonic_time", ::g_get_monotonic_time)
.addCFunction ("build_filename", ARDOUR::LuaAPI::build_filename)
.addFunction ("new_noteptr", ARDOUR::LuaAPI::new_noteptr)
.addFunction ("note_list", ARDOUR::LuaAPI::note_list)
.addCFunction ("sample_to_timecode", ARDOUR::LuaAPI::sample_to_timecode)
.addCFunction ("timecode_to_sample", ARDOUR::LuaAPI::timecode_to_sample)