ardour
Classes | Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
ARDOUR::MidiModel Class Reference

#include <midi_model.h>

Inheritance diagram for ARDOUR::MidiModel:
ARDOUR::AutomatableSequence< Evoral::Beats > ARDOUR::Automatable Evoral::Sequence< Evoral::Beats > Evoral::ControlSet Evoral::ControlSet

Classes

class  DiffCommand
 
class  NoteDiffCommand
 
class  PatchChangeDiffCommand
 
class  SysExDiffCommand
 
struct  WriteLockImpl
 

Public Types

typedef Evoral::Beats TimeType
 
- Public Types inherited from Evoral::ControlSet
typedef std::map< Parameter,
boost::shared_ptr< Control > > 
Controls
 
- Public Types inherited from Evoral::Sequence< Evoral::Beats >
enum  StuckNoteOption
 
enum  NoteOperator
 
enum  OverlapPitchResolution
 
typedef boost::shared_ptr
< Evoral::Note< Evoral::Beats > > 
NotePtr
 
typedef boost::weak_ptr
< Evoral::Note< Evoral::Beats > > 
WeakNotePtr
 
typedef boost::shared_ptr
< const Evoral::Note
< Evoral::Beats > > 
constNotePtr
 
typedef boost::shared_ptr
< Glib::Threads::RWLock::ReaderLock > 
ReadLock
 
typedef boost::shared_ptr
< WriteLockImpl > 
WriteLock
 
typedef std::multiset< NotePtr,
EarlierNoteComparator > 
Notes
 
typedef boost::shared_ptr
< Event< Evoral::Beats > > 
SysExPtr
 
typedef boost::shared_ptr
< const Event< Evoral::Beats > > 
constSysExPtr
 
typedef std::multiset
< SysExPtr,
EarlierSysExComparator > 
SysExes
 
typedef boost::shared_ptr
< PatchChange< Evoral::Beats > > 
PatchChangePtr
 
typedef boost::shared_ptr
< const PatchChange
< Evoral::Beats > > 
constPatchChangePtr
 
typedef std::multiset
< PatchChangePtr,
EarlierPatchChangeComparator > 
PatchChanges
 

Public Member Functions

 MidiModel (boost::shared_ptr< MidiSource >)
 
NoteMode note_mode () const
 
void set_note_mode (NoteMode mode)
 
MidiModel::NoteDiffCommandnew_note_diff_command (const std::string name="midi edit")
 
MidiModel::SysExDiffCommandnew_sysex_diff_command (const std::string name="midi edit")
 
MidiModel::PatchChangeDiffCommandnew_patch_change_diff_command (const std::string name="midi edit")
 
void apply_command (Session &session, Command *cmd)
 
void apply_command_as_subcommand (Session &session, Command *cmd)
 
bool sync_to_source (const Glib::Threads::Mutex::Lock &source_lock)
 
bool write_to (boost::shared_ptr< MidiSource > source, const Glib::Threads::Mutex::Lock &source_lock)
 
bool write_section_to (boost::shared_ptr< MidiSource > source, const Glib::Threads::Mutex::Lock &source_lock, Evoral::Beats begin=Evoral::MinBeats, Evoral::Beats end=Evoral::MaxBeats)
 
XMLNodeget_state ()
 
int set_state (const XMLNode &)
 
boost::shared_ptr< const
MidiSource
midi_source ()
 
void set_midi_source (boost::shared_ptr< MidiSource >)
 
boost::shared_ptr
< Evoral::Note< TimeType > > 
find_note (NotePtr)
 
PatchChangePtr find_patch_change (Evoral::event_id_t)
 
boost::shared_ptr
< Evoral::Note< TimeType > > 
find_note (gint note_id)
 
boost::shared_ptr
< Evoral::Event< TimeType > > 
find_sysex (gint)
 
InsertMergePolicy insert_merge_policy () const
 
void set_insert_merge_policy (InsertMergePolicy)
 
boost::shared_ptr
< Evoral::Control
control_factory (const Evoral::Parameter &id)
 
void insert_silence_at_start (TimeType)
 
void transpose (TimeType, TimeType, int)
 
std::set< WeakNotePtr > & active_notes ()
 
