Ardour  9.5-107-gea8286bce0
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 #pragma once
24 
25 #include <string>
26 
27 #include "pbd/mutex.h"
28 
29 #include "evoral/PatchChange.h"
30 
31 #include "ardour/ardour.h"
32 #include "ardour/plugin.h"
33 #include "ardour/track.h"
34 
35 namespace ARDOUR {
36 
37 class Session;
38 class AudioRegion;
39 class AudioPlaylist;
40 class MidiRegion;
41 
43 {
44 public:
47 
48  int init ();
49  int connect ();
50 
51  bool auditioning() const;
52  void audition_region (std::shared_ptr<Region>, bool loop = false);
53  int play_audition (samplecnt_t nframes);
54  void cancel_audition ();
55 
57  void seek_to_percent (float const pos);
58  sampleoffset_t seek_sample() const { return _seeking ? _seek_sample : -1;}
60 
62 
64  return _patch_change[chn & 0xf];
65  }
66 
68 
69  bool needs_monitor() const { return via_monitor; }
70 
72 
73  virtual ChanCount input_streams () const;
74 
76 
77  /* Track */
78  int roll (pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, bool& need_butler);
79  DataType data_type () const;
80 
81  int roll_audio (pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, bool& need_butler);
82  int roll_midi (pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, bool& need_butler);
83 
84  /* fake track */
85  void set_state_part_two () {}
86  int set_state (const XMLNode&, int) { return 0; }
87  bool bounceable (std::shared_ptr<Processor>, bool) const { return false; }
89  void unfreeze () {}
90 
91  /* MIDI Track -- listen to Bank/Patch */
92  void update_controls (BufferSet const& bufs);
93 
94  std::shared_ptr<Region> bounce (InterThreadInfo&, std::string const& name) {
95  return std::shared_ptr<Region> ();
96  }
97 
98  std::shared_ptr<Region> bounce_range (samplepos_t, samplepos_t, InterThreadInfo&, std::shared_ptr<Processor>, bool, std::string const&, bool) {
99  return std::shared_ptr<Region> ();
100  }
101 
102  int export_stuff (BufferSet&, samplepos_t, samplecnt_t, std::shared_ptr<Processor>, bool, bool, bool, MidiNoteTracker&) { return -1; }
103 
105  PluginInfoPtr get_audition_synth_info() {return audition_synth_info;}
106 
107  samplecnt_t output_latency () const { return 0; }
108 
109 private:
110 
111  PluginInfoPtr audition_synth_info; //we will use this to create a new synth on-the-fly each time an audition is requested
112 
113  std::shared_ptr<AudioRegion> the_region;
114  std::shared_ptr<MidiRegion> midi_region;
116  mutable std::atomic<int> _auditioning;
121  bool _seeking;
126  bool _loop;
127 
128  std::shared_ptr<Processor> asynth;
129 
131 
133  void drop_ports ();
135  bool load_synth();
136  void unload_synth (bool);
137  static void*_drop_ports (void*);
141 };
142 
143 }; /* namespace ARDOUR */
144 
PluginInfoPtr get_audition_synth_info()
Definition: auditioner.h:105
static void * _drop_ports(void *)
void actually_drop_ports()
std::shared_ptr< AudioRegion > the_region
Definition: auditioner.h:113
PBD::Signal< void(ARDOUR::samplecnt_t, ARDOUR::samplecnt_t)> AuditionProgress
Definition: auditioner.h:75
PluginInfoPtr audition_synth_info
Definition: auditioner.h:111
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:114
void update_misc_port_state(XMLNode &)
timecnt_t length
Definition: auditioner.h:118
bool needs_monitor() const
Definition: auditioner.h:69
sampleoffset_t seek_sample() const
Definition: auditioner.h:58
int roll_midi(pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, bool &need_butler)
timepos_t _import_position
Definition: auditioner.h:140
void seek_to_sample(sampleoffset_t pos)
samplecnt_t output_latency() const
Definition: auditioner.h:107
bool auditioning() const
int export_stuff(BufferSet &, samplepos_t, samplecnt_t, std::shared_ptr< Processor >, bool, bool, bool, MidiNoteTracker &)
Definition: auditioner.h:102
void freeze_me(InterThreadInfo &)
Definition: auditioner.h:88
int play_audition(samplecnt_t nframes)
std::shared_ptr< Processor > asynth
Definition: auditioner.h:128
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:86
void audition_region(std::shared_ptr< Region >, bool loop=false)
bool bounceable(std::shared_ptr< Processor >, bool) const
Definition: auditioner.h:87
std::atomic< int > _auditioning
Definition: auditioner.h:116
void seek_to_percent(float const pos)
std::shared_ptr< Region > bounce(InterThreadInfo &, std::string const &name)
Definition: auditioner.h:94
Evoral::PatchChange< MidiBuffer::TimeType > const & patch_change(uint8_t chn)
Definition: auditioner.h:63
void seek_response(sampleoffset_t pos)
virtual ChanCount input_streams() const
void output_changed(IOChange)
void lookup_fallback_synth()
samplepos_t current_sample
Definition: auditioner.h:115
void unload_synth(bool)
sampleoffset_t _seek_sample
Definition: auditioner.h:119
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:98
void set_state_part_two()
Definition: auditioner.h:85
int roll(pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, bool &need_butler)
MonitorState monitoring_state() const
PBD::Mutex lock
Definition: auditioner.h:117
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:64