diff --git a/libs/ardour/ardour/midi_pattern_source.h b/libs/ardour/ardour/midi_pattern_source.h new file mode 100644 index 0000000000..30d79268b6 --- /dev/null +++ b/libs/ardour/ardour/midi_pattern_source.h @@ -0,0 +1,94 @@ +/* + Copyright (C) 2006 Paul Davis + Author: David Robillard + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef __ardour_midi_pattern_source_h__ +#define __ardour_midi_pattern_source_h__ + +#include "ardour/midi_source.h" +#include "ardour/pattern_source.h" + +namespace ARDOUR { + +/** Source for MIDI patterns */ +class LIBARDOUR_API MidiPatternSource : public MidiSource, public PatternSource +{ + public: + typedef Evoral::Beats TimeType; + + MidiPatternSource (Session& session, std::string const & name); + MidiPatternSource (Session& session, const XMLNode&); + virtual ~MidiPatternSource (); + + /* PatternSources are modified using the PatternSource API, not the + MidiSource one, so these are no-ops. + */ + void append_event_beats(const Lock& lock, + const Evoral::Event& ev) {} + void append_event_frames(const Lock& lock, + const Evoral::Event& ev, + framepos_t source_start) {} + void mark_streaming_midi_write_started (const Lock& lock, NoteMode mode) {} + void mark_streaming_write_started (const Lock& lock) {} + void mark_streaming_write_completed (const Lock& lock) {} + void mark_write_starting_now (framecnt_t position, + framecnt_t capture_length, + framecnt_t loop_length) {} + void mark_midi_streaming_write_completed ( + const Lock& lock, + Evoral::Sequence::StuckNoteOption stuck_option, + Evoral::Beats when = Evoral::Beats()) {} + + bool empty () const; + framecnt_t length (framepos_t pos) const; + void update_length (framecnt_t); + + void session_saved() {} + + XMLNode& get_state (); + int set_state (const XMLNode&, int version); + + bool length_mutable() const { return true; } + + void set_length_beats(TimeType l) { _length_beats = l; } + TimeType length_beats() const { return _length_beats; } + + virtual void load_model(const Glib::Threads::Mutex::Lock& lock, bool force_reload=false) = 0; + virtual void destroy_model(const Glib::Threads::Mutex::Lock& lock) = 0; + + protected: + void flush_midi(const Lock& lock) {} + + framecnt_t read_unlocked (const Lock& lock, + Evoral::EventSink& dst, + framepos_t position, + framepos_t start, + framecnt_t cnt, + Evoral::Range* loop_range, + MidiStateTracker* tracker, + MidiChannelFilter* filter) const; + + framecnt_t write_unlocked (const Lock& lock, + MidiRingBuffer& source, + framepos_t position, + framecnt_t cnt); +}; + +} + +#endif /* __ardour_midi_source_h__ */ diff --git a/libs/ardour/ardour/pattern_source.h b/libs/ardour/ardour/pattern_source.h new file mode 100644 index 0000000000..05d191a93a --- /dev/null +++ b/libs/ardour/ardour/pattern_source.h @@ -0,0 +1,44 @@ +/* + Copyright (C) 2016 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __ardour_pattern_source_h__ +#define __ardour_pattern_source_h__ + +#include + + +#include "ardour/source.h" +#include "ardour/data_type.h" + +namespace ARDOUR { + +class Session; + +class LIBARDOUR_API PatternSource : virtual public Source +{ + public: + PatternSource (Session&, DataType type, const std::string& name); + PatternSource (Session&, const XMLNode&); + + virtual ~PatternSource (); +}; + +} + +#endif /* __ardour_pattern_source_h__ */ diff --git a/libs/ardour/ardour/source.h b/libs/ardour/ardour/source.h index 1e8b582b32..83131e734e 100644 --- a/libs/ardour/ardour/source.h +++ b/libs/ardour/ardour/source.h @@ -50,6 +50,7 @@ class LIBARDOUR_API Source : public SessionObject Destructive = 0x80, Empty = 0x100, /* used for MIDI only */ RF64_RIFF = 0x200, + Pattern = 0x400 }; typedef Glib::Threads::Mutex::Lock Lock; @@ -81,6 +82,7 @@ class LIBARDOUR_API Source : public SessionObject int set_state (const XMLNode&, int version); bool destructive() const { return (_flags & Destructive); } + bool is_pattern() const { return (_flags & Pattern); } bool writable () const; virtual bool set_destructive (bool /*yn*/) { return false; } virtual bool length_mutable() const { return false; } diff --git a/libs/ardour/midi_pattern_source.cc b/libs/ardour/midi_pattern_source.cc new file mode 100644 index 0000000000..1d2c36814b --- /dev/null +++ b/libs/ardour/midi_pattern_source.cc @@ -0,0 +1,96 @@ +/* + Copyright (C) 2016 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "ardour/midi_pattern_source.h" +#include "pbd/i18n.h" + +using namespace std; +using namespace ARDOUR; +using namespace PBD; + +MidiPatternSource::MidiPatternSource (Session& s, std::string const & name) + : Source (s, DataType::MIDI, name, Source::Pattern) + , MidiSource (s, name) + , PatternSource (s, DataType::MIDI, name) +{ +} + +MidiPatternSource::MidiPatternSource (Session& s, const XMLNode& node) + : Source (s, node) + , MidiSource (s, node) + , PatternSource (s, node) +{ + // set_state (node Stateful::loading_state_version); +} + +MidiPatternSource::~MidiPatternSource () +{ +} + +framecnt_t +MidiPatternSource::length (framepos_t) const +{ + return max_framepos - 1; +} + +bool +MidiPatternSource::empty () const +{ + return false; +} + +void +MidiPatternSource::update_length (framecnt_t) +{ + return; +} + +XMLNode& +MidiPatternSource::get_state () +{ + XMLNode* node = new XMLNode ("midi-pattern-source"); + return *node; +} + +int +MidiPatternSource::set_state (XMLNode const& node, int) +{ + return 0; +} + +framecnt_t +MidiPatternSource::write_unlocked (Lock const& lock, + MidiRingBuffer& source, + framepos_t position, + framecnt_t cnt) +{ + return 0; +} + +framecnt_t +MidiPatternSource::read_unlocked (const Lock& lock, + Evoral::EventSink& dst, + framepos_t position, + framepos_t start, + framecnt_t cnt, + Evoral::Range* loop_range, + MidiStateTracker* tracker, + MidiChannelFilter* filter) const +{ + return 0; +} diff --git a/libs/ardour/pattern_source.cc b/libs/ardour/pattern_source.cc new file mode 100644 index 0000000000..4c5a95df67 --- /dev/null +++ b/libs/ardour/pattern_source.cc @@ -0,0 +1,39 @@ +/* + Copyright (C) 2016 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "ardour/pattern_source.h" +#include "pbd/i18n.h" + +using namespace std; +using namespace ARDOUR; +using namespace PBD; + +PatternSource::PatternSource (Session& s, DataType type, const std::string& name) + : Source (s, type, name, Source::Pattern) +{ +} + +PatternSource::PatternSource (Session& s, const XMLNode& node) + : Source (s, node) +{ +} + +PatternSource::~PatternSource () +{ +} diff --git a/libs/ardour/wscript b/libs/ardour/wscript index c6821546d2..2de48a2e3b 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -128,6 +128,7 @@ libardour_sources = [ 'midi_diskstream.cc', 'midi_model.cc', 'midi_patch_manager.cc', + 'midi_pattern_source.cc', 'midi_playlist.cc', 'midi_playlist_source.cc', 'midi_port.cc', @@ -160,6 +161,7 @@ libardour_sources = [ 'panner_manager.cc', 'panner_shell.cc', 'parameter_descriptor.cc', + 'pattern_source.cc', 'pcm_utils.cc', 'phase_control.cc', 'playlist.cc',