diff options
Diffstat (limited to 'libs/ardour/ardour')
-rw-r--r-- | libs/ardour/ardour/async_midi_port.h | 6 | ||||
-rw-r--r-- | libs/ardour/ardour/location.h | 11 | ||||
-rw-r--r-- | libs/ardour/ardour/midi_scene_change.h | 63 | ||||
-rw-r--r-- | libs/ardour/ardour/midi_scene_changer.h | 72 | ||||
-rw-r--r-- | libs/ardour/ardour/midiport_manager.h | 12 | ||||
-rw-r--r-- | libs/ardour/ardour/rc_configuration_vars.h | 1 | ||||
-rw-r--r-- | libs/ardour/ardour/scene_changer.h | 56 | ||||
-rw-r--r-- | libs/ardour/ardour/session.h | 50 |
8 files changed, 251 insertions, 20 deletions
diff --git a/libs/ardour/ardour/async_midi_port.h b/libs/ardour/ardour/async_midi_port.h index c5babf6135..26946e3016 100644 --- a/libs/ardour/ardour/async_midi_port.h +++ b/libs/ardour/ardour/async_midi_port.h @@ -22,6 +22,8 @@ #include <string> #include <iostream> +#include <boost/function.hpp> + #include "pbd/xml++.h" #include "pbd/crossthread.h" #include "pbd/signals.h" @@ -64,6 +66,8 @@ class LIBARDOUR_API AsyncMIDIPort : public ARDOUR::MidiPort, public MIDI::Port { #endif } + void set_timer (boost::function<framecnt_t (void)>&); + static void set_process_thread (pthread_t); static pthread_t get_process_thread () { return _process_thread; } static bool is_process_thread(); @@ -71,6 +75,8 @@ class LIBARDOUR_API AsyncMIDIPort : public ARDOUR::MidiPort, public MIDI::Port { private: bool _currently_in_cycle; MIDI::timestamp_t _last_write_timestamp; + bool have_timer; + boost::function<framecnt_t (void)> timer; RingBuffer< Evoral::Event<double> > output_fifo; Evoral::EventRingBuffer<MIDI::timestamp_t> input_fifo; Glib::Threads::Mutex output_fifo_lock; diff --git a/libs/ardour/ardour/location.h b/libs/ardour/ardour/location.h index b0956eea36..6cea208f05 100644 --- a/libs/ardour/ardour/location.h +++ b/libs/ardour/ardour/location.h @@ -34,10 +34,13 @@ #include "pbd/statefuldestructible.h" #include "ardour/ardour.h" +#include "ardour/scene_change.h" #include "ardour/session_handle.h" namespace ARDOUR { +class SceneChange; + class LIBARDOUR_API Location : public SessionHandleRef, public PBD::StatefulDestructible { public: @@ -93,6 +96,9 @@ class LIBARDOUR_API Location : public SessionHandleRef, public PBD::StatefulDest Flags flags () const { return _flags; } + boost::shared_ptr<SceneChange> scene_change() const { return _scene_change; } + void set_scene_change (boost::shared_ptr<SceneChange>); + PBD::Signal1<void,Location*> name_changed; PBD::Signal1<void,Location*> end_changed; PBD::Signal1<void,Location*> start_changed; @@ -116,6 +122,8 @@ class LIBARDOUR_API Location : public SessionHandleRef, public PBD::StatefulDest void set_position_lock_style (PositionLockStyle ps); void recompute_frames_from_bbt (); + static PBD::Signal0<void> scene_changed; + private: std::string _name; framepos_t _start; @@ -125,6 +133,7 @@ class LIBARDOUR_API Location : public SessionHandleRef, public PBD::StatefulDest Flags _flags; bool _locked; PositionLockStyle _position_lock_style; + boost::shared_ptr<SceneChange> _scene_change; void set_mark (bool yn); bool set_flag_internal (bool yn, Flags flag); @@ -161,6 +170,8 @@ class LIBARDOUR_API Locations : public SessionHandleRef, public PBD::StatefulDes int set_current (Location *, bool want_lock = true); Location *current () const { return current_location; } + Location* mark_at (framepos_t, framecnt_t slop = 0) const; + framepos_t first_mark_before (framepos_t, bool include_special_ranges = false); framepos_t first_mark_after (framepos_t, bool include_special_ranges = false); diff --git a/libs/ardour/ardour/midi_scene_change.h b/libs/ardour/ardour/midi_scene_change.h new file mode 100644 index 0000000000..86793c57fb --- /dev/null +++ b/libs/ardour/ardour/midi_scene_change.h @@ -0,0 +1,63 @@ +/* + Copyright (C) 2014 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 __libardour_midi_scene_change_h__ +#define __libardour_midi_scene_change_h__ + +#include "evoral/PatchChange.hpp" + +#include "ardour/scene_change.h" + +namespace ARDOUR +{ + +class MidiPort; + +class MIDISceneChange : public SceneChange +{ + public: + MIDISceneChange (framepos_t time, int channel, int bank = -1, int program = -1); + MIDISceneChange (const XMLNode&, int version); + ~MIDISceneChange (); + + void set_channel (int channel); + void set_program (int program); + void set_bank (int bank); + + int channel () const { return _channel; } + int program () const { return _program; } + int bank () const { return _bank; } + + size_t get_bank_msb_message (uint8_t* buf, size_t size) const; + size_t get_bank_lsb_message (uint8_t* buf, size_t size) const; + size_t get_program_message (uint8_t* buf, size_t size) const; + + XMLNode& get_state(); + int set_state (const XMLNode&, int version); + + private: + int _bank; + int _program; + uint8_t _channel; +}; + +} /* namespace */ + + +#endif /* __libardour_scene_change_h__ */ diff --git a/libs/ardour/ardour/midi_scene_changer.h b/libs/ardour/ardour/midi_scene_changer.h new file mode 100644 index 0000000000..2cc0464bec --- /dev/null +++ b/libs/ardour/ardour/midi_scene_changer.h @@ -0,0 +1,72 @@ +/* + Copyright (C) 2014 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 __libardour_midi_scene_changer_h__ +#define __libardour_midi_scene_changer_h__ + +#include "ardour/scene_changer.h" + +namespace ARDOUR +{ + +class MIDISceneChanger : public SceneChanger +{ + public: + MIDISceneChanger (Session&); + ~MIDISceneChanger (); + + void run (framepos_t start, framepos_t end); + void set_input_port (MIDI::Port*); + void set_output_port (boost::shared_ptr<MidiPort>); + + uint8_t bank_at (framepos_t, uint8_t channel); + uint8_t program_at (framepos_t, uint8_t channel); + + void set_recording (bool); + void locate (framepos_t); + + private: + typedef std::multimap<framepos_t,boost::shared_ptr<MIDISceneChange> > Scenes; + + MIDI::Port* input_port; + boost::shared_ptr<MidiPort> output_port; + Scenes scenes; + bool _recording; + framepos_t last_bank_message_time; + framepos_t last_program_message_time; + unsigned short current_bank; + int last_delivered_program; + int last_delivered_bank; + + void gather (); + bool recording () const; + void jump_to (int bank, int program); + void deliver (MidiBuffer&, framepos_t, boost::shared_ptr<MIDISceneChange>); + + void bank_change_input (MIDI::Parser&, unsigned short); + void program_change_input (MIDI::Parser&, MIDI::byte); + void locations_changed (Locations::Change); + + PBD::ScopedConnection incoming_bank_change_connection; + PBD::ScopedConnection incoming_program_change_connection; +}; + +} // namespace + +#endif /* __libardour_midi_scene_changer_h__ */ diff --git a/libs/ardour/ardour/midiport_manager.h b/libs/ardour/ardour/midiport_manager.h index b5b46e8510..5e87238c22 100644 --- a/libs/ardour/ardour/midiport_manager.h +++ b/libs/ardour/ardour/midiport_manager.h @@ -30,6 +30,7 @@ #include "midi++/port.h" #include "ardour/libardour_visibility.h" +#include "ardour/midi_port.h" #include "ardour/types.h" namespace ARDOUR { @@ -56,7 +57,12 @@ class LIBARDOUR_API MidiPortManager { MIDI::Port* midi_output_port () const { return _midi_output_port; } MIDI::Port* mmc_input_port () const { return _mmc_input_port; } MIDI::Port* mmc_output_port () const { return _mmc_output_port; } + MIDI::Port* scene_input_port () const { return _scene_input_port; } + MIDI::Port* scene_output_port () const { return _scene_output_port; } + boost::shared_ptr<MidiPort> scene_in() const { return boost::dynamic_pointer_cast<MidiPort>(_scene_in); } + boost::shared_ptr<MidiPort> scene_out() const { return boost::dynamic_pointer_cast<MidiPort>(_scene_out); } + /* Ports used for synchronization. These have their I/O handled inside the * process callback. */ @@ -77,13 +83,17 @@ class LIBARDOUR_API MidiPortManager { MIDI::Port* _midi_output_port; MIDI::Port* _mmc_input_port; MIDI::Port* _mmc_output_port; - /* these point to the same objects as the 4 members above, + MIDI::Port* _scene_input_port; + MIDI::Port* _scene_output_port; + /* these point to the same objects as the members above, but cast to their ARDOUR::Port base class */ boost::shared_ptr<Port> _midi_in; boost::shared_ptr<Port> _midi_out; boost::shared_ptr<Port> _mmc_in; boost::shared_ptr<Port> _mmc_out; + boost::shared_ptr<Port> _scene_in; + boost::shared_ptr<Port> _scene_out; /* synchronously handled ports: ARDOUR::MidiPort */ boost::shared_ptr<MidiPort> _mtc_input_port; diff --git a/libs/ardour/ardour/rc_configuration_vars.h b/libs/ardour/ardour/rc_configuration_vars.h index d290d8ebc8..4401b1f74c 100644 --- a/libs/ardour/ardour/rc_configuration_vars.h +++ b/libs/ardour/ardour/rc_configuration_vars.h @@ -44,6 +44,7 @@ CONFIG_VARIABLE (int32_t, mmc_receive_device_id, "mmc-receive-device-id", 0x7f) CONFIG_VARIABLE (int32_t, mmc_send_device_id, "mmc-send-device-id", 0) CONFIG_VARIABLE (int32_t, initial_program_change, "initial-program-change", -1) CONFIG_VARIABLE (bool, first_midi_bank_is_zero, "display-first-midi-bank-as-zero", false) +CONFIG_VARIABLE (int32_t, inter_scene_gap_msecs, "inter-scene-gap-msecs", 1) /* Timecode and related */ diff --git a/libs/ardour/ardour/scene_changer.h b/libs/ardour/ardour/scene_changer.h new file mode 100644 index 0000000000..d5ba984e92 --- /dev/null +++ b/libs/ardour/ardour/scene_changer.h @@ -0,0 +1,56 @@ +/* + Copyright (C) 2014 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 __libardour_scene_changer_h__ +#define __libardour_scene_changer_h__ + +#include <map> + +#include "pbd/signals.h" + +#include "ardour/location.h" +#include "ardour/midi_scene_change.h" +#include "ardour/session_handle.h" +#include "ardour/types.h" + +namespace MIDI +{ +class Parser; +class Port; +} + +namespace ARDOUR +{ + +class Session; +class AsyncMidiPort; + +class SceneChanger : public SessionHandleRef +{ + public: + SceneChanger (Session& s) : SessionHandleRef (s) {} + virtual ~SceneChanger () {}; + + virtual void run (framepos_t start, framepos_t end) = 0; +}; + +} /* namespace */ + + +#endif /* __libardour_scene_change_h__ */ diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 15af67ada7..40ada138a6 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -129,6 +129,7 @@ class Route; class RouteGroup; class SMFSource; class Send; +class SceneChanger; class SessionDirectory; class SessionMetadata; class SessionPlaylists; @@ -868,23 +869,31 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop */ static PBD::Signal2<void,std::string,std::string> VersionMismatch; + SceneChanger* scene_changer() const { return _scene_changer; } + boost::shared_ptr<Port> ltc_input_port() const; boost::shared_ptr<Port> ltc_output_port() const; boost::shared_ptr<IO> ltc_input_io() { return _ltc_input; } boost::shared_ptr<IO> ltc_output_io() { return _ltc_output; } - MIDI::Port* midi_input_port () const; - MIDI::Port* midi_output_port () const; - MIDI::Port* mmc_output_port () const; - MIDI::Port* mmc_input_port () const; + MIDI::Port* midi_input_port () const; + MIDI::Port* midi_output_port () const; + MIDI::Port* mmc_output_port () const; + MIDI::Port* mmc_input_port () const; - boost::shared_ptr<MidiPort> midi_clock_output_port () const; - boost::shared_ptr<MidiPort> midi_clock_input_port () const; - boost::shared_ptr<MidiPort> mtc_output_port () const; - boost::shared_ptr<MidiPort> mtc_input_port () const; + MIDI::Port* scene_input_port () const; + MIDI::Port* scene_output_port () const; - MIDI::MachineControl& mmc() { return *_mmc; } + boost::shared_ptr<MidiPort> scene_in () const; + boost::shared_ptr<MidiPort> scene_out () const; + + boost::shared_ptr<MidiPort> midi_clock_output_port () const; + boost::shared_ptr<MidiPort> midi_clock_input_port () const; + boost::shared_ptr<MidiPort> mtc_output_port () const; + boost::shared_ptr<MidiPort> mtc_input_port () const; + + MIDI::MachineControl& mmc() { return *_mmc; } protected: friend class AudioEngine; @@ -1607,16 +1616,19 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop void reconnect_ltc_input (); void reconnect_ltc_output (); - /* persistent, non-track related MIDI ports */ - MidiPortManager* _midi_ports; - MIDI::MachineControl* _mmc; - - void setup_ltc (); - void setup_click (); - void setup_click_state (const XMLNode*); - void setup_bundles (); - - static int get_session_info_from_path (XMLTree& state_tree, const std::string& xmlpath); + /* Scene Changing */ + SceneChanger* _scene_changer; + + /* persistent, non-track related MIDI ports */ + MidiPortManager* _midi_ports; + MIDI::MachineControl* _mmc; + + void setup_ltc (); + void setup_click (); + void setup_click_state (const XMLNode*); + void setup_bundles (); + + static int get_session_info_from_path (XMLTree& state_tree, const std::string& xmlpath); }; } // namespace ARDOUR |