Ardour  9.0-pre0-582-g084a23a80d
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 <glibmm/threads.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 
71  virtual ChanCount input_streams () const;
72 
74 
75  /* Track */
76  int roll (pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, bool& need_butler);
77  DataType data_type () const;
78 
79  int roll_audio (pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, bool& need_butler);
80  int roll_midi (pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, bool& need_butler);
81 
82  /* fake track */
83  void set_state_part_two () {}
84  int set_state (const XMLNode&, int) { return 0; }
85  bool bounceable (std::shared_ptr<Processor>, bool) const { return false; }
87  void unfreeze () {}
88 
89  /* MIDI Track -- listen to Bank/Patch */
90  void update_controls (BufferSet const& bufs);
91 
92  std::shared_ptr<Region> bounce (InterThreadInfo&, std::string const& name) {
93  return std::shared_ptr<Region> ();
94  }
95 
96  std::shared_ptr<Region> bounce_range (samplepos_t, samplepos_t, InterThreadInfo&, std::shared_ptr<Processor>, bool, std::string const&, bool) {
97  return std::shared_ptr<Region> ();
98  }
99 
100  int export_stuff (BufferSet&, samplepos_t, samplecnt_t, std::shared_ptr<Processor>, bool, bool, bool, MidiNoteTracker&) { return -1; }
101 
103  PluginInfoPtr get_audition_synth_info() {return audition_synth_info;}
104 
105  samplecnt_t output_latency () const { return 0; }
106 
107 private:
108 
109  PluginInfoPtr audition_synth_info; //we will use this to create a new synth on-the-fly each time an audition is requested
110 
111  std::shared_ptr<AudioRegion> the_region;
112  std::shared_ptr<MidiRegion> midi_region;
114  mutable std::atomic<int> _auditioning;
115  Glib::Threads::Mutex lock;
119  bool _seeking;
124  bool _loop;
125 
126  std::shared_ptr<Processor> asynth;
127 
129 
131  void drop_ports ();
133  bool load_synth();
134  void unload_synth (bool);
135  static void*_drop_ports (void*);
137  void output_changed (IOChange, void*);
139 };
140 
141 }; /* namespace ARDOUR */
142 
PluginInfoPtr get_audition_synth_info()
Definition: auditioner.h:103
static void * _drop_ports(void *)
void actually_drop_ports()
std::shared_ptr< AudioRegion > the_region
Definition: auditioner.h:111
PBD::Signal< void(ARDOUR::samplecnt_t, ARDOUR::samplecnt_t)> AuditionProgress
Definition: auditioner.h:73
PluginInfoPtr audition_synth_info
Definition: auditioner.h:109
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:112
Glib::Threads::Mutex lock
Definition: auditioner.h:115
timecnt_t length
Definition: auditioner.h:116
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:138
void seek_to_sample(sampleoffset_t pos)
samplecnt_t output_latency() const
Definition: auditioner.h:105
bool auditioning() const
int export_stuff(BufferSet &, samplepos_t, samplecnt_t, std::shared_ptr< Processor >, bool, bool, bool, MidiNoteTracker &)
Definition: auditioner.h:100
void freeze_me(InterThreadInfo &)
Definition: auditioner.h:86
int play_audition(samplecnt_t nframes)
void output_changed(IOChange, void *)
std::shared_ptr< Processor > asynth
Definition: auditioner.h:126
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:84
void audition_region(std::shared_ptr< Region >, bool loop=false)
bool bounceable(std::shared_ptr< Processor >, bool) const
Definition: auditioner.h:85
std::atomic< int > _auditioning
Definition: auditioner.h:114
void seek_to_percent(float const pos)
std::shared_ptr< Region > bounce(InterThreadInfo &, std::string const &name)
Definition: auditioner.h:92
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 lookup_fallback_synth()
samplepos_t current_sample
Definition: auditioner.h:113
void unload_synth(bool)
sampleoffset_t _seek_sample
Definition: auditioner.h:117
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:96
void set_state_part_two()
Definition: auditioner.h:83
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:65