§
    ƒØjW  ã                  óÄ   — d dl mZ d dlZd dlmZ d dlmZ  ej        d¦  «        Z	 	 dd„Zdd	„Z	 G d
„ dej
        ¦  «        Zedk    rd dlZ ej        e¦  «         dS dS )é    )ÚannotationsN)Úenvironment)ÚscalezaudioSearch.transcriberTç      4@c                ó4  — ddl m} |€t          j        d¦  «        }|du rt                               ¦   «         dz  }n	|du rd}n|}|du r%|                     |t          |¦  «        ¬¦  «        }n#|                     t          |¦  «        ¬	¦  «        }| 	                    ||¦  «        }	| 
                    |	¦  «        }	|                     |	|¦  «        \  }
}|                     |
¦  «        \  }}|                     ||d¬
¦  «        \  }}| r|                     ¦   «          |r\	 ddl}n## t           $ r |                     d¦  «        ‚w xY w|j                             |¦  «         |j                             ¦   «          t                               d¦  «         |S )a¥  
    runs all the methods to record from audio for `seconds` length (default 10.0)
    and transcribe the resulting melody returning a music21.Score object

    if `show` is True, show the stream.

    if `plot` is True, then a Tk graph of the frequencies will be displayed.

    if `useMic` is True then use the microphone.  If False it will load the file of `saveFile`
    or the default temp file to run transcriptions from.

    a different scale than the chromatic scale can be specified by setting `useScale`.
    See :ref:`moduleScale` for a list of allowable scales. (or a custom one can be given).
    Microtonal scales are totally accepted, as are retuned scales where A != 440hz.

    if `saveFile` is False, then the recorded audio is saved to disk.  If
    set to `True` then `environLocal.getRootTempDir() / 'ex.wav'` is
    used as the filename.  If set to anything else then it will use that as the
    filename.
    r   ©ÚaudioSearchNÚC4Tzex.wavF)ÚlengthÚstoreWaveFilename©ÚwaveFilename©ÚremoveRestsAtBeginningz)Cannot plot without matplotlib installed.z* END)Úmusic21r	   r   ÚChromaticScaleÚenvironLocalÚgetRootTempDirÚgetFrequenciesFromMicrophoneÚstrÚgetFrequenciesFromAudioFileÚdetectPitchFrequenciesÚsmoothFrequenciesÚpitchFrequenciesToObjectsÚjoinConsecutiveIdenticalPitchesÚnotesAndDurationsToStreamÚshowÚmatplotlib.pyplotÚImportErrorÚAudioSearchExceptionÚpyplotÚplotÚ
printDebug)r   r"   ÚuseMicÚsecondsÚuseScaleÚsaveFileÚaudioSearchBaser   ÚfreqFromAQListÚdetectedPitchesFreqÚdetectedPitchObjectsÚlistplotÚ	notesListÚdurationListÚmyScoreÚunused_length_partÚ
matplotlibs                    ú”/Users/tedpeters/Documents/Projects/Claude Projects/Misc Tools/notename-sheets/.venv/lib/python3.11/site-packages/music21/audioSearch/transcriber.pyÚrunTranscriber3      s  € ð, 7Ð6Ð6Ð6Ð6Ð6àÐÝÔ'¨Ñ-Ô-ˆà�4ÐÐÝ#×2Ò2Ñ4Ô4°xÑ?ˆˆØ	�UÐ	Ð	Øˆˆàˆð �€~€~Ø(×EÒEØÝ! ,Ñ/Ô/ð Fñ 1ô 1ˆˆð )×DÒDÝ˜\Ñ*Ô*ð Eñ ,ô ,ˆð *×@Ò@ÀÐQYÑZÔZÐØ)×;Ò;Ð<OÑPÔPÐà#×=Ò=Ð>QÐS[Ñ\Ô\ñÐØà'×GÒGÐH\Ñ]Ô]ñ€YØØ"1×"KÒ"KØØØ#ð #Lñ #%ô #%Ñ€GÐð
 ð Ø�Š‰Œˆàð !ð	=à$Ð$Ð$Ð$Ð$øÝð 	=ð 	=ð 	=Ø!×6Ò6Ø;ñ=ô =ð =ð	=øøøð 	Ô×Ò˜xÑ(Ô(Ð(ØÔ×ÒÑ Ô Ð Ý×Ò˜GÑ$Ô$Ð$à€Ns   Ä#D( Ä( Ec                óZ  — ddl m} |                     | ¬¦  «        }|                     ||¦  «        }|                     |¦  «        }|                     ||¦  «        \  }}|                     |¦  «        \  }}|                     ||d¬¦  «        \  }	}
|	j         	                    ¦   «         S )a|  
    Reads in a .wav file and returns a stream representing the transcribed, monophonic audio.

    `fileName` should be the complete path to a file on the disk.

    A different scale than the chromatic scale can be specified by setting `useScale`.
    See :ref:`moduleScale` for a list of allowable scales. (or a custom one can be given).
    Microtonal scales are totally accepted, as are retuned scales where A != 440hz.

    We demonstrate with an audio file beginning with an ascending scale.

    >>> import os #_DOCS_HIDE
    >>> taw = 'test_audio.wav' #_DOCS_HIDE
    >>> waveFile = str(common.getSourceFilePath() / 'audioSearch' / taw) #_DOCS_HIDE
    >>> #_DOCS_SHOW waveFile = 'test_audio.wav'
    >>> p = audioSearch.transcriber.monophonicStreamFromFile(waveFile)
    >>> p
    <music21.stream.Part ...>
    >>> p.show('text')
    {0.0} <music21.note.Note C>
    {0.25} <music21.note.Note C>
    {0.75} <music21.note.Note D>
    {1.75} <music21.note.Note E>
    {2.75} <music21.note.Note F>
    {4.25} <music21.note.Note G>
    {5.25} <music21.note.Note A>
    {6.25} <music21.note.Note B>
    {7.25} <music21.note.Note C>
    ...
    r   r   r   Tr   )
r   r	   r   r   r   r   r   r   ÚpartsÚfirst)ÚfileNamer&   r(   r)   r*   r+   Úunused_listplotr-   r.   r/   r0   s              r2   ÚmonophonicStreamFromFiler9   ]   sÐ   € ð> 7Ð6Ð6Ð6Ð6Ð6à$×@Ò@ÈhÐ@ÑWÔW€Nà)×@Ò@ÀÐQYÑZÔZÐØ)×;Ò;Ð<OÑPÔPÐà*×DÒDÐEXÐZbÑcÔcñÐØà'×GÒGÐH\Ñ]Ô]ñ€YØØ"1×"KÒ"KØ�<¸ð #Lñ #>ô #>Ñ€GÐàŒ=×ÒÑ Ô Ð ó    c                  ó   — e Zd Zd„ Zd„ ZdS )ÚTestExternalc                ód   — t                                ¦   «         dz  }t          dd|d¬¦  «         d S )Nznew_song.wavFg      $@)r   r"   r'   r%   ©r   r   r3   ©Úselfr'   s     r2   Úx_testRunTranscribez TestExternal.x_testRunTranscribe�   s5   € Ý×.Ò.Ñ0Ô0°>ÑAˆÝ˜5 u°xÈÐNÑNÔNÐNÐNÐNr:   c                ód   — t                                ¦   «         dz  }t          d|dd¬¦  «         d S )Nzpachelbel.wavF)r$   r'   r"   r   r>   r?   s     r2   Úx_testTranscribePachelbelz&TestExternal.x_testTranscribePachelbel‘   s5   € Ý×.Ò.Ñ0Ô0°?ÑBˆÝ˜U¨X¸EÈÐNÑNÔNÐNÐNÐNr:   N)Ú__name__Ú
__module__Ú__qualname__rA   rC   © r:   r2   r<   r<   ‹   s:   € € € € € ðOð Oð OðOð Oð Oð Oð Or:   r<   Ú__main__)TTTr   NT)N)Ú
__future__r   Úunittestr   r   r   ÚEnvironmentr   r3   r9   ÚTestCaser<   rD   ÚmainTestrG   r:   r2   ú<module>rN      sû   ðð #Ð "Ð "Ð "Ð "Ð "à €€€à Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à&ˆ{Ô&Ð'@ÑAÔA€ð 04Ø8<ðDð Dð Dð DðN+!ð +!ð +!ð +!ð\Oð Oð Oð Oð O�8Ô$ñ Oô Oð Oð ˆzÒÐØ€N€N€NØ€GÔ�\Ñ"Ô"Ð"Ð"Ð"ð Ðr:   