本文整理汇总了C++中Composition::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Composition::clear方法的具体用法?C++ Composition::clear怎么用?C++ Composition::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composition
的用法示例。
在下文中一共展示了Composition::clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: file
bool RG21Loader::load(const QString &fileName, Composition &comp)
{
m_composition = ∁
comp.clear();
QFile file(fileName);
if (file.open(QIODevice::ReadOnly)) {
m_stream = new QTextStream(&file);
} else {
return false;
}
m_studio->unassignAllInstruments();
while (!m_stream->atEnd()) {
if (!readNextLine())
break;
QString firstToken = m_tokens.first();
if (firstToken == "Staves" || firstToken == "Staffs") { // nb staves
m_nbStaves = m_tokens[1].toUInt();
} else if (firstToken == "Name") { // Staff name
m_currentStaffName = m_tokens[1]; // we don't do anything with it yet
m_currentSegment = new Segment;
++m_currentSegmentNb;
} else if (firstToken == "Clef") {
parseClef();
} else if (firstToken == "Key") {
parseKey();
} else if (firstToken == "Metronome") {
if (!readNextLine())
break;
parseMetronome();
} else if (firstToken == ":") { // chord
m_tokens.removeFirst(); // get rid of 1st token ':'
parseChordItem();
} else if (firstToken == "Rest") { // rest
if (!readNextLine())
break;
parseRest();
} else if (firstToken == "Text") {
if (!readNextLine())
break;
parseText();
} else if (firstToken == "Group") {
if (!readNextLine())
break;
parseGroupStart();
} else if (firstToken == "Mark") {
if (m_tokens[1] == "start")
parseIndicationStart();
else if (m_tokens[1] == "end")
closeIndication();
} else if (firstToken == "Bar") {
parseBarType();
} else if (firstToken == "Stave") {
parseStaveType();
} else if (firstToken == "End") {
if (m_inGroup)
closeGroup();
else
closeSegment();
} else {
RG_DEBUG << "RG21Loader::parse: Unsupported element type \"" << firstToken << "\", ignoring" << endl;
}
}
delete m_stream;
//.........这里部分代码省略.........
示例2: getBeatRealTimes
// Initialize FitToBeatsCommand
// @author Tom Breton (Tehom)
void
FitToBeatsCommand::initialise(Segment *s)
{
m_oldTempi.clear();
m_newTempi.clear();
m_oldSegments.clear();
m_newSegments.clear();
// Get the real times from the beat segment
vecRealTime beatRealTimes;
int success =
getBeatRealTimes(s, beatRealTimes);
if(!success) { return; }
// Store the current tempos
getCurrentTempi(*m_composition, m_oldTempi);
tempoT defaultTempo = m_composition->getCompositionDefaultTempo();
// A temporary copy of the composition. It is not intended to be
// a complete copy, it just provides a place for new segments and
// tempi to live until we have fully copied events to their new
// state.
Composition scratchComposition;
scratchComposition.clear();
scratchComposition.setCompositionDefaultTempo(defaultTempo);
// Set tempos in scratchComposition such that each observed beat
// in beatRealTimes takes one beatTime.
{
// Starting time is the same for both.
timeT firstBeatTime =
m_composition->getElapsedTimeForRealTime(beatRealTimes[0]);
unsigned int numBeats = beatRealTimes.size();
// Get interval between beats from time signature.
// Get time signature
TimeSignature timeSig =
m_composition->getTimeSignatureAt(firstBeatTime);
timeT beatTime = timeSig.getBeatDuration();
// We're going to visit the beats in reverse order, and always
// remembering the next beat (the next beat time-wise, which
// the iterator visited last time)
vecRealTime::const_reverse_iterator i = beatRealTimes.rbegin();
// Treat the final beat specially
timeT finalBeatTime = firstBeatTime + ((numBeats - 1) * beatTime);
RealTime finalRealTime = beatRealTimes.back();
scratchComposition.addTempoAtTime(finalBeatTime, defaultTempo, -1);
// Step past it
++i;
// Set up loop variables
timeT nextBeatTime = finalBeatTime;
RealTime nextRealTime = finalRealTime;
// nextTempo is unused, it will be used if we make ramped
// tempi.
/* tempoT nextTempo = defaultTempo; */
// Treat all the other beats.
while (i != beatRealTimes.rend()) {
timeT timeNow = nextBeatTime - beatTime;
RealTime realTimeNow = *i;
RealTime realTimeDelta = nextRealTime - realTimeNow;
// Calculate what tempoT will get us to the right real
// time. For now, we use unramped tempi.
tempoT rampTo = -1;
tempoT tempo = Composition::timeRatioToTempo(realTimeDelta,
beatTime, rampTo);
scratchComposition.addTempoAtTime(timeNow, tempo, rampTo);
// Step
nextBeatTime = timeNow;
nextRealTime = realTimeNow;
/* nextTempo = tempo; */
++i;
}
}
// We don't try to copy over tempo changes that are outside the
// range of the groove segment (before or after). We don't try to
// correct for accumulated error.
// Done setting Tempi
// Collect tempi
getCurrentTempi(scratchComposition, m_newTempi);
// Copy all the events to scratchComposition. The copies will be
// at the same realtime but not the same timeT. Even events in
// the groove segment get copied.
segmentcontainer &origSegments = m_composition->getSegments();
for (Composition::iterator i = origSegments.begin();
i != origSegments.end();
++i) {
//.........这里部分代码省略.........