Ardour  8.12
auditioner.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2006 Taybin Rutkin <taybin@taybin.com>
3  * Copyright (C) 2006-2017 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2009-2014 David Robillard <d@drobilla.net>
5  * Copyright (C) 2010-2012 Carl Hetherington <carl@carlh.net>
6  * Copyright (C) 2014-2018 Robin Gareus <robin@gareus.org>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22 
23 #ifndef __ardour_auditioner_h__
24 #define __ardour_auditioner_h__
25 
26 #include <string>
27 
28 #include <glibmm/threads.h>
29 
30 #include "evoral/PatchChange.h"
31 
32 #include "ardour/ardour.h"
33 #include "ardour/plugin.h"
34 #include "ardour/track.h"
35 
36 namespace ARDOUR {
37 
38 class Session;
39 class AudioRegion;
40 class AudioPlaylist;
41 class MidiRegion;
42 
44 {
45 public:
48 
49  int init ();
50  int connect ();
51 
52  bool auditioning() const;
53  void audition_region (std::shared_ptr<Region>, bool loop = false);
54  int play_audition (samplecnt_t nframes);
55  void cancel_audition ();
56 
58  void seek_to_percent (float const pos);
59  sampleoffset_t seek_sample() const { return _seeking ? _seek_sample : -1;}
61 
63 
65  return _patch_change[chn & 0xf];
66  }
67 
69 
70  bool needs_monitor() const { return via_monitor; }
71 
72  virtual ChanCount input_streams () const;
73 
74  PBD::Signal2<void, ARDOUR::samplecnt_t, ARDOUR::samplecnt_t> AuditionProgress;
75 
76  /* Track */
77  int roll (pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, bool& need_butler);
78  DataType data_type () const;
79 
80  int roll_audio (pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, bool& need_butler);
81  int roll_midi (pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, bool& need_butler);
82 
83  /* fake track */
84  void set_state_part_two () {}
85  int set_state (const XMLNode&, int) { return 0; }
86  bool bounceable (std::shared_ptr<Processor>, bool) const { return false; }
88  void unfreeze () {}
89 
90  /* MIDI Track -- listen to Bank/Patch */
91  void update_controls (BufferSet const& bufs);
92 
93  std::shared_ptr<Region> bounce (InterThreadInfo&, std::string const& name) {
94  return std::shared_ptr<Region> ();
95  }
96 
97  std::shared_ptr<Region> bounce_range (samplepos_t, samplepos_t, InterThreadInfo&, std::shared_ptr<Processor>, bool, std::string const&, bool) {
98  return std::shared_ptr<Region> ();
99  }
100 
101  int export_stuff (BufferSet&, samplepos_t, samplecnt_t, std::shared_ptr<Processor>, bool, bool, bool, MidiNoteTracker&) { return -1; }
102 
104  PluginInfoPtr get_audition_synth_info() {return audition_synth_info;}
105 
106  samplecnt_t output_latency () const { return 0; }
107 
108 private:
109 
110  PluginInfoPtr audition_synth_info; //we will use this to create a new synth on-the-fly each time an audition is requested
111 
112  std::shared_ptr<AudioRegion> the_region;
113  std::shared_ptr<MidiRegion> midi_region;
115  mutable std::atomic<int> _auditioning;
116  Glib::Threads::Mutex lock;
120  bool _seeking;
125  bool _loop;
126 
127  std::shared_ptr<Processor> asynth;
128 
130 
132  void drop_ports ();
134  bool load_synth();
135  void unload_synth (bool);
136  static void*_drop_ports (void*);
138  void output_changed (IOChange, void*);
140 };
141 
142 }; /* namespace ARDOUR */
143 
144 #endif /* __ardour_auditioner_h__ */
PluginInfoPtr get_audition_synth_info()
Definition: auditioner.h:104
static void * _drop_ports(void *)
void actually_drop_ports()
std::shared_ptr< AudioRegion > the_region
Definition: auditioner.h:112
PluginInfoPtr audition_synth_info
Definition: auditioner.h:110
void update_controls(BufferSet const &bufs)
Auditioner(Session &)
DataType data_type() const
void set_audition_synth_info(PluginInfoPtr in)
std::shared_ptr< MidiRegion > midi_region
Definition: auditioner.h:113
Glib::Threads::Mutex lock
Definition: auditioner.h:116
timecnt_t length
Definition: auditioner.h:117
bool needs_monitor() const
Definition: auditioner.h:70
sampleoffset_t seek_sample() const
Definition: auditioner.h:59
int roll_midi(pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, bool &need_butler)
timepos_t _import_position
Definition: auditioner.h:139
void seek_to_sample(sampleoffset_t pos)
samplecnt_t output_latency() const
Definition: auditioner.h:106
bool auditioning() const
int export_stuff(BufferSet &, samplepos_t, samplecnt_t, std::shared_ptr< Processor >, bool, bool, bool, MidiNoteTracker &)
Definition: auditioner.h:101
void freeze_me(InterThreadInfo &)
Definition: auditioner.h:87
int play_audition(samplecnt_t nframes)
void output_changed(IOChange, void *)
std::shared_ptr< Processor > asynth
Definition: auditioner.h:127
int roll_audio(pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, bool &need_butler)
int set_state(const XMLNode &, int)
Definition: auditioner.h:85
void audition_region(std::shared_ptr< Region >, bool loop=false)
bool bounceable(std::shared_ptr< Processor >, bool) const
Definition: auditioner.h:86
std::atomic< int > _auditioning
Definition: auditioner.h:115
void seek_to_percent(float const pos)
std::shared_ptr< Region > bounce(InterThreadInfo &, std::string const &name)
Definition: auditioner.h:93
Evoral::PatchChange< MidiBuffer::TimeType > const & patch_change(uint8_t chn)
Definition: auditioner.h:64
void seek_response(sampleoffset_t pos)
virtual ChanCount input_streams() const
void lookup_fallback_synth()
samplepos_t current_sample
Definition: auditioner.h:114
PBD::Signal2< void, ARDOUR::samplecnt_t, ARDOUR::samplecnt_t > AuditionProgress
Definition: auditioner.h:74
void unload_synth(bool)
sampleoffset_t _seek_sample
Definition: auditioner.h:118
PluginInfoPtr lookup_fallback_synth_plugin_info(std::string const &) const
std::shared_ptr< Region > bounce_range(samplepos_t, samplepos_t, InterThreadInfo &, std::shared_ptr< Processor >, bool, std::string const &, bool)
Definition: auditioner.h:97
void set_state_part_two()
Definition: auditioner.h:84
int roll(pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, bool &need_butler)
MonitorState monitoring_state() const
Definition: xml++.h:114
GtkImageIconNameData name
Definition: gtkimage.h:6
#define LIBARDOUR_API
uint32_t pframes_t
Temporal::samplecnt_t samplecnt_t
Temporal::sampleoffset_t sampleoffset_t
Temporal::samplepos_t samplepos_t
std::shared_ptr< PluginInfo > PluginInfoPtr
Definition: plugin.h:66