$Id$
*/
+#define __STDC_FORMAT_MACROS 1
+#include <inttypes.h>
+
#include <cmath>
#include <cerrno>
#include <fstream>
StreamPanner::StreamPanner (Panner& p)
: parent (p),
- _control (*this)
+ _control (X_("panner"), *this)
{
_muted = false;
}
void
-BaseStereoPanner::snapshot (jack_nframes_t now)
+BaseStereoPanner::snapshot (nframes_t now)
{
if (_automation.automation_state() == Write || _automation.automation_state() == Touch) {
_automation.rt_add (now, x);
}
void
-BaseStereoPanner::transport_stopped (jack_nframes_t frame)
+BaseStereoPanner::transport_stopped (nframes_t frame)
{
_automation.reposition_for_rt_add (frame);
out << "begin" << endl;
for (AutomationList::const_iterator i = _automation.const_begin(); i != _automation.const_end(); ++i) {
- out << '\t' << (jack_nframes_t) floor ((*i)->when) << ' ' << (*i)->value << endl;
+ out << '\t' << (nframes_t) floor ((*i)->when) << ' ' << (*i)->value << endl;
if (!out) {
error << string_compose (_("error writing pan automation file (%s)"), strerror (errno)) << endmsg;
return -1;
_automation.clear ();
while (in.getline (line, sizeof (line), '\n')) {
- jack_nframes_t when;
+ nframes_t when;
double value;
++linecnt;
}
void
-BaseStereoPanner::distribute (AudioBuffer& srcbuf, BufferSet& obufs, gain_t gain_coeff, jack_nframes_t nframes)
+BaseStereoPanner::distribute (AudioBuffer& srcbuf, BufferSet& obufs, gain_t gain_coeff, nframes_t nframes)
{
assert(obufs.count().get(DataType::AUDIO) == 2);
/* interpolate over 64 frames or nframes, whichever is smaller */
- jack_nframes_t limit = min ((jack_nframes_t)64, nframes);
- jack_nframes_t n;
+ nframes_t limit = min ((nframes_t)64, nframes);
+ nframes_t n;
delta = -(delta / (float) (limit));
/* interpolate over 64 frames or nframes, whichever is smaller */
- jack_nframes_t limit = min ((jack_nframes_t)64, nframes);
- jack_nframes_t n;
+ nframes_t limit = min ((nframes_t)64, nframes);
+ nframes_t n;
delta = -(delta / (float) (limit));
void
EqualPowerStereoPanner::distribute_automated (AudioBuffer& srcbuf, BufferSet& obufs,
- jack_nframes_t start, jack_nframes_t end, jack_nframes_t nframes,
+ nframes_t start, nframes_t end, nframes_t nframes,
pan_t** buffers)
{
assert(obufs.count().get(DataType::AUDIO) == 2);
const float pan_law_attenuation = -3.0f;
const float scale = 2.0f - 4.0f * powf (10.0f,pan_law_attenuation/20.0f);
- for (jack_nframes_t n = 0; n < nframes; ++n) {
+ for (nframes_t n = 0; n < nframes; ++n) {
float panR = buffers[0][n];
float panL = 1 - panR;
dst = obufs.get_audio(0).data(nframes);
pbuf = buffers[0];
- for (jack_nframes_t n = 0; n < nframes; ++n) {
+ for (nframes_t n = 0; n < nframes; ++n) {
dst[n] += src[n] * pbuf[n];
}
dst = obufs.get_audio(1).data(nframes);
pbuf = buffers[1];
- for (jack_nframes_t n = 0; n < nframes; ++n) {
+ for (nframes_t n = 0; n < nframes; ++n) {
dst[n] += src[n] * pbuf[n];
}
root->add_property (X_("automation-style"), buf);
StreamPanner::add_state (*root);
+ root->add_child_nocopy (_control.get_state ());
return *root;
}
}
StreamPanner::set_state (node);
+
+ for (XMLNodeConstIterator iter = node.children().begin(); iter != node.children().end(); ++iter) {
+ if ((*iter)->name() == X_("panner")) {
+ _control.set_state (**iter);
+ parent.session().add_controllable (&_control);
+ }
+ }
return 0;
}
}
void
-Multi2dPanner::snapshot (jack_nframes_t now)
+Multi2dPanner::snapshot (nframes_t now)
{
// how?
}
void
-Multi2dPanner::transport_stopped (jack_nframes_t frame)
+Multi2dPanner::transport_stopped (nframes_t frame)
{
//what?
}
}
void
-Multi2dPanner::distribute (AudioBuffer& srcbuf, BufferSet& obufs, gain_t gain_coeff, jack_nframes_t nframes)
+Multi2dPanner::distribute (AudioBuffer& srcbuf, BufferSet& obufs, gain_t gain_coeff, nframes_t nframes)
{
Sample* dst;
pan_t pan;
/* interpolate over 64 frames or nframes, whichever is smaller */
- jack_nframes_t limit = min ((jack_nframes_t)64, nframes);
- jack_nframes_t n;
+ nframes_t limit = min ((nframes_t)64, nframes);
+ nframes_t n;
delta = -(delta / (float) (limit));
if (pan != 0.0f) {
- for (jack_nframes_t n = 0; n < nframes; ++n) {
+ for (nframes_t n = 0; n < nframes; ++n) {
dst[n] += src[n] * pan;
}
} else {
- for (jack_nframes_t n = 0; n < nframes; ++n) {
+ for (nframes_t n = 0; n < nframes; ++n) {
dst[n] += src[n];
}
void
Multi2dPanner::distribute_automated (AudioBuffer& src, BufferSet& obufs,
- jack_nframes_t start, jack_nframes_t end, jack_nframes_t nframes,
+ nframes_t start, nframes_t end, nframes_t nframes,
pan_t** buffers)
{
if (_muted) {
}
void
-Panner::transport_stopped (jack_nframes_t frame)
+Panner::transport_stopped (nframes_t frame)
{
for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
(*i)->transport_stopped (frame);
}
void
-Panner::snapshot (jack_nframes_t now)
+Panner::snapshot (nframes_t now)
{
for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
(*i)->snapshot (now);
ofstream out (automation_path.c_str());
if (!out) {
- error << string_compose (_("cannot open pan automation file \"%1\" for saving (%s)"), automation_path, strerror (errno))
+ error << string_compose (_("cannot open pan automation file \"%1\" for saving (%2)"), automation_path, strerror (errno))
<< endmsg;
return -1;
}
}
void
-Panner::distribute_no_automation (BufferSet& inbufs, BufferSet& outbufs, jack_nframes_t nframes, jack_nframes_t offset, gain_t gain_coeff)
+Panner::distribute_no_automation (BufferSet& inbufs, BufferSet& outbufs, nframes_t nframes, nframes_t offset, gain_t gain_coeff)
{
if (outbufs.count().get(DataType::AUDIO) == 0) {
// Don't want to lose audio...
}
void
-Panner::distribute (BufferSet& inbufs, BufferSet& outbufs, jack_nframes_t start_frame, jack_nframes_t end_frame, jack_nframes_t nframes, jack_nframes_t offset)
+Panner::distribute (BufferSet& inbufs, BufferSet& outbufs, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset)
{
if (outbufs.count().get(DataType::AUDIO) == 0) {
// Failing to deliver audio we were asked to deliver is a bug