~ubuntu-branches/ubuntu/karmic/rosegarden/karmic

« back to all changes in this revision

Viewing changes to src/base/SegmentNotationHelper.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Ebner
  • Date: 2008-05-02 00:33:44 UTC
  • mfrom: (1.1.7 upstream) (6.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080502003344-67vbfhgqx2yl0ksi
Tags: 1:1.7.0-1ubuntu1
* Merge from Debian unstable. (LP: #225849) Remaining Ubuntu changes:
  - Add usr/share/doc/kde/HTML to rosegarden-data, to provide online
    help documentation.
  - Change fftw3-dev to libfftw3-dev.
  - Update maintainer field as per spec.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
    Rosegarden
5
5
    A sequencer and musical notation editor.
6
6
 
7
 
    This program is Copyright 2000-2007
 
7
    This program is Copyright 2000-2008
8
8
        Guillaume Laurent   <glaurent@telegraph-road.org>,
9
9
        Chris Cannam        <cannam@all-day-breakfast.com>,
10
10
        Richard Bown        <bownie@bownie.com>
111
111
        from = segment().findTime(startTime);
112
112
        to   = segment().findTime(endTime);
113
113
    }
114
 
 
 
114
/*!!!
115
115
    bool justSeenGraceNote = false;
116
116
    timeT graceNoteStart = 0;
117
 
 
 
117
*/
118
118
    for (Segment::iterator i = from;
119
119
         i != to && segment().isBeforeEndMarker(i); ++i) {
120
120
 
121
 
        if ((*i)->has(NOTE_TYPE) && !(*i)->has(IS_GRACE_NOTE)) continue;
 
121
        if ((*i)->has(NOTE_TYPE) /*!!! && !(*i)->has(IS_GRACE_NOTE) */) continue;
122
122
 
123
123
        timeT duration = (*i)->getNotationDuration();
124
124
 
138
138
        if ((*i)->isa(Note::EventType) || (*i)->isa(Note::EventRestType)) {
139
139
 
140
140
            if ((*i)->isa(Note::EventType)) {
141
 
                
 
141
/*!!!           
142
142
                if ((*i)->has(IS_GRACE_NOTE) &&
143
143
                    (*i)->get<Bool>(IS_GRACE_NOTE)) {
144
144
 
152
152
                    duration += (*i)->getNotationAbsoluteTime() - graceNoteStart;
153
153
                    justSeenGraceNote = false;
154
154
                }
 
155
*/
155
156
            }
156
157
 
157
158
            Note n(Note::getNearestNote(duration));
1220
1221
void
1221
1222
SegmentNotationHelper::makeBeamedGroup(timeT from, timeT to, string type)
1222
1223
{
1223
 
    makeBeamedGroupAux(segment().findTime(from), segment().findTime(to), type);
 
1224
    makeBeamedGroupAux(segment().findTime(from), segment().findTime(to),
 
1225
                       type, false);
1224
1226
}
1225
1227
 
1226
1228
void
1229
1231
    makeBeamedGroupAux
1230
1232
      ((from == end()) ? from : segment().findTime((*from)->getAbsoluteTime()),
1231
1233
         (to == end()) ? to   : segment().findTime((*to  )->getAbsoluteTime()),
1232
 
         type);
 
1234
       type, false);
 
1235
}
 
1236
 
 
1237
void
 
1238
SegmentNotationHelper::makeBeamedGroupExact(iterator from, iterator to, string type)
 
1239
{
 
1240
    makeBeamedGroupAux(from, to, type, true);
1233
1241
}
1234
1242
 
1235
1243
void
1236
1244
SegmentNotationHelper::makeBeamedGroupAux(iterator from, iterator to,
1237
 
                                          string type)
 
1245
                                          string type, bool groupGraces)
1238
1246
{
 
1247
//    cerr << "SegmentNotationHelper::makeBeamedGroupAux: type " << type << endl;
 
1248
//    if (from == to) cerr << "from == to" <<endl;
 
1249
 
1239
1250
    int groupId = segment().getNextId();
1240
1251
    bool beamedSomething = false;
1241
1252
 
1242
1253
    for (iterator i = from; i != to; ++i) {
 
1254
//      std::cerr << "looking at " << (*i)->getType() << " at " << (*i)->getAbsoluteTime() << std::endl;
1243
1255
 
1244
1256
        // don't permit ourselves to change the type of an
1245
1257
        // already-grouped event here
1248
1260
            continue;
1249
1261
        }
1250
1262
 
 
1263
        if (!groupGraces) {
 
1264
            if ((*i)->has(IS_GRACE_NOTE) &&
 
1265
                (*i)->get<Bool>(IS_GRACE_NOTE)) {
 
1266
                continue;
 
1267
            }
 
1268
        }
 
1269
 
1251
1270
        // don't beam anything longer than a quaver unless it's
1252
1271
        // between beamed quavers -- in which case marking it as
1253
1272
        // beamed will ensure that it gets re-stemmed appropriately
1254
1273
 
1255
1274
        if ((*i)->isa(Note::EventType) &&
1256
1275
            (*i)->getNotationDuration() >= Note(Note::Crotchet).getDuration()) {
 
1276
//          std::cerr << "too long" <<std::endl;
1257
1277
            if (!beamedSomething) continue;
1258
1278
            iterator j = i;
1259
1279
            bool somethingLeft = false;
1268
1288
            if (!somethingLeft) continue;
1269
1289
        }
1270
1290
 
 
1291
//      std::cerr << "beaming it" <<std::endl;
1271
1292
        (*i)->set<Int>(BEAMED_GROUP_ID, groupId);
1272
1293
        (*i)->set<String>(BEAMED_GROUP_TYPE, type);
1273
1294
    }
1675
1696
{
1676
1697
    Event dummy("dummy", time, 0, MIN_SUBORDERING);
1677
1698
    
1678
 
//    cerr << "SegmentNotationHelper::removeRests(" << time
1679
 
//         << ", " << duration << ")\n";
 
1699
    std::cerr << "SegmentNotationHelper::removeRests(" << time
 
1700
              << ", " << duration << ")" << std::endl;
1680
1701
 
1681
1702
    iterator from = segment().lower_bound(&dummy);
1682
1703