Add .dir-locals.el file.

Also change all tabs to spaces and use spaces going forward.
looper
Ben Niemann 2017-10-04 17:56:06 +02:00
parent 6072e7b74d
commit ee4117bce0
14 changed files with 246 additions and 226 deletions

25
.dir-locals.el Normal file
View File

@ -0,0 +1,25 @@
; TODO:
; - add shortcuts to run tests
; - add tweaks to C++ indentation
; - no indentation for namespace
; - correct indentation for arg list continuation
((nil . (
; Uses spaces for indentation.
(indent-tabs-mode . nil)
; Be more generous than 80 columns.
(fill-column . 100)
; Highlight tabs, so they don't slip in unnoticed.
; TODO: make this work correctly
; - should only show leading tabs
; - disrupts colors in magit
;(eval . (add-hook 'font-lock-mode-hook
; (lambda ()
; (font-lock-add-keywords
; nil
; '(("\t" 0 'trailing-whitespace prepend))))))
)
)
)

View File

@ -49,11 +49,6 @@
- absl::Substitude for sprintf
- absl::string_view for method args
- absl::GetCurrentTimeNanos() for PerfStats
* Use .dir-local.el :FR:
- https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html
- use spaces for indentation in C++, too
- tweak C++ indentation
- C-o C-t to run tests
* Do SVG conversion at build time :FR:
- the stuff in SvgSymbol.strip_dom()
* ProcessorFluidSynth :FR:

View File

