}
XMLNode&
-EqualPowerStereoPanner::state (bool full_state)
+EqualPowerStereoPanner::state (bool /*full_state*/)
{
XMLNode* root = new XMLNode ("StreamPanner");
char buf[64];
}
void
-Multi2dPanner::distribute_automated (AudioBuffer& src, BufferSet& obufs,
- nframes_t start, nframes_t end, nframes_t nframes,
- pan_t** buffers)
+Multi2dPanner::distribute_automated (AudioBuffer& /*src*/, BufferSet& /*obufs*/,
+ nframes_t /*start*/, nframes_t /*end*/, nframes_t /*nframes*/,
+ pan_t** /*buffers*/)
{
if (_muted) {
return;
}
int
-Multi2dPanner::load (istream& in, string path, uint32_t& linecnt)
+Multi2dPanner::load (istream& /*in*/, string /*path*/, uint32_t& /*linecnt*/)
{
return 0;
}
}
XMLNode&
-Multi2dPanner::state (bool full_state)
+Multi2dPanner::state (bool /*full_state*/)
{
XMLNode* root = new XMLNode ("StreamPanner");
char buf[64];
/*---------------------------------------------------------------------- */
Panner::Panner (string name, Session& s)
- : Processor(s, name, PostFader)
+ : SessionObject (s, name)
+ , AutomatableControls (s)
{
//set_name_old_auto (name);
set_name (name);
}
+void
+Panner::reset_to_default ()
+{
+ vector<float> positions;
+
+ switch (outputs.size()) {
+ case 0:
+ case 1:
+ return;
+ }
+
+ if (outputs.size() == 2) {
+ switch (_streampanners.size()) {
+ case 1:
+ _streampanners.front()->set_position (0.5);
+ _streampanners.front()->pan_control()->list()->reset_default (0.5);
+ return;
+ break;
+ case 2:
+ _streampanners.front()->set_position (0.0);
+ _streampanners.front()->pan_control()->list()->reset_default (0.0);
+ _streampanners.back()->set_position (1.0);
+ _streampanners.back()->pan_control()->list()->reset_default (1.0);
+ return;
+ default:
+ break;
+ }
+ }
+
+ vector<Output>::iterator o;
+ vector<StreamPanner*>::iterator p;
+
+ for (o = outputs.begin(), p = _streampanners.begin(); o != outputs.end() && p != _streampanners.end(); ++o, ++p) {
+ (*p)->set_position ((*o).x, (*o).y);
+ }
+}
+
+void
+Panner::reset_streampanner (uint32_t which)
+{
+ if (which >= _streampanners.size() || which >= outputs.size()) {
+ return;
+ }
+
+ switch (outputs.size()) {
+ case 0:
+ case 1:
+ return;
+
+ case 2:
+ switch (_streampanners.size()) {
+ case 1:
+ /* stereo out, 1 stream, default = middle */
+ _streampanners.front()->set_position (0.5);
+ _streampanners.front()->pan_control()->list()->reset_default (0.5);
+ break;
+ case 2:
+ /* stereo out, 2 streams, default = hard left/right */
+ if (which == 0) {
+ _streampanners.front()->set_position (0.0);
+ _streampanners.front()->pan_control()->list()->reset_default (0.0);
+ } else {
+ _streampanners.back()->set_position (1.0);
+ _streampanners.back()->pan_control()->list()->reset_default (1.0);
+ }
+ break;
+ }
+ return;
+
+ default:
+ _streampanners[which]->set_position (outputs[which].x, outputs[which].y);
+ }
+}
+
void
Panner::reset (uint32_t nouts, uint32_t npans)
{
Panner::remove (uint32_t which)
{
vector<StreamPanner*>::iterator i;
- for (i = _streampanners.begin(); i != _streampanners.end() && which; ++i, --which);
+ for (i = _streampanners.begin(); i != _streampanners.end() && which; ++i, --which) {}
if (i != _streampanners.end()) {
delete *i;
AutoState
Panner::automation_state () const
{
+ boost::shared_ptr<AutomationList> l;
if (!empty()) {
- return ((AutomationList*)_streampanners.front()->pan_control()->list().get())->automation_state ();
- } else {
- return Off;
+ boost::shared_ptr<AutomationControl> control = _streampanners.front()->pan_control();
+ if (control) {
+ l = boost::dynamic_pointer_cast<AutomationList>(control->list());
+ }
}
+
+ return l ? l->automation_state() : Off;
}
AutoStyle
Panner::automation_style () const
{
+ boost::shared_ptr<AutomationList> l;
if (!empty()) {
- return ((AutomationList*)_streampanners.front()->pan_control()->list().get())->automation_style ();
- } else {
- return Absolute;
+ boost::shared_ptr<AutomationControl> control = _streampanners.front()->pan_control();
+ if (control) {
+ l = boost::dynamic_pointer_cast<AutomationList>(control->list());
+ }
}
-}
+ return l ? l->automation_style() : Absolute;
+}
struct PanPlugins {
string name;
XMLNode&
Panner::state (bool full)
{
- XMLNode& node = Processor::state(full);
-
- node.add_property ("type", "panner");
+ XMLNode* node = new XMLNode ("Panner");
char buf[32];
- node.add_property (X_("linked"), (_linked ? "yes" : "no"));
- node.add_property (X_("link_direction"), enum_2_string (_link_direction));
- node.add_property (X_("bypassed"), (bypassed() ? "yes" : "no"));
+ node->add_property (X_("linked"), (_linked ? "yes" : "no"));
+ node->add_property (X_("link_direction"), enum_2_string (_link_direction));
+ node->add_property (X_("bypassed"), (bypassed() ? "yes" : "no"));
for (vector<Panner::Output>::iterator o = outputs.begin(); o != outputs.end(); ++o) {
XMLNode* onode = new XMLNode (X_("Output"));
onode->add_property (X_("x"), buf);
snprintf (buf, sizeof (buf), "%.12g", (*o).y);
onode->add_property (X_("y"), buf);
- node.add_child_nocopy (*onode);
+ node->add_child_nocopy (*onode);
}
-
+
for (vector<StreamPanner*>::const_iterator i = _streampanners.begin(); i != _streampanners.end(); ++i) {
- node.add_child_nocopy ((*i)->state (full));
+ node->add_child_nocopy ((*i)->state (full));
}
- return node;
+ return *node;
}
int
clear_panners ();
- Processor::set_state(node);
-
ChanCount ins = ChanCount::ZERO;
ChanCount outs = ChanCount::ZERO;
}
void
-Panner::distribute_no_automation (BufferSet& inbufs, BufferSet& outbufs, nframes_t nframes, nframes_t offset, gain_t gain_coeff)
+Panner::distribute_no_automation (BufferSet& inbufs, BufferSet& outbufs, nframes_t nframes, gain_t gain_coeff)
{
if (outbufs.count().n_audio() == 0) {
// Don't want to lose audio...
/* only one output, and gain was zero, so make it silent */
- dst.silence(offset);
+ dst.silence (nframes);
} else if (gain_coeff == 1.0f){
/* mix all buffers into the output */
// copy the first
- dst.read_from(inbufs.get_audio(0), nframes, offset);
+ dst.read_from(inbufs.get_audio(0), nframes);
// accumulate starting with the second
- if (inbufs.count().n_audio() > 0) {
- BufferSet::audio_iterator i = inbufs.audio_begin();
- for (++i; i != inbufs.audio_end(); ++i) {
- dst.accumulate_from(*i, nframes, offset);
- }
- }
+ if (inbufs.count().n_audio() > 0) {
+ BufferSet::audio_iterator i = inbufs.audio_begin();
+ for (++i; i != inbufs.audio_end(); ++i) {
+ dst.merge_from(*i, nframes);
+ }
+ }
} else {
/* mix all buffers into the output, scaling them all by the gain */
// copy the first
- dst.read_from(inbufs.get_audio(0), nframes, offset);
+ dst.read_from(inbufs.get_audio(0), nframes);
// accumulate (with gain) starting with the second
- if (inbufs.count().n_audio() > 0) {
- BufferSet::audio_iterator i = inbufs.audio_begin();
- for (++i; i != inbufs.audio_end(); ++i) {
- dst.accumulate_with_gain_from(*i, nframes, offset, gain_coeff);
- }
- }
+ if (inbufs.count().n_audio() > 0) {
+ BufferSet::audio_iterator i = inbufs.audio_begin();
+ for (++i; i != inbufs.audio_end(); ++i) {
+ dst.accumulate_with_gain_from(*i, nframes, gain_coeff);
+ }
+ }
}
/* the terrible silence ... */
for (BufferSet::audio_iterator i = outbufs.audio_begin(); i != outbufs.audio_end(); ++i) {
- i->silence(nframes, offset);
+ i->silence(nframes);
}
BufferSet::audio_iterator i = inbufs.audio_begin();
}
void
-Panner::run_out_of_place (BufferSet& inbufs, BufferSet& outbufs, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset)
+Panner::run (BufferSet& inbufs, BufferSet& outbufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes)
{
if (outbufs.count().n_audio() == 0) {
// Failing to deliver audio we were asked to deliver is a bug
assert(!empty());
// If we shouldn't play automation defer to distribute_no_automation
- if ( !( automation_state() & Play ||
- ((automation_state() & Touch) && !touching()) ) ) {
+ if (!(automation_state() & Play || ((automation_state() & Touch) && !touching()))) {
// Speed quietning
gain_t gain_coeff = 1.0;
+
if (fabsf(_session.transport_speed()) > 1.5f) {
gain_coeff = speed_quietning;
}
- distribute_no_automation(inbufs, outbufs, nframes, offset, gain_coeff);
+ distribute_no_automation (inbufs, outbufs, nframes, gain_coeff);
return;
}
// FIXME: apply gain automation?
// copy the first
- dst.read_from(inbufs.get_audio(0), nframes, offset);
+ dst.read_from(inbufs.get_audio(0), nframes);
// accumulate starting with the second
BufferSet::audio_iterator i = inbufs.audio_begin();
for (++i; i != inbufs.audio_end(); ++i) {
- dst.accumulate_from(*i, nframes, offset);
+ dst.merge_from(*i, nframes);
}
return;
/* the terrible silence ... */
for (BufferSet::audio_iterator i = outbufs.audio_begin(); i != outbufs.audio_end(); ++i) {
- i->silence(nframes, offset);
+ i->silence(nframes);
}
BufferSet::audio_iterator i = inbufs.audio_begin();