本文整理汇总了C++中Alg_seq_ptr::tracks方法的典型用法代码示例。如果您正苦于以下问题:C++ Alg_seq_ptr::tracks方法的具体用法?C++ Alg_seq_ptr::tracks怎么用?C++ Alg_seq_ptr::tracks使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Alg_seq_ptr
的用法示例。
在下文中一共展示了Alg_seq_ptr::tracks方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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) {
//.........这里部分代码省略.........
示例2: readSMF
bool MidiImport::readSMF( TrackContainer* tc )
{
QString filename = file().fileName();
closeFile();
const int preTrackSteps = 2;
QProgressDialog pd( TrackContainer::tr( "Importing MIDI-file..." ),
TrackContainer::tr( "Cancel" ), 0, preTrackSteps, gui->mainWindow() );
pd.setWindowTitle( TrackContainer::tr( "Please wait..." ) );
pd.setWindowModality(Qt::WindowModal);
pd.setMinimumDuration( 0 );
pd.setValue( 0 );
Alg_seq_ptr seq = new Alg_seq(filename.toLocal8Bit(), true);
seq->convert_to_beats();
pd.setMaximum( seq->tracks() + preTrackSteps );
pd.setValue( 1 );
// 128 CC + Pitch Bend
smfMidiCC ccs[129];
smfMidiChannel chs[256];
MeterModel & timeSigMM = Engine::getSong()->getTimeSigModel();
AutomationPattern * timeSigNumeratorPat =
AutomationPattern::globalAutomationPattern( &timeSigMM.numeratorModel() );
AutomationPattern * timeSigDenominatorPat =
AutomationPattern::globalAutomationPattern( &timeSigMM.denominatorModel() );
// TODO: adjust these to Time.Sig changes
double beatsPerTact = 4;
double ticksPerBeat = DefaultTicksPerTact / beatsPerTact;
// Time-sig changes
Alg_time_sigs * timeSigs = &seq->time_sig;
for( int s = 0; s < timeSigs->length(); ++s )
{
Alg_time_sig timeSig = (*timeSigs)[s];
// Initial timeSig, set song-default value
if(/* timeSig.beat == 0*/ true )
{
// TODO set song-global default value
printf("Another timesig at %f\n", timeSig.beat);
timeSigNumeratorPat->putValue( timeSig.beat*ticksPerBeat, timeSig.num );
timeSigDenominatorPat->putValue( timeSig.beat*ticksPerBeat, timeSig.den );
}
else
{
}
}
pd.setValue( 2 );
// Tempo stuff
AutomationPattern * tap = tc->tempoAutomationPattern();
if( tap )
{
tap->clear();
Alg_time_map * timeMap = seq->get_time_map();
Alg_beats & beats = timeMap->beats;
for( int i = 0; i < beats.len - 1; i++ )
{
Alg_beat_ptr b = &(beats[i]);
double tempo = ( beats[i + 1].beat - b->beat ) /
( beats[i + 1].time - beats[i].time );
tap->putValue( b->beat * ticksPerBeat, tempo * 60.0 );
}
if( timeMap->last_tempo_flag )
{
Alg_beat_ptr b = &( beats[beats.len - 1] );
tap->putValue( b->beat * ticksPerBeat, timeMap->last_tempo * 60.0 );
}
}
// Song events
for( int e = 0; e < seq->length(); ++e )
{
Alg_event_ptr evt = (*seq)[e];
if( evt->is_update() )
{
printf("Unhandled SONG update: %d %f %s\n",
evt->get_type_code(), evt->time, evt->get_attribute() );
}
}
// Tracks
for( int t = 0; t < seq->tracks(); ++t )
{
QString trackName = QString( tr( "Track" ) + " %1" ).arg( t );
Alg_track_ptr trk = seq->track( t );
pd.setValue( t + preTrackSteps );
for( int c = 0; c < 129; c++ )
{
ccs[c].clear();
}
//.........这里部分代码省略.........
示例3: readline
//.........这里部分代码省略.........
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
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;
Alg_parameters_ptr attributes = NULL;
if (line_parser.peek() == '#') {
// look for #track
line_parser.get_nonspace_quoted(field);
if (streql(field, "#track")) {
line_parser.get_nonspace_quoted(field); // number
track_num = parse_int(field - 1);
seq->add_track(track_num);
}
// maybe we have a comment
} 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)) {
line_parser.get_nonspace_quoted(field + strlen(field));
}
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) {
parse_error(field, 0, "Next specified twice");
} else {
next = parse_dur(field, time);
}