~ubuntu-branches/ubuntu/oneiric/muse/oneiric

« back to all changes in this revision

Viewing changes to muse/importmidi.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Fabrice Coutadeur
  • Date: 2010-11-17 21:43:38 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20101117214338-1hvfl7oo2dsqnvrb
Tags: 1.1-0ubuntu1
* New upstream release (LP: #668631)
* Switch to dpkg-source 3.0 (quilt) format
* Switch to dh7 short form
* debian/rules:
  - added --enable-dssi and --enable-osc to conf flags for dssi support
  - added -ljackserver to LDFLAGS to fix a FTBFS because of --as-needed
* debian/control:
  - added build build dependency on liblo-dev and dssi-dev for dssi support
  - bump Standards-version to 3.9.1. No changes required.
* debian/muse.desktop, debian/muse.xpm: dropped as desktop file and icon is
  now shipped upstream.
* fix-desktop-categories.patch: fix Categories tag in upstream desktop file
* 10_es_locale_fix.dpatch: refreshed and converted to quilt as
  fix_es_locale.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include "drummap.h"
28
28
#include "xml.h"
29
29
#include "audio.h"
 
30
#include "gconfig.h"
30
31
 
31
32
//---------------------------------------------------------
32
33
//   importMidi
288
289
                  lastTick = epos;
289
290
            }
290
291
 
 
292
      QString partname = track->name();
291
293
      int len = song->roundUpBar(lastTick+1);
292
 
      int bar2, beat;
293
 
      unsigned tick;
294
 
      sigmap.tickValues(len, &bar2, &beat, &tick);
295
 
 
296
 
      QString partname = track->name();
297
 
 
298
 
      int lastOff = 0;
299
 
      int st = -1;      // start tick current part
300
 
      int x1 = 0;       // start tick current measure
301
 
      int x2 = 0;       // end tick current measure
302
 
 
303
 
      for (int bar = 0; bar < bar2; ++bar, x1 = x2) {
304
 
            x2 = sigmap.bar2tick(bar+1, 0, 0);
305
 
            if (lastOff > x2) {
306
 
                  // this measure is busy!
307
 
                  continue;
308
 
                  }
309
 
            iEvent i1 = tevents->lower_bound(x1);
310
 
            iEvent i2 = tevents->lower_bound(x2);
311
 
 
312
 
            if (i1 == i2) {   // empty?
313
 
                  if (st != -1) {
314
 
                        MidiPart* part = new MidiPart(track);
315
 
                        part->setTick(st);
316
 
                        part->setLenTick(x1-st);
317
 
// printf("new part %d len: %d\n", st, x1-st);
318
 
                        part->setName(partname);
319
 
                        pl->add(part);
320
 
                        st = -1;
321
 
                        }
322
 
                  }
323
 
            else {
324
 
                  if (st == -1)
325
 
                        st = x1;    // begin new  part
326
 
                  //HACK:
327
 
                  //lastOff:
328
 
                  for (iEvent i = i1; i != i2; ++i) {
329
 
                        Event event = i->second;
330
 
                        if (event.type() == Note) {
331
 
                              int off = event.tick() + event.lenTick();
332
 
                              if (off > lastOff)
333
 
                                    lastOff = off;
334
 
                              }
335
 
                        }
336
 
                  }
337
 
            }
338
 
      if (st != -1) {
339
 
            MidiPart* part = new MidiPart(track);
340
 
            part->setTick(st);
341
 
// printf("new part %d len: %d\n", st, x2-st);
342
 
            part->setLenTick(x2-st);
343
 
            part->setName(partname);
344
 
            pl->add(part);
345
 
            }
 
294
 
 
295
      // p3.3.27
 
296
      if(config.importMidiSplitParts)
 
297
      {
 
298
        
 
299
        int bar2, beat;
 
300
        unsigned tick;
 
301
        sigmap.tickValues(len, &bar2, &beat, &tick);
 
302
        
 
303
        int lastOff = 0;
 
304
        int st = -1;      // start tick current part
 
305
        int x1 = 0;       // start tick current measure
 
306
        int x2 = 0;       // end tick current measure
 
307
  
 
308
        for (int bar = 0; bar < bar2; ++bar, x1 = x2) {
 
309
              x2 = sigmap.bar2tick(bar+1, 0, 0);
 
310
              if (lastOff > x2) {
 
311
                    // this measure is busy!
 
312
                    continue;
 
313
                    }
 
314
              iEvent i1 = tevents->lower_bound(x1);
 
315
              iEvent i2 = tevents->lower_bound(x2);
 
316
  
 
317
              if (i1 == i2) {   // empty?
 
318
                    if (st != -1) {
 
319
                          MidiPart* part = new MidiPart(track);
 
320
                          part->setTick(st);
 
321
                          part->setLenTick(x1-st);
 
322
  // printf("new part %d len: %d\n", st, x1-st);
 
323
                          part->setName(partname);
 
324
                          pl->add(part);
 
325
                          st = -1;
 
326
                          }
 
327
                    }
 
328
              else {
 
329
                    if (st == -1)
 
330
                          st = x1;    // begin new  part
 
331
                    //HACK:
 
332
                    //lastOff:
 
333
                    for (iEvent i = i1; i != i2; ++i) {
 
334
                          Event event = i->second;
 
335
                          if (event.type() == Note) {
 
336
                                int off = event.tick() + event.lenTick();
 
337
                                if (off > lastOff)
 
338
                                      lastOff = off;
 
339
                                }
 
340
                          }
 
341
                    }
 
342
              }
 
343
        if (st != -1) {
 
344
              MidiPart* part = new MidiPart(track);
 
345
              part->setTick(st);
 
346
  // printf("new part %d len: %d\n", st, x2-st);
 
347
              part->setLenTick(x2-st);
 
348
              part->setName(partname);
 
349
              pl->add(part);
 
350
              }
 
351
      }
 
352
      else
 
353
      {
 
354
        // Just one long part...
 
355
        MidiPart* part = new MidiPart(track);
 
356
        //part->setTick(st);
 
357
        part->setTick(0);
 
358
        part->setLenTick(len);
 
359
        part->setName(partname);
 
360
        pl->add(part);
 
361
      }
346
362
 
347
363
      //-------------------------------------------------------------
348
364
      //    assign events to parts