§
    ƒØjÂ]  ã                  óL  — d dl mZ d dlmZ d dlZd dlmZ d dlmZ d dl	m
Z
 d dl	mZ d dl	mZ d d	l	mZ d d
l	mZ  G d„ d¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ d¦  «        Z G d„ dej        ¦  «        Zdd„Zedk    rd dl	Z	 e	j        e¦  «         dS dS )é    )Úannotations)ÚdeepcopyN)ÚopFrac)ÚOffsetQL)Úduration)Úexpressions)Úinterval)Únote)Ústreamc                  ó(   — e Zd ZdZ	 dd„Z	 ddd
„ZdS )ÚOrnamentRecognizerzò
    An object to identify if a stream of notes is an expanded ornament.
    Busy notes refer to the expanded ornament notes.
    Simple note(s) refer to the base note of ornament which is often shown
    with the ornament marking on it.
    Nc                óp   — t          |¦  «        }|                      ||¦  «        }t          ||z  ¦  «        S )a  
        Finds the quarter length value for each ornament note
        assuming busy notes all are an expanded ornament.

        Expanded ornament total duration is time of all busy notes combined or
        duration of the first note in simpleNotes when provided.
        )ÚlenÚcalculateOrnamentTotalQlr   )ÚselfÚ	busyNotesÚsimpleNotesÚnumOrnamentNotesÚtotalDurationQuarterLengths        úž/Users/tedpeters/Documents/Projects/Claude Projects/Misc Tools/notename-sheets/.venv/lib/python3.11/site-packages/music21/alpha/analysis/ornamentRecognizer.pyÚcalculateOrnamentNoteQlz*OrnamentRecognizer.calculateOrnamentNoteQl   s;   € õ ˜y™>œ>ÐØ%)×%BÒ%BÀ9ÈkÑ%ZÔ%ZÐ"ÝÐ0Ð3CÑCÑDÔDÐDó    r   úlist[note.GeneralNote]r   úlist[note.GeneralNote] | NoneÚreturnr   c                óŽ   — |r|d         j         j        S d}|D ]}|t          |j         j        ¦  «        z  }Œt          |¦  «        S )zÝ
        Returns total length of trill assuming busy notes are all an expanded trill.
        This is either the time of all busy notes combined or
        duration of the first note in simpleNotes when provided.
        r   g        )r   ÚquarterLengthÚfloatr   )r   r   r   ÚtrillQlÚns        r   r   z+OrnamentRecognizer.calculateOrnamentTotalQl/   sU   € ð ð 	9Ø˜q”>Ô*Ô8Ð8ØˆØð 	7ð 	7ˆAØ•u˜QœZÔ5Ñ6Ô6Ñ6ˆGˆGÝ�g‰ŒÐr   ©N)r   r   r   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   © r   r   r   r      sY   € € € € € ðð ð ðEð Eð Eð Eð& 48ðð ð ð ð ð ð r   r   c                  ó$   — e Zd ZdZdd„Zd	d
d„ZdS )ÚTrillRecognizera[  
    An object to identify if a stream of ("busy") notes is an expanded trill.

    By default, does not consider Nachschlag trills, but setting checkNachschlag will consider.

    When optional stream of simpleNotes are provided, considers if busyNotes are
    an expansion of a trill which would be denoted on the first note in simpleNotes.
    Fc                ó0   — || _         d| _        d| _        d S )Né   é   )ÚcheckNachschlagÚacceptableIntervalÚminimumLengthForNachschlag)r   r,   s     r   Ú__init__zTrillRecognizer.__init__J   s    € Ø.ˆÔØ"#ˆÔØ*+ˆÔ'Ð'Ð'r   Nr   úbool | expressions.Trillc                ó>  — t          |¦  «        dk    rdS |d         }|d         }|j        r|j        sdS t          |j        j        |j        j        z
  ¦  «        | j        k    rdS d}d}t          t          |¦  «        ¦  «        D ]N}||         }|j        s dS |dz  dk    r|j        |j        k    rd} n|dz  dk    r|j        |j        k    rd} nŒOd}|rn@| j        sdS t          |¦  «        | j        k    }	|t          |¦  «        dz  k    }
