port member name consistency

master
zetaPRIME 2022-03-23 18:47:37 -04:00
parent e63c93e146
commit be67e02004
5 changed files with 22 additions and 22 deletions

View File

@ -60,13 +60,13 @@ void CommandPort::pull() {
lock.lock();
if (tickUpdatedOn == t) { lock.unlock(); return; } // someone else got here before us
dataSize = 0;
size = 0;
if (type == Input) {
for (auto c : connections) {
if (auto p = std::static_pointer_cast<CommandPort>(c.lock()); p && p->dataType() == Command) {
p->pull();
data = p->data; // just repoint to input's buffer
dataSize = p->dataSize;
size = p->size;
break;
}
}
@ -74,7 +74,7 @@ void CommandPort::pull() {
// valid passthrough
pt->pull();
data = pt->data; // again, just repoint
dataSize = pt->dataSize;
size = pt->size;
} // don't need an else case, size is already zero
tickUpdatedOn = t;
@ -83,9 +83,9 @@ void CommandPort::pull() {
void CommandPort::push(std::vector<uint8_t> v) {
tickUpdatedOn = audioEngine->curTickId();
dataSize = v.size();
data = static_cast<uint8_t*>(audioEngine->tickAlloc(dataSize));
memcpy(data, v.data(), dataSize);
size = v.size();
data = static_cast<uint8_t*>(audioEngine->tickAlloc(size));
memcpy(data, v.data(), size);
}
void ParameterPort::pull() {
@ -94,24 +94,24 @@ void ParameterPort::pull() {
lock.lock();
if (tickUpdatedOn == t) { lock.unlock(); return; } // someone else got here before us
buf = nullptr;
data = nullptr;
if (type == Input) {
if (isConnected()) {
if (auto p = std::static_pointer_cast<ParameterPort>(connections[0].lock()); p) {
p->pull();
buf = p->buf;
data = p->data;
size = p->size;
}
}
} else if (auto pt = std::static_pointer_cast<ParameterPort>(passthroughTo.lock()); pt && pt->dataType() == Parameter) {
pt->pull();
buf = pt->buf;
data = pt->data;
size = pt->size;
}
if (!buf) { // no buffer pulled from input or passthrough; create a new one
if (!data) { // no buffer pulled from input or passthrough; create a new one
size = audioEngine->curTickSize();
buf = static_cast<double*>(audioEngine->tickAlloc(size * sizeof(double)));
std::fill_n(buf, size, std::numeric_limits<double>::quiet_NaN());
data = static_cast<double*>(audioEngine->tickAlloc(size * sizeof(double)));
std::fill_n(data, size, std::numeric_limits<double>::quiet_NaN());
}
tickUpdatedOn = t;

View File

@ -44,7 +44,7 @@ namespace Xybrid::Data {
class CommandPort : public Port {
public:
uint8_t* data;
size_t dataSize;
size_t size;
CommandPort() = default;
~CommandPort() override = default;
@ -60,14 +60,14 @@ namespace Xybrid::Data {
class ParameterPort : public Port {
public:
double* buf;
double* data;
size_t size;
ParameterPort() = default;
~ParameterPort() override = default;
double& operator[](size_t at) { return buf[at]; }
double& at(size_t at) { return buf[at]; }
double& operator[](size_t at) { return data[at]; }
double& at(size_t at) { return data[at]; }
Port::DataType dataType() const override { return Port::Parameter; }

View File

@ -8,7 +8,7 @@ using namespace Xybrid::Data;
CommandReader::CommandReader(CommandPort* p) {
p->pull();
data = p->data;
dataSize = p->dataSize;
dataSize = p->size;
}
CommandReader::operator bool() const { return dataSize >= cur+5; }

View File

@ -49,12 +49,12 @@ void Transpose::process() {
in->pull();
out->pull();
out->data = reinterpret_cast<uint8_t*>(audioEngine->tickAlloc(in->dataSize));
out->dataSize = in->dataSize;
memcpy(out->data, in->data, in->dataSize); // precopy
out->data = reinterpret_cast<uint8_t*>(audioEngine->tickAlloc(in->size));
out->size = in->size;
memcpy(out->data, in->data, in->size); // precopy
size_t mi = 0;
while (out->dataSize >= mi+5) {
while (out->size >= mi+5) {
int16_t& n = reinterpret_cast<int16_t&>(out->data[mi+2]);
if (n > -1) {
int nn = n;

View File

@ -74,7 +74,7 @@ void TestSynth::process() {
auto smp = *(project->samples.begin());
size_t mi = 0;
while (cp->dataSize >= mi+5) {
while (cp->size >= mi+5) {
uint16_t id = reinterpret_cast<uint16_t&>(cp->data[mi]);
int16_t n = reinterpret_cast<int16_t&>(cp->data[mi+2]);
if (n > -1) {