WriteLock edit_lock ()
 
- Public Member Functions inherited from ARDOUR::AutomatableSequence< Evoral::Beats >
 AutomatableSequence (Session &s)
 
 AutomatableSequence (const AutomatableSequence< Evoral::Beats > &other)
 
- Public Member Functions inherited from ARDOUR::Automatable
 Automatable (Session &)
 
 Automatable (const Automatable &other)
 
virtual ~Automatable ()
 
boost::shared_ptr
< AutomationControl
automation_control (const Evoral::Parameter &id, bool create_if_missing=false)
 
boost::shared_ptr< const
AutomationControl
automation_control (const Evoral::Parameter &id) const
 
virtual void add_control (boost::shared_ptr< Evoral::Control >)
 
void clear_controls ()
 
virtual void transport_located (framepos_t now)
 
virtual void transport_stopped (framepos_t now)
 
virtual std::string describe_parameter (Evoral::Parameter param)
 
virtual std::string value_as_string (boost::shared_ptr< AutomationControl >) const
 
AutoState get_parameter_automation_state (Evoral::Parameter param)
 
virtual void set_parameter_automation_state (Evoral::Parameter param, AutoState)
 
AutoStyle get_parameter_automation_style (Evoral::Parameter param)
 
void set_parameter_automation_style (Evoral::Parameter param, AutoStyle)
 
void protect_automation ()
 
const std::set
< Evoral::Parameter > & 
what_can_be_automated () const
 
void what_has_existing_automation (std::set< Evoral::Parameter > &) const
 
int set_automation_xml_state (const XMLNode &, Evoral::Parameter default_param)
 
XMLNodeget_automation_xml_state ()
 
- Public Member Functions inherited from Evoral::ControlSet
 ControlSet ()
 
 ControlSet (const ControlSet &)
 
virtual ~ControlSet ()
 
boost::shared_ptr< Controlcontrol (const Parameter &id, bool create_if_missing=false)
 
boost::shared_ptr< const Controlcontrol (const Parameter &id) const
 
Controlscontrols ()
 
const Controlscontrols () const
 
bool find_next_event (double start, double end, ControlEvent &ev) const
 
virtual bool controls_empty () const
 
void what_has_data (std::set< Parameter > &) const
 
Glib::Threads::Mutex & control_lock () const
 
- Public Member Functions inherited from Evoral::Sequence< Evoral::Beats >
 Sequence (const TypeMap &type_map)
 
 Sequence (const Sequence< Evoral::Beats > &other)
 
virtual ReadLock read_lock () const
 
virtual WriteLock write_lock ()
 
void clear ()
 
bool percussive () const
 
void set_percussive (bool p)
 
void start_write ()
 
bool writing () const
 
void end_write (StuckNoteOption, Evoral::Beatswhen=Evoral::Beats())
 
void append (const Event< Evoral::Beats > &ev, Evoral::event_id_t evid)
 
const TypeMaptype_map () const
 
size_t n_notes () const
 
bool empty () const
 
Notesnotes ()
 
const Notesnotes () const
 
void get_notes (Notes &, NoteOperator, uint8_t val, int chan_mask=0) const
 
void remove_overlapping_notes ()
 
void trim_overlapping_notes ()
 
void remove_duplicate_notes ()
 
bool overlapping_pitches_accepted () const
 
void overlapping_pitches_accepted (bool yn)
 
OverlapPitchResolution overlap_pitch_resolution () const
 
void set_overlap_pitch_resolution (OverlapPitchResolution opr)
 
void set_notes (const typename Sequence< Evoral::Beats >::Notes &n)
 
SysExessysexes ()
 
const SysExessysexes () const
 
PatchChangespatch_changes ()
 
const PatchChangespatch_changes () const
 
void dump (std::ostream &) const
 
const_iterator begin (Evoral::Beatst=Evoral::Beats(), bool force_discrete=false, const std::set< Evoral::Parameter > &f=std::set< Evoral::Parameter >(), const std::set< WeakNotePtr > *active_notes=NULL) const
 
const const_iteratorend () const
 
Notes::const_iterator note_lower_bound (Evoral::Beatst) const
 
