本文整理汇总了C++中Alg_seq_ptr::convert_to_seconds方法的典型用法代码示例。如果您正苦于以下问题:C++ Alg_seq_ptr::convert_to_seconds方法的具体用法?C++ Alg_seq_ptr::convert_to_seconds怎么用?C++ Alg_seq_ptr::convert_to_seconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Alg_seq_ptr
的用法示例。
在下文中一共展示了Alg_seq_ptr::convert_to_seconds方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: process_attributes
Alg_parameters_ptr Alg_reader::process_attributes(
Alg_parameters_ptr attributes, double time)
{
// print "process_attributes:", attributes
bool ts_flag = false;
if (attributes) {
Alg_parameters_ptr a;
bool in_seconds = seq->get_units_are_seconds();
if (a = Alg_parameters::remove_key(&attributes, "tempor")) {
double tempo = a->parm.r;
seq->insert_tempo(tempo, seq->get_time_map()->time_to_beat(time));
}
if (a = Alg_parameters::remove_key(&attributes, "beatr")) {
double beat = a->parm.r;
seq->insert_beat(time, beat);
}
if (a = Alg_parameters::remove_key(&attributes, "timesig_numr")) {
tsnum = a->parm.r;
ts_flag = true;
}
if (a = Alg_parameters::remove_key(&attributes, "timesig_denr")) {
tsden = a->parm.r;
ts_flag = true;
}
if (ts_flag) {
seq->set_time_sig(seq->get_time_map()->time_to_beat(time),
tsnum, tsden);
}
if (in_seconds) seq->convert_to_seconds();
}
return attributes; // in case it was modified
}
示例2: 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) {
//.........这里部分代码省略.........
示例3: readline
//.........这里部分代码省略.........
seq.set_time_sig(seq.map.time_to_beat(time), tsnum, tsden);
}
}
}
#else /* EXPERIMENTAL_NOTE_TRACK */
Alg_parameters_ptr Alg_reader::process_attributes(
Alg_parameters_ptr attributes, double time)
{
// print "process_attributes:", attributes
bool ts_flag = false;
if (attributes) {
Alg_parameters_ptr a;
bool in_seconds = seq->get_units_are_seconds();
if (a = Alg_parameters::remove_key(&attributes, "tempor")) {
double tempo = a->parm.r;
seq->insert_tempo(tempo, seq->get_time_map()->time_to_beat(time));
}
if (a = Alg_parameters::remove_key(&attributes, "beatr")) {
double beat = a->parm.r;
seq->insert_beat(time, beat);
}
if (a = Alg_parameters::remove_key(&attributes, "timesig_numr")) {
tsnum = a->parm.r;
ts_flag = true;
}
if (a = Alg_parameters::remove_key(&attributes, "timesig_denr")) {
tsden = a->parm.r;
ts_flag = true;
}
if (ts_flag) {
seq->set_time_sig(seq->get_time_map()->time_to_beat(time),
tsnum, tsden);
}
if (in_seconds) seq->convert_to_seconds();
}
return attributes; // in case it was modified
}
#endif /* EXPERIMENTAL_NOTE_TRACK */
#ifndef EXPERIMENTAL_NOTE_TRACK
bool Allegro_reader::parse()
{
int voice = 0;
int key = 60;
double loud = 100.0;
double pitch = 60.0;
double dur = 1.0;
double time = 0.0;
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
double new_pitch = 0.0;
bool new_key_flag = false; // "K" syntax
int new_key = 0;
bool new_note_flag = false; // "A"-"G" syntax
int new_note = 0;
Parameters_ptr attributes = NULL;
line_parser.get_nonspace_quoted(field);
char pk = line_parser.peek();