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


C++ Composition::getNbTracks方法代码示例

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


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

示例1: str

bool
MupExporter::write()
{
    Composition *c = m_composition;

    std::ofstream str(m_fileName.c_str(), std::ios::out);
    if (!str) {
        std::cerr << "MupExporter::write() - can't write file " << m_fileName
        << std::endl;
        return false;
    }

    str << "score\n";
    str << "\tstaffs=" << c->getNbTracks() << "\n";

    int ts = c->getTimeSignatureCount();
    std::pair<timeT, TimeSignature> tspair;
    if (ts > 0)
        tspair = c->getTimeSignatureChange(0);
    str << "\ttime="
    << tspair.second.getNumerator() << "/"
    << tspair.second.getDenominator() << "\n";

    for (int barNo = -1; barNo < c->getNbBars(); ++barNo) {

        for (TrackId trackNo = c->getMinTrackId();
                trackNo <= c->getMaxTrackId(); ++trackNo) {

            if (barNo < 0) {
                writeClefAndKey(str, trackNo);
                continue;
            }

            if (barNo == 0 && trackNo == 0) {
                str << "\nmusic\n";
            }

            str << "\t" << trackNo + 1 << ":";

            Segment *s = 0;
            timeT barStart = c->getBarStart(barNo);
            timeT barEnd = c->getBarEnd(barNo);

            for (Composition::iterator ci = c->begin(); ci != c->end(); ++ci) {
                if ((*ci)->getTrack() == trackNo &&
                        (*ci)->getStartTime() < barEnd &&
                        (*ci)->getEndMarkerTime() > barStart) {
                    s = *ci;
                    break;
                }
            }

            TimeSignature timeSig(c->getTimeSignatureAt(barStart));

            if (!s) {
                // write empty bar
                writeInventedRests(str, timeSig, 0, barEnd - barStart);
                continue;
            }

            if (s->getStartTime() > barStart) {
                writeInventedRests(str, timeSig,
                                   0, s->getStartTime() - barStart);
            }

            // Mup insists that every bar has the correct duration, and won't
            // recover if one goes wrong.  Keep careful tabs on this: it means
            // that for example we have to round chord durations down where
            // the next chord starts too soon
            //!!! we _really_ can't cope with time sig changes yet!

            timeT writtenDuration = writeBar(str, c, s, barStart, barEnd,
                                             timeSig, trackNo);

            if (writtenDuration < timeSig.getBarDuration()) {
                RG_DEBUG << "writtenDuration: " << writtenDuration
                << ", bar duration " << timeSig.getBarDuration()
                << endl;
                writeInventedRests(str, timeSig, writtenDuration,
                                   timeSig.getBarDuration() - writtenDuration);

            } else if (writtenDuration > timeSig.getBarDuration()) {
                std::cerr << "WARNING: overfull bar in Mup export: duration " << writtenDuration
                << " into bar of duration " << timeSig.getBarDuration()
                << std::endl;
                //!!! warn user
            }

            str << "\n";
        }

        if (barNo >= 0)
            str << "bar" << std::endl;
    }

    str << "\n" << std::endl;
    str.close();
    return true;
}
开发者ID:EQ4,项目名称:RosegardenW,代码行数:99,代码来源:MupExporter.cpp


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