Canorus 0.0
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
CAPlayableLength Class Reference

Musical length of notes and rests. More...

#include <playablelength.h>

Public Types

enum  CAMusicLength {
  Undefined = -1 , Breve = 0 , Whole = 1 , Half = 2 ,
  Quarter = 4 , Eighth = 8 , Sixteenth = 16 , ThirtySecond = 32 ,
  SixtyFourth = 64 , HundredTwentyEighth = 128
}
 

Public Member Functions

 CAPlayableLength ()
 
 CAPlayableLength (CAMusicLength l, int dotted=0)
 
const CAMusicLength musicLength ()
 
const int dotted ()
 
void setMusicLength (const CAMusicLength l)
 
void setDotted (const int d)
 
bool operator== (CAPlayableLength)
 
bool operator!= (CAPlayableLength)
 

Static Public Member Functions

static const QString musicLengthToString (CAMusicLength length)
 
static CAMusicLength musicLengthFromString (const QString length)
 
static const int playableLengthToTimeLength (CAPlayableLength length)
 
static const int musicLengthToTimeLength (CAMusicLength l)
 
static QList< CAPlayableLengthtimeLengthToPlayableLengthList (int timeLength, bool longNotesFirst=true, int dotsLimit=4)
 
static QList< CAPlayableLengthmatchToBars (CAPlayableLength len, int timeStart, CABarline *lastBarline, CATimeSignature *ts, int dotsLimit=4)
 
static QList< CAPlayableLengthmatchToBars (int timeLength, int timeStart, CABarline *lastBarline, CATimeSignature *ts, int dotsLimit=4, int separiationTime=0)
 

Private Attributes

CAMusicLength _musicLength
 
int _dotted
 

Detailed Description

Musical length of notes and rests.

Copyright (c) 2008, Matevž Jekovec, Canorus development team All Rights Reserved. See AUTHORS for a complete list of authors.

Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.

This class represents a musical length (quarter, half, whole etc.) of notes and rests with number of dots.

It consists of two properties:

Playable length can be easily converted to timeLength. Vice-versa is a bit more difficult.

See also
playableLengthToTimeLength(), CARest::composeRests()

Member Enumeration Documentation

◆ CAMusicLength

Enumerator
Undefined 
Breve 
Whole 
Half 
Quarter 
Eighth 
Sixteenth 
ThirtySecond 
SixtyFourth 
HundredTwentyEighth 

Constructor & Destructor Documentation

◆ CAPlayableLength() [1/2]

CAPlayableLength::CAPlayableLength ( )

References setDotted(), setMusicLength(), and Undefined.

Referenced by matchToBars(), musicLengthToTimeLength(), and timeLengthToPlayableLengthList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CAPlayableLength() [2/2]

CAPlayableLength::CAPlayableLength ( CAMusicLength  l,
int  dotted = 0 
)

References dotted(), setDotted(), and setMusicLength().

Here is the call graph for this function:

Member Function Documentation

◆ dotted()

const int CAPlayableLength::dotted ( )
inline

◆ matchToBars() [1/2]

QList< CAPlayableLength > CAPlayableLength::matchToBars ( CAPlayableLength  len,
int  timeStart,
CABarline lastBarline,
CATimeSignature ts,
int  dotsLimit = 4 
)
static

Split a playable to match a given bar border and bar length. This function is used at music input with a midi keyboard.

References CATimeSignature::beat(), CATimeSignature::beats(), CAPlayableLength(), playableLengthToTimeLength(), timeLengthToPlayableLengthList(), and CAMusElement::timeStart().

Referenced by CAKeybdInput::midiInEventToScore(), and CAMidiImport::writeMidiChannelEventsToVoice_New().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ matchToBars() [2/2]

QList< CAPlayableLength > CAPlayableLength::matchToBars ( int  timeLength,
int  timeStart,
CABarline lastBarline,
CATimeSignature ts,
int  dotsLimit = 4,
int  separationTime = 0 
)
static