Notes::iterator note_lower_bound (Evoral::Beatst)
 
PatchChanges::const_iterator patch_change_lower_bound (Evoral::Beatst) const
 
PatchChanges::iterator patch_change_lower_bound (Evoral::Beatst)
 
SysExes::const_iterator sysex_lower_bound (Evoral::Beatst) const
 
SysExes::iterator sysex_lower_bound (Evoral::Beatst)
 
bool control_to_midi_event (boost::shared_ptr< Event< Evoral::Beats > > &ev, const ControlIterator &iter) const
 
bool edited () const
 
void set_edited (bool yn)
 
bool overlaps (const NotePtr &ev, const NotePtr &ignore_this_note) const
 
bool contains (const NotePtr &ev) const
 
bool add_note_unlocked (const NotePtr note, void *arg=0)
 
void remove_note_unlocked (const constNotePtr note)
 
void add_patch_change_unlocked (const PatchChangePtr)
 
void remove_patch_change_unlocked (const constPatchChangePtr)
 
void add_sysex_unlocked (const SysExPtr)
 
void remove_sysex_unlocked (const SysExPtr)
 
uint8_t lowest_note () const
 
uint8_t highest_note () const
 

Public Attributes

PBD::Signal0< void > ContentsChanged
 
- Public Attributes inherited from ARDOUR::Automatable
PBD::Signal0< void > AutomationStateChanged
 

Protected Member Functions

int resolve_overlaps_unlocked (const NotePtr, void *arg=0)
 
- Protected Member Functions inherited from ARDOUR::Automatable
void can_automate (Evoral::Parameter)
 
int load_automation (const std::string &path)
 
int old_set_automation_state (const XMLNode &)
 
- Protected Member Functions inherited from Evoral::Sequence< Evoral::Beats >
Pitchespitches (uint8_t chan)
 
const Pitchespitches (uint8_t chan) const
 

Private Member Functions

void source_interpolation_changed (Evoral::Parameter, Evoral::ControlList::InterpolationStyle)
 
void source_automation_state_changed (Evoral::Parameter, AutoState)
 
void control_list_interpolation_changed (Evoral::Parameter, Evoral::ControlList::InterpolationStyle)
 
void automation_list_automation_state_changed (Evoral::Parameter, AutoState)
 
void control_list_marked_dirty ()
 

Private Attributes

PBD::ScopedConnectionList _midi_source_connections
 
boost::weak_ptr< MidiSource_midi_source
 
InsertMergePolicy _insert_merge_policy
 
std::set< WeakNotePtr_active_notes
 

Friends

class DeltaCommand
 

Additional Inherited Members

- Static Public Member Functions inherited from Evoral::Sequence< Evoral::Beats >
static bool note_time_comparator (const boost::shared_ptr< const Note< Evoral::Beats > > &a, const boost::shared_ptr< const Note< Evoral::Beats > > &b)
 
- Static Public Attributes inherited from ARDOUR::Automatable
static const std::string xml_node_name = X_("Automation")
 
- Protected Types inherited from Evoral::Sequence< Evoral::Beats >
typedef std::multiset< NotePtr,
NoteNumberComparator > 
Pitches
 
- Protected Attributes inherited from ARDOUR::Automatable
Session_a_session
 
std::set< Evoral::Parameter_can_automate_list
 
framepos_t _last_automation_snapshot
 
- Protected Attributes inherited from Evoral::ControlSet
Glib::Threads::Mutex _control_lock
 
Controls _controls
 
PBD::ScopedConnectionList _list_connections
 
- Protected Attributes inherited from Evoral::Sequence< Evoral::Beats >
bool _edited
 
bool _overlapping_pitches_accepted
 
OverlapPitchResolution _overlap_pitch_resolution
 
Glib::Threads::RWLock _lock
 
bool _writing
 

Detailed Description

This is a higher level (than MidiBuffer) model of MIDI data, with separate representations for notes (instead of just unassociated note on/off events) and controller data. Controller data is represented as part of the Automatable base (i.e. in a map of AutomationList, keyed by Parameter). Because of this MIDI controllers and automatable controllers/widgets/etc are easily interchangeable.

Definition at line 55 of file midi_model.h.

