Numerous bug fixes, including strides
This commit is contained in:
parent
b6e6713860
commit
c91115dad4
@ -98,7 +98,7 @@ static int microphone_perform(CHiPubNode *pubn) {
|
||||
size_t width = roundf(CHi_Time_GetDelta(pubn->ng) * 48000.f);
|
||||
do {
|
||||
}while((node->paBufferWriteIdx - node->paBufferReadIdx + pabufsize) % pabufsize < width); // Wait until available
|
||||
CHiImage *ret = CHi_Image_New(2, 1, 2 * width, width, 1, NULL);
|
||||
CHiImage *ret = CHi_Image_New(2, 1, (2 * width + 15) & ~15, width, 1, NULL);
|
||||
if(node->paBufferReadIdx + width >= pabufsize) {
|
||||
memcpy(ret->data16, node->paBuffer + node->paBufferReadIdx, sizeof(*node->paBuffer) * (pabufsize - node->paBufferReadIdx));
|
||||
memcpy(ret->data16 + pabufsize - node->paBufferReadIdx, node->paBuffer, sizeof(*node->paBuffer) * (width - pabufsize + node->paBufferReadIdx));
|
||||
|
14
hi/node.c
14
hi/node.c
@ -663,13 +663,15 @@ static int constantsample_perform(CHiPubNode *node) {
|
||||
size_t w = sz->data.vec4[0] < 1 ? 1 : sz->data.vec4[0];
|
||||
size_t h = sz->data.vec4[1] < 1 ? 1 : sz->data.vec4[1];
|
||||
|
||||
CHiImage *img = CHi_Image_New(2, 4, 8 * w, w, h, NULL);
|
||||
CHiImage *img = CHi_Image_New(2, 4, 8 * ((w + 1) & ~1), w, h, NULL);
|
||||
if(CHi_Node_Active(node)) {
|
||||
for(size_t i = 0; i < w * h; i++) {
|
||||
img->data16[i * 4 + 0] = sink->data.vec4[2] * 65535;
|
||||
img->data16[i * 4 + 1] = sink->data.vec4[1] * 65535;
|
||||
img->data16[i * 4 + 2] = sink->data.vec4[0] * 65535;
|
||||
img->data16[i * 4 + 3] = 65535;
|
||||
for(size_t y = 0; y < h; y++) {
|
||||
for(size_t x = 0; x < w; x++) {
|
||||
img->data16[y * img->stride / 2 + x * 4 + 0] = sink->data.vec4[2] * 65535;
|
||||
img->data16[y * img->stride / 2 + x * 4 + 1] = sink->data.vec4[1] * 65535;
|
||||
img->data16[y * img->stride / 2 + x * 4 + 2] = sink->data.vec4[0] * 65535;
|
||||
img->data16[y * img->stride / 2 + x * 4 + 3] = 65535;
|
||||
}
|
||||
}
|
||||
}
|
||||
node->sources->data.sample = img;
|
||||
|
@ -289,6 +289,7 @@ CUTIVIS CHiValue *CHi_Crawl(CHiValue*);
|
||||
|
||||
CUTIVIS bool CHi_Node_Active(CHiPubNode*);
|
||||
|
||||
CUTIVIS void CHi_Node_Destroy(CHiPubNode*);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
27
ui/frame.cpp
27
ui/frame.cpp
@ -99,10 +99,9 @@ static void ShapeGrNode(GrNode *gn) {
|
||||
gn->sources = {{"Audio", GrNode::Port::Type::SAMPLE}};
|
||||
|
||||
int numSinks = gn->logical->sinkCount;
|
||||
while(numSinks > 0 && gn->logical->sinks[numSinks - 1].type == CUTIHI_VAL_NONE) {
|
||||
numSinks--;
|
||||
}
|
||||
if(gn->logical->sinks[numSinks - 1].type == CUTIHI_VAL_NONE) {
|
||||
numSinks++;
|
||||
}
|
||||
|
||||
gn->sinks.clear();
|
||||
for(int s = 0; s < numSinks; s++) {
|
||||
@ -640,7 +639,7 @@ GrNode::GrNode(NodeGraph *parent) : wxPanel(parent, wxID_ANY, {0, 0}, {175, 80})
|
||||
if(dlg.ShowModal() == wxID_OK) {
|
||||
pthread_mutex_lock(&this->logical->ng->mut);
|
||||
|
||||
CHiValue newv;
|
||||
CHiValue newv = {};
|
||||
newv.type = CUTIHI_VAL_VEC4;
|
||||
newv.data.vec4[0] = dlg.GetColourData().GetColour().Red() / 255.f;
|
||||
newv.data.vec4[1] = dlg.GetColourData().GetColour().Green() / 255.f;
|
||||
@ -656,7 +655,7 @@ GrNode::GrNode(NodeGraph *parent) : wxPanel(parent, wxID_ANY, {0, 0}, {175, 80})
|
||||
if(dlg.ShowModal() == wxID_OK) {
|
||||
pthread_mutex_lock(&this->logical->ng->mut);
|
||||
|
||||
CHiValue newv;
|
||||
CHiValue newv = {};
|
||||
newv.type = CUTIHI_VAL_TEXT;
|
||||
newv.data.text = strdup(dlg.GetPath().utf8_str());
|
||||
CHi_ConfigureSink(this->logical, p, newv);
|
||||
@ -669,7 +668,7 @@ GrNode::GrNode(NodeGraph *parent) : wxPanel(parent, wxID_ANY, {0, 0}, {175, 80})
|
||||
if(dlg.ShowModal() == wxID_OK) {
|
||||
pthread_mutex_lock(&this->logical->ng->mut);
|
||||
|
||||
CHiValue newv;
|
||||
CHiValue newv = {};
|
||||
newv.type = CUTIHI_VAL_TEXT;
|
||||
newv.data.text = strdup(dlg.GetPath().utf8_str());
|
||||
CHi_ConfigureSink(this->logical, p, newv);
|
||||
@ -717,7 +716,7 @@ GrNode::GrNode(NodeGraph *parent) : wxPanel(parent, wxID_ANY, {0, 0}, {175, 80})
|
||||
ctrl->Bind(wxEVT_KILL_FOCUS, [=](wxFocusEvent &ev){
|
||||
pthread_mutex_lock(&this->logical->ng->mut);
|
||||
|
||||
CHiValue newv;
|
||||
CHiValue newv = {};
|
||||
newv.type = CUTIHI_VAL_TEXT;
|
||||
char *c = (char*) malloc(ctrl->GetValue().Len() + 1);
|
||||
memcpy(c, ctrl->GetValue().c_str(), ctrl->GetValue().Len() + 1);
|
||||
@ -732,7 +731,7 @@ GrNode::GrNode(NodeGraph *parent) : wxPanel(parent, wxID_ANY, {0, 0}, {175, 80})
|
||||
if(ev.GetKeyCode() == WXK_RETURN) {
|
||||
pthread_mutex_lock(&this->logical->ng->mut);
|
||||
|
||||
CHiValue newv;
|
||||
CHiValue newv = {};
|
||||
newv.type = CUTIHI_VAL_TEXT;
|
||||
char *c = (char*) malloc(ctrl->GetValue().Len() + 1);
|
||||
memcpy(c, ctrl->GetValue().c_str(), ctrl->GetValue().Len() + 1);
|
||||
@ -756,7 +755,7 @@ GrNode::GrNode(NodeGraph *parent) : wxPanel(parent, wxID_ANY, {0, 0}, {175, 80})
|
||||
if(dlg.ShowModal() == wxID_OK) {
|
||||
pthread_mutex_lock(&this->logical->ng->mut);
|
||||
|
||||
CHiValue newv;
|
||||
CHiValue newv = {};
|
||||
newv.type = CUTIHI_VAL_TEXT;
|
||||
newv.data.text = strdup(CHi_Microphone_GetSourceName((size_t) (uintptr_t) dlg.GetSelectionData()));
|
||||
CHi_ConfigureSink(this->logical, p, newv);
|
||||
@ -779,7 +778,7 @@ GrNode::GrNode(NodeGraph *parent) : wxPanel(parent, wxID_ANY, {0, 0}, {175, 80})
|
||||
if(dlg.ShowModal() == wxID_OK) {
|
||||
pthread_mutex_lock(&this->logical->ng->mut);
|
||||
|
||||
CHiValue newv;
|
||||
CHiValue newv = {};
|
||||
newv.type = CUTIHI_VAL_TEXT;
|
||||
newv.data.text = strdup(choicesOrig[dlg.GetSelection()]);
|
||||
CHi_ConfigureSink(this->logical, p, newv);
|
||||
@ -822,7 +821,7 @@ GrNode::GrNode(NodeGraph *parent) : wxPanel(parent, wxID_ANY, {0, 0}, {175, 80})
|
||||
if(!isSource) {
|
||||
pthread_mutex_lock(&daNode->ng->mut);
|
||||
|
||||
CHiValue val;
|
||||
CHiValue val = {};
|
||||
val.type = CUTIHI_VAL_NONE;
|
||||
CHi_ConfigureSink(daNode, daPortIdx, val);
|
||||
|
||||
@ -831,6 +830,10 @@ GrNode::GrNode(NodeGraph *parent) : wxPanel(parent, wxID_ANY, {0, 0}, {175, 80})
|
||||
|
||||
parent->Dirtify(this);
|
||||
parent->Refresh();
|
||||
} else {
|
||||
auto ng = (NodeGraph*) GetParent();
|
||||
|
||||
ng->DestroyNode(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -868,7 +871,7 @@ ImageViewer::ImageViewer(Frame *f) : wxPanel(f, wxID_ANY) {
|
||||
Bind(wxEVT_PAINT, [this](wxPaintEvent &ev){
|
||||
if(bm.IsOk()) {
|
||||
wxPaintDC dc(this);
|
||||
dc.DrawBitmap(bm, pos);
|
||||
dc.DrawBitmap(bm, pos + (GetSize() - bm.GetSize()) / 2);
|
||||
}
|
||||
});
|
||||
Bind(wxEVT_MIDDLE_DOWN, [this](wxMouseEvent &ev){
|
||||
|
Loading…
Reference in New Issue
Block a user