Пример #1
0
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;
}
Пример #2
0
char *rtosc_splat(const char *path, std::set<std::string> v)
{
    char argT[v.size()+1];
    rtosc_arg_t arg[v.size()];
    unsigned i=0;
    for(auto vv : v) {
        argT[i]  = 's';
        arg[i].s = vv.c_str();
        i++;
    }
    argT[v.size()] = 0;

    size_t len = rtosc_amessage(0, 0, path, argT, arg);
    char *buf = new char[len];
    rtosc_amessage(buf, len, path, argT, arg);
    return buf;
}
Пример #3
0
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);
}
Пример #4
0
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);
}
Пример #5
0
            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));

            for(int i=0; i<MAX_BANK_ROOT_DIRS; ++i) {
                if(!c.cfg.presetsDirList[i].empty()) {
                    types[pos] = 's';
                    args[pos].s  = c.cfg.presetsDirList[i].c_str();
                    pos++;
                }
            }
            char buffer[1024*5];
            rtosc_amessage(buffer, sizeof(buffer), d.loc, types, args);
            d.reply(buffer);
        }},
    {"cfg.bankRootDirList", rProp(parameter) rDoc("list of bank 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.clearbankrootdirlist();
                for(int i=0; i<(int)args.size(); ++i)
                    if(args[i] == 's')
                        c.cfg.bankRootDirList[i] = rtosc_argument(msg, i).s;
            }