Member Typedef Documentation

Definition at line 57 of file midi_model.h.

Constructor & Destructor Documentation

MidiModel::MidiModel ( boost::shared_ptr< MidiSource s)

Definition at line 49 of file midi_model.cc.

Member Function Documentation

std::set<WeakNotePtr>& ARDOUR::MidiModel::active_notes ( )
inline

Definition at line 292 of file midi_model.h.

void MidiModel::apply_command ( Session session,
Command cmd 
)

Apply a command.

Ownership of cmd is taken, it must not be deleted by the caller. The command will constitute one item on the undo stack.

Definition at line 97 of file midi_model.cc.

void MidiModel::apply_command_as_subcommand ( Session session,
Command cmd 
)

Apply a command as part of a larger reversible transaction

Ownership of cmd is taken, it must not be deleted by the caller. The command will constitute one item on the undo stack.

Definition at line 111 of file midi_model.cc.

void MidiModel::automation_list_automation_state_changed ( Evoral::Parameter  p,
AutoState  s 
)
privatevirtual

Reimplemented from ARDOUR::Automatable.

Definition at line 1895 of file midi_model.cc.

boost::shared_ptr< Evoral::Control > MidiModel::control_factory ( const Evoral::Parameter id)
virtual

Reimplemented from ARDOUR::Automatable.

Definition at line 1903 of file midi_model.cc.

void MidiModel::control_list_interpolation_changed ( Evoral::Parameter  p,
Evoral::ControlList::InterpolationStyle  s 
)
privatevirtual

A ControlList has signalled that its interpolation style has changed. Again, in order to keep MidiSource and ControlList interpolation state in sync, we pass this change onto our MidiSource.

Reimplemented from Evoral::ControlSet.

Definition at line 1878 of file midi_model.cc.

void MidiModel::control_list_marked_dirty ( )
privatevirtual

Reimplemented from Evoral::Sequence< Evoral::Beats >.

Definition at line 2027 of file midi_model.cc.

MidiModel::WriteLock MidiModel::edit_lock ( )

Lock and invalidate the source. This should be used by commands and editing things

Definition at line 1618 of file midi_model.cc.

Evoral::Sequence< MidiModel::TimeType >::NotePtr MidiModel::find_note ( NotePtr  other)

Definition at line 1550 of file midi_model.cc.

Evoral::Sequence< MidiModel::TimeType >::NotePtr MidiModel::find_note ( gint  note_id)

Definition at line 1571 of file midi_model.cc.

MidiModel::PatchChangePtr MidiModel::find_patch_change ( Evoral::event_id_t  id)

Definition at line 1587 of file midi_model.cc.

boost::shared_ptr< Evoral::Event< MidiModel::TimeType > > MidiModel::find_sysex ( gint  sysex_id)

Definition at line 1599 of file midi_model.cc.

XMLNode & MidiModel::get_state ( void  )

Definition at line 1543 of file midi_model.cc.

InsertMergePolicy MidiModel::insert_merge_policy ( ) const

Definition at line 1828 of file midi_model.cc.

void MidiModel::insert_silence_at_start ( TimeType  t)

Moves notes, patch changes, controllers and sys-ex to insert silence at the start of the model. Adds commands to the session's current undo stack to reflect the movements.

Definition at line 1934 of file midi_model.cc.

boost::shared_ptr< const MidiSource > MidiModel::midi_source ( )

Definition at line 1925 of file midi_model.cc.

MidiModel::NoteDiffCommand * MidiModel::new_note_diff_command ( const std::string  name = "midi edit")

Start a new NoteDiff command.

This has no side-effects on the model or Session, the returned command can be held on to for as long as the caller wishes, or discarded without formality, until apply_command is called and ownership is taken.

Definition at line 62 of file midi_model.cc.

MidiModel::PatchChangeDiffCommand * MidiModel::new_patch_change_diff_command ( const std::string  name = "midi edit")

Start a new PatchChangeDiff command

Definition at line 82 of file midi_model.cc.

MidiModel::SysExDiffCommand * MidiModel::new_sysex_diff_command ( const std::string  name = "midi edit")

Start a new SysExDiff command

Definition at line 72 of file midi_model.cc.