|	r|
rd}ndS |s™|j        j        |j        j        k    rt          j
        ¦   «         }nt          j        ¦   «         }|                      ||¦  «        |_        |rd|_        |j        j        �|j        j        |_        |                     |¦  «         |S |d         }|j        j        |j        j        |j        j        fvrdS |}|}|j        j        |j        j        k    r|}|}|j        j        |j        j        k    rt          j
        ¦   «         }nt          j        ¦   «         }|                      ||¦  «        |_        |rd|_        |j        j        �|j        j        |_        |                     |¦  «         |S )aÉ  
        Tries to identify the busy notes as a trill.

        When simple notes is provided, tries to identify busy notes
        as the trill shortened by simple notes.
        Currently only supports one simple note in simple notes.

        Only when checkNachschlag is true, allows last few notes to break trill rules.

        Trill interval size is interval between busy notes.

        Returns: False if not possible or the Trill Expression
        é   Fr   é   T)r   ÚisNoteÚabsÚpitchÚmidir-   Úranger,   r.   r   ÚTrillÚInvertedTrillr   r   Ú
nachschlagÚ
accidentalÚresolveOrnamentalPitches)r   r   r   Ún1Ún2ÚtwoNoteOscillationÚiÚnoteConsideringÚisNachschlagÚlengthOkÚnotTooMuchNachschlagÚtrillÚ
simpleNoteÚendNoteÚ	startNotes                  r   Ú	recognizezTrillRecognizer.recognizeO   sÞ  € õ ˆy‰>Œ>˜QÒÐØ�5ð �qŒ\ˆØ�qŒ\ˆàŒyð 	 ¤	ð 	Ø�5åˆrŒxŒ}˜rœxœ}Ñ,Ñ-Ô-°Ô0GÒGÐGØ�5à!ÐØˆÝ•s˜9‘~”~Ñ&Ô&ð 		ð 		ˆAØ'¨œlˆOØ"Ô)ð Ø�u�uØ�1‰u˜Šzˆz˜oÔ3°r´xÒ?Ð?Ø%*Ð"Ø�Ø�Q‘˜!’� Ô 5¸¼Ò AÐ AØ%*Ð"Ø�øàˆØð 
	ØØÔ%ð 	Ø�5å˜9‘~”~¨Ô)HÒHˆHØ#$­¨I©¬¸Ñ(:Ò#:Ð Øð Ð0ð Ø#��à�uàð 	àŒxŒ} ¤¤Ò-Ð-Ý#Ô)Ñ+Ô+��å#Ô1Ñ3Ô3�Ø"&×">Ò">¸yÈ+Ñ"VÔ"VˆEÔØð (Ø#'�Ô àŒxÔ"Ð.Ø#%¤8Ô#6�Ô Ø×*Ò*¨2Ñ.Ô.Ð.ØˆLð ! ”^ˆ
ð ÔÔ ¨¬¬¸¼¼Ð(FÐFÐFØ�5àˆØˆ	ØÔÔ  B¤H¤MÒ1Ð1ØˆGØˆIð Œ?Ô 7¤=Ô#5Ò5Ð5ÝÔ%Ñ'Ô'ˆEˆEåÔ-Ñ/Ô/ˆEØ"×:Ò:¸9ÀkÑRÔRˆÔØð 	$Ø#ˆEÔàŒ=Ô#Ð/Ø&œ}Ô7ˆEÔØ×&Ò& yÑ1Ô1Ð1Øˆr   )Fr!   )r   r0   )r"   r#   r$   r%   r/   rJ   r&   r   r   r(   r(   A   sR   € € € € € ðð ð,ð ,ð ,ð ,ð
^ð ^ð ^ð ^ð ^ð ^ð ^r   r(   c                  ó(   — e Zd Zd„ Zd
d„Z	 ddd	„ZdS )ÚTurnRecognizerc                ó  — d| _         d| _        t          j        d¦  «        t          j        d¦  «        t          j        d¦  «        t          j        d¦  «        t          j        d¦  «        t          j        d¦  «        g| _        d S )	Nr*   é   ÚM2úM-2Úm2úm-2ÚA2zA-2)r-   r.   r	   ÚIntervalÚacceptableIntervals)r   s    r   r/   zTurnRecognizer.__init__°   ss   € Ø"#ˆÔØ*+ˆÔ'åÔ˜dÑ#Ô#¥XÔ%6°uÑ%=Ô%=ÝÔ˜dÑ#Ô#¥XÔ%6°uÑ%=Ô%=ÝÔ˜dÑ#Ô#¥XÔ%6°uÑ%=Ô%=ð$
ˆÔ Ð Ð r   ÚintervalToCheckúinterval.Intervalr   Úboolc                ó   — || j         v S )zC
        Returns whether that interval can occur in a turn
        )rU   )r   rV   s     r   ÚisAcceptableIntervalz#TurnRecognizer.isAcceptableInterval¹   s   € ð  $Ô":Ð:Ð:r   Nú2bool | expressions.Turn | expressions.InvertedTurnc                ó¾  — t          |¦  «        dk    rdS |r@d}d}|D ]}||j        j        z  }Œt          |d         j        j        |z
  ¦  «        |k    rdS |d         j        j        |d         j        j        k    rdS |r(|d         j        j        |d         j        j        k    rdS t          j        |d         |d         ¬¦  «        }|                      |¦  «        sdS t          j        |d         |d         ¬¦  «        }|                      |¦  «        sdS t          j        |d         |d         ¬¦  «        }|                      |¦  «        sdS |j	        |j	        k    rdS |j	        |j	        k    rdS |j	        t          j        d	¦  «        j	        k    rt          j        ¦   «         }	nt          j        ¦   «         }	|                      ||¦  «        |	_        |	S )