@ -89,8 +89,8 @@ Status AudioStreamBase::pipe_read(char* data, size_t size) {
if (fds.revents & POLLIN) {
ssize_t bytes_read = read(_pipe_in, data, size);
if (bytes_read < 0) {
// TODO: Status::ErrorFromErrno
return ERROR_STATUS("Failed to read from pipe.");
// TODO: Status::ErrorFromErrno
return ERROR_STATUS("Failed to read from pipe.");
}
data += bytes_read;
size -= bytes_read;
@ -122,8 +122,8 @@ Status AudioStreamBase::pipe_write(const char* data, size_t size) {
if (fds.revents & POLLOUT) {
ssize_t bytes_written = write(_pipe_out, data, size);
if (bytes_written < 0) {
// TODO: Status::ErrorFromErrno
return ERROR_STATUS("Failed to write to pipe.");
// TODO: Status::ErrorFromErrno
return ERROR_STATUS("Failed to write to pipe.");
}
data += bytes_written;
size -= bytes_written;

View File

@ -34,8 +34,8 @@ public:
IPCRequest(const string& request_bytes)
: _request_bytes(request_bytes),
_words(
(::capnp::word*)_request_bytes.c_str(),
_request_bytes.size() / sizeof(::capnp::word)),
(::capnp::word*)_request_bytes.c_str(),
_request_bytes.size() / sizeof(::capnp::word)),
_reader(_words) {}
capnp::BlockData::Reader reader() {
@ -115,7 +115,7 @@ Status IPCBackend::begin_block(BlockContext* ctxt) {
::capnp::Data::Reader data = block.getData();
ctxt->buffers.emplace(
string(block.getId().cStr()),
BlockContext::Buffer{data.size(), (const BufferPtr)data.begin()});
BlockContext::Buffer{data.size(), (const BufferPtr)data.begin()});
}
ctxt->in_messages.clear();

View File

@ -135,7 +135,7 @@ Status PortAudioBackend::begin_block(BlockContext* ctxt) {
for (int c = 0 ; c < 2 ; ++c) {
if (_samples[c] != nullptr) {
delete _samples[c];
delete _samples[c];
}
_samples[c] = new uint8_t[_settings.block_size * sizeof(float)];
}

View File

@ -124,7 +124,7 @@ Status AtomData::mix_buffers(HostData* host_data, uint32_t block_size, const Buf
lv2_atom_forge_sequence_head(&forge, &frame, host_data->lv2->urid.atom_frame_time);
while (!lv2_atom_sequence_is_end(&seq1->body, seq1->atom.size, event1)
&& !lv2_atom_sequence_is_end(&seq2->body, seq2->atom.size, event2)) {
&& !lv2_atom_sequence_is_end(&seq2->body, seq2->atom.size, event2)) {
LV2_Atom_Event* event;
if (event1->time.frames <= event2->time.frames) {
event = event1;

View File

@ -73,9 +73,9 @@ Status LV2SubSystem::setup() {
_features.emplace_back(
Feature {
LV2_URID__map,
bind(&LV2SubSystem::create_map_feature, this, placeholders::_1),
nullptr
LV2_URID__map,
bind(&LV2SubSystem::create_map_feature, this, placeholders::_1),
nullptr
});
_features.emplace_back(
Feature {
@ -92,14 +92,14 @@ Status LV2SubSystem::setup() {
_features.emplace_back(
Feature {
LV2_BUF_SIZE__boundedBlockLength,
nullptr,
nullptr,
nullptr
});
_features.emplace_back(
Feature {
LV2_BUF_SIZE__powerOf2BlockLength,
nullptr,
nullptr
LV2_BUF_SIZE__powerOf2BlockLength,
nullptr,
nullptr
});
// _features[LV2_WORKER__schedule] = nullptr;
@ -137,9 +137,9 @@ LV2_Feature* LV2SubSystem::create_feature(const string& uri) {
LV2_Feature* feature = new LV2_Feature;
feature->URI = f.uri.c_str();
if (f.create_func != nullptr) {
f.create_func(feature);
f.create_func(feature);
} else {
feature->data = nullptr;
feature->data = nullptr;
}
return feature;
}
@ -153,7 +153,7 @@ void LV2SubSystem::delete_feature(LV2_Feature* feature) {
for (const auto& f : _features) {
if (f.uri == uri) {
if (f.delete_func != nullptr) {
f.delete_func(feature);
f.delete_func(feature);
}
delete feature;
return;

View File

@ -128,8 +128,8 @@ Status run_FETCH_MESSAGES(BlockContext* ctxt, ProgramState* state, const vector<
for (const auto& msg_bytes : ctxt->in_messages) {
kj::ArrayPtr<::capnp::word> words(
(::capnp::word*)msg_bytes.c_str(),
msg_bytes.size() / sizeof(::capnp::word));
(::capnp::word*)msg_bytes.c_str(),
msg_bytes.size() / sizeof(::capnp::word));
::capnp::FlatArrayMessageReader reader(words);
capnp::Message::Reader msg(reader.getRoot<capnp::Message>());
@ -142,14 +142,14 @@ Status run_FETCH_MESSAGES(BlockContext* ctxt, ProgramState* state, const vector<
for (const auto& label_a : labelset.getLabels()) {
matched = false;
for (const auto& label_b : msg.getLabelset().getLabels()) {
if (label_b.getKey() == label_a.getKey() && label_b.getValue() == label_a.getValue()) {
matched = true;
break;
}
if (label_b.getKey() == label_a.getKey() && label_b.getValue() == label_a.getValue()) {
matched = true;
break;
}
}
if (!matched) {
break;
break;
}
}
@ -275,8 +275,8 @@ Status run_LOG_ATOM(BlockContext* ctxt, ProgramState* state, const vector<OpArg>
LV2_Atom_Sequence* seq = (LV2_Atom_Sequence*)buf->data();
if (seq->atom.type != state->host_data->lv2->urid.atom_sequence) {
return ERROR_STATUS(
"Buffer %d: Excepted sequence (%d), got %d.",
idx, state->host_data->lv2->urid.atom_sequence, seq->atom.type);
"Buffer %d: Excepted sequence (%d), got %d.",
idx, state->host_data->lv2->urid.atom_sequence, seq->atom.type);
}
LV2_Atom_Event* event = lv2_atom_sequence_begin(&seq->body);

View File

@ -144,35 +144,35 @@ Status ProcessorCSoundBase::set_code(const string& orchestra, const string& scor
MYFLT* channel_ptr;
int type = csoundGetChannelPtr(
instance->csnd, &channel_ptr, port.name().c_str(), 0);
instance->csnd, &channel_ptr, port.name().c_str(), 0);
if (type < 0) {
return ERROR_STATUS("Orchestra does not define the channel '%s'", port.name().c_str());
}
if (port.direction() == PortDirection::Output
&& !(type & CSOUND_OUTPUT_CHANNEL)) {
&& !(type & CSOUND_OUTPUT_CHANNEL)) {
return ERROR_STATUS("Channel '%s' is not an output channel", port.name().c_str());
}
if (port.direction() == PortDirection::Input
&& !(type & CSOUND_INPUT_CHANNEL)) {
&& !(type & CSOUND_INPUT_CHANNEL)) {
return ERROR_STATUS("Channel '%s' is not an input channel", port.name().c_str());
}
if (port.type() == PortType::audio || port.type() == PortType::aRateControl) {
if (port.type() == PortType::audio || port.type() == PortType::aRateControl) {
if ((type & CSOUND_CHANNEL_TYPE_MASK) != CSOUND_AUDIO_CHANNEL) {
return ERROR_STATUS("Channel '%s' is not an audio channel", port.name().c_str());
return ERROR_STATUS("Channel '%s' is not an audio channel", port.name().c_str());
}
} else if (port.type() == PortType::kRateControl) {
if ((type & CSOUND_CHANNEL_TYPE_MASK) != CSOUND_CONTROL_CHANNEL) {
return ERROR_STATUS("Channel '%s' is not an control channel", port.name().c_str());
return ERROR_STATUS("Channel '%s' is not an control channel", port.name().c_str());
}
} else {
return ERROR_STATUS("Internal error, channel '%s' type %d", port.name().c_str(), port.type());
}
int rc = csoundGetChannelPtr(
instance->csnd, &channel_ptr, port.name().c_str(), type);
instance->csnd, &channel_ptr, port.name().c_str(), type);
if (rc < 0) {
return ERROR_STATUS("Failed to get channel pointer for port '%s'", port.name().c_str());
}
@ -180,7 +180,7 @@ Status ProcessorCSoundBase::set_code(const string& orchestra, const string& scor
instance->channel_ptr[port_idx] = channel_ptr;
instance->channel_lock[port_idx] = csoundGetChannelLock(
instance->csnd, port.name().c_str());
instance->csnd, port.name().c_str());
}
prev_next_instance = _next_instance.exchange(instance.release());
@ -254,18 +254,18 @@ Status ProcessorCSoundBase::run(BlockContext* ctxt) {
for (uint32_t port_idx = 0 ; port_idx < _spec->num_ports() ; ++port_idx) {
const auto& port = _spec->get_port(port_idx);
if (port.direction() == PortDirection::Output) {
if (port.type() == PortType::audio
|| port.type() == PortType::aRateControl) {
float* buf = (float*)_buffers[port_idx];
for (uint32_t i = 0 ; i < ctxt->block_size ; ++i) {
*buf++ = 0.0;
}
} else if (port.type() == PortType::kRateControl) {
float* buf = (float*)_buffers[port_idx];
*buf = 0.0;
} else {
return ERROR_STATUS("Port %d has unsupported type %d", port_idx, port.type());
}
if (port.type() == PortType::audio
|| port.type() == PortType::aRateControl) {
float* buf = (float*)_buffers[port_idx];
for (uint32_t i = 0 ; i < ctxt->block_size ; ++i) {
*buf++ = 0.0;
}
} else if (port.type() == PortType::kRateControl) {
float* buf = (float*)_buffers[port_idx];
*buf = 0.0;
} else {
return ERROR_STATUS("Port %d has unsupported type %d", port_idx, port.type());
}
}
}
@ -275,11 +275,11 @@ Status ProcessorCSoundBase::run(BlockContext* ctxt) {
for (uint32_t port_idx = 0 ; port_idx < _spec->num_ports() ; ++port_idx) {
const auto& port = _spec->get_port(port_idx);
if (port.direction() == PortDirection::Input
&& port.type() == PortType::atomData) {
&& port.type() == PortType::atomData) {
LV2_Atom_Sequence* seq = (LV2_Atom_Sequence*)_buffers[port_idx];
if (seq->atom.type != _host_data->lv2->urid.atom_sequence) {
return ERROR_STATUS(
"Excepted sequence in port '%s', got %d.", port.name().c_str(), seq->atom.type);
return ERROR_STATUS(
"Excepted sequence in port '%s', got %d.", port.name().c_str(), seq->atom.type);
}
LV2_Atom_Event* event = lv2_atom_sequence_begin(&seq->body);
int instr = 1; // TODO: use port.csound_instr
@ -294,92 +294,92 @@ Status ProcessorCSoundBase::run(BlockContext* ctxt) {
for (uint32_t port_idx = 0 ; port_idx < _spec->num_ports() ; ++port_idx) {
const auto& port = _spec->get_port(port_idx);
if (port.direction() == PortDirection::Input) {
if (port.type() == PortType::audio
|| port.type() == PortType::aRateControl) {
float* buf = (float*)_buffers[port_idx];
buf += pos;
if (port.type() == PortType::audio
|| port.type() == PortType::aRateControl) {
float* buf = (float*)_buffers[port_idx];
buf += pos;
MYFLT* channel_ptr = instance->channel_ptr[port_idx];
int *lock = instance->channel_lock[port_idx];
csoundSpinLock(lock);
for (uint32_t i = 0 ; i < ksmps ; ++i) {
*channel_ptr++ = *buf++;
}
csoundSpinUnLock(lock);
} else if (port.type() == PortType::kRateControl) {
float* buf = (float*)_buffers[port_idx];
MYFLT* channel_ptr = instance->channel_ptr[port_idx];
int *lock = instance->channel_lock[port_idx];
csoundSpinLock(lock);
for (uint32_t i = 0 ; i < ksmps ; ++i) {
*channel_ptr++ = *buf++;
}
csoundSpinUnLock(lock);
} else if (port.type() == PortType::kRateControl) {
float* buf = (float*)_buffers[port_idx];
MYFLT* channel_ptr = instance->channel_ptr[port_idx];
int *lock = instance->channel_lock[port_idx];
csoundSpinLock(lock);
*channel_ptr = *buf;
csoundSpinUnLock(lock);
} else if (port.type() == PortType::atomData) {
EventInputPort &ep = _event_input_ports[port_idx];
MYFLT* channel_ptr = instance->channel_ptr[port_idx];
int *lock = instance->channel_lock[port_idx];
csoundSpinLock(lock);
*channel_ptr = *buf;
csoundSpinUnLock(lock);
} else if (port.type() == PortType::atomData) {
EventInputPort &ep = _event_input_ports[port_idx];
// TODO: is instrument started with one ksmps delay? needs further testing.
while (!lv2_atom_sequence_is_end(
&ep.seq->body, ep.seq->atom.size, ep.event)
&& ep.event->time.frames < pos + ksmps) {
LV2_Atom& atom = ep.event->body;
if (atom.type == _host_data->lv2->urid.midi_event) {
uint8_t* midi = (uint8_t*)LV2_ATOM_CONTENTS(LV2_Atom, &atom);
if ((midi[0] & 0xf0) == 0x90) {
MYFLT p[5] = {
/* p1: instr */ (MYFLT)ep.instr + (MYFLT)midi[1] / 1000.0,
/* p2: time */ 0.0,
/* p3: duration */ -1.0,
/* p4: pitch */ (MYFLT)midi[1],
/* p5: velocity */ (MYFLT)midi[2],
};
//_logger->info("i %f %f %f %f %f", p[0], p[1], p[2], p[3], p[4]);
int rc = csoundScoreEvent(instance->csnd, 'i', p, 5);
if (rc < 0) {
return ERROR_STATUS("csoundScoreEvent failed (code %d).", rc);
}
} else if ((midi[0] & 0xf0) == 0x80) {
MYFLT p[3] = {
/* p1: instr */ -((MYFLT)ep.instr + (MYFLT)midi[1] / 1000.0),
/* p2: time */ 0.0,
/* p3: duration */ 0.0,
};
//_logger->info("i %f %f %f", p[0], p[1], p[2]);
int rc = csoundScoreEvent(instance->csnd, 'i', p, 3);
if (rc < 0) {
return ERROR_STATUS("csoundScoreEvent failed (code %d).", rc);
}
} else {
_logger->warning("Ignoring unsupported midi event %d.", midi[0] & 0xf0);
}
} else {
_logger->warning("Ignoring event %d in sequence.", atom.type);
}
ep.event = lv2_atom_sequence_next(ep.event);
}
} else {
return ERROR_STATUS("Port %s has unsupported type %d", port.name().c_str(), port.type());
}
// TODO: is instrument started with one ksmps delay? needs further testing.
while (!lv2_atom_sequence_is_end(
&ep.seq->body, ep.seq->atom.size, ep.event)
&& ep.event->time.frames < pos + ksmps) {
LV2_Atom& atom = ep.event->body;
if (atom.type == _host_data->lv2->urid.midi_event) {
uint8_t* midi = (uint8_t*)LV2_ATOM_CONTENTS(LV2_Atom, &atom);
if ((midi[0] & 0xf0) == 0x90) {
MYFLT p[5] = {
/* p1: instr */ (MYFLT)ep.instr + (MYFLT)midi[1] / 1000.0,
/* p2: time */ 0.0,
/* p3: duration */ -1.0,
/* p4: pitch */ (MYFLT)midi[1],
/* p5: velocity */ (MYFLT)midi[2],
};
//_logger->info("i %f %f %f %f %f", p[0], p[1], p[2], p[3], p[4]);
int rc = csoundScoreEvent(instance->csnd, 'i', p, 5);
if (rc < 0) {
return ERROR_STATUS("csoundScoreEvent failed (code %d).", rc);
}
} else if ((midi[0] & 0xf0) == 0x80) {
MYFLT p[3] = {
/* p1: instr */ -((MYFLT)ep.instr + (MYFLT)midi[1] / 1000.0),
/* p2: time */ 0.0,
/* p3: duration */ 0.0,
};
//_logger->info("i %f %f %f", p[0], p[1], p[2]);
int rc = csoundScoreEvent(instance->csnd, 'i', p, 3);
if (rc < 0) {
return ERROR_STATUS("csoundScoreEvent failed (code %d).", rc);
}
} else {
_logger->warning("Ignoring unsupported midi event %d.", midi[0] & 0xf0);
}
} else {
_logger->warning("Ignoring event %d in sequence.", atom.type);
}
ep.event = lv2_atom_sequence_next(ep.event);
}
} else {
return ERROR_STATUS("Port %s has unsupported type %d", port.name().c_str(), port.type());
}
} else {
assert(port.direction() == PortDirection::Output);
assert(port.direction() == PortDirection::Output);
if (port.type() == PortType::audio
|| port.type() == PortType::aRateControl) {
MYFLT* channel_ptr = instance->channel_ptr[port_idx];
int *lock = instance->channel_lock[port_idx];
csoundSpinLock(lock);
for (uint32_t i = 0 ; i < ksmps ; ++i) {
*channel_ptr++ = 0.0;
}
csoundSpinUnLock(lock);
} else if (port.type() == PortType::kRateControl) {
MYFLT* channel_ptr = instance->channel_ptr[port_idx];
int *lock = instance->channel_lock[port_idx];
csoundSpinLock(lock);
*channel_ptr = 0.0;
csoundSpinUnLock(lock);
} else {
return ERROR_STATUS("Port %s has unsupported type %d", port.name().c_str(), port.type());
}
if (port.type() == PortType::audio
|| port.type() == PortType::aRateControl) {
MYFLT* channel_ptr = instance->channel_ptr[port_idx];
int *lock = instance->channel_lock[port_idx];
csoundSpinLock(lock);
for (uint32_t i = 0 ; i < ksmps ; ++i) {
*channel_ptr++ = 0.0;
}
csoundSpinUnLock(lock);
} else if (port.type() == PortType::kRateControl) {
MYFLT* channel_ptr = instance->channel_ptr[port_idx];
int *lock = instance->channel_lock[port_idx];
csoundSpinLock(lock);
*channel_ptr = 0.0;
csoundSpinUnLock(lock);
} else {
return ERROR_STATUS("Port %s has unsupported type %d", port.name().c_str(), port.type());
}
}
}
@ -392,29 +392,29 @@ Status ProcessorCSoundBase::run(BlockContext* ctxt) {
for (uint32_t port_idx = 0 ; port_idx < _spec->num_ports() ; ++port_idx) {
const auto& port = _spec->get_port(port_idx);
if (port.direction() == PortDirection::Output) {
if (port.type() == PortType::audio
|| port.type() == PortType::aRateControl) {
float* buf = (float*)_buffers[port_idx];
buf += pos;
if (port.type() == PortType::audio
|| port.type() == PortType::aRateControl) {
float* buf = (float*)_buffers[port_idx];
buf += pos;
MYFLT* channel_ptr = instance->channel_ptr[port_idx];
int *lock = instance->channel_lock[port_idx];
csoundSpinLock(lock);
for (uint32_t i = 0 ; i < ksmps ; ++i) {
*buf++ = *channel_ptr++;
}
csoundSpinUnLock(lock);
} else if (port.type() == PortType::kRateControl) {
float* buf = (float*)_buffers[port_idx];
MYFLT* channel_ptr = instance->channel_ptr[port_idx];
int *lock = instance->channel_lock[port_idx];
csoundSpinLock(lock);
for (uint32_t i = 0 ; i < ksmps ; ++i) {
*buf++ = *channel_ptr++;
}
csoundSpinUnLock(lock);
} else if (port.type() == PortType::kRateControl) {
float* buf = (float*)_buffers[port_idx];
MYFLT* channel_ptr = instance->channel_ptr[port_idx];
int *lock = instance->channel_lock[port_idx];
csoundSpinLock(lock);
*buf = *channel_ptr;
csoundSpinUnLock(lock);
} else {
return ERROR_STATUS("Port %s has unsupported type %d", port.name().c_str(), port.type());
}
MYFLT* channel_ptr = instance->channel_ptr[port_idx];
int *lock = instance->channel_lock[port_idx];
csoundSpinLock(lock);
*buf = *channel_ptr;
csoundSpinUnLock(lock);
} else {
return ERROR_STATUS("Port %s has unsupported type %d", port.name().c_str(), port.type());
}
}
}

View File

@ -73,31 +73,31 @@ Status ProcessorCustomCSound::setup(const ProcessorSpec* spec) {
const auto& port_spec = _spec->get_port(i);
if (port_spec.type() == PortType::audio
&& port_spec.direction() == PortDirection::Input) {
&& port_spec.direction() == PortDirection::Input) {
orchestra_preamble += sprintf(
"ga%s chnexport \"%s\", 1\n",
port_name_to_csound_label(port_spec.name()).c_str(),
port_spec.name().c_str());
"ga%s chnexport \"%s\", 1\n",
port_name_to_csound_label(port_spec.name()).c_str(),
port_spec.name().c_str());
} else if (port_spec.type() == PortType::audio
&& port_spec.direction() == PortDirection::Output) {
&& port_spec.direction() == PortDirection::Output) {
orchestra_preamble += sprintf(
"ga%s chnexport \"%s\", 2\n",
port_name_to_csound_label(port_spec.name()).c_str(),
port_spec.name().c_str());
"ga%s chnexport \"%s\", 2\n",
port_name_to_csound_label(port_spec.name()).c_str(),
port_spec.name().c_str());
} else if (port_spec.type() == PortType::aRateControl
&& port_spec.direction() == PortDirection::Input) {
&& port_spec.direction() == PortDirection::Input) {
orchestra_preamble += sprintf(
"ga%s chnexport \"%s\", 1\n",
port_name_to_csound_label(port_spec.name()).c_str(),
port_spec.name().c_str());
"ga%s chnexport \"%s\", 1\n",
port_name_to_csound_label(port_spec.name()).c_str(),
port_spec.name().c_str());
} else if (port_spec.type() == PortType::aRateControl
&& port_spec.direction() == PortDirection::Output) {
&& port_spec.direction() == PortDirection::Output) {
orchestra_preamble += sprintf(
"ga%s chnexport \"%s\", 2\n",
port_name_to_csound_label(port_spec.name()).c_str(),
port_spec.name().c_str());
"ga%s chnexport \"%s\", 2\n",
port_name_to_csound_label(port_spec.name()).c_str(),
port_spec.name().c_str());
} else if (port_spec.type() == PortType::atomData
&& port_spec.direction() == PortDirection::Input) {
&& port_spec.direction() == PortDirection::Input) {
} else {
return ERROR_STATUS("Port %s not supported", port_spec.name().c_str());
}

View File

@ -155,44 +155,44 @@ Status ProcessorFluidSynth::run(BlockContext* ctxt) {
uint32_t esample_pos;
if (event->time.frames != -1) {
if (event->time.frames < 0 || event->time.frames >= ctxt->block_size) {
return ERROR_STATUS(
"Event timestamp %d out of bounds [0,%d]", event->time.frames, ctxt->block_size);
}
if (event->time.frames < 0 || event->time.frames >= ctxt->block_size) {
return ERROR_STATUS(
"Event timestamp %d out of bounds [0,%d]", event->time.frames, ctxt->block_size);
}
esample_pos = event->time.frames;
esample_pos = event->time.frames;
} else {
esample_pos = 0;
esample_pos = 0;
}
if (esample_pos > segment_start) {
uint32_t num_samples = esample_pos - segment_start;
float *lmap[1] = { out_left };
float *rmap[1] = { out_right };
int rc = fluid_synth_nwrite_float(_synth, num_samples, lmap, rmap, nullptr, nullptr);
if (rc == FLUID_FAILED) {
// TODO: error message
return ERROR_STATUS("Failed to render samples");
}
uint32_t num_samples = esample_pos - segment_start;
float *lmap[1] = { out_left };
float *rmap[1] = { out_right };
int rc = fluid_synth_nwrite_float(_synth, num_samples, lmap, rmap, nullptr, nullptr);
if (rc == FLUID_FAILED) {
// TODO: error message
return ERROR_STATUS("Failed to render samples");
}
segment_start = esample_pos;
out_left += num_samples;
out_right += num_samples;
segment_start = esample_pos;
out_left += num_samples;
out_right += num_samples;
}
uint8_t* midi = (uint8_t*)LV2_ATOM_CONTENTS(LV2_Atom, &event->body);
if ((midi[0] & 0xf0) == 0x90) {
int rc = fluid_synth_noteon(_synth, 0, midi[1], midi[2]);
if (rc == FLUID_FAILED) {
_logger->warning("noteon failed.");
}
int rc = fluid_synth_noteon(_synth, 0, midi[1], midi[2]);
if (rc == FLUID_FAILED) {
_logger->warning("noteon failed.");
}
} else if ((midi[0] & 0xf0) == 0x80) {
int rc = fluid_synth_noteoff(_synth, 0, midi[1]);
if (rc == FLUID_FAILED) {
_logger->warning("noteoff failed.");
}
int rc = fluid_synth_noteoff(_synth, 0, midi[1]);
if (rc == FLUID_FAILED) {
_logger->warning("noteoff failed.");
}
} else {
_logger->warning("Ignoring unsupported midi event %d.", midi[0] & 0xf0);
_logger->warning("Ignoring unsupported midi event %d.", midi[0] & 0xf0);
}
} else {
_logger->warning("Ignoring event %d in sequence.", event->body.type);

View File

@ -106,12 +106,12 @@ Status ProcessorIPC::run(BlockContext* ctxt) {
for (const auto& span : response.getPerfData().getSpans()) {
ctxt->perf->append_span(
PerfStats::Span{
span.getId(),
span.getName().cStr(),
span.getParentId() != 0 ? span.getParentId() : ctxt->perf->current_span_id(),
span.getStartTimeNSec(),
span.getEndTimeNSec()});
PerfStats::Span{
span.getId(),
span.getName().cStr(),
span.getParentId() != 0 ? span.getParentId() : ctxt->perf->current_span_id(),
span.getStartTimeNSec(),
span.getEndTimeNSec()});
}
bool ports_written[2] = { false, false };

View File

@ -86,7 +86,7 @@ Status ProcessorSoundFile::setup(const ProcessorSpec* spec) {
if (rc) {
char buf[AV_ERROR_MAX_STRING_SIZE];
return ERROR_STATUS(
"Failed to init swr context: %s", av_make_error_string(buf, sizeof(buf), rc));
"Failed to init swr context: %s", av_make_error_string(buf, sizeof(buf), rc));
}
unique_ptr<float> frames(new float[1024 * sfinfo.channels]);
@ -106,13 +106,13 @@ Status ProcessorSoundFile::setup(const ProcessorSpec* spec) {
(uint8_t*)(_right_samples.get() + out_pos)
};
int samples_written = swr_convert(
ctxt,
out_planes, _num_samples - out_pos,
in_planes, frames_read);
ctxt,
out_planes, _num_samples - out_pos,
in_planes, frames_read);
if (rc < 0) {
char buf[AV_ERROR_MAX_STRING_SIZE];
return ERROR_STATUS(
"Failed to convert samples: %s", av_make_error_string(buf, sizeof(buf), samples_written));
"Failed to convert samples: %s", av_make_error_string(buf, sizeof(buf), samples_written));
}
in_pos += frames_read;
@ -131,7 +131,7 @@ Status ProcessorSoundFile::setup(const ProcessorSpec* spec) {
if (rc < 0) {
char buf[AV_ERROR_MAX_STRING_SIZE];
return ERROR_STATUS(
"Failed to convert samples: %s", av_make_error_string(buf, sizeof(buf), samples_written));
"Failed to convert samples: %s", av_make_error_string(buf, sizeof(buf), samples_written));
}
out_pos += samples_written;
@ -168,18 +168,18 @@ Status ProcessorSoundFile::run(BlockContext* ctxt) {
for (uint32_t i = 0 ; i < ctxt->block_size ; ++i) {
if (_pos >= _num_samples) {
if (_loop) {
_pos = 0;
_pos = 0;
} else {
if (_playing) {
_playing = false;
if (_playing) {
_playing = false;
SoundFileCompleteMessage msg(node_id());
ctxt->out_messages->push(&msg);
}
SoundFileCompleteMessage msg(node_id());
ctxt->out_messages->push(&msg);
}
*l_out++ = 0.0;
*r_out++ = 0.0;
continue;
*l_out++ = 0.0;
*r_out++ = 0.0;
continue;
}
}

View File

@ -221,9 +221,9 @@ Status VM::process_block(Backend* backend, BlockContext* ctxt) {
_logger->info("Use program v%d", program->version);
Program* old_program = _current_program.exchange(program);
if (old_program) {
_logger->info("Unuse program v%d", old_program->version);
old_program = _old_program.exchange(old_program);
assert(old_program == nullptr);
_logger->info("Unuse program v%d", old_program->version);
old_program = _old_program.exchange(old_program);
assert(old_program == nullptr);
}
}
}
@ -239,7 +239,7 @@ Status VM::process_block(Backend* backend, BlockContext* ctxt) {
auto end_block = scopeGuard([&]() {
Status status = backend->end_block(ctxt);
if (status.is_error()) {
_logger->error("Ignore error in Backend::end_block(): %s", status.message().c_str());
_logger->error("Ignore error in Backend::end_block(): %s", status.message().c_str());
}
});