diff options
author | Robin Gareus <robin@gareus.org> | 2017-03-18 18:37:19 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2017-03-18 19:07:03 +0100 |
commit | 6ceade76b32fe5e63901ae926b7198870c1b79a4 (patch) | |
tree | d13007edd6298ab8530d51c2175faf3caf5f2f13 /libs | |
parent | 940707e327014f30791d75be00ccbd33b0a0555d (diff) |
Lua bindings to access MIDI region/source note-events
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/lua_api.h | 4 | ||||
-rw-r--r-- | libs/ardour/lua_api.cc | 14 | ||||
-rw-r--r-- | libs/ardour/luabindings.cc | 16 |
3 files changed, 33 insertions, 1 deletions
diff --git a/libs/ardour/ardour/lua_api.h b/libs/ardour/ardour/lua_api.h index cbbe750164..bd71576e7c 100644 --- a/libs/ardour/ardour/lua_api.h +++ b/libs/ardour/ardour/lua_api.h @@ -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 { diff --git a/libs/ardour/lua_api.cc b/libs/ardour/lua_api.cc index c32a9e9338..8499e5c7ff 100644 --- a/libs/ardour/lua_api.cc +++ b/libs/ardour/lua_api.cc @@ -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; +} diff --git a/libs/ardour/luabindings.cc b/libs/ardour/luabindings.cc index d9f460461f..2993567876 100644 --- a/libs/ardour/luabindings.cc +++ b/libs/ardour/luabindings.cc @@ -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) |