a%  
        Tries to identify the busy notes as a turn or inverted turn.

        When simple notes is provided, tries to identify busy notes
        as the turn shortened by simple notes.
        Currently only supports one simple note in simple notes.

        Turns and inverted turns have four notes separated by m2, M2, A2.

        Turns:
        start above base note
        go down to base note,
        go down again,
        and go back up to base note

        Inverted Turns:
        start below base note
        go up to base note,
        go up again,
        and go back down to base note

        When going up or down, must go to the adjacent note name,
        so A goes down to G, G#, G flat, G##, etc

        Returns: False if not possible or the Turn/Inverted Turn Expression
        é   Fgš™™™™™¹?r   r3   r*   )Ú	noteStartÚnoteEndr2   rP   )r   r   r   r5   r6   r7   r	   rT   rZ   Ú	directionr   ÚTurnÚInvertedTurnr   )
r   r   r   ÚepsÚtotalBusyNotesDurationr    ÚfirstIntervalÚsecondIntervalÚthirdIntervalÚturns
             r   rJ   zTurnRecognizer.recognize¿   s   € õ@ ˆy‰>Œ>˜QÒÐØ�5àð 	ØˆCØ%&Ð"Øð Cð C�Ø&¨!¬*Ô*BÑBÐ&Ð&Ý�;˜q”>Ô*Ô8Ð;QÑQÑRÔRÐUXÒXÐXØ�uð �QŒ<ÔÔ" i°¤lÔ&8Ô&=Ò=Ð=Ø�5Øð 	˜; qœ>Ô/Ô4¸	À!¼Ô8JÔ8OÒOÐOØ�5õ !Ô)°I¸a´LÈ)ÐTUÌ,ÐWÑWÔWˆØ×(Ò(¨Ñ7Ô7ð 	Ø�5Ý!Ô*°Y¸q´\È9ÐUVÌ<ÐXÑXÔXˆØ×(Ò(¨Ñ8Ô8ð 	Ø�5Ý Ô)°I¸a´LÈ)ÐTUÌ,ÐWÑWÔWˆØ×(Ò(¨Ñ7Ô7ð 	Ø�5ð Ô" nÔ&>Ò>Ð>Ø�5àÔ# }Ô'>Ò>Ð>Ø�5ð Ô"¥hÔ&7¸Ñ&>Ô&>Ô&HÒHÐHÝÔ#Ñ%Ô%ˆDˆDåÔ+Ñ-Ô-ˆDØ!×9Ò9¸)À[ÑQÔQˆÔØˆr   )rV   rW   r   rX   r!   )r   r[   )r"   r#   r$   r/   rZ   rJ   r&   r   r   rL   rL   ¯   s\   € € € € € ð
ð 
ð 
ð;ð ;ð ;ð ;ð ðIð Ið Ið Ið Ið Ið Ir   rL   c                  ó   — e Zd Z	 dd„ZdS )Ú_TestConditionNFc                óh   — || _         || _        || _        || _        || _        || _        || _        d S r!   )Únamer   Ú
isOrnamentr   ÚornamentSizerC   Ú
isInverted)r   rl   r   rm   r   rn   rC   ro   s           r   r/   z_TestCondition.__init__  s<   € ð ˆŒ	Ø"ˆŒØ$ˆŒØ&ˆÔØ(ˆÔØ(ˆÔØ$ˆŒˆˆr   )NNFF)r"   r#   r$   r/   r&   r   r   rj   rj   
  s/   € € € € € ð MRð
%ð 
%ð 
%ð 
%ð 
%ð 
%r   rj   c                  ó    — e Zd Zd„ Zd„ Zd„ ZdS )ÚTestc                óB   — ddl m}  || t          ¦   «         ¦  «         d S )Nr   )ÚtestCopyAll)Úmusic21.test.commonTestrs   Úglobals)r   rs   s     r   ÚtestCopyAndDeepcopyzTest.testCopyAndDeepcopy  s0   € Ø7Ð7Ð7Ð7Ð7Ð7Øˆ�D�'™)œ)Ñ$Ô$Ð$Ð$Ð$r   c                ó¢  — g }t          j        d¦  «        }t          j        d¦  «        }t          j        d¦  «        }t          j        d¦  «        }t          j        d¦  «        t          j        d¦  «        t          j        d¦  «        t          j        d¦  «        g}|D ](}|j        j        t	          |¦  «        z  |j        _        Œ)t          j        d¦  «        t          j        d¦  «        t          j        d¦  «        t          j        d¦  «        g}d|j        j        z  t	          |¦  «        z  |d         j        _        t          dt	          |¦  «        ¦  «        D ]3}	|j        j        dt	          |¦  «        z  z  }
|
||	         j        _        Œ4t          j        d¦  «        t          j        d¦  «        t          j        d¦  «        t          j        d¦  «        g}d	|d         j        _        d
|d         j        _        d|d         j        _        d|d         j        _        t          j        d¦  «        t          j        d¦  «        t          j        d¦  «        t          j        d¦  «        g}|D ](}|j        j        t	          |¦  «        z  |j        _        Œ)|                     t          d|d¬¦  «        ¦  «         |                     t          d||gd¬¦  «        ¦  «         |                     t          d||gd¬¦  «        ¦  «         |                     t          d||gd¬¦  «        ¦  «         |                     t          d||gd¬¦  «        ¦  «         |                     t          d|d¬¦  «        ¦  «         |                     t          d|d¬¦  «        ¦  «         |                     t          d|dd¬¦  «        ¦  «         |                     t          dt          j        d¦  «        t          j        d¦  «        t          j        d¦  «        t          j        d¦  «        gd¬¦  «        ¦  «         |                     t          dt          j        d¦  «        t          j        d¦  «        t          j        d¦  «        t          j        d¦  «        gd¬¦  «        ¦  «         |                     t          dt          j        d¦  «        t          j        d¦  «        t          j        d¦  «        t          j        d¦  «        gd¬¦  «        ¦  «         |                     t          dt          j        d¦  «        t          j        d¦  «        t          j        d¦  «        t          j        d¦  «        t          j        d¦  «        gd¬¦  «        ¦  «         |                     t          d t          j        d¦  «        t          j        d¦  «        t          j        d¦  «        gd¬¦  «        ¦  «         |                     t          d!t          j        d¦  «        t          j        d¦  «        t          j        d¦  «        t          j        d¦  «        g|gd¬¦  «        ¦  «         |D ]Ê}t          ¦   «         }|j	        r"| 
                    |j        |j	        ¬"¦  «        }n| 
                    |j        ¦  «        }|j        rU|j        r'|                      |t          j        |j        ¦  «         Œˆ|                      |t          j        |j        ¦  «         Œ¯|                      ||j        ¦  «         ŒËd S )#NzF#zG-ÚGÚAÚEr2   r   r3   g      Ð?g333333Ã?gš™™™™™É?gš™™™™™Ù?r*   zeven turn no simple noteT©rl   r   rm   zeven turn with simple note©rl   r   r   rm   z%even turn with enharmonic simple notez.even turn with wrong simple note still in turnFz,even turn with wrong simple note not in turnz+rubato turn with all notes different lengthzdelayed turnzinverted turn)rl   r   ro   rm   zone wrong noteÚDznon-adjacent note jumpztrill is not a turnztoo many notes for turnztoo few notes for turnz/total turn notes length longer than simple note©r   )r
   ÚNoter   r   r   r8   Úappendrj   rL   r   rJ   r   rm   ro   ÚassertIsInstancer   rb   rl   ra   ÚassertFalse)r   ÚtestConditionsr>   Ún1EnharmonicÚnoteInTurnNotBaseÚnoteNotInTurnÚevenTurnr    ÚdelayedTurnrA   ÚsmallerDurationÚ