NoteMode ARDOUR::MidiModel::note_mode ( ) const
inline

Definition at line 61 of file midi_model.h.

int MidiModel::resolve_overlaps_unlocked ( const NotePtr  note,
void *  arg = 0 
)
protectedvirtual

Reimplemented from Evoral::Sequence< Evoral::Beats >.

Definition at line 1636 of file midi_model.cc.

void ARDOUR::MidiModel::set_insert_merge_policy ( InsertMergePolicy  )
void MidiModel::set_midi_source ( boost::shared_ptr< MidiSource s)

Definition at line 1838 of file midi_model.cc.

void ARDOUR::MidiModel::set_note_mode ( NoteMode  mode)
inline

Definition at line 62 of file midi_model.h.

int ARDOUR::MidiModel::set_state ( const XMLNode )
inline

Definition at line 272 of file midi_model.h.

void MidiModel::source_automation_state_changed ( Evoral::Parameter  p,
AutoState  s 
)
private

Definition at line 1887 of file midi_model.cc.

void MidiModel::source_interpolation_changed ( Evoral::Parameter  p,
Evoral::ControlList::InterpolationStyle  s 
)
private

The source has signalled that the interpolation style for a parameter has changed. In order to keep MidiSource and ControlList interpolation state the same, we pass this change onto the appropriate ControlList.

The idea is that MidiSource and the MidiModel's ControlList states are kept in sync, and one or the other is listened to by the GUI.

Definition at line 1868 of file midi_model.cc.

bool MidiModel::sync_to_source ( const Glib::Threads::Mutex::Lock &  source_lock)

very similar to ::write_to() but writes to the model's own existing midi_source, without making it call MidiSource::drop_model(). the caller is a MidiSource that needs to catch up with the state of the model.

Definition at line 1443 of file midi_model.cc.

void MidiModel::transpose ( TimeType  from,
TimeType  to,
int  semitones 
)

Transpose notes in a time range by a given number of semitones. Notes will be clamped at 0 and 127 if the transposition would make them exceed that range.

Parameters
fromStart time.
endEnd time.
semitonesNumber of semitones to transpose by (+ve is higher, -ve is lower).

Definition at line 1995 of file midi_model.cc.

bool MidiModel::write_section_to ( boost::shared_ptr< MidiSource source,
const Glib::Threads::Mutex::Lock &  source_lock,
Evoral::Beats  begin_time = Evoral::MinBeats,
Evoral::Beats  end_time = Evoral::MaxBeats 
)

Write part or all of the model to a MidiSource (i.e. save the model). This is different from manually using read to write to a source in that note off events are written regardless of the track mode. This is so the user can switch a recorded track (with note durations from some instrument) to percussive, save, reload, then switch it back to sustained without destroying the original note durations.

Definition at line 1483 of file midi_model.cc.

bool MidiModel::write_to ( boost::shared_ptr< MidiSource source,
const Glib::Threads::Mutex::Lock &  source_lock 
)

Write all of the model to a MidiSource (i.e. save the model). This is different from manually using read to write to a source in that note off events are written regardless of the track mode. This is so the user can switch a recorded track (with note durations from some instrument) to percussive, save, reload, then switch it back to sustained without destroying the original note durations.

Similarly, control events are written without interpolation (as with the `Discrete' mode).

Definition at line 1414 of file midi_model.cc.

Friends And Related Function Documentation

friend class DeltaCommand
friend

Definition at line 313 of file midi_model.h.

Member Data Documentation

std::set<WeakNotePtr> ARDOUR::MidiModel::_active_notes
private

Definition at line 328 of file midi_model.h.

InsertMergePolicy ARDOUR::MidiModel::_insert_merge_policy
private

Definition at line 326 of file midi_model.h.

boost::weak_ptr<MidiSource> ARDOUR::MidiModel::_midi_source
private

Definition at line 325 of file midi_model.h.

PBD::ScopedConnectionList ARDOUR::MidiModel::_midi_source_connections
private

Definition at line 322 of file midi_model.h.

PBD::Signal0<void> ARDOUR::MidiModel::ContentsChanged

Definition at line 274 of file midi_model.h.


The documentation for this class was generated from the following files: