Logo Search packages:      
Sourcecode: canorus version File versions  Download package

QList< CARest * > CARest::composeRests ( int  timeLength,
int  timeStart,
CAVoice voice = 0,
CARestType  type = Hidden 
) [static]

Generates a list of new rests in the total length of timeLength. Rests are sorted from the shortes to the longest one. The first rest has the given timeStart. Passing voice and restType is optional.

This function is usually called when a gap between two voices with shared elements appear in one voice and the gap with custom length needs to be filled with rests.

Note:
Only non-dotted rests are generated.

Definition at line 96 of file rest.cpp.

References CARest().

Referenced by CAMainWin::deleteSelection(), CAMainWin::insertMusElementAt(), CAMainWin::scoreViewPortKeyPress(), and CAStaff::synchronizeVoices().

                                                                                                    {
      QList<CARest*> list;

      // 2048 is the longest rest (breve)
      for ( ; timeLength > 2048; timeLength-= 2048, timeStart+=2048 )
            list << new CARest( type, CAPlayableLength(CAPlayableLength::Breve), voice, timeStart );

      for ( int i = 0, TL=2048; i<256; (i?i*=2:i++), TL/=2 ) {
            if ( TL <= timeLength) {
                  list << new CARest( type, CAPlayableLength( static_cast<CAPlayableLength::CAMusicLength>(i) ), voice, timeStart );
                  timeLength -= TL;
                  timeStart += TL;
            }
      }

      return list;
}


Generated by  Doxygen 1.6.0   Back to index