rubatoTurnÚinvertedTurnÚcondÚturnRecognizerrh   s                   r   ÚtestRecognizeTurnzTest.testRecognizeTurn  sß  € àˆåŒY�t‰_Œ_ˆÝ”y ‘”ˆÝ œI c™NœNÐÝœ	 #™œˆå”I˜c‘N”N¥D¤I¨d¡O¤OµT´Y¸s±^´^ÅTÄYÈtÁ_Ä_ÐUˆØð 	Qð 	QˆAØ')¤{Ô'@Å3ÀxÁ=Ä=Ñ'PˆAŒJÔ$Ð$å”y ‘~”~¥t¤y°¡¤½¼	À#¹¼ÍÌ	ÐRVÉÌÐXˆØ01°B´KÔ4MÑ0MÕPSÐT_ÑP`ÔP`Ñ0`ˆ�AŒÔÔ-Ý�q�#˜kÑ*Ô*Ñ+Ô+ð 	Dð 	DˆAØ œkÔ7¸1½sÀ;Ñ?OÔ?OÑ;OÑPˆOØ4CˆK˜ŒNÔ#Ô1Ð1å”i ‘n”n¥d¤i°¡o¤oµt´yÀ±~´~ÅtÄyÐQUÁÄÐWˆ
à/2ˆ
�1ŒÔÔ,Ø/2ˆ
�1ŒÔÔ,Ø/1ˆ
�1ŒÔÔ,Ø/1ˆ
�1ŒÔÔ,åœ	 #™œ­¬	°$©¬½¼À3¹¼ÍÌÐSWÉÌÐYˆØð 	Uð 	UˆAØ')¤{Ô'@Å3À|ÑCTÔCTÑ'TˆAŒJÔ$Ð$à×ÒÝØ/Ø"Øð!ñ !ô !ñ	
ô 	
ð 	
ð 	×ÒÝØ1Ø"Ø˜DØð	!ñ !ô !ñ	
ô 	
ð 	
ð 	×ÒÝØ<Ø"Ø)˜NØð	!ñ !ô !ñ	
ô 	
ð 	
ð 	×ÒÝØEØ"Ø.Ð/Ø ð	"ñ "ô "ñ	
ô 	
ð 	
ð 	×ÒÝØCØ"Ø*˜OØ ð	"ñ "ô "ñ	
ô 	
ð 	
ð 	×ÒÝØBØ$Øð!ñ !ô !ñ	
ô 	
ð 	
ð 	×ÒÝØ#Ø%Øð!ñ !ô !ñ	
ô 	
ð 	
ð 	×ÒÝØ$Ø&ØØð	!ñ !ô !ñ	
ô 	
ð 	
ð 	×ÒÝØ%Ýœ9 S™>œ>­4¬9°T©?¬?½D¼IÀc¹N¼NÍDÌIÐVYÉNÌNÐ[Ø ð"ñ "ô "ñ	
ô 	
ð 	
ð 	×ÒÝØ-Ýœ9 S™>œ>­4¬9°S©>¬>½4¼9ÀS¹>¼>Í4Ì9ÐUXÉ>Ì>ÐZØ ð"ñ "ô "ñ	
ô 	
ð 	
ð 	×ÒÝØ*Ýœ9 S™>œ>­4¬9°T©?¬?½D¼IÀc¹N¼NÍDÌIÐVZÉOÌOÐ\Ø ð"ñ "ô "ñ	
ô 	
ð 	
ð 	×ÒÝØ.Ýœ9 S™>œ>­4¬9°T©?¬?½D¼IÀc¹N¼NÍDÌIÐVZÉOÌOÝœ9 S™>œ>ð+à ð	"ñ "ô "ñ	
ô 	
ð 	
ð 	×ÒÝØ-Ýœ9 S™>œ>­4¬9°T©?¬?½D¼IÀc¹N¼NÐKØ ð"ñ "ô "ñ	
ô 	
ð 	
ð 	×ÒÝØFÝœ9 S™>œ>­4¬9°T©?¬?½D¼IÀc¹N¼NÍDÌIÐVZÉOÌOÐ\Ø˜DØ ð	"ñ "ô "ñ	
ô 	
ð 	
ð #ð 	2ð 	2ˆDÝ+Ñ-Ô-ˆNØÔð @Ø%×/Ò/°´ÈDÔL\Ð/Ñ]Ô]��à%×/Ò/°´Ñ?Ô?�àŒð 2Ø”?ð MØ×)Ò)¨$µÔ0HÈ$Ì)ÑTÔTÐTÐTà×)Ò)¨$µÔ0@À$Ä)ÑLÔLÐLÐLà× Ò   t¤yÑ1Ô1Ð1Ð1ð	2ð 	2r   c           
     ó.  — g }t          j        d¦  «        }d}t          j        d¦  «        }t          j        d¦  «        }t	          j        d¦  «        }||_         t	          j        d¦  «        }||_         t          j        ¦   «         }t          ||¦  «        }	|	|_	        | 
                    |¦  «        d         }
t          |
¦  «        }t	          j        ¦   «         }t          j        |	¦  «        |_         ||d<   |                     t          d	|
d
|¬¦  «        ¦  «         |                     t          d|
|gd
|¬¦  «        ¦  «         |                     t          d|
|gd
|¬¦  «        ¦  «         |                     t          d|
t	          j        d¦  «        gd
|¬¦  «        ¦  «         |                     t          d|
t	          j        d¦  «        gd¬¦  «        ¦  «         |                     t          d|d¬¦  «        ¦  «         t          j        d¦  «        }d}t          j        d¦  «        }t          j        d¦  «        }t	          j        d¦  «        }||_         t	          j        d¦  «        }||_         t          j        t          ||¦  «        ¦  «        }t	          j        d¦  «        }||_         t	          j        d¦  «        }||_         t          j        ¦   «         }|                     ||t          |¦  «        t          |¦  «        t          |¦  «        g¦  «         |                     t          d|d
|¬¦  «        ¦  «         |                     t          d||gd
|¬¦  «        ¦  «         |                     t          d||gd
|¬¦  «        ¦  «         t          j        d¦  «        }d}t          j        d¦  «        }t          j        d¦  «        }t	          j        d ¦  «        }||_         t          j        t          ||¦  «        ¦  «        }t	          j        d!¦  «        }||_         t	          j        d ¦  «        }||_         t	          j        d"¦  «        }||_         t	          j        d#¦  «        } || _         t	          j        d$¦  «        }!||!_         t          j        ¦   «         }"|"                     ||t          |¦  «        t          |¦  «        t          |¦  «        || |!g¦  «         |                     t          d%|"d¬¦  «        ¦  «         |                     t          d&|"d
d
|¬'¦  «        ¦  «         |                     t          d(|"|gd
d
|¬)¦  «        ¦  «         t          j        d*¦  «        }#t	          j        d¦  «        }$|#|$_         t	          j        d¦  «        }%|#|%_         |                     t          d+|$gd¬¦  «        ¦  «         |                     t          d,|$|%gd¬¦  «        ¦  «         t          j        d*¦  «        }&t	          j        d¦  «        }'|&|'_         t	          j        d-¦  «        }(|&|(_         t          j        ¦   «         })|)                     |'|(t          |'¦  «        t          |(¦  «        g¦  «         |                     t          d.|)d¬¦  «        ¦  «         t          j        d*¦  «        }*t	          j        d/¦  «        }+|*|+_         t	          j        d¦  «        },|*|,_         t	          j        d¦  «        }-||-_         t          j        ¦   «         })|)                     |+|,t          |+¦  «        |-g¦  «         |                     t          d0|)d¬¦  «        ¦  «         |D �]”}.t#          ¦   «         }/|.j        rd
|/_        |.j        r"|/                     |.j        |.j        ¬1¦  «        }0n|/                     |.j        ¦  «        }0|.j        �r|                      |0t          j        |.j        ¦  «         |                      |0j        |.j        |.j        ¦  «         |.j        rº|.j        rr|.j        d         j        j        |.j        d2         j        j        k    r!|0                     |.j        d2         ¦  «        }1nA|0                     |.j        d         ¦  «        }1n |0                     |.j        d         ¦  «        }1|                      |1|.j        |.j        ¦  «         �Œy|                       |0|.j        ¦  «         �Œ–d S )3NÚquarterr]   rO   rP   rx   ry   r   r2   z,even whole step trill up without simple noteT)rl   r   rm   rn   z)even whole step trill up from simple note)rl   r   r   rm   rn   z'even whole step trill up to simple notez(valid trill up to enharmonic simple notezG##z$valid trill but not with simple noterz   Fr|   zinvalid trill has rest insider{   Úhalfr+   rQ   rR   zG#z,odd half step trill down without simple notez'odd half step trill down to simple notezodd trill down from simple noteé   ÚBÚC5ÚD5ÚE5ÚF5z1Nachschlag trill when not checking for nachschlagz-Nachschlag trill when checking for nachschlag)rl   r   rC   rm   rn   z?Nachschlag trill when checking for nachschlag up to simple note)rl   r   r   rC   rm   rn   ÚeighthzOne note not a trillzTwo notes not a trillÚCz+Too big of oscillating interval to be trillÚFz5Right interval but not oscillating between same notesr~   r3   )!r   ÚDurationr	   rT   r
   r   r   r9   ÚcalculateTrillNoteDurationr   Úrealizer   ÚRestr€   rj   r   ÚStreamr(   rC   r,   r   rJ   r   rm   r�   rl   ÚassertEqualr;   rn   r6   r7   ÚgetSizer‚   )2r   rƒ   Ú