Split a playable length to match a virtual or real next barline by recognising a given previous barline and bar length by a given time signature. In lack of barline or timesignature asumptions are made, maybe resulting in returning an empty split list.

separationTime is an additional splitting point, meant to do there key signature changes.

This function is used in midi import, could be used at mouse note input too, probably. See also matchToBars with CAPlayableLength as parameter, which is used at midi keyboard input. This functions probably could be merged.

References CATimeSignature::beat(), CATimeSignature::beats(), CAPlayableLength(), playableLengthToTimeLength(), Quarter, timeLengthToPlayableLengthList(), and CAMusElement::timeStart().

Here is the call graph for this function:

◆ musicLength()

const CAMusicLength CAPlayableLength::musicLength ( )
inline

◆ musicLengthFromString()

CAPlayableLength::CAMusicLength CAPlayableLength::musicLengthFromString ( const QString  length)
static

References Breve, Eighth, Half, HundredTwentyEighth, Quarter, Sixteenth, SixtyFourth, ThirtySecond, Undefined, and Whole.

Referenced by CACanorusMLImport::importMark(), and CACanorusMLImport::startElement().

Here is the caller graph for this function:

◆ musicLengthToString()

const QString CAPlayableLength::musicLengthToString ( CAPlayableLength::CAMusicLength  length)
static

References Breve, Eighth, Half, HundredTwentyEighth, Quarter, Sixteenth, SixtyFourth, ThirtySecond, Undefined, and Whole.

Referenced by CACanorusMLExport::exportPlayableLength().

Here is the caller graph for this function:

◆ musicLengthToTimeLength()

static const int CAPlayableLength::musicLengthToTimeLength ( CAMusicLength  l)
inlinestatic

References CAPlayableLength(), and playableLengthToTimeLength().

Referenced by CATimeSignature::barDuration(), CAMainWin::scoreViewMouseMove(), and timeLengthToPlayableLengthList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator!=()

bool CAPlayableLength::operator!= ( CAPlayableLength  l)

Compares two playable lengths.

◆ operator==()

bool CAPlayableLength::operator== ( CAPlayableLength  l)

Compares two playable lengths.

References dotted(), and musicLength().

Here is the call graph for this function:

◆ playableLengthToTimeLength()

const int CAPlayableLength::playableLengthToTimeLength ( CAPlayableLength  length)
static

◆ setDotted()

void CAPlayableLength::setDotted ( const int  d)
inline

◆ setMusicLength()

void CAPlayableLength::setMusicLength ( const CAMusicLength  l)
inline

References _musicLength.

Referenced by CAPlayableLength(), and CALilyPondImport::playableLengthFromLilyPond().

Here is the caller graph for this function:

◆ timeLengthToPlayableLengthList()

QList< CAPlayableLength > CAPlayableLength::timeLengthToPlayableLengthList ( int  t,
bool  longNotesFirst = true,
int  dotsLimit = 4 
)
static

Compute for a given time length the CAPlayableLengths. In the general case this could result in several notes. In the canorus GUI we can have max. 4 dots. By default longer notes appear first in the list, but with negating longNotesFirst the short ones appear first. This is useful for end of bar notes.

To make this computation fast we take in account that note durations are a binary presentation of the time duration. The breve value is not exactly a log2 value, so we do this singular nonlinear operation through the method of computation (see **).

Limitations: Maximum four dots per note, and the smallest resulting time duration is SixtyFourth;

Todo: Allow change of limitations as function parameters, which are longest note and number of dots.

References Breve, CAPlayableLength(), HundredTwentyEighth, musicLengthToTimeLength(), and playableLengthToTimeLength().

Referenced by matchToBars(), and CAMusicXmlImport::readNote().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _dotted

int CAPlayableLength::_dotted
private

Referenced by dotted(), and setDotted().

◆ _musicLength

CAMusicLength CAPlayableLength::_musicLength
private

Referenced by musicLength(), and setMusicLength().


The documentation for this class was generated from the following files: