bool UndoHistoryImpl::mergeEvent(time_t now, const char *msg, char *buf, size_t N) { if(history_pos == 0) return false; for(int i=history_pos-1; i>=0; --i) { if(difftime(now, history[i].first) > 2) break; if(!strcmp(getUndoAddress(msg), getUndoAddress(history[i].second))) { //We can splice events together, merging them into one event rtosc_arg_t args[3]; args[0] = rtosc_argument(msg, 0); args[1] = rtosc_argument(history[i].second,1); args[2] = rtosc_argument(msg, 2); rtosc_amessage(buf, N, msg, rtosc_argument_string(msg), args); delete [] history[i].second; history[i].second = buf; history[i].first = now; return true; } } return false; }
void EnvelopeFreeEdit::OSC_raw(const char *msg) { const char *args = rtosc_argument_string(msg); if(strstr(msg,"Penvpoints") && !strcmp(args, "i")) { Penvpoints = rtosc_argument(msg, 0).i; } else if(strstr(msg,"Penvdt") && !strcmp(args, "b")) { rtosc_blob_t b = rtosc_argument(msg, 0).b; assert(b.len == MAX_ENVELOPE_POINTS); memcpy(Penvdt, b.data, MAX_ENVELOPE_POINTS); } else if(strstr(msg,"Penvval") && !strcmp(args, "b")) { rtosc_blob_t b = rtosc_argument(msg, 0).b; assert(b.len == MAX_ENVELOPE_POINTS); memcpy(Penvval, b.data, MAX_ENVELOPE_POINTS); } else if(strstr(msg, "Penvval") && !strcmp(args, "c")) { const char *str = strstr(msg, "Penvval"); int id = atoi(str+7); assert(0 <= id && id < MAX_ENVELOPE_POINTS); Penvval[id] = rtosc_argument(msg, 0).i; } else if(strstr(msg, "Penvdt") && !strcmp(args, "c")) { const char *str = strstr(msg, "Penvdt"); int id = atoi(str+6); assert(0 <= id && id < MAX_ENVELOPE_POINTS); Penvdt[id] = rtosc_argument(msg, 0).i; } else if(strstr(msg,"Penvsustain") && !strcmp(args, "i")) { Penvsustain = rtosc_argument(msg, 0).i; } redraw(); do_callback(); }
void UndoHistory::showHistory(void) const { int i = 0; for(auto s : impl->history) printf("#%d type: %s dest: %s arguments: %s\n", i++, s.second, rtosc_argument(s.second, 0).s, rtosc_argument_string(s.second)); }
void UndoHistoryImpl::rewind(const char *msg) { memset(tmp, 0, sizeof(tmp)); printf("rewind('%s')\n", msg); rtosc_arg_t arg = rtosc_argument(msg,1); rtosc_amessage(tmp, 256, rtosc_argument(msg,0).s, rtosc_argument_string(msg)+2, &arg); cb(tmp); }
void BankView::OSC_raw(const char *msg) { if(strcmp(rtosc_argument_string(msg), "iss")) return; int nslot = rtosc_argument(msg,0).i; const char *name = rtosc_argument(msg,1).s; const char *fname = rtosc_argument(msg,2).s; if(0 <= nslot && nslot < 160) slots[nslot]->update(name, fname); }
void UndoHistoryImpl::replay(const char *msg) { printf("replay...'%s'\n", msg); rtosc_arg_t arg = rtosc_argument(msg,2); printf("replay address: '%s'\n", rtosc_argument(msg, 0).s); int len = rtosc_amessage(tmp, 256, rtosc_argument(msg,0).s, rtosc_argument_string(msg)+2, &arg); if(len) cb(tmp); }
bool rtosc_match_args(const char *pattern, const char *msg) { //match anything if now arg restriction is present //(ie the ':') if(*pattern++ != ':') return true; const char *arg_str = rtosc_argument_string(msg); bool arg_match = *pattern || *pattern == *arg_str; while(*pattern && *pattern != ':') arg_match &= (*pattern++==*arg_str++); if(*pattern==':') { if(arg_match && !*arg_str) return true; else return rtosc_match_args(pattern, msg); //retry } return arg_match; }
static const rtosc::Ports ports = { //rString(cfg.LinuxOSSWaveOutDev), //rString(cfg.LinuxOSSSeqInDev), rParamI(cfg.SampleRate, "samples of audio per second"), rParamI(cfg.SoundBufferSize, "Size of processed audio buffer"), rParamI(cfg.OscilSize, "Size Of Oscillator Wavetable"), rToggle(cfg.SwapStereo, "Swap Left And Right Channels"), rToggle(cfg.BankUIAutoClose, "Automatic Closing of BackUI After Patch Selection"), rParamI(cfg.GzipCompression, "Level of Gzip Compression For Save Files"), rParamI(cfg.Interpolation, "Level of Interpolation, Linear/Cubic"), {"cfg.presetsDirList", rProp(parameter) rDoc("list of preset search directories"), 0, [](const char *msg, rtosc::RtData &d) { Config &c = *(Config*)d.obj; if(rtosc_narguments(msg) != 0) { std::string args = rtosc_argument_string(msg); //clear everything c.clearpresetsdirlist(); for(int i=0; i<(int)args.size(); ++i) if(args[i] == 's') c.cfg.presetsDirList[i] = rtosc_argument(msg, i).s; } char types[MAX_BANK_ROOT_DIRS+1]; rtosc_arg_t args[MAX_BANK_ROOT_DIRS]; size_t pos = 0; //zero out data memset(types, 0, sizeof(types)); memset(args, 0, sizeof(args));