n1DurationÚ
t1NumNotesÚt1UpIntervalÚt1DownIntervalÚn1LowerÚn1UpperÚt1Út1NoteDurationÚt1NotesÚt1NotesWithRestÚr1Ú
n2DurationÚ
t2NumNotesÚt2UpIntervalÚt2DownIntervalÚn2LowerÚn2UpperÚt2NoteDurationÚt2n1Út2n2Út2NotesÚ
n3DurationÚ
t3NumNotesÚt3UpIntervalÚt3DownIntervalÚn3Út3NoteDurationÚt3n1Út3n2ÚnachschlagN1ÚnachschlagN2ÚnachschlagN3Út3NotesÚ
t4DurationÚt4n1Út4n2Út5NoteDurationÚt5n1Út5n2Út5NotesÚt6NoteDurationÚt6n1Út6n2Út6n3rŒ   ÚtrillRecognizerrF   Úsizes2                                                     r   ÚtestRecognizeTrillzTest.testRecognizeTrill¦  s	  € àˆåÔ& yÑ1Ô1ˆ
Øˆ
ÝÔ(¨Ñ.Ô.ˆÝ!Ô*¨5Ñ1Ô1ˆÝ”)˜C‘.”.ˆØ%ˆÔÝ”)˜C‘.”.ˆØ%ˆÔÝÔÑ Ô ˆÝ3°JÀ
ÑKÔKˆØ)ˆÔØ—*’*˜WÑ%Ô% aÔ(ˆÝ" 7Ñ+Ô+ˆÝŒY‰[Œ[ˆÝÔ'¨Ñ7Ô7ˆŒØˆ˜ÑØ×ÒÝØCØ!ØØ)ð	+ñ +ô +ñ	
ô 	
ð 	
ð 	×ÒÝØ@Ø!Ø$˜IØØ)ð+ñ +ô +ñ	
ô 	
ð 	
ð 	×ÒÝØ>Ø!Ø$˜IØØ+ð-ñ -ô -ñ	
ô 	
ð 	
ð 	×ÒÝØ?Ø!Ý!œY uÑ-Ô-Ð.ØØ+ð-ñ -ô -ñ	
ô 	
ð 	
ð 	×ÒÝØ;Ø!Ý!œY s™^œ^Ð,Ø ð	"ñ "ô "ñ	
ô 	
ð 	
ð 	×ÒÝØ4Ø)Ø ð"ñ "ô "ñ	
ô 	
ð 	
õ Ô& vÑ.Ô.ˆ
Øˆ
ÝÔ(¨Ñ.Ô.ˆÝ!Ô*¨5Ñ1Ô1ˆÝ”)˜D‘/”/ˆØ%ˆÔÝ”)˜C‘.”.ˆØ%ˆÔÝ!Ô*Õ+EÀjÐR\Ñ+]Ô+]Ñ^Ô^ˆÝŒy˜‰~Œ~ˆØ&ˆŒÝŒy˜‰ŒˆØ&ˆŒÝ”-‘/”/ˆØ�Š˜˜d¥H¨T¡N¤NµH¸T±N´NÅHÈTÁNÄNÐSÑTÔTÐTØ×ÒÝØCØ!ØØ+ð	-ñ -ô -ñ	
ô 	
ð 	
ð 	×ÒÝØ>Ø!Ø$˜IØØ)ð+ñ +ô +ñ	
ô 	
ð 	
ð 	×ÒÝØ6Ø!Ø$˜IØØ+ð-ñ -ô -ñ	
ô 	
ð 	
õ Ô& yÑ1Ô1ˆ
Øˆ
ÝÔ(¨Ñ.Ô.ˆÝ!Ô*¨5Ñ1Ô1ˆÝŒY�s‰^Œ^ˆØ ˆŒÝ!Ô*Õ+EÀjÐR\Ñ+]Ô+]Ñ^Ô^ˆÝŒy˜‰ŒˆØ&ˆŒÝŒy˜‰~Œ~ˆØ&ˆŒÝ”y ‘”ˆØ .ˆÔÝ”y ‘”ˆØ .ˆÔÝ”y ‘”ˆØ .ˆÔÝ”-‘/”/ˆØ�ŠØ�4� $™œ­°$©¬½À$¹¼Ø˜,¨ð6ñ	
ô 	
ð 	
ð
 	×ÒÝØHØ!Ø ð"ñ "ô "ñ	
