void update(){ if(i1.value > i2.value){ push_output(0,(audio)i2.value); }else if(i1.value < -i2.value){ push_output(0,(audio)-i2.value); }else{ push_output(0,(audio)i1.value); } }
int network_process_io(int timeout) { nhandle *h, *hnext; nlistener *l; mplex_clear(); for (l = all_nlisteners; l; l = l->next) mplex_add_reader(l->fd); for (h = all_nhandles; h; h = h->next) { if (!h->input_suspended) mplex_add_reader(h->rfd); if (h->output_head) mplex_add_writer(h->wfd); } add_registered_fds(); if (mplex_wait(timeout)) return 0; else { for (l = all_nlisteners; l; l = l->next) if (mplex_is_readable(l->fd)) accept_new_connection(l); for (h = all_nhandles; h; h = hnext) { hnext = h->next; if ((mplex_is_readable(h->rfd) && !pull_input(h)) || (mplex_is_writable(h->wfd) && !push_output(h))) { server_close(h->shandle); close_nhandle(h); } } check_registered_fds(); return 1; } }
void AddNode::update(){ if(f1.set){ float f = f1.value + f2.value; push_output(0, f); f1.set = false; } }
void line_play::update(){ if(f.size() > 0){ tstart += speed; push_output(0,mtof(f[mod((int) (tstart),f.size())])); } }
void Phasor::update(){; phase = fmod(phase + (float)freq/44100.0*3.14,3.14*2.0); freq = freq*(phase/6.28) +target_freq.value*(3.14*2.0 - phase)/6.28; float out = fabs(sin(phase))*10000.0; push_output(0,(audio) out); }
static int enqueue_output(network_handle nh, const char *line, int line_length, int add_eol, int flush_ok) { nhandle *h = (nhandle *)nh.ptr; int length = line_length + (add_eol ? eol_length : 0); char *buffer; text_block *block; if (h->output_length != 0 && h->output_length + length > MAX_QUEUED_OUTPUT) { /* must flush... */ int to_flush; text_block *b; (void) push_output(h); to_flush = h->output_length + length - MAX_QUEUED_OUTPUT; if (to_flush > 0 && !flush_ok) return 0; while (to_flush > 0 && (b = h->output_head)) { h->output_length -= b->length; to_flush -= b->length; h->output_lines_flushed++; h->output_head = b->next; free_text_block(b); } if (h->output_head == 0) h->output_tail = &(h->output_head); } buffer = (char *) (char *)mymalloc(length * sizeof(char), M_NETWORK); block = (text_block *) mymalloc(sizeof(text_block), M_NETWORK); memcpy(buffer, line, line_length); if (add_eol) memcpy(buffer + line_length, proto.eol_out_string, eol_length); block->buffer = block->start = buffer; block->length = length; block->next = 0; *(h->output_tail) = block; h->output_tail = &(block->next); h->output_length += length; return 1; }
static void close_nhandle(nhandle * h) { text_block *b, *bb; (void) push_output(h); *(h->prev) = h->next; if (h->next) h->next->prev = h->prev; b = h->output_head; while (b) { bb = b->next; free_text_block(b); b = bb; } free_stream(h->input); proto_close_connection(h->rfd, h->wfd); free_str(h->name); myfree(h, M_NETWORK); }
void update(){ audio f = i1.value / i2.value; push_output(0,f); }
void update(){ audio f = sqrt(i1.value * i2.value); push_output(0,f); }
void FloatNode::update(){ push_output(0, f.value); }
void SubAudio::update(){ audio a = i1.value - i2.value; push_output(0, a); }
void AddAudio::update(){ audio o = i1.value + i2.value; push_output(0, o); }