当前位置: 首页>>代码示例>>C++>>正文


C++ Alg_seq_ptr::add_event方法代码示例

本文整理汇总了C++中Alg_seq_ptr::add_event方法的典型用法代码示例。如果您正苦于以下问题:C++ Alg_seq_ptr::add_event方法的具体用法?C++ Alg_seq_ptr::add_event怎么用?C++ Alg_seq_ptr::add_event使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Alg_seq_ptr的用法示例。


在下文中一共展示了Alg_seq_ptr::add_event方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: parse

bool Alg_reader::parse()
{
    int voice = 0;
    int key = 60;
    double loud = 100.0;
    double pitch = 60.0;
    double dur = 1.0;
    double time = 0.0;
    int track_num = 0;
    seq->convert_to_seconds();
    //seq->set_real_dur(0.0); // just in case it's not initialized already
    readline();
    bool valid = false; // ignore blank lines
    while (line_parser_flag) {
        bool time_flag = false;
        bool next_flag = false;
        double next;
        bool voice_flag = false;
        bool loud_flag = false;
        bool dur_flag = false;
        bool new_pitch_flag = false; // "P" syntax or "A"-"G" syntax
        double new_pitch = 0.0;
        bool new_key_flag = false;   // "K" syntax
        int new_key = 0;
        Alg_parameters_ptr attributes = NULL;
        if (line_parser.peek() == '#') {
            // look for #track
            line_parser.get_nonspace_quoted(field);
            if (streql(field.c_str(), "#track")) {
                line_parser.get_nonspace_quoted(field); // number
                field.insert(0, " "); // need char at beginning because
                // parse_int ignores the first character of the argument
                track_num = parse_int(field);
                seq->add_track(track_num);

                // maybe we have a sequence or track name
                line_parser.get_remainder(field);
                // if there is a non-space character after #track n then
                // use it as sequence or track name. Note that because we
                // skip over spaces, a sequence or track name cannot begin
                // with leading blanks. Another decision is that the name
                // must be at time zero
                if (field.length() > 0) {
                    // insert the field as sequence name or track name
                    Alg_update_ptr update = new Alg_update;
                    update->chan = -1;
                    update->time = 0;
                    update->set_identifier(-1);
                    // sequence name is whatever is on track 0
                    // other tracks have track names
                    const char *attr =
                            (track_num == 0 ? "seqnames" : "tracknames");
                    update->parameter.set_attr(
                            symbol_table.insert_string(attr));
                    update->parameter.s = heapify(field.c_str());
                    seq->add_event(update, track_num);
                }
            } else if (streql(field.c_str(), "#offset")) {
                if (offset_found) {
                    parse_error(field, 0, "#offset specified twice");
                }
                offset_found = true;
                line_parser.get_nonspace_quoted(field); // number
                field.insert(0, " "); // need char at beginning because
                // parse_real ignores first character in the argument
                offset = parse_real(field);
            }
        } else {
            // we must have a track to insert into
            if (seq->tracks() == 0) seq->add_track(0);
            line_parser.get_nonspace_quoted(field);
            char pk = line_parser.peek();
            // attributes are parsed as two adjacent nonspace_quoted tokens
            // so we have to conditionally call get_nonspace_quoted() again
            if (pk && !isspace(pk)) {
                string field2;
                line_parser.get_nonspace_quoted(field2);
                field.append(field2);
            }
            while (field[0]) {
                char first = toupper(field[0]);
                if (strchr("ABCDEFGKLPUSIQHW-", first)) {
                    valid = true; // it's a note or event
                }
                if (first == 'V') {
                    if (voice_flag) {
                        parse_error(field, 0, "Voice specified twice");
                    } else {
                        voice = parse_chan(field);
                    }
                    voice_flag = true;
                } else if (first == 'T') {
                    if (time_flag) {
                        parse_error(field, 0, "Time specified twice");
                    } else {
                        time = parse_dur(field, 0.0);
                    }
                    time_flag = true;
                } else if (first == 'N') {
                    if (next_flag) {
//.........这里部分代码省略.........
开发者ID:AkiraShirase,项目名称:audacity,代码行数:101,代码来源:allegrord.cpp

示例2: readline


//.........这里部分代码省略.........
        //   K200 with neither P60 nor C4 uses 
        //       pitch from before
        // figure out what the key/instance is:
        if (new_key_flag) { // it was directly specified
            key = new_key;
            if (key < 128 && new_note_flag) {
                parse_error("", 0, "Pitch specified twice");
            }
        } else if (new_note_flag) { // "A"-"G" used
            key = new_note;
        }
        if (new_pitch_flag) {
            pitch = new_pitch;
        } else if (key < 128) {
            pitch = key;
        }
        // now we've acquired new parameters
        // if (it is a note, then enter the note
        if (valid) {
            // change tempo or beat
            process_attributes(attributes, time);
            // if there's a duration or pitch, make a note:
            if (new_pitch_flag || dur_flag || new_note_flag) {
                new_key_flag = false;
                new_pitch_flag = false;
                Allegro_note_ptr note_ptr = new Allegro_note;
                note_ptr->chan = voice;
                note_ptr->time = time;
                note_ptr->dur = dur;
                note_ptr->key = key;
                note_ptr->pitch = pitch;
                note_ptr->loud = loud;
                note_ptr->parameters = attributes;
                seq.add_event(note_ptr); // sort later
            } else {
                int update_key = -1;
                // key or pitch must appear explicitly; otherwise
                //    update applies to channel
                if (new_key_flag || new_pitch_flag) {
                    update_key = key;
                }
                if (loud_flag) {
                    Allegro_update_ptr new_upd = new Allegro_update;
                    new_upd->chan = voice;
                    new_upd->time = time;
                    new_upd->key = update_key;
                    new_upd->parameter.set_attr(symbol_table.insert_string("loudr"));
                    new_upd->parameter.r = pitch;
                    seq.add_event(new_upd);
                }
                if (attributes) {
                    while (attributes) {
                        Allegro_update_ptr new_upd = new Allegro_update;
                        new_upd->chan = voice;
                        new_upd->time = time;
                        new_upd->key = update_key;
                        new_upd->parameter = attributes->parm;
                        seq.add_event(new_upd);
                        Parameters_ptr p = attributes;
                        attributes = attributes->next;
                        delete p;
                    }
                }
            }
            if (next_flag) {
                time = time + next;
开发者ID:ruthmagnus,项目名称:audacity,代码行数:67,代码来源:allegrord.cpp


注:本文中的Alg_seq_ptr::add_event方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。