ô 	
ð 	
ð 	×ÒÝØDØ!Ø!ØØ+ð-ñ -ô -ñ	
ô 	
ð 	
ð 	×ÒÝØVØ!Ø˜DØ!ØØ)ð+ñ +ô +ñ	
ô 	
ð 	
õ Ô& xÑ0Ô0ˆ
ÝŒy˜‰~Œ~ˆØ"ˆŒÝŒy˜‰~Œ~ˆØ"ˆŒØ×ÒÝØ+Ø˜&Ø ð"ñ "ô "ñ	
ô 	
ð 	
ð 	×ÒÝØ,Ø ˜,Ø ð"ñ "ô "ñ	
ô 	
ð 	
õ "Ô*¨8Ñ4Ô4ˆÝŒy˜‰~Œ~ˆØ&ˆŒÝŒy˜‰~Œ~ˆØ&ˆŒÝ”-‘/”/ˆØ�Š˜˜d¥H¨T¡N¤NµH¸T±N´NÐCÑDÔDÐDØ×ÒÝØBØ!Ø ð"ñ "ô "ñ	
ô 	
ð 	
õ "Ô*¨8Ñ4Ô4ˆÝŒy˜‰~Œ~ˆØ&ˆŒÝŒy˜‰~Œ~ˆØ&ˆŒÝŒy˜‰~Œ~ˆØ&ˆŒÝ”-‘/”/ˆØ�Š˜˜d¥H¨T¡N¤N°DÐ9Ñ:Ô:Ð:Ø×ÒÝØLØ!Ø ð"ñ "ô "ñ	
ô 	
ð 	
ð #ð 	3ñ 	3ˆDÝ-Ñ/Ô/ˆOØÔ ð 7Ø26�Ô/àÔð BØ'×1Ò1°$´.ÈdÔN^Ð1Ñ_Ô_��à'×1Ò1°$´.ÑAÔA�àŒñ 3Ø×%Ò% e­[Ô->ÀÄ	ÑJÔJÐJà× Ò  Ô!1°4Ô3DÀdÄiÑPÔPÐPØÔ$ð IØÔ'ð @ØÔ+¨AÔ.Ô4Ô9¸T¼^ÈAÔ=NÔ=TÔ=YÒYÐYØ#(§=¢=°´ÀÔ1BÑ#CÔ#C˜D˜Dà#(§=¢=°´ÀÔ1BÑ#CÔ#C˜D˜Dà$Ÿ}š}¨T¬^¸AÔ->Ñ?Ô?˜Ø×$Ò$ T¨4Ô+<¸d¼iÑHÔHÐHùà× Ò  ¨¬	Ñ2Ô2Ð2Ñ2ð1	3ð 	3r   N)r"   r#   r$   rv   rŽ   rÐ   r&   r   r   rq   rq     sJ   € € € € € ð%ð %ð %ðH2ð H2ð H2ðT`3ð `3ð `3ð `3ð `3r   rq   ÚnumTrillNotesÚintÚtotalDurationúduration.Durationr   r   c                ó0   — t          |j        | z  ¦  «        S r!   )r   r   )rÑ   rÓ   s     r   rœ   rœ   ‰  s   € õ �-Ô-°Ñ=Ñ>Ô>Ð>r   Ú__main__)rÑ   rÒ   rÓ   rÔ   r   r   )Ú
__future__r   Úcopyr   ÚunittestÚmusic21.common.numberToolsr   Úmusic21.common.typesr   Úmusic21r   r   r	   r
   r   r   r(   rL   rj   ÚTestCaserq   rœ   r"   ÚmainTestr&   r   r   ú<module>rß      sì  ðð #Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ð Ð Ø €€€à -Ð -Ð -Ð -Ð -Ð -Ø )Ð )Ð )Ð )Ð )Ð )Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð ð&ð &ð &ð &ð &ñ &ô &ð &ðRlð lð lð lð lÐ(ñ lô lð lð\Yð Yð Yð Yð YÐ'ñ Yô Yð Yðv%ð %ð %ð %ð %ñ %ô %ð %ðo3ð o3ð o3ð o3ð o3ˆ8Ôñ o3ô o3ð o3ðd?ð ?ð ?ð ?ð ˆzÒÐØ€N€N€NØ€GÔ�TÑÔÐÐÐð Ðr   