ó
    ‡Ó}j«  ã                   ód   • S SK r S SKrS SKJr  S SKrS SKJr  S SKJrJ	r	  S SK
Jr   " S S5      rg)é    N)ÚPath)ÚTensor)Ú_coreÚAudioSamples)Úcreate_audio_decoderc            
       óÆ   • \ rS rSrSrSSSS.S\\-  \R                  -  \R                  -  \
-  \-  S\S-  S\S-  S\S-  4S	 jjrS
\4S jr SS\S\S-  S
\4S jjrSrg)ÚAudioDecoderé   aO  A single-stream audio decoder.

This can be used to decode audio from pure audio files (e.g. mp3, wav,
etc.), or from videos that contain audio streams (e.g. mp4 videos).

.. tip::

   If you are decoding WAV files, consider using
   :class:`~torchcodec.decoders.WavDecoder` instead for significantly faster
   decoding.

Returned samples are float samples normalized in [-1, 1]

Args:
    source (str, ``Pathlib.path``, bytes, ``torch.Tensor`` or file-like
        object): The source of the video or audio:

        - If ``str``: a local path or a URL to a video or audio file.
        - If ``Pathlib.path``: a path to a local video or audio file.
        - If ``bytes`` object or ``torch.Tensor``: the raw encoded audio data.
        - If file-like object: we read video data from the object on demand. The object must
          expose the methods `read(self, size: int) -> bytes` and
          `seek(self, offset: int, whence: int) -> int`. Read more in:
          :ref:`sphx_glr_generated_examples_decoding_file_like.py`.
    stream_index (int, optional): Specifies which stream in the file to decode samples from.
        Note that this index is absolute across all media types. If left unspecified, then
        the :term:`best stream` is used.
    sample_rate (int, optional): The desired output sample rate of the decoded samples.
        By default, the sample rate of the source is used.
    num_channels (int, optional): The desired number of channels of the decoded samples.
        By default, the number of channels of the source is used.

Attributes:
    metadata (AudioStreamMetadata): Metadata of the audio stream.
    stream_index (int): The stream index that this decoder is retrieving samples from. If a
        stream index was provided at initialization, this is the same value. If it was left
        unspecified, this is the :term:`best stream`.
N)Ústream_indexÚsample_rateÚnum_channelsÚsourcer   r   r   c                óÎ   • [         R                  R                  S5        [        USUUUS9u  U l        U l        U l        Ub  UU l        g U R                  R                  U l        g )Nz torchcodec.decoders.AudioDecoderÚapproximate)r   Ú	seek_moder   r   r   )	ÚtorchÚ_CÚ_log_api_usage_oncer   Ú_decoderr   Úmetadatar   Ú_desired_sample_rate)Úselfr   r   r   r   s        Ú°C:\Users\johnn\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\torchcodec/decoders/_audio_decoder.pyÚ__init__ÚAudioDecoder.__init__;   sl   € ô 	�‰×$Ñ$Ð%GÔHô !ØØ#Ø%Ø#Ø%ñ
ñ		
ØŒMØÔØŒMð 'Ñ2ˆKð 	Õ!Ø8<¿¹×8QÑ8Qð 	Õ!ó    Úreturnc                 ó"   • U R                  5       $ )zÛReturns all the audio samples from the source.

To decode samples in a specific range, use
:meth:`~torchcodec.decoders.AudioDecoder.get_samples_played_in_range`.

Returns:
    AudioSamples: The samples within the file.
)Úget_samples_played_in_range)r   s    r   Úget_all_samplesÚAudioDecoder.get_all_samplesU   s   € ð ×/Ñ/Ó1Ð1r   Ústart_secondsÚstop_secondsc                 ó®  ^
^• Ub  X::  d  [        SU SU S35      e[        R                  " U R                  UUS9u  nm
T
R	                  5       m
U R
                  mTc   eS[        S[        4U
U4S jjnT
U:  a  U" U5      nUnOS	nT
nUR                  S
   nUb  [        Xt" U5      5      nOUnUSS2XX24   n	[        U	UU	R                  S
   T-  TS9$ )aÆ  Returns audio samples in the given range.

Samples are in the half open range [start_seconds, stop_seconds).

To decode all the samples from beginning to end, you can call this
method while leaving ``start_seconds`` and ``stop_seconds`` to their
default values, or use
:meth:`~torchcodec.decoders.AudioDecoder.get_all_samples` as a more
convenient alias.

Args:
    start_seconds (float): Time, in seconds, of the start of the
        range. Default: 0.
    stop_seconds (float or None): Time, in seconds, of the end of the
        range. As a half open range, the end is excluded. Default: None,
        which decodes samples until the end.

Returns:
    AudioSamples: The samples within the specified range.
NzInvalid start seconds: z1. It must be less than or equal to stop seconds (z).)r"   r#   Úsecondsr   c                 óB   >• [         R                  " U T-
  T-  S-   5      $ )Ng      à?)ÚmathÚfloor)r%   Ú	first_ptsr   s    €€r   Ú	offset_ofÚ;AudioDecoder.get_samples_played_in_range.<locals>.offset_of”   s#   ø€ ô —:’:˜w¨Ñ2°kÑAÀCÑGÓHÐHr   r   é   )ÚdataÚpts_secondsÚduration_secondsr   )Ú
ValueErrorÚcoreÚ get_frames_by_pts_in_range_audior   Úitemr   ÚfloatÚintÚshapeÚminr   )r   r"   r#   Úframesr*   Úoffset_beginningÚoutput_pts_secondsÚnum_samplesÚ
offset_endr-   r)   r   s             @@r   r   Ú(AudioDecoder.get_samples_played_in_range`   s%  ù€ ð. Ñ#¨MÓ,IÜØ)¨-¨Ð8iÐjvÐiwÐwyÐzóð ô !×AÒAØ�M‰MØ'Ø%ñ
Ñˆ�	ð
 —N‘NÓ$ˆ	ð  ×/Ñ/ˆàÑ&Ð&Ð&ð	Iœuð 	I¬÷ 	Ið 	Ið �}Ó$Ù(¨Ó7ÐØ!.Ñð
  !ÐØ!*Ðà—l‘l 1‘oˆØÑ#Ü˜[¨)°LÓ*AÓB‰Jà$ˆJà’aÐ)Ð4Ð4Ñ5ˆÜØØ*Ø!ŸZ™Z¨™]¨[Ñ8Ø#ñ	
ð 	
r   )r   r   r   r   )g        N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ústrr   ÚioÚ	RawIOBaseÚBufferedReaderÚbytesr   r5   r   r   r    r4   r   Ú__static_attributes__© r   r   r	   r	      sª   † ñ%ðV $(Ø"&Ø#'ò
à�d‘
˜RŸ\™\Ñ)¨B×,=Ñ,=Ñ=ÀÑEÈÑNð
ð ˜D‘jð	
ð
 ˜4‘Zð
ð ˜D‘jõ
ð4	2 ô 	2ð HLñT
Ø"ðT
Ø8=À¹ðT
à	÷T
ð T
r   r	   )rD   r'   Úpathlibr   r   r   Ú
torchcodecr   r1   r   Útorchcodec._core._decoder_utilsr   r	   rI   r   r   Ú<module>rM      s(   ðó 
Û Ý ã Ý ç 2Ý @÷a
ò a
r   