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

View File

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

View File

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

View File

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

View File

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