Ë
    ;–¼jÎ ã            '       óˆ  — U d Z dZddlZddlZddlZddlm	Z	 ddl
mZ ddlmZmZmZ ddlmZmZmZmZmZ ddlZddlmZ dd	lmZ eez  ez  ej<                  e   z  Zee d
<   ejB                  e"edf   ejF                  ejH                  ejJ                  z  ejL                  z  ejN                  z     f   Z(ee d<   ejB                  e"eef   ejF                  ejH                  ejJ                  z  ejL                  z  ejN                  z     f   Z)ee d<   ed   Z*ee d<   ee d<   ee d<   dddddddddddœ
Z+ee,eef      e d<   i dd“d d!“d"d#“d$d%“d&d'“d(d)“d*d+“d,d-“d.d/“d0d1“d2d3“d4d5“d6d7“d8d9“d:d;“d<d=“d>d?“d@dAdBdCdDdEdFdGdHdIœ	¥Z-ee,eef      e dJ<   i dKd“dLd“dMd“dNd“dOd“dPd“dQd“dRd“dSdT“dUdV“dWdX“dYdZ“d[d\“d]d^“d_d`“dadb“dcdd“i dedf“dgdh“didj“dkdl“dmdn“dodp“dqdr“dsdt“dudv“dwdx“dydz“d{d|“d}d~“dd€“d�d‚“dƒd„“d…d†“¥Z.ee,eef      e d‡<   ddˆd‰dŠd‹œZ/ee,eef      e dŒ<   i ddL“d dL“d"dL“d&dL“d(dL“d*dL“d,dL“d.dL“d0dL“d2dQ“d4dQ“d6dL“d8ds“d:dL“d<dL“d>dL“d�dL“dLdLdLdSdudLdLd…dŽœ¥Z0ee,eef      e d�<   d�d‘d’d“dœZ1ee,eef      e d”<   dddd•œZ2ee,eef      e d–<   	 ejf                  d—k(  rdd˜l3m4Z5 d™ e5«       z   dšz   Z6n~ejf                  d›k(  r8ddl7Z8 e8jr                  «       Z:e:dœk(  rd�Z6nRe:džk(  rdŸZ6nJe:d›k(  rd Z6nB e;d¡e:› �«      ‚ejf                  d¢k(  r dd˜l3m4Z5  e5«       d£v rd¤Z6nd™ e5«       z   d¥z   Z6n e;d¦«      ‚ddl<Z<ejz                  j}                  e<j~                  «      Z@ejz                  jƒ                  e@e6«      ZB ej†                  eB«      ZD ej–                  eDj™                  «       «      j›                  d¯d°«      ZNeNjŸ                  d±«      reN ePd±«      d ZN	 	 	 	 dãd²ed³ed´edµedz  d¶e*d·eQd¸eRdz  d¹e(e)z  dz  dºedz  d»edz  d¼edz  d½edz  d¾edz  d¿eQdÀe"e(e)z  ef   fdÁ„ZS	 	 	 	 däd²edÂe(dºed½edz  d¾edz  d¼edz  d¿eQdÃeRdz  dÄedz  dÀdfdÅ„ZT	 	 	 	 	 	 	 	 dåd²edÆedz  dÇed³ed´edµedz  d¶e*d·eQd¸eRdz  d¹e(e)z  dz  dºedz  d»edz  d¼edz  d½edz  d¾edz  d¿eQdÀe	e(ddf   e	e)ddf   z  f"dÈ„ZU G dÉ„ dÊ«      ZVdæd²edËeQdÀeVfdÌ„ZWdÀe,eef   fdÍ„ZXdçd¼edz  dÀe,eef   fdÎ„ZY	 	 dèd¼ed½edz  d¾edz  dÀeQfdÏ„ZZd¼edÀedz  fdÐ„Z[ G dÑ„ dÒ«      Z\dédÓ„Z]dÔ„ Z^dÕ„ Z_dÖ„ Z`d×„ ZadØ„ ZbeDjÆ                  fdÙ„ZddÚ„ ZedÛ„ ZfdÜ„ Zg G dÝ„ dÞeh«      Zi G dß„ dàeiej«      Zk G dá„ dâek«      Zly# e;eEeFf$ ré 	  ed§«      ZGeG€ e;d¨«      ‚ ej†                  eG«      ZDn¿# e;$ r· ejf                  d—k(  rd©ZHn%ejf                  d›k(  rdªZHnejf                  d¢k(  rd«ZHn‚ dd˜l3m4Z5 ejf                  d—k(  rV e5«       d¬k(  rLejz                  j“                  d­«      rd­nd®ZJ ej†                  ejz                  jƒ                  eJeH«      «      ZDn ej†                  eH«      ZDY nw xY wY �Œ·w xY w)êak  python-soundfile is an audio library based on libsndfile, CFFI and NumPy.

Sound files can be read or written directly using the functions
`read()` and `write()`.
To read a sound file in a block-wise fashion, use `blocks()`.
Alternatively, sound files can be opened as `SoundFile` objects.

For further information, see https://python-soundfile.readthedocs.io/.

z0.14.0é    N)Ú	Generator)Úfind_library)ÚSEEK_CURÚSEEK_ENDÚSEEK_SET)ÚAnyÚBinaryIOÚFinalÚLiteralÚ	TypeAlias)ÚSelf)ÚffiÚFileDescriptorOrPath.Ú	AudioDataÚAudioData_2d)Úfloat64Úfloat32Úint32Úint16Ú	dtype_strÚ_sndÚ_ffié   é   é   é   é   é   é   é   é	   é   )
ÚtitleÚ	copyrightÚsoftwareÚartistÚcommentÚdateÚalbumÚlicenseÚtracknumberÚgenreÚ
_str_typesÚWAVi   ÚAIFFi   ÚAUi   ÚRAWi   ÚPAFi   ÚSVXi   ÚNISTi   ÚVOCi   ÚIRCAMi  
 ÚW64i   ÚMAT4i   ÚMAT5i   ÚPVFi   ÚXIi   ÚHTKi   ÚSDSi   ÚAVRi   i   i   i   i   i   i    i  ! i  " i  # )	ÚWAVEXÚSD2ÚFLACÚCAFÚWVEÚOGGÚMPC2KÚRF64ÚMP3Ú_formatsÚPCM_S8ÚPCM_16ÚPCM_24ÚPCM_32ÚPCM_U8ÚFLOATÚDOUBLEÚULAWÚALAWé   Ú	IMA_ADPCMé   ÚMS_ADPCMé   ÚGSM610é    Ú	VOX_ADPCMé!   ÚNMS_ADPCM_16é"   ÚNMS_ADPCM_24é#   ÚNMS_ADPCM_32é$   ÚG721_32é0   ÚG723_24é1   ÚG723_40é2   ÚDWVW_12é@   ÚDWVW_16éA   ÚDWVW_24éB   ÚDWVW_NéC   ÚDPCM_8éP   ÚDPCM_16éQ   ÚVORBISé`   ÚOPUSéd   ÚALAC_16ép   ÚALAC_20éq   ÚALAC_24ér   ÚALAC_32és   ÚMPEG_LAYER_Ié€   ÚMPEG_LAYER_IIé�   ÚMPEG_LAYER_IIIé‚   Ú	_subtypesi   i    i   0)ÚFILEÚLITTLEÚBIGÚCPUÚ_endiansr?   )r@   rA   rB   rC   rD   rE   rF   rG   Ú_default_subtypesÚdoubleÚfloatÚintÚshortÚ
_ffi_types)ÚCONSTANTÚAVERAGEÚVARIABLEÚ_bitrate_modesÚdarwin)ÚmachineÚlibsndfile_z.dylibÚwin32z	win-arm64zlibsndfile_arm64.dllz	win-amd64zlibsndfile_x64.dllzlibsndfile_x86.dllz no packaged library for Windows Úlinux)Úaarch64Ú
aarch64_beÚarmv8bÚarmv8lzlibsndfile_arm64.soz.soz%no packaged library for this platformÚsndfilez8sndfile library not found using ctypes.util.find_libraryzlibsndfile.dylibzlibsndfile.dllzlibsndfile.soÚarm64z/opt/homebrew/lib/z/usr/local/lib/úutf-8Úreplacezlibsndfile-ÚfileÚframesÚstartÚstopÚdtypeÚ	always_2dÚ
fill_valueÚoutÚ
samplerateÚchannelsÚformatÚsubtypeÚendianÚclosefdÚreturnc           
      ó¼   — t        | d||	|||
|«      5 }|j                  |||«      }|j                  |||||«      }ddd«       j                  fS # 1 sw Y   ŒxY w)a  Provide audio data from a sound file as NumPy array.

    By default, the whole file is read from the beginning, but the
    position to start reading can be specified with *start* and the
    number of frames to read can be specified with *frames*.
    Alternatively, a range can be specified with *start* and *stop*.

    If there is less data left in the file than requested, the rest of
    the frames are filled with *fill_value*.
    If no *fill_value* is specified, a smaller array is returned.

    Parameters
    ----------
    file : str or int or file-like object
        The file to read from.  See `SoundFile` for details.
    frames : int, optional
        The number of frames to read. If *frames* is negative, the whole
        rest of the file is read.  Not allowed if *stop* is given.
    start : int, optional
        Where to start reading.  A negative value counts from the end.
    stop : int, optional
        The index after the last frame to be read.  A negative value
        counts from the end.  Not allowed if *frames* is given.
    dtype : {'float64', 'float32', 'int32', 'int16'}, optional
        Data type of the returned array, by default ``'float64'``.
        Floating point audio data is typically in the range from
        ``-1.0`` to ``1.0``.  Integer data is in the range from
        ``-2**15`` to ``2**15-1`` for ``'int16'`` and from ``-2**31`` to
        ``2**31-1`` for ``'int32'``.

        .. note:: Reading int values from a float file will *not*
            scale the data to [-1.0, 1.0). If the file contains
            ``np.array([42.6], dtype='float32')``, you will read
            ``np.array([43], dtype='int32')`` for ``dtype='int32'``.

    Returns
    -------
    audiodata : `numpy.ndarray` or type(out)
        A two-dimensional (frames x channels) NumPy array is returned.
        If the sound file has only one channel, a one-dimensional array
        is returned.  Use ``always_2d=True`` to return a two-dimensional
        array anyway.

        If *out* was specified, it is returned.  If *out* has more
        frames than available in the file (or if *frames* is smaller
        than the length of *out*) and no *fill_value* is given, then
        only a part of *out* is overwritten and a view containing all
        valid frames is returned.
    samplerate : int
        The sample rate of the audio file.

    Other Parameters
    ----------------
    always_2d : bool, optional
        By default, reading a mono sound file will return a
        one-dimensional array.  With ``always_2d=True``, audio data is
        always returned as a two-dimensional array, even if the audio
        file has only one channel.
    fill_value : float, optional
        If more frames are requested than available in the file, the
        rest of the output is be filled with *fill_value*.  If
        *fill_value* is not specified, a smaller array is returned.
    out : `numpy.ndarray` or subclass, optional
        If *out* is specified, the data is written into the given array
        instead of creating a new array.  In this case, the arguments
        *dtype* and *always_2d* are silently ignored!  If *frames* is
        not given, it is obtained from the length of *out*.
    samplerate, channels, format, subtype, endian, closefd
        See `SoundFile`.

    Examples
    --------
    >>> import soundfile as sf
    >>> data, samplerate = sf.read('stereo_file.wav')
    >>> data
    array([[ 0.71329652,  0.06294799],
           [-0.26450912, -0.38874483],
           ...
           [ 0.67398441, -0.11516333]])
    >>> samplerate
    44100

    ÚrN)Ú	SoundFileÚ_prepare_readÚreadrª   )r¢   r£   r¤   r¥   r¦   r§   r¨   r©   rª   r«   r¬   r­   r®   r¯   ÚfÚdatas                   úL/root/repos/pocs/video-evals/.venv/lib/python3.12/site-packages/soundfile.pyrµ   rµ   á   ss   € ôp 
�4˜˜j¨(Ø˜F F¨Gó
5ð AØ89Ø—‘ ¨¨fÓ5ˆØ�v‰v�f˜e Y°
¸CÓ@ˆ÷Að �—‘ÐÐ÷	Að Aús   “)AÁAr·   Úcompression_levelÚbitrate_modec	                 óä   — ddl }	|	j                  |«      }|j                  dk(  rd}
n|j                  d   }
t	        | d||
||||||«
      5 }|j                  |«       ddd«       y# 1 sw Y   yxY w)a  Write data to a sound file.

    .. note:: If *file* exists, it will be truncated and overwritten!

    Parameters
    ----------
    file : str or int or file-like object
        The file to write to.  See `SoundFile` for details.
    data : array_like
        The data to write.  Usually two-dimensional (frames x channels),
        but one-dimensional *data* can be used for mono files.
        Only the data types ``'float64'``, ``'float32'``, ``'int32'``
        and ``'int16'`` are supported.

        .. note:: The data type of *data* does **not** select the data
                  type of the written file. Audio data will be
                  converted to the given *subtype*. Writing int values
                  to a float file will *not* scale the values to
                  [-1.0, 1.0). If you write the value ``np.array([42],
                  dtype='int32')``, to a ``subtype='FLOAT'`` file, the
                  file will then contain ``np.array([42.],
                  dtype='float32')``.

    samplerate : int
        The sample rate of the audio data.
    subtype : str, optional
        See `default_subtype()` for the default value and
        `available_subtypes()` for all possible values.

    Other Parameters
    ----------------
    format, endian, closefd, compression_level, bitrate_mode
        See `SoundFile`.

    Examples
    --------
    Write 10 frames of random data to a new file:

    >>> import numpy as np
    >>> import soundfile as sf
    >>> sf.write('stereo_file.wav', np.random.randn(10, 2), 44100, 'PCM_24')

    r   Nr   Úw)ÚnumpyÚasarrayÚndimÚshaper³   Úwrite)r¢   r·   rª   r­   r®   r¬   r¯   r¹   rº   Únpr«   r¶   s               r¸   rÁ   rÁ   A  st   € ó` Ø�:‰:�dÓ€DØ‡y�y�A‚~Ø‰à—:‘:˜a‘=ˆÜ	�4˜˜j¨(Ø˜F F¨GØ$ ló
4ð à78Ø	�‰�Œ÷÷ ñ ús   ÁA&Á&A/Ú	blocksizeÚoverlapc           
   #   óÂ   K  — t        | d|
|||||«      5 }|j                  |||«      }|j                  |||||||	«      E d{  –—†  ddd«       y7 Œ# 1 sw Y   yxY w­w)a8  Return a generator for block-wise reading.

    By default, iteration starts at the beginning and stops at the end
    of the file.  Use *start* to start at a later position and *frames*
    or *stop* to stop earlier.

    If you stop iterating over the generator before it's exhausted,
    the sound file is not closed. This is normally not a problem
    because the file is opened in read-only mode. To close the file
    properly, the generator's ``close()`` method can be called.

    Parameters
    ----------
    file : str or int or file-like object
        The file to read from.  See `SoundFile` for details.
    blocksize : int
        The number of frames to read per block.
        Either this or *out* must be given.
    overlap : int, optional
        The number of frames to rewind between each block.

    Yields
    ------
    `numpy.ndarray` or type(out)
        Blocks of audio data.
        If *out* was given, and the requested frames are not an integer
        multiple of the length of *out*, and no *fill_value* was given,
        the last block will be a smaller view into *out*.

    Other Parameters
    ----------------
    frames, start, stop
        See `read()`.
    dtype : {'float64', 'float32', 'int32', 'int16'}, optional
        See `read()`.
    always_2d, fill_value, out
        See `read()`.
    samplerate, channels, format, subtype, endian, closefd
        See `SoundFile`.

    Examples
    --------
    >>> import soundfile as sf
    >>> for block in sf.blocks('stereo_file.wav', blocksize=1024):
    >>>     pass  # do something with 'block'

    r²   N)r³   r´   Úblocks)r¢   rÃ   rÄ   r£   r¤   r¥   r¦   r§   r¨   r©   rª   r«   r¬   r­   r®   r¯   r¶   s                    r¸   rÆ   rÆ   |  s{   è ø€ ôn 
�4˜˜j¨(Ø˜F F¨Gó
5ð [Ø89Ø—‘ ¨¨fÓ5ˆØ—8‘8˜I w°¸¸yÈ*ÐVYÓZ×ZÐZ÷[ð [ð 	[ø÷[ð [üs.   ‚A•.AÁAÁAÁ	AÁAÁAÁAc                   ó,   — e Zd ZdZd„ Zed„ «       Zd„ Zy)Ú_SoundFileInfozInformation about a SoundFilec                 ó  — || _         t        |«      5 }|j                  | _        |j                  | _        |j                  | _        |j
                  | _        t        | j
                  «      |j                  z  | _        |j                  | _        |j                  | _	        |j                  | _
        |j                  | _        |j                  | _        |j                  | _        |j                  | _        d d d «       y # 1 sw Y   y xY w©N)Úverboser³   Únamerª   r«   r£   r�   Údurationr¬   r­   r®   Úformat_infoÚsubtype_infoÚsectionsÚ
extra_info)Úselfr¢   rË   r¶   s       r¸   Ú__init__z_SoundFileInfo.__init__¼  s»   € Ø$ˆŒÜ�t‹_ð 	0 Ø)*¯©ˆDŒIØ#$§<¡<ˆDŒOØ!"§¡ˆDŒMØ Ÿx™xˆDŒKÜ#(¨¯©Ó#5°a·l±lÑ#BˆDŒMØ Ÿx™xˆDŒKØ !§	¡	ˆDŒLØ Ÿx™xˆDŒKØ$%§M¡MˆDÔØ%&§^¡^ˆDÔØ!"§¡ˆDŒMØ#$§<¡<ˆDŒO÷	0÷ 	0ñ 	0ús   “C#C?Ã?Dc                 óÜ   — t        | j                  d«      \  }}t        |d«      \  }}|dk\  r|d›d|d›d|d›d�}|S |dk\  r|d›d|d›d	�}|S |dk  r| j                  d
›d�}|S |d›d�}|S )Ni  é<   r   z.0gú:z02.0gz05.3fz hz minÚdz samplesz.3fz s)ÚdivmodrÍ   r£   )rÒ   ÚhoursÚrestÚminutesÚsecondsrÍ   s         r¸   Ú_duration_strz_SoundFileInfo._duration_strÌ  s°   € ä˜TŸ]™]¨DÓ1‰ˆˆtÜ! $¨Ó+Ñˆ�Ø�AŠ:Ø ˜ A g¨e _°A°g¸e°_ÀBÐGˆHð ˆð ˜Š\Ø! %˜¨¨'°%¨¸Ð=ˆHð
 ˆð	 ˜Š\ØŸ+™+ a˜¨Ð1ˆHð ˆð " #˜ bÐ)ˆHØˆó    c                 óú  — dj                  | j                  › d| j                  › d�d| j                  › �d| j                  › �d| j
                  › d| j                  › d�d	| j                  › d| j                  › d�g«      }| j                  rnd
j                  | j                  j                  d«      «      }|dj                  d| j                  › �d| j                  › �d| j                  › �dd|› d�g«      z  }|S )Nú
zsamplerate: z Hzz
channels: z
duration: zformat: z [ú]z	subtype: z
    z	
endian: z
sections: zframes: zextra_info: """z    z""")ÚjoinrÌ   rª   r«   rÝ   rÎ   r¬   rÏ   r­   rË   rÑ   Úsplitr®   rÐ   r£   )rÒ   ÚinfoÚindented_extra_infos      r¸   Ú__repr__z_SoundFileInfo.__repr__Ú  s  € Ø�y‰yØ—	‘	ˆ{Ø˜DŸO™OÐ,¨CÐ0Ø˜$Ÿ-™-˜Ð)Ø˜$×,Ñ,Ð-Ð.Ø˜×(Ñ(Ð)¨¨D¯K©K¨=¸Ð:Ø˜×*Ñ*Ð+¨2¨d¯l©l¨^¸1Ð=ð?ó@ˆð �<Š<Ø#-×"3Ñ"3°D·O±O×4IÑ4IÈ$Ó4OÓ"PÐØ�D—I‘IØ˜dŸk™k˜]Ð+Ø˜dŸm™m˜_Ð-Ø˜DŸK™K˜=Ð)Ø"ØÐ+Ð,¨CÐ0ð	2ó3ñ 3ˆDð ˆrÞ   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rÓ   ÚpropertyrÝ   ræ   © rÞ   r¸   rÈ   rÈ   ¹  s#   „ Ù'ò0ð  ñó ðórÞ   rÈ   rË   c                 ó   — t        | |«      S )zŸReturns an object with information about a `SoundFile`.

    Parameters
    ----------
    verbose : bool
        Whether to print additional information.
    )rÈ   )r¢   rË   s     r¸   rä   rä   í  s   € ô ˜$ Ó(Ð(rÞ   c                  ód   — t        t        t        j                  t        j                  «      «      S )a©  Return a dictionary of available major formats.

    Examples
    --------
    >>> import soundfile as sf
    >>> sf.available_formats()
    {'FLAC': 'FLAC (FLAC Lossless Audio Codec)',
     'OGG': 'OGG (OGG Container format)',
     'WAV': 'WAV (Microsoft)',
     'AIFF': 'AIFF (Apple/SGI)',
     ...
     'WAVEX': 'WAVEX (Microsoft)',
     'RAW': 'RAW (header-less)',
     'MAT5': 'MAT5 (GNU Octave 2.1 / Matlab 5.0)'}

    )ÚdictÚ_available_formats_helperr   ÚSFC_GET_FORMAT_MAJOR_COUNTÚSFC_GET_FORMAT_MAJORrì   rÞ   r¸   Úavailable_formatsró   ø  s-   € ô" Ô)¬$×*IÑ*IÜ*.×*CÑ*CóEó Fð FrÞ   c                 ó¦   — t        t        j                  t        j                  «      }|D ��ci c]  \  }}| �t	        | |«      r||“Œ c}}S c c}}w )ad  Return a dictionary of available subtypes.

    Parameters
    ----------
    format : str
        If given, only compatible subtypes are returned.

    Examples
    --------
    >>> import soundfile as sf
    >>> sf.available_subtypes('FLAC')
    {'PCM_24': 'Signed 24 bit PCM',
     'PCM_16': 'Signed 16 bit PCM',
     'PCM_S8': 'Signed 8 bit PCM'}

    )rð   r   ÚSFC_GET_FORMAT_SUBTYPE_COUNTÚSFC_GET_FORMAT_SUBTYPEÚcheck_format)r¬   Úsubtypesr­   rÌ   s       r¸   Úavailable_subtypesrù     sY   € ô" )¬×)JÑ)JÜ)-×)DÑ)DóF€Hà/7÷ D™m˜g tØ�>¤\°&¸'Ô%Bð �T‰Mó Dð Dùó Ds   ®Ac                 óZ   — 	 t        t        | ||«      «      S # t        t        f$ r Y yw xY w)záCheck if the combination of format/subtype/endian is valid.

    Examples
    --------
    >>> import soundfile as sf
    >>> sf.check_format('WAV', 'PCM_24')
    True
    >>> sf.check_format('FLAC', 'VORBIS')
    False

    F)ÚboolÚ_format_intÚ
ValueErrorÚ	TypeError)r¬   r­   r®   s      r¸   r÷   r÷   $  s2   € ðÜ”K ¨°Ó8Ó9Ð9øÜœ	Ð"ò Ùðús   ‚ ˜*©*c                 ó^   — t        | «       t        j                  | j                  «       «      S )zÍReturn the default subtype for a given format.

    Examples
    --------
    >>> import soundfile as sf
    >>> sf.default_subtype('WAV')
    'PCM_16'
    >>> sf.default_subtype('MAT5')
    'DOUBLE'

    )Ú_check_formatr‹   ÚgetÚupper)r¬   s    r¸   Údefault_subtyper  7  s#   € ô �&ÔÜ× Ñ  §¡£Ó0Ð0rÞ   c                   ó&  — e Zd ZdZ	 	 	 	 	 	 dPdededz  dedz  dedz  dedz  dedz  d	edz  d
ededz  dedz  ddfd„Z	 e
d„ «      Z	  e
d„ «      Z	  e
d„ «      Z	  e
d„ «      Z	  e
d„ «      Z	  e
d„ «      Z	  e
d„ «      Z	  e
d„ «      Z	  e
d„ «      Z	  e
d„ «      Z	  e
d„ «      Z	  e
d„ «      Z	  e
d„ «      Z	  e
d„ «      Z	  e
d„ «      Z	 e
d„ «       ZdZdefd„ZdQd „Zdefd!„Zd"e ddfd#„Z!d$ed%e ddfd&„Z"d$ede fd'„Z#defd(„Z$defd)„Z%defd*„Z&defd+„Z'e(fd,ed-edefd.„Z)defd/„Z*	 	 	 dRd,ed0e+d1ed2edz  d3e,e-z  dz  de,e-z  fd4„Z.dSd,ed0e+dz  de/fd5„Z0d6e1e/z  e z  d0e+defd7„Z2d8e,ddfd9„Z3d8e4d0e+ddfd:„Z5	 	 	 	 dTd;edz  d<ed,ed0e+d1ed2edz  d3e,e-z  dz  de6e,ddf   e6e-ddf   z  fd=„Z7dUd,edz  ddfd>„Z8dQd?„Z9dQd@„Z: e;jx                  «       Z=dA„ Z>dB„ Z?dC„ Z@dD„ ZAdE„ ZBdF„ ZCdG„ ZDdH„ ZEdI„ ZFdJ„ ZGdK„ ZHdL„ ZIdeJeef   fdM„ZKdN„ ZLdO„ ZMy)Vr³   z­A sound file.

    For more documentation see the __init__() docstring (which is also
    used for the online documentation (https://python-soundfile.readthedocs.io/).

    Nr¢   Úmoderª   r«   r­   r®   r¬   r¯   r¹   rº   r°   c           	      óò  — t        |t        j                  «      rt        j                  |«      }|| _        |€t        |dd«      }|€t        d«      ‚t        |«      }|| _        |	| _	        |
| _
        t        |||||||«      | _        | j                  |||«      | _        t        |«      j!                  d«      r!| j#                  «       r| j%                  d«       t&        j)                  | j                  t&        j*                  t,        j.                  t&        j0                  «       | j                  �D| j3                  | j                  «       | j                  �| j5                  | j                  «       yyy)að  Open a sound file.

        If a file is opened with `mode` ``'r'`` (the default) or
        ``'r+'``, no sample rate, channels or file format need to be
        given because the information is obtained from the file. An
        exception is the ``'RAW'`` data format, which always requires
        these data points.

        File formats consist of three case-insensitive strings:

        * a *major format* which is by default obtained from the
          extension of the file name (if known) and which can be
          forced with the format argument (e.g. ``format='WAVEX'``).
        * a *subtype*, e.g. ``'PCM_24'``. Most major formats have a
          default subtype which is used if no subtype is specified.
        * an *endian-ness*, which doesn't have to be specified at all in
          most cases.

        A `SoundFile` object is a *context manager*, which means
        if used in a "with" statement, `close()` is automatically
        called when reaching the end of the code block inside the "with"
        statement.

        Parameters
        ----------
        file : str or int or file-like object
            The file to open.  This can be a file name, a file
            descriptor or a Python file object (or a similar object with
            the methods ``read()``/``readinto()``, ``write()``,
            ``seek()`` and ``tell()``).
        mode : {'r', 'r+', 'w', 'w+', 'x', 'x+'}, optional
            Open mode.  Has to begin with one of these three characters:
            ``'r'`` for reading, ``'w'`` for writing (truncates *file*)
            or ``'x'`` for writing (raises an error if *file* already
            exists).  Additionally, it may contain ``'+'`` to open
            *file* for both reading and writing.
            The character ``'b'`` for *binary mode* is implied because
            all sound files have to be opened in this mode.
            If *file* is a file descriptor or a file-like object,
            ``'w'`` doesn't truncate and ``'x'`` doesn't raise an error.
        samplerate : int
            The sample rate of the file.  If `mode` contains ``'r'``,
            this is obtained from the file (except for ``'RAW'`` files).
        channels : int
            The number of channels of the file.
            If `mode` contains ``'r'``, this is obtained from the file
            (except for ``'RAW'`` files).
        subtype : str, sometimes optional
            The subtype of the sound file.  If `mode` contains ``'r'``,
            this is obtained from the file (except for ``'RAW'``
            files), if not, the default value depends on the selected
            `format` (see `default_subtype()`).
            See `available_subtypes()` for all possible subtypes for
            a given `format`.
        endian : {'FILE', 'LITTLE', 'BIG', 'CPU'}, sometimes optional
            The endian-ness of the sound file.  If `mode` contains
            ``'r'``, this is obtained from the file (except for
            ``'RAW'`` files), if not, the default value is ``'FILE'``,
            which is correct in most cases.
        format : str, sometimes optional
            The major format of the sound file.  If `mode` contains
            ``'r'``, this is obtained from the file (except for
            ``'RAW'`` files), if not, the default value is determined
            from the file extension.  See `available_formats()` for
            all possible values.
        closefd : bool, optional
            Whether to close the file descriptor on `close()`. Only
            applicable if the *file* argument is a file descriptor.
        compression_level : float, optional
            The compression level on 'write()'. The compression level
            should be between 0.0 (minimum compression level) and 1.0
            (highest compression level).
            See `libsndfile document <https://github.com/libsndfile/libsndfile/blob/c81375f070f3c6764969a738eacded64f53a076e/docs/command.md>`__.
        bitrate_mode : {'CONSTANT', 'AVERAGE', 'VARIABLE'}, optional
            The bitrate mode on 'write()'.
            See `libsndfile document <https://github.com/libsndfile/libsndfile/blob/c81375f070f3c6764969a738eacded64f53a076e/docs/command.md>`__.

        Examples
        --------
        >>> from soundfile import SoundFile

        Open an existing file for reading:

        >>> myfile = SoundFile('existing_file.wav')
        >>> # do something with myfile
        >>> myfile.close()

        Create a new sound file for reading and writing using a with
        statement:

        >>> with SoundFile('new_file.wav', 'x+', 44100, 2) as myfile:
        >>>     # do something with myfile
        >>>     # ...
        >>>     assert not myfile.closed
        >>>     # myfile.close() is called automatically at the end
        >>> assert myfile.closed

        Nr  z6Can not get `mode` from file. provided `mode` is None.zr+r   )Ú
isinstanceÚ_osÚPathLikeÚfspathÚ_nameÚgetattrrþ   Ú_check_modeÚ_modeÚ_compression_levelÚ_bitrate_modeÚ_create_info_structÚ_infoÚ_openÚ_fileÚsetÚ
issupersetÚseekableÚseekr   Ú
sf_commandÚSFC_SET_CLIPPINGr   ÚNULLÚSF_TRUEÚ_set_compression_levelÚ_set_bitrate_mode)rÒ   r¢   r  rª   r«   r­   r®   r¬   r¯   r¹   rº   Úmode_ints               r¸   rÓ   zSoundFile.__init__O  s5  € ôP �dœCŸL™LÔ)Ü—:‘:˜dÓ#ˆDØˆŒ
Øˆ<Ü˜4 ¨Ó.ˆDØˆ|ÜÐ XÓYÐYÜ˜tÓ$ˆØˆŒ
Ø"3ˆÔØ)ˆÔÜ(¨¨t°ZÀØ)/°¸&óBˆŒ
à—Z‘Z  h°Ó8ˆŒ
Üˆt‹9×Ñ Ô%¨$¯-©-¬/à�I‰I�aŒLÜ�‰˜Ÿ
™
¤D×$9Ñ$9¼4¿9¹9ÜŸ™ô	&ð ×"Ñ"Ð.à×'Ñ'¨×(?Ñ(?Ô@Ø×!Ñ!Ð-Ø×&Ñ& t×'9Ñ'9Õ:ð .ð /rÞ   c                 ó   — | j                   S rÊ   )r  ©rÒ   s    r¸   ú<lambda>zSoundFile.<lambda>Ò  ó
   €  §¡€ rÞ   c                 ó   — | j                   S rÊ   )r  r!  s    r¸   r"  zSoundFile.<lambda>Ô  r#  rÞ   c                 ó.   — | j                   j                  S rÊ   )r  rª   r!  s    r¸   r"  zSoundFile.<lambda>Ö  s   €  t§z¡z×'<Ñ'<€ rÞ   c                 ó.   — | j                   j                  S rÊ   ©r  r£   r!  s    r¸   r"  zSoundFile.<lambda>Ø  s   €  4§:¡:×#4Ñ#4€ rÞ   c                 ó.   — | j                   j                  S rÊ   )r  r«   r!  s    r¸   r"  zSoundFile.<lambda>Ú  ó   €  T§Z¡Z×%8Ñ%8€ rÞ   c                 ób   — t        | j                  j                  t        j                  z  «      S rÊ   )Ú_format_strr  r¬   r   ÚSF_FORMAT_TYPEMASKr!  s    r¸   r"  zSoundFile.<lambda>Ý  s    € ”[ §¡×!2Ñ!2´T×5LÑ5LÑ!LÓM€ rÞ   c                 ób   — t        | j                  j                  t        j                  z  «      S rÊ   )r+  r  r¬   r   ÚSF_FORMAT_SUBMASKr!  s    r¸   r"  zSoundFile.<lambda>à  ó    € ”[ §¡×!2Ñ!2´T×5KÑ5KÑ!KÓL€ rÞ   c                 ób   — t        | j                  j                  t        j                  z  «      S rÊ   )r+  r  r¬   r   ÚSF_FORMAT_ENDMASKr!  s    r¸   r"  zSoundFile.<lambda>ã  r/  rÞ   c                 óh   — t        | j                  j                  t        j                  z  «      d   S ©Nr   )Ú_format_infor  r¬   r   r,  r!  s    r¸   r"  zSoundFile.<lambda>æ  s-   € ”\ $§*¡*×"3Ñ"3Ü"&×"9Ñ"9ñ#:ó ;Ø;<ñ>€ rÞ   c                 óh   — t        | j                  j                  t        j                  z  «      d   S r3  )r4  r  r¬   r   r.  r!  s    r¸   r"  zSoundFile.<lambda>ê  s-   € ”\ $§*¡*×"3Ñ"3Ü"&×"8Ñ"8ñ#9ó :Ø:;ñ=€ rÞ   c                 ó.   — | j                   j                  S rÊ   )r  rÐ   r!  s    r¸   r"  zSoundFile.<lambda>í  r)  rÞ   c                 ó   — | j                   d u S rÊ   )r  r!  s    r¸   r"  zSoundFile.<lambda>ï  s   €  4§:¡:°Ð#5€ rÞ   c                 ó@   — t         j                  | j                  «      S rÊ   )r   Úsf_errorr  r!  s    r¸   r"  zSoundFile.<lambda>ñ  s   € ¤t§}¡}°T·Z±ZÓ'@€ rÞ   c                 ó   — | j                   S rÊ   )r  r!  s    r¸   r"  zSoundFile.<lambda>ó  s   € ¨d×.EÑ.E€ rÞ   c                 ó   — | j                   S rÊ   )r  r!  s    r¸   r"  zSoundFile.<lambda>õ  s   € ¨×);Ñ);€ rÞ   c                 óþ   — t        j                  dd«      }t        j                  | j                  t        j
                  |t        j                  |«      «       t        j                  |«      j                  dd«      S )z8Retrieve the log string generated when opening the file.zchar[]i @  r    r¡   )	r   Únewr   r  r  ÚSFC_GET_LOG_INFOÚsizeofÚstringÚdecode)rÒ   rä   s     r¸   rÑ   zSoundFile.extra_infoø  sX   € ô �x‰x˜ %Ó(ˆÜ�‰˜Ÿ
™
¤D×$9Ñ$9ØœdŸk™k¨$Ó/ô	1ä�{‰{˜4Ó ×'Ñ'¨°Ó;Ð;rÞ   c                 ó>  — | j                   �d| j                   › �nd}|| j                  �d| j                  › d�ndz  }d| j                  ›d| j                  ›d| j                  › d| j
                  › d	| j                  ›d
| j                  ›d| j                  ›|› d�S )Nz, compression_level=Ú z, bitrate_mode='ú'z
SoundFile(z, mode=z, samplerate=z, channels=z	, format=z
, subtype=z	, endian=ú))	r¹   rº   rÌ   r  rª   r«   r¬   r­   r®   )rÒ   Úcompression_settings     r¸   ræ   zSoundFile.__repr__  sÄ   € à"&×"8Ñ"8Ð"Dð "6°d×6LÑ6LÐ5MÑNØJLð 	àØ#'×#4Ñ#4Ð#@ð #3°4×3DÑ3DÐ2EÀQÑ GØFHñ	JÐà˜TŸY™Y˜M¨°·±°ð >Ø"Ÿo™oÐ.¨k¸$¿-¹-¸ð IØŸ+™+˜¨
°4·<±<Ð2Bð CØŸ+™+˜Ð)<Ð(=¸Qð@ð 	ArÞ   c                 ó$   — | j                  «        y rÊ   ©Úcloser!  s    r¸   Ú__del__zSoundFile.__del__  ó   € Ø�
‰
�rÞ   c                 ó   — | S rÊ   rì   r!  s    r¸   Ú	__enter__zSoundFile.__enter__  s   € ØˆrÞ   Úargsc                 ó$   — | j                  «        y rÊ   rH  )rÒ   rN  s     r¸   Ú__exit__zSoundFile.__exit__  rK  rÞ   rÌ   Úvaluec                 óæ   — |t         v rR| j                  «        t        j                  | j                  t         |   |j                  «       «      }t        |«       yt        j                  | ||«       y)z:Write text meta-data in the sound file through properties.N)	r-   Ú_check_if_closedr   Úsf_set_stringr  ÚencodeÚ_error_checkÚobjectÚ__setattr__)rÒ   rÌ   rQ  Úerrs       r¸   rX  zSoundFile.__setattr__  sV   € à”:ÑØ×!Ñ!Ô#Ü×$Ñ$ T§Z¡Z´¸DÑ1AØ%*§\¡\£^ó5ˆCä˜Õä×Ñ˜t T¨5Õ1rÞ   c                 óî   — |t         v r`| j                  «        t        j                  | j                  t         |   «      }|r%t        j                  |«      j                  dd«      S dS t        d|›�«      ‚)z9Read text meta-data in the sound file through properties.r    r¡   rC  z$'SoundFile' object has no attribute )	r-   rS  r   Úsf_get_stringr  r   r@  rA  ÚAttributeError)rÒ   rÌ   r·   s      r¸   Ú__getattr__zSoundFile.__getattr__   sm   € à”:ÑØ×!Ñ!Ô#Ü×%Ñ% d§j¡j´*¸TÑ2BÓCˆDÙCG”4—;‘;˜tÓ$×+Ñ+¨G°YÓ?ÐOÈRÐOä Ø6°t°hÐ?óAð ArÞ   c                 ó.   — | j                   j                  S rÊ   r'  r!  s    r¸   Ú__len__zSoundFile.__len__*  s   € ð �z‰z× Ñ Ð rÞ   c                  ó   — y)NTrì   r!  s    r¸   Ú__bool__zSoundFile.__bool__/  s   € ð rÞ   c                 ó"   — | j                  «       S rÊ   )ra  r!  s    r¸   Ú__nonzero__zSoundFile.__nonzero__4  s   € ð �}‰}‹ÐrÞ   c                 óP   — | j                   j                  t        j                  k(  S )z)Return True if the file supports seeking.)r  r  r   r  r!  s    r¸   r  zSoundFile.seekable9  s   € à�z‰z×"Ñ"¤d§l¡lÑ2Ð2rÞ   r£   Úwhencec                 ó’   — | j                  «        t        j                  | j                  ||«      }t	        | j
                  «       |S )aÜ  Set the read/write position.

        Parameters
        ----------
        frames : int
            The frame index or offset to seek.
        whence : {SEEK_SET, SEEK_CUR, SEEK_END}, optional
            By default (``whence=SEEK_SET``), *frames* are counted from
            the beginning of the file.
            ``whence=SEEK_CUR`` seeks from the current position
            (positive and negative values are allowed for *frames*).
            ``whence=SEEK_END`` seeks from the end (use negative value
            for *frames*).

        Returns
        -------
        int
            The new absolute read/write position in frames.

        Examples
        --------
        >>> from soundfile import SoundFile, SEEK_END
        >>> myfile = SoundFile('stereo_file.wav')

        Seek to the beginning of the file:

        >>> myfile.seek(0)
        0

        Seek to the end of the file:

        >>> myfile.seek(0, SEEK_END)
        44100  # this is the file length

        )rS  r   Úsf_seekr  rV  Ú
_errorcode)rÒ   r£   re  Úpositions       r¸   r  zSoundFile.seek=  s8   € ðH 	×ÑÔÜ—<‘< §
¡
¨F°FÓ;ˆÜ�T—_‘_Ô%ØˆrÞ   c                 ó.   — | j                  dt        «      S )z'Return the current read/write position.r   )r  r   r!  s    r¸   ÚtellzSoundFile.tellf  s   € à�y‰y˜œHÓ%Ð%rÞ   r¦   r§   r¨   r©   c                 óð   — |€&| j                  ||«      }| j                  |||«      }n|dk  s|t        |«      kD  rt        |«      }| j                  d||«      }t        |«      |kD  r|€|d| }|S |||d |S )a  Read from the file and return data as NumPy array.

        Reads the given number of frames in the given data format
        starting at the current read/write position.  This advances the
        read/write position by the same number of frames.
        By default, all frames from the current read/write position to
        the end of the file are returned.
        Use `seek()` to move the current read/write position.

        Parameters
        ----------
        frames : int, optional
            The number of frames to read. If ``frames < 0``, the whole
            rest of the file is read.
        dtype : {'float64', 'float32', 'int32', 'int16'}, optional
            Data type of the returned array, by default ``'float64'``.
            Floating point audio data is typically in the range from
            ``-1.0`` to ``1.0``. Integer data is in the range from
            ``-2**15`` to ``2**15-1`` for ``'int16'`` and from
            ``-2**31`` to ``2**31-1`` for ``'int32'``.

            .. note:: Reading int values from a float file will *not*
                scale the data to [-1.0, 1.0). If the file contains
                ``np.array([42.6], dtype='float32')``, you will read
                ``np.array([43], dtype='int32')`` for
                ``dtype='int32'``.

        Returns
        -------
        audiodata : `numpy.ndarray` or type(out)
            A two-dimensional NumPy (frames x channels) array is
            returned. If the sound file has only one channel, a
            one-dimensional array is returned. Use ``always_2d=True``
            to return a two-dimensional array anyway.

            If *out* was specified, it is returned. If *out* has more
            frames than available in the file (or if *frames* is
            smaller than the length of *out*) and no *fill_value* is
            given, then only a part of *out* is overwritten and a view
            containing all valid frames is returned.

        Other Parameters
        ----------------
        always_2d : bool, optional
            By default, reading a mono sound file will return a
            one-dimensional array. With ``always_2d=True``, audio data
            is always returned as a two-dimensional array, even if the
            audio file has only one channel.
        fill_value : float, optional
            If more frames are requested than available in the file,
            the rest of the output is be filled with *fill_value*. If
            *fill_value* is not specified, a smaller array is
            returned.
        out : `numpy.ndarray` or subclass, optional
            If *out* is specified, the data is written into the given
            array instead of creating a new array. In this case, the
            arguments *dtype* and *always_2d* are silently ignored! If
            *frames* is not given, it is obtained from the length of
            *out*.

        Examples
        --------
        >>> from soundfile import SoundFile
        >>> myfile = SoundFile('stereo_file.wav')

        Reading 3 frames from a stereo file:

        >>> myfile.read(3)
        array([[ 0.71329652,  0.06294799],
               [-0.26450912, -0.38874483],
               [ 0.67398441, -0.11516333]])
        >>> myfile.close()

        See Also
        --------
        buffer_read, .write

        Nr   rµ   )Ú_check_framesÚ_create_empty_arrayÚlenÚ	_array_io)rÒ   r£   r¦   r§   r¨   r©   s         r¸   rµ   zSoundFile.readk  s“   € ðb ˆ;Ø×'Ñ'¨°
Ó;ˆFØ×*Ñ*¨6°9¸eÓD‰Cà˜Šz˜V¤c¨#£hÒ.Ü˜S›�Ø—‘ ¨¨VÓ4ˆÜˆs‹8�fÒØÐ!Ø˜'˜6�l�ð ˆ
ð  *��F�G�Øˆ
rÞ   c                 óö   — | j                  |d¬«      }| j                  |«      }t        j                  |dz   || j                  z  «      }| j                  d|||«      }||k(  sJ ‚t        j                  |«      S )a‘  Read from the file and return data as buffer object.

        Reads the given number of *frames* in the given data format
        starting at the current read/write position.  This advances the
        read/write position by the same number of frames.
        By default, all frames from the current read/write position to
        the end of the file are returned.
        Use `seek()` to move the current read/write position.

        Parameters
        ----------
        frames : int, optional
            The number of frames to read. If ``frames < 0``, the whole
            rest of the file is read.
        dtype : {'float64', 'float32', 'int32', 'int16'}
            Audio data will be converted to the given data type.

        Returns
        -------
        buffer
            A buffer containing the read data.

        See Also
        --------
        buffer_read_into, .read, buffer_write

        N)r¨   z[]rµ   )rm  Ú_check_dtyper   r=  r«   Ú	_cdata_ioÚbuffer)rÒ   r£   r¦   ÚctypeÚcdataÚread_framess         r¸   Úbuffer_readzSoundFile.buffer_readË  sw   € ð8 ×#Ñ# F°tÐ#Ó<ˆØ×!Ñ! %Ó(ˆÜ—‘˜ ™ v°·±Ñ'=Ó>ˆØ—n‘n V¨U°E¸6ÓBˆØ˜fÒ$Ð$Ð$Ü�{‰{˜5Ó!Ð!rÞ   rt  c                 óz   — | j                  |«      }| j                  ||«      \  }}| j                  d|||«      }|S )a�  Read from the file into a given buffer object.

        Fills the given *buffer* with frames in the given data format
        starting at the current read/write position (which can be
        changed with `seek()`) until the buffer is full or the end
        of the file is reached.  This advances the read/write position
        by the number of frames that were read.

        Parameters
        ----------
        buffer : writable buffer
            Audio frames from the file are written to this buffer.
        dtype : {'float64', 'float32', 'int32', 'int16'}
            The data type of *buffer*.

        Returns
        -------
        int
            The number of frames that were read from the file.
            This can be less than the size of *buffer*.
            The rest of the buffer is not filled with meaningful data.

        See Also
        --------
        buffer_read, .read

        rµ   )rr  Ú_check_bufferrs  )rÒ   rt  r¦   ru  rv  r£   s         r¸   Úbuffer_read_intozSoundFile.buffer_read_intoî  sC   € ð8 ×!Ñ! %Ó(ˆØ×*Ñ*¨6°5Ó9‰ˆˆvØ—‘ ¨¨u°fÓ=ˆØˆrÞ   r·   c                 ó¨   — ddl }|j                  |«      }| j                  d|t        |«      «      }|t        |«      k(  sJ ‚| j	                  |«       y)aø  Write audio data from a NumPy array to the file.

        Writes a number of frames at the read/write position to the
        file. This also advances the read/write position by the same
        number of frames and enlarges the file if necessary.

        Note that writing int values to a float file will *not* scale
        the values to [-1.0, 1.0). If you write the value
        ``np.array([42], dtype='int32')``, to a ``subtype='FLOAT'``
        file, the file will then contain ``np.array([42.],
        dtype='float32')``.

        Parameters
        ----------
        data : array_like
            The data to write. Usually two-dimensional (frames x
            channels), but one-dimensional *data* can be used for mono
            files. Only the data types ``'float64'``, ``'float32'``,
            ``'int32'`` and ``'int16'`` are supported.

            .. note:: The data type of *data* does **not** select the
                  data type of the written file. Audio data will be
                  converted to the given *subtype*. Writing int values
                  to a float file will *not* scale the values to
                  [-1.0, 1.0). If you write the value ``np.array([42],
                  dtype='int32')``, to a ``subtype='FLOAT'`` file, the
                  file will then contain ``np.array([42.],
                  dtype='float32')``.

        Examples
        --------
        >>> import numpy as np
        >>> from soundfile import SoundFile
        >>> myfile = SoundFile('stereo_file.wav')

        Write 10 frames of random data to a new file:

        >>> with SoundFile('stereo_file.wav', 'w', 44100, 2, 'PCM_24') as f:
        >>>     f.write(np.random.randn(10, 2))

        See Also
        --------
        buffer_write, .read

        r   NrÁ   )r½   Úascontiguousarrayrp  ro  Ú_update_frames)rÒ   r·   rÂ   Úwrittens       r¸   rÁ   zSoundFile.write  sP   € ó\ 	ð ×#Ñ# DÓ)ˆØ—.‘. ¨$´°D³	Ó:ˆØœ#˜d›)Ò#Ð#Ð#Ø×Ñ˜GÕ$rÞ   c                 ó¨   — | j                  |«      }| j                  ||«      \  }}| j                  d|||«      }||k(  sJ ‚| j                  |«       y)a€  Write audio data from a buffer/bytes object to the file.

        Writes the contents of *data* to the file at the current
        read/write position.
        This also advances the read/write position by the number of
        frames that were written and enlarges the file if necessary.

        Parameters
        ----------
        data : buffer or bytes
            A buffer or bytes object containing the audio data to be
            written.
        dtype : {'float64', 'float32', 'int32', 'int16'}
            The data type of the audio data stored in *data*.

        See Also
        --------
        .write, buffer_read

        rÁ   N)rr  rz  rs  r~  )rÒ   r·   r¦   ru  rv  r£   r  s          r¸   Úbuffer_writezSoundFile.buffer_writeE  sZ   € ð* ×!Ñ! %Ó(ˆØ×*Ñ*¨4°Ó7‰ˆˆvØ—.‘. ¨%°¸Ó?ˆØ˜&Ò Ð Ð Ø×Ñ˜GÕ$rÞ   rÃ   rÄ   c           	   #   ó`  K  — ddl }d| j                  vrd| j                  vrt        d«      ‚| j                  ||«      }|€3|€t	        d«      ‚|�|nt        ||«      }	| j                  |	||«      }d}
n|�t	        d«      ‚t        |«      }d	}
d}|dkD  r—|€d}nt        |«      }||d| t        ||z
  |«      }| j                  ||||||d «       |r!|€|j                  || d «      }n	|| d |dd |||z   kD  r|€	|d||z    }n|}|
r|j                  |«      n|–— ||z  }|dkD  rŒ–yy­w)
aÆ  Return a generator for block-wise reading.

        By default, the generator yields blocks of the given
        *blocksize* (using a given *overlap*) until the end of the file
        is reached; *frames* can be used to stop earlier.

        Parameters
        ----------
        blocksize : int
            The number of frames to read per block. Either this or *out*
            must be given.
        overlap : int, optional
            The number of frames to rewind between each block.
        frames : int, optional
            The number of frames to read.
            If ``frames < 0``, the file is read until the end.
        dtype : {'float64', 'float32', 'int32', 'int16'}, optional
            See `read()`.

        Yields
        ------
        `numpy.ndarray` or type(out)
            Blocks of audio data.
            If *out* was given, and the requested frames are not an
            integer multiple of the length of *out*, and no
            *fill_value* was given, the last block will be a smaller
            view into *out*.


        Other Parameters
        ----------------
        always_2d, fill_value, out
            See `read()`.
        fill_value : float, optional
            See `read()`.
        out : `numpy.ndarray` or subclass, optional
            If *out* is specified, the data is written into the given
            array instead of creating a new array. In this case, the
            arguments *dtype* and *always_2d* are silently ignored!

        Examples
        --------
        >>> from soundfile import SoundFile
        >>> with SoundFile('stereo_file.wav') as f:
        >>>     for block in f.blocks(blocksize=1024):
        >>>         pass  # do something with 'block'

        r   Nr²   ú+z*blocks() is not allowed in write-only modez)One of {blocksize, out} must be specifiedTz-Only one of {blocksize, out} may be specifiedF)
r½   r  ÚSoundFileRuntimeErrorrm  rþ   Úminrn  ro  rµ   Úcopy)rÒ   rÃ   rÄ   r£   r¦   r§   r¨   r©   rÂ   Úout_sizeÚcopy_outÚoverlap_memoryÚoutput_offsetÚtoreadÚblocks                  r¸   rÆ   zSoundFile.blocks`  s‚  è ø€ óh 	à�d—i‘iÑ C¨t¯y©yÑ$8Ü'Ð(TÓUÐUà×#Ñ# F¨JÓ7ˆØˆ;ØÐ ÜÐ KÓLÐLØ$.Ð$:‘yÄÀIÈvÓ@VˆHØ×*Ñ*¨8°YÀÓFˆCØ‰HàÐ$ÜØCóEð Eä˜C›ˆIØˆHàˆØ�qŠjØÐ%Ø !‘ä # NÓ 3�Ø&4��N�]Ð#ä˜ ]Ñ2°FÓ;ˆFØ�I‰I�f˜e Y°
¸CÀÀÐ<OÔPáØ!Ð)Ø%'§W¡W¨S°'°°¨^Ó%<‘Nà(+¨W¨H¨I¨�N¡1Ð%à˜6 GÑ+Ò+°
Ð0BØÐ-˜V gÑ-Ð.‘à�Ù$,�"—'‘'˜%”.°%Ò7Ø�fÑˆFð+ �q�jùs   ‚D)D.Ä,D.c                 óR  — |€| j                  «       }t        j                  | j                  t        j                  t        j                  d|«      t        j                  d«      «      }|r+t        j                  | j                  «      }t        |d«      ‚|| j                  _        y)an  Truncate the file to a given number of frames.

        After this command, the read/write position will be at the new
        end of the file.

        Parameters
        ----------
        frames : int, optional
            Only the data before *frames* is kept, the rest is deleted.
            If not specified, the current read/write position is used.

        Nzsf_count_t*Ú
sf_count_tzError truncating the file)rk  r   r  r  ÚSFC_FILE_TRUNCATEr   r=  r?  r9  ÚLibsndfileErrorr  r£   )rÒ   r£   rY  s      r¸   ÚtruncatezSoundFile.truncate¿  s{   € ð ˆ>Ø—Y‘Y“[ˆFÜ�o‰o˜dŸj™j¬$×*@Ñ*@Ü"Ÿh™h }°fÓ=Ü"Ÿk™k¨,Ó7ó9ˆñ ä—-‘- §
¡
Ó+ˆCÜ! #Ð'BÓCÐCØ"ˆ�
‰
ÕrÞ   c                 ób   — | j                  «        t        j                  | j                  «       y)aj  Write unwritten data to the file system.

        Data written with `write()` is not immediately written to
        the file system but buffered in memory to be written at a later
        time.  Calling `flush()` makes sure that all changes are
        actually written to the file system.

        This has no effect on files opened in read-only mode.

        N)rS  r   Úsf_write_syncr  r!  s    r¸   ÚflushzSoundFile.flush×  s"   € ð 	×ÑÔÜ×Ñ˜4Ÿ:™:Õ&rÞ   c                 ó    — | j                   sB| j                  «        t        j                  | j                  «      }d| _        t        |«       yy)z.Close the file.  Can be called multiple times.N)Úclosedr”  r   Úsf_closer  rV  )rÒ   rY  s     r¸   rI  zSoundFile.closeå  s8   € à�{Š{à�J‰JŒLÜ—-‘- §
¡
Ó+ˆCØˆDŒJÜ˜Õð rÞ   c                 ó$  ‡ ‡— t        |t        t        f«      �rt        j                  j                  |«      r’d‰ j                  v rt        d‰ j                  ›�«      ‚t        ‰ j                  «      j                  d«      rHt        j                  t        j                  |t        j                  t        j                  z  «      «       t        j                   }t        |t        «      rˆt"        j$                  dk(  rt        j&                  }nd|j)                  t#        j*                  «       «      }n@t        |t,        «      rˆfd„}n*t/        ||«      rˆ fd„}nt1        d‰ j                  ›�«      ‚‰ j2                  5   |||‰ j4                  «      }|t6        j8                  k(  r0t        j;                  |«      }t=        |d‰ j                  ›d	�¬
«      ‚	 ddd«       |t        j>                  k(  rd‰ j4                  _         S # 1 sw Y   Œ/xY w)z9Call the appropriate sf_open*() function from libsndfile.ÚxzFile exists: zw+r˜   c                 ó4   •— t         j                  | ||‰«      S rÊ   )r   Ú
sf_open_fd)r¢   r  rä   r¯   s      €r¸   r"  z!SoundFile._open.<locals>.<lambda>  s   ø€ ¼¿¹ÈÈhÐX\Ð^eÓ8f€ rÞ   c                 ón   •— t         j                  ‰j                  | «      ||t        j                  «      S rÊ   )r   Úsf_open_virtualÚ_init_virtual_ior   r  )r¢   r  rä   rÒ   s      €r¸   r"  z!SoundFile._open.<locals>.<lambda>  s,   ø€ ¼×8LÑ8LÈT×MbÑMbÐcgÓMhØ,4°d¼D¿I¹Ió9G€ rÞ   zInvalid file: zError opening z: ©ÚprefixNr   )!r  ÚstrÚbytesr  ÚpathÚisfiler  ÚOSErrorrÌ   r  r  rI  ÚopenÚO_WRONLYÚO_TRUNCr   Úsf_openÚ_sysÚplatformÚsf_wchar_openrU  ÚgetfilesystemencodingrŽ   Ú_has_virtual_io_attrsrþ   Ú_sf_error_lockr  r   r  r9  r�  Ú	SFM_WRITEr£   )rÒ   r¢   r  r¯   ÚopenfunctionÚfile_ptrrY  s   `  `   r¸   r  zSoundFile._openõ  s‡  ù€ ä�dœS¤%˜LÕ)Ü�x‰x�‰˜tÔ$Ø˜$Ÿ)™)Ñ#Ü! M°$·)±)°Ð"?Ó@Ð@Ü˜Ÿ™“^×.Ñ.¨tÔ4ä—I‘IœcŸh™h t¬S¯\©\¼C¿K¹KÑ-GÓHÔIÜŸ<™<ˆLÜ˜$¤Ô$Ü—=‘= GÒ+Ü#'×#5Ñ#5‘LàŸ;™;¤t×'AÑ'AÓ'CÓD‘DÜ˜œcÔ"Ûf‰LÜ" 4¨Ô2óG‰Lô ˜n¨T¯Y©Y¨MÐ:Ó;Ð;à× Ñ ñ 	TÙ# D¨(°D·J±JÓ?ˆHØœ4Ÿ9™9Ò$Ü—m‘m HÓ-�Ü% c°NÀ4Ç9Á9À-ÈrÐ2RÔSÐSð %÷	Tð
 ”t—~‘~Ò%ð !"ˆD�J‰JÔð ˆ÷	Tð 	Tús   Å?AHÈHc                 ó€  ‡— t        j                  d«      ˆfd„«       }t        j                  d«      ˆfd„«       }t        j                  d«      ˆfd„«       }t        j                  d«      ˆfd„«       }t        j                  d	«      ˆfd
„«       }|||||dœ| _        t        j                  d| j                  «      S )z4Initialize callback functions for sf_open_virtual().Úsf_vio_get_filelenc                 ó    •— ‰j                  «       }‰j                  dt        «       ‰j                  «       }‰j                  |t        «       |S ©Nr   )rk  r  r   r   )Ú	user_dataÚcurrÚsizer¢   s      €r¸   Úvio_get_filelenz3SoundFile._init_virtual_io.<locals>.vio_get_filelen  s:   ø€ à—9‘9“;ˆDØ�I‰I�aœÔ"Ø—9‘9“;ˆDØ�I‰I�dœHÔ%ØˆKrÞ   Úsf_vio_seekc                 óH   •— ‰j                  | |«       ‰j                  «       S rÊ   )r  rk  )Úoffsetre  r·  r¢   s      €r¸   Úvio_seekz,SoundFile._init_virtual_io.<locals>.vio_seek$  s   ø€ à�I‰I�f˜fÔ%Ø—9‘9“;ÐrÞ   Úsf_vio_readc                 óæ   •— 	 t        j                  | |«      }‰j                  |«      }|S # t        $ r; ‰j	                  |«      }t        |«      }t        j                  | |«      }||d| Y |S w xY wr¶  )r   rt  Úreadintor\  rµ   ro  )ÚptrÚcountr·  ÚbufÚ	data_readr·   r¢   s         €r¸   Úvio_readz,SoundFile._init_virtual_io.<locals>.vio_read)  sx   ø€ ð(Ü—k‘k # uÓ-�Ø ŸM™M¨#Ó.�	ð Ðøô "ò (Ø—y‘y Ó'�Ü ›I�	Ü—k‘k # yÓ1�Ø#'��A�iÑ ØÐð(ús   ƒ', ¬A A0Á/A0Úsf_vio_writec                 óh   •— t        j                  | |«      }|d d  }‰j                  |«      }|€|}|S rÊ   )r   rt  rÁ   )rÂ  rÃ  r·  rÄ  r·   r  r¢   s         €r¸   Ú	vio_writez-SoundFile._init_virtual_io.<locals>.vio_write6  s9   ø€ ä—+‘+˜c 5Ó)ˆCØ‘q�6ˆDØ—j‘j Ó&ˆGàˆØ�ØˆNrÞ   Úsf_vio_tellc                 ó$   •— ‰j                  «       S rÊ   )rk  )r·  r¢   s    €r¸   Úvio_tellz,SoundFile._init_virtual_io.<locals>.vio_tell@  s   ø€ à—9‘9“;ÐrÞ   )Úget_filelenr  rµ   rÁ   rk  zSF_VIRTUAL_IO*)r   ÚcallbackÚ_virtual_ior=  )rÒ   r¢   rº  r¾  rÆ  rÉ  rÌ  s    `     r¸   rž  zSoundFile._init_virtual_io  sÈ   ø€ ä	�‰Ð+Ó	,ó	ó 
-ð	ô 
�‰�}Ó	%ó	ó 
&ð	ô 
�‰�}Ó	%ó
	ó 
&ð
	ô 
�‰�~Ó	&ó	ó 
'ð	ô 
�‰�}Ó	%ó	ó 
&ð	ð ,;Ø$,Ø$,Ø%.Ø$,ñ	.ˆÔô �x‰xÐ(¨$×*:Ñ*:Ó;Ð;rÞ   c                 ó   — t         S )z€Return all attributes used in __setattr__ and __getattr__.

        This is useful for auto-completion (e.g. IPython).

        )r-   r!  s    r¸   Ú_getAttributeNameszSoundFile._getAttributeNamesM  s
   € ô ÐrÞ   c                 ó2   — | j                   rt        d«      ‚y)z…Check if the file is closed and raise an error if it is.

        This should be used in every method that uses self._file.

        zI/O operation on closed fileN)r–  r„  r!  s    r¸   rS  zSoundFile._check_if_closedU  s   € ð �;Š;Ü'Ð(FÓGÐGð rÞ   c                 ó    — | j                  «       r-| j                  | j                  «       z
  }|dk  s||kD  r|€|}|S |dk  rt        d«      ‚|S )z8Reduce frames to no more than are available in the file.r   z/frames must be specified for non-seekable files)r  r£   rk  rý   )rÒ   r£   r¨   Úremaining_framess       r¸   rm  zSoundFile._check_frames^  s[   € à�=‰=Œ?Ø#Ÿ{™{¨T¯Y©Y«[Ñ8ÐØ˜Šz˜fÐ'7Ò7Ø(Ð0Ø)�ð ˆð �aŠZÜÐNÓOÐOØˆrÞ   c                 ó  — |t         j                  «       v sJ ‚t        |t        «      st	        j
                  |«      }t        t        |«      | j                  t	        j                  |«      z  «      \  }}|rt        d«      ‚||fS )z1Convert buffer to cdata and check for valid size.z*Data size must be a multiple of frame size)r�   Úvaluesr  r¢  r   Úfrom_bufferrØ   ro  r«   r?  rý   )rÒ   r·   ru  r£   Ú	remainders        r¸   rz  zSoundFile._check_bufferi  sw   € àœ
×)Ñ)Ó+Ñ+Ð+Ð+Ü˜$¤Ô&Ü×#Ñ# DÓ)ˆDÜ"¤3 t£9Ø#'§=¡=´4·;±;¸uÓ3EÑ#EóGÑˆ�	áÜÐIÓJÐJØ�Vˆ|ÐrÞ   c                 óx   — ddl }|s| j                  dkD  r|| j                  f}n|f}|j                  ||d¬«      S )z-Create an empty array with appropriate shape.r   Nr   ÚC)Úorder)r½   r«   Úempty)rÒ   r£   r§   r¦   rÂ   rÀ   s         r¸   rn  zSoundFile._create_empty_arrayt  s=   € ãÙ˜Ÿ™¨Ò)Ø˜DŸM™MÐ)‰Eà�GˆEØ�x‰x˜˜u¨CˆxÓ0Ð0rÞ   c                 óˆ   — 	 t         |   S # t        $ r- t        dt        t         j	                  «       «      ›d|›�«      ‚w xY w)z7Check if dtype string is valid and return ctype string.zdtype must be one of z	 and not )r�   ÚKeyErrorrý   ÚsortedÚkeys)rÒ   r¦   s     r¸   rr  zSoundFile._check_dtype}  sM   € ð	fÜ˜eÑ$Ð$øÜò 	fÜÐ4´V¼J¿O¹OÓ<MÓ5NÐ4QÐQZÐ[`ÐZcÐdÓeÐeð	fús	   ‚ ‹6Ac           	      óŠ  — |j                   dvr-t        d|j                  ›d|j                   dk  rdnd› d�«      ‚|j                   dk(  rdn|j                  d   }|| j                  k7  r)t        d|j                  ›d| j                  › d	|› d�«      ‚|j                  j
                  st        d
«      ‚| j                  |j                  j                  «      }|j                  j                  t        j                  |«      k(  sJ ‚t        j                  |dz   |j                  d   d   «      }| j                  ||||«      S )z+Check array and call low-level IO function.)r   r   zInvalid shape: z (r   z0 dimensions not supportedztoo many dimensionsrE  z (Expected z channels, got zData must be C-contiguousÚ*r·   r   )r¿   rý   rÀ   r«   ÚflagsÚc_contiguousrr  r¦   rÌ   Úitemsizer   r?  ÚcastÚ__array_interface__rs  )rÒ   ÚactionÚarrayr£   Úarray_channelsru  rv  s          r¸   rp  zSoundFile._array_io„  s4  € à�:‰:˜UÑ"Ü˜¨u¯{©{¨o¸RÐ`e×`jÑ`jÐmnÒ`nÑ@\ð  uJð  @Kð  KLð  Mó  Nð  NØ#Ÿj™j¨Ašo™°5·;±;¸q±>ˆØ˜TŸ]™]Ò*Ü˜¨u¯{©{¨o¸[ÈÏÉÈÐWfÐguÐfvÐvwÐxÓyÐyØ�{‰{×'Ò'ÜÐ8Ó9Ð9Ø×!Ñ! %§+¡+×"2Ñ"2Ó3ˆØ�{‰{×#Ñ#¤t§{¡{°5Ó'9Ò9Ð9Ð9Ü—	‘	˜% #™+ u×'@Ñ'@ÀÑ'HÈÑ'KÓLˆØ�~‰~˜f e¨U°FÓ;Ð;rÞ   c                 óp  — |t         j                  «       v sJ ‚| j                  «        d}| j                  «       r| j	                  «       }t        t        d|z   dz   |z   «      } || j                  ||«      }t        | j                  «       | j                  «       r| j                  ||z   t        «       |S )z.Call one of libsndfile's read/write functions.r   Úsf_Úf_)r�   rÖ  rS  r  rk  r  r   r  rV  rh  r  r   )rÒ   rè  r·   ru  r£   r¸  Úfuncs          r¸   rs  zSoundFile._cdata_io’  s–   € àœ
×)Ñ)Ó+Ñ+Ð+Ð+Ø×ÑÔØˆØ�=‰=Œ?Ø—9‘9“;ˆDÜ”t˜U V™^¨dÑ2°UÑ:Ó;ˆÙ�d—j‘j $¨Ó/ˆÜ�T—_‘_Ô%Ø�=‰=Œ?Ø�I‰I�d˜V‘m¤XÔ.ØˆrÞ   c                 óú   — | j                  «       rL| j                  «       }| j                  dt        «      | j                  _        | j                  |t        «       y| j                  xj
                  |z  c_        y)z!Update self.frames after writing.r   N)r  rk  r  r   r  r£   r   )rÒ   r  r¸  s      r¸   r~  zSoundFile._update_frames   sP   € à�=‰=Œ?Ø—9‘9“;ˆDØ $§	¡	¨!¬XÓ 6ˆD�J‰JÔØ�I‰I�dœHÕ%à�J‰J×Ò Ñ(ÖrÞ   c                 ó*  — |dk7  r| j                  «       st        d«      ‚|dk\  r|�t        d«      ‚t        ||«      j	                  | j
                  «      \  }}}||k  r|}|dk  r||z
  }| j                  «       r| j                  |t        «       |S )z)Seek to start frame and calculate length.r   z(start is only allowed for seekable filesz&Only one of {frames, stop} may be used)r  rý   rþ   ÚsliceÚindicesr£   r  r   )rÒ   r¤   r¥   r£   Ú_s        r¸   r´   zSoundFile._prepare_read©  sŽ   € à�AŠ:˜dŸm™mœoÜÐGÓHÐHØ�QŠ;˜4Ð+ÜÐDÓEÐEä˜u dÓ+×3Ñ3°D·K±KÓ@‰ˆˆt�QØ�%Š<ØˆDØ�AŠ:Ø˜E‘\ˆFØ�=‰=Œ?Ø�I‰I�eœXÔ&ØˆrÞ   c                 óØ   — i }t         j                  «       D ]P  \  }}t        j                  | j                  |«      }|sŒ)t        j                  |«      j                  dd«      ||<   ŒR |S )a5  Get all metadata present in this SoundFile

        Returns
        -------

        metadata: dict[str, str]
            A dict with all metadata. Possible keys are: 'title', 'copyright',
            'software', 'artist', 'comment', 'date', 'album', 'license',
            'tracknumber' and 'genre'.
        r    r¡   )r-   Úitemsr   r[  r  r   r@  rA  )rÒ   ÚstrsÚstrtypeÚstridr·   s        r¸   Úcopy_metadatazSoundFile.copy_metadata¹  sf   € ð ˆÜ(×.Ñ.Ó0ò 	M‰NˆG�UÜ×%Ñ% d§j¡j°%Ó8ˆDÚÜ $§¡¨DÓ 1× 8Ñ 8¸À)Ó L��W’ð	Mð ˆrÞ   c                 ób  — |t         v sJ ‚t        j                  d«      }t         |   |d<   t        j	                  | j
                  t        j                  |t        j                  |«      «      }|t        j                  k7  r.t        j                  | j
                  «      }t        |d|› �«      ‚y)z,Call libsndfile's set bitrate mode function.zint[1]r   zError set bitrate mode N)r”   r   r=  r   r  r  ÚSFC_SET_BITRATE_MODEr?  r  r9  r�  )rÒ   rº   Úpointer_bitrate_moderY  s       r¸   r  zSoundFile._set_bitrate_modeË  s“   € àœ~Ñ-Ð-Ð-ä#Ÿx™x¨Ó1ÐÜ"0°Ñ">Ð˜QÑÜ�o‰o˜dŸj™j¬$×*CÑ*CÐEYÔ[_×[fÑ[fÐg{Ó[|Ó}ˆØ”$—,‘,ÒÜ—-‘- §
¡
Ó+ˆCÜ! #Ð)@ÀÀÐ'OÓPÐPð rÞ   c                 ó„  — d|cxk  rdk  st        d«      ‚ t        d«      ‚t        j                  d«      }||d<   t        j	                  | j
                  t        j                  |t        j                  |«      «      }|t        j                  k7  r.t        j                  | j
                  «      }t        |d|› �«      ‚y)z1Call libsndfile's set compression level function.r   r   z)Compression level must be in range [0..1]z	double[1]zError set compression level N)rý   r   r=  r   r  r  ÚSFC_SET_COMPRESSION_LEVELr?  r  r9  r�  )rÒ   r¹   Úpointer_compression_levelrY  s       r¸   r  z SoundFile._set_compression_level×  s¸   € àÐ&Ô+¨!Ò+ÜÐHÓIÐIð ,ÜÐHÓIÐIä$(§H¡H¨[Ó$9Ð!Ø'8Ð! !Ñ$Ü�o‰o˜dŸj™j¬$×*HÑ*HÐJcÔei×epÑepð  rKó  fLó  MˆØ”$—,‘,ÒÜ—-‘- §
¡
Ó+ˆCÜ! #Ð)EÐFWÐEXÐ'YÓZÐZð rÞ   )	r²   NNNNNTNN)r°   N)éÿÿÿÿr   FNN)r   N)Nr   r   r   FNNrÊ   )Nrç   rè   ré   rê   r   r¡  rŽ   rû   r�   rÓ   rë   rÌ   r  rª   r£   r«   r¬   r­   r®   rÎ   rÏ   rÐ   r–  rh  r¹   rº   rÑ   r  ræ   rJ  r   rM  r   rP  rX  r]  r_  ra  rc  r  r   r  rk  r   r   r   rµ   Ú
memoryviewrx  Ú	bytearrayr{  rÁ   r¢  r�  r   rÆ   r‘  r”  rI  Ú
_threadingÚLockr¯  r  rž  rÑ  rS  rm  rz  rn  rr  rp  rs  r~  r´   rï   rù  r  r  rì   rÞ   r¸   r³   r³   G  sx  „ ñð GJØGKØBFØ<@Ø37Ø,0ñA;Ð1ð A;¸¸t¹ð A;Ø  4™ZðA;Ø:=À¹*ðA;à ™*ðA;à58¸4±ZðA;ð ˜t™ðA;ð 6:ðA;ð %*¨D¡Lð	A;ð
  # T™zðA;ð
 6:óA;ñF Ñ+Ó,€DØ*ÙÑ+Ó,€DØ7ÙÑ<Ó=€JØ,ÙÑ4Ó5€FØ1ÙÑ8Ó9€HØ3ÙÙMóO€Fà-ÙÙLóN€Gà4ÙÙLóN€Fà8Ùñ	>ó?€Kð ?Ùñ	=ó>€Lð :ÙÑ8Ó9€HØ3ÙÑ5Ó6€FØ2ÙÑ@ÓA€JØ'Ù Ñ!EÓFÐØ,ÙÑ;Ó<€LØ'àñ<ó ð<ð €EðA˜#ó Aóð˜4ó ð˜cð  dó ð2 ð 2¨Cð 2°Dó 2ðA ð A¨ó Að!˜ó !ð
˜$ó ð
˜Tó ð
3˜$ó 3ð /7ñ '˜3ð '¨ð '¸3ó 'ðR&�có &ð
 9BØ@DØ37ñ]˜3ð ]¨Ið ]Øð]Ø16¸±ð]à˜\Ñ)¨DÑ0ð]à<EÈÑ<Tó]ñ@!" #ð !"°9¸tÑ3Cð !"Èzó !"ðF y°:Ñ'=ÀÑ'Cð ÈIð ÐZ]ó ðB4%˜)ð 4%¨ó 4%ðl% ð %¨yð %¸Tó %ð6 CDØ4=ØCGØ6:ñ]  d¡
ð ]¸Cð ]Øð]Ø(1ð]àð]à49¸D±Lð]ð  Ñ,¨tÑ3ð]ð @IÈÐTXÐZ^ÐI^Ñ?_ÐbkÐlxÐz~ð  AEð  mEñ  cFñ  @Fó]ñ~#˜s T™zð #°Tó #ó0'óð %�Z—_‘_Ó&€Nò#òJ1<òfòHò	ò	ò1òfò<òò)òð ˜t C¨ H™~ó ò$	Qó
[rÞ   r³   c                 ó(   — | dk7  rt        | |¬«      ‚y)z+Raise LibsndfileError if there is an error.r   rŸ  N)r�  )rY  r   s     r¸   rV  rV  ä  s   € à
ˆa‚xÜ˜c¨&Ô1Ð1ð rÞ   c                 óX  — t        | «      }|€t        | «      }|€,t        d| ›�«      ‚t        |t        «      st        d|›�«      ‚	 |t
        |j                  «          z  }|€d}nt        |t        «      st        d|›�«      ‚	 |t        |j                  «          z  }t        j                  d«      }||_        d|_        t        j                  |«      t        j                   k(  rt        d	«      ‚|S # t        $ r t        d|›�«      ‚w xY w# t        $ r t        d|›�«      ‚w xY w)
z8Return numeric ID for given format|subtype|endian combo.z$No default subtype for major format zInvalid subtype: zUnknown subtype: r†   zInvalid endian-ness: zUnknown endian-ness: úSF_INFO*r   z1Invalid combination of format, subtype and endian)r   r  rþ   r  r¡  r…   r  rÞ  rý   rŠ   r   r=  r¬   r«   r   Úsf_format_checkÚSF_FALSE)r¬   r­   r®   Úresulträ   s        r¸   rü   rü   ê  sF  € ä˜6Ó"€FØ€Ü! &Ó)ˆØˆ?ÜØ6°v°jÐAóCð Cä˜¤Ô%ÜÐ+¨G¨;Ð7Ó8Ð8ð:Ø”)˜GŸM™M›OÑ,Ñ,ˆð €~Ø‰Ü˜¤Ô$ÜÐ/°¨zÐ:Ó;Ð;ð=Ø”(˜6Ÿ<™<›>Ñ*Ñ*ˆô �8‰8�JÓ€DØ€D„KØ€D„MÜ×Ñ˜DÓ!¤T§]¡]Ò2ÜØ?óAð 	Aà€Møô# ò :ÜÐ,¨W¨KÐ8Ó9Ð9ð:ûô ò =ÜÐ0°°
Ð;Ó<Ð<ð=ús   ÁC6 ÂD Ã6DÄD)c                 óŒ  — t        | t        «      st        d| ›�«      ‚t        | «      }|j	                  d«      st        | «      t        |«      kD  rt        d| ›�«      ‚t        |j                  d«      «      dk7  rt        d«      ‚d|v rt        j                  }|S d|v rt        j                  }|S t        j                  }|S )z=Check if mode is valid and return its integer representation.zInvalid mode: zxrwb+Úxrwr   z&mode must contain exactly one of 'xrw'rƒ  r²   )r  r¡  rþ   r  Ú
differencero  rý   Úintersectionr   ÚSFM_RDWRÚSFM_READr°  )r  Úmode_setr  s      r¸   r  r  
  sº   € ä�dœCÔ Ü˜.¨¨Ð1Ó2Ð2Ü�4‹y€HØ×Ñ˜7Ô#¤s¨4£y´3°x³=Ò'@Ü˜>¨$¨Ð2Ó3Ð3Ü
ˆ8× Ñ  Ó'Ó(¨AÒ-ÜÐAÓBÐBà
ˆh�Ü—=‘=ˆð
 €Oð	 
�‰Ü—=‘=ˆð €Oô —>‘>ˆØ€OrÞ   c                 ót  — |}|€t        | |«      }t        |t        «      sJ ‚t        |«       t	        j
                  d«      }d|vs|j                  «       dk(  r<|€t        d«      ‚||_        |€t        d«      ‚||_	        t        |||«      |_        |S t        d„ |||||fD «       «      rt        d«      ‚|S )z*Check arguments and create SF_INFO struct.r  r²   r1   zsamplerate must be specifiedzchannels must be specifiedc              3   ó$   K  — | ]  }|d u–— Œ
 y ­wrÊ   rì   )Ú.0Úargs     r¸   ú	<genexpr>z&_create_info_struct.<locals>.<genexpr>1  s   è ø€ ò I 3ˆs˜$Œñ Iùs   ‚z\Not allowed for existing files (except 'RAW'): samplerate, channels, format, subtype, endian)Ú_get_format_from_filenamer  r¡  r   r   r=  r  rþ   rª   r«   rü   r¬   Úany)	r¢   r  rª   r«   r¬   r­   r®   Úoriginal_formaträ   s	            r¸   r  r    sß   € ð €OØ€~Ü*¨4°Ó6ˆÜ˜&¤#Ô&Ð&Ð&ä�fÔä�8‰8�JÓ€DØ
�$�˜&Ÿ,™,›.¨EÒ1ØÐÜÐ:Ó;Ð;Ø$ˆŒØÐÜÐ8Ó9Ð9Ø ˆŒÜ! &¨'°6Ó:ˆŒð €Kô	 ñ IØ˜H o°wÀð+Hô Iô Iäð Ló Mð Mà€KrÞ   c                 ó  — d}t        | d| «      } 	 t        j                  j                  | «      d   dd }|j	                  dd«      }|j                  «       t        vrd|vrt        d	| ›�«      ‚|S # t
        $ r Y Œ5w xY w)
a  Return a format string obtained from file (or file.name).

    If file already exists (= read mode), an empty string is returned on
    error.  If not, an exception is raised.
    The return type will always be str or unicode (even if
    file/file.name is a bytes object).

    rC  rÌ   r   r   Nr    r¡   r²   zBNo format specified and unable to get format from file extension: )	r  r  r£  ÚsplitextrA  Ú	Exceptionr  rH   rþ   )r¢   r  r¬   s      r¸   r  r  8  s—   € ð €FÜ�4˜ Ó&€Dðä—‘×"Ñ" 4Ó(¨Ñ,¨Q¨RÐ0ˆà—‘˜w¨	Ó2ˆð ‡|�|ƒ~œXÑ%¨#°T©/Üð +Ø+/¨(ð4ó 5ð 	5à€Møô ò Ùðús   ‘7A2 Á2	A>Á=A>c                 óv   — t         t        t        fD ]%  }|j                  «       D ]  \  }}|| k(  sŒ|c c S  Œ' y)z;Return the string representation of a given numeric format.zn/a)rH   r…   rŠ   rõ  )Ú
format_intÚ
dictionaryÚkÚvs       r¸   r+  r+  P  sE   € ä¤	¬8Ð3ò ˆ
Ø×$Ñ$Ó&ò 	‰DˆAˆqØ�J‹Ø”ñ	ðð
 rÞ   c                 óB  — t        j                  d«      }| |_        t        j	                  t         j
                  ||t        j                  d«      «       |j                  }t        |j                  «      |r&t        j                  |«      j                  dd«      fS dfS )z6Return the ID and short description of a given format.zSF_FORMAT_INFO*ÚSF_FORMAT_INFOr    r¡   rC  )r   r=  r¬   r   r  r  r?  rÌ   r+  r@  rA  )r  Úformat_flagrÎ   rÌ   s       r¸   r4  r4  Z  s‹   € ä—(‘(Ð,Ó-€KØ#€KÔÜ‡O�O”D—I‘I˜{¨KÜ—K‘KÐ 0Ó1ô3à×Ñ€DÜ˜×*Ñ*Ó+Ù<@ŒD�K‰K˜Ó×$Ñ$ W¨iÓ8ðJð JØFHðJð JrÞ   c              #   óê   K  — t        j                  d«      }t        j                  t         j                  | |t        j
                  d«      «       t        |d   «      D ]  }t        ||«      –— Œ y­w)z8Helper for available_formats() and available_subtypes().zint*rŽ   r   N)r   r=  r   r  r  r?  Úranger4  )Ú
count_flagr$  rÃ  r  s       r¸   rð   rð   e  sW   è ø€ ä�H‰H�VÓ€EÜ‡O�O”D—I‘I˜z¨5´$·+±+¸eÓ2DÔEÜ˜E !™H“oò 4ˆ
Ü˜: {Ó3Ó3ñ4ùs   ‚A1A3c                 ó¨   — t        | t        «      st        d| ›�«      ‚	 t        | j	                  «          }|S # t
        $ r t        d| ›�«      ‚w xY w)z4Check if `format_str` is valid and return format ID.zInvalid format: zUnknown format: )r  r¡  rþ   rH   r  rÞ  rý   )Ú
format_strr  s     r¸   r   r   m  sc   € ä�j¤#Ô&ÜÐ*¨:¨.Ð9Ó:Ð:ð<Ü˜j×.Ñ.Ó0Ñ1ˆ
ð Ðøô ò <ÜÐ+¨J¨>Ð:Ó;Ð;ð<ús	    9 ¹Ac           	      óè   — |t         j                  k(  }|t         j                  k(  }t        t	        | d«      t	        | d«      t	        | d«      xs |t	        | d«      xs t	        | d«      xs |g«      S )z>Check if file has all the necessary attributes for virtual IO.r  rk  rÁ   rµ   rÁ  )r   r  r°  ÚallÚhasattr)r¢   r  ÚreadonlyÚ	writeonlys       r¸   r®  r®  x  sn   € àœ4Ÿ=™=Ñ(€HØœDŸN™NÑ*€IÜÜ��fÓÜ��fÓÜ��gÓÒ* (Ü��fÓÒG¤¨¨zÓ!:ÒG¸ið	ó ð rÞ   c                   ó   — e Zd ZdZy)ÚSoundFileErrorz-Base class for all soundfile-specific errors.N©rç   rè   ré   rê   rì   rÞ   r¸   r0  r0  „  s   „ Ù7ØrÞ   r0  c                   ó   — e Zd ZdZy)r„  zKsoundfile module runtime error.

    Errors that used to be `RuntimeError`.Nr1  rì   rÞ   r¸   r„  r„  ˆ  s   „ ñ.ð 	rÞ   r„  c                   óH   — e Zd ZdZd	dededdfd„Zedefd„«       Zdefd„Z	y)
r�  zjlibsndfile errors.


    Attributes
    ----------
    code
        libsndfile internal error number.
    Úcoder   r°   Nc                 óN   — t         j                  | ||«       || _        || _        y rÊ   )r„  rÓ   r4  r   )rÒ   r4  r   s      r¸   rÓ   zLibsndfileError.__init__—  s"   € Ü×&Ñ& t¨T°6Ô:ØˆŒ	Øˆ�rÞ   c                 ó¤   — | j                   rDt        j                  | j                   «      }t        j                  |«      j                  dd«      S y)zRaw libsndfile error message.r    r¡   z'(Garbled error message from libsndfile))r4  r   Úsf_error_numberr   r@  rA  )rÒ   Úerr_strs     r¸   Úerror_stringzLibsndfileError.error_stringœ  s@   € ð �9Š9Ü×*Ñ*¨4¯9©9Ó5ˆGÜ—;‘;˜wÓ'×.Ñ.¨w¸	ÓBÐBð
 =rÞ   c                 ó4   — | j                   | j                  z   S rÊ   )r   r9  r!  s    r¸   Ú__str__zLibsndfileError.__str__¨  s   € Ø�{‰{˜T×.Ñ.Ñ.Ð.rÞ   ©rC  )
rç   rè   ré   rê   rŽ   r¡  rÓ   rë   r9  r;  rì   rÞ   r¸   r�  r�  Ž  sH   „ ññ˜Sð ¨#ð °tó ð
 ð	=˜cò 	=ó ð	=ð/˜ô /rÞ   r�  )r   r   Nr   FNNNNNNNT)NNNTNN)Nr   r   r   Nr   FNNNNNNNT)FrÊ   )NNr<  )mrê   Ú__version__Úosr  Úsysrª  Ú	threadingr  Úcollections.abcr   Úctypes.utilr   Ú_find_libraryr   r   r   Útypingr   r	   r
   r   r   r½   Útyping_extensionsr   Ú
_soundfiler   r   r¡  rŽ   r	  r   Ú__annotations__ÚndarrayÚtupler¦   r   r   r   r   r   r   r   r-   rï   rH   r…   rŠ   r‹   r�   r”   r«  r–   Ú_machineÚ_packaged_libnameÚ	sysconfigÚ
_sysconfigÚget_platformÚ_win_machiner¥  Ú_soundfile_datar£  ÚdirnameÚ__file__Ú_pathrâ   Ú
_full_pathÚdlopenr   ÚImportErrorrþ   Ú_libnameÚ_explicit_libnameÚisdirÚ_hbrew_pathr@  Úsf_version_stringrA  Ú__libsndfile_version__Ú
startswithro  rû   r�   rµ   rÁ   rÆ   rÈ   rä   ró   rù   r÷   r  r³   rV  rü   r  r  r  r+  ÚSFC_GET_FORMAT_INFOr4  rð   r   r®  r  r0  ÚRuntimeErrorr„  r�  rì   rÞ   r¸   ú<module>r`     sc  ðò	ð €ã Û Û Ý %Ý 5ß +Ñ +ß ;Õ ;ã Ý "å "à"%¨¡)¨hÑ"6¸¿¹ÀcÑ9JÑ"JÐ �iÓ JØ—}‘} U¨3°¨8¡_°e·k±kÀ%Ç-Á-ÐRW×R_ÑR_ÑB_Ðbg×bmÑbmÑBmÐpu×p{Ñp{ÑB{Ñ6|Ð%|Ñ}€	ˆ9Ó }ØŸ-™-¨¨c°3¨h©¸¿¹ÀUÇ]Á]ÐUZ×UbÑUbÑEbÐej×epÑepÑEpÐsx×s~Ñs~ÑE~Ñ9Ð(ñ  A€ˆió  AØÐEÑF€	ˆ9Ó FØ	ƒ	Ø	ƒ	ð ØØØØØØØØØñ%€
ˆE�$�s˜C�x‘.Ñ!ó ð#Ø	ˆXð#à
ˆXð#ð 	ˆXð#ð 
ˆXð	#ð
 
ˆXð#ð 
ˆXð#ð ˆXð#ð 
ˆXð#ð ˆXð#ð 
ˆXð#ð ˆXð#ð ˆXð#ð 
ˆXð#ð 	ˆXð#ð 
ˆXð#ð  
ˆXð!#ð" 
ˆXð##ð$ ØØØØØØØØò5#€ˆ%��S˜#�X‘Ñ
ó ð:#$Ø�fð#$à�fð#$ð �fð#$ð �fð	#$ð
 �fð#$ð �fð#$ð �fð#$ð �fð#$ð �fð#$ð �fð#$ð �fð#$ð �fð#$ð �fð#$ð �fð#$ð �fð#$ð  �fð!#$ð" �fñ##$ð$ �fð%#$ð& �fð'#$ð( �fð)#$ð* �fð+#$ð, �fð-#$ð. �fð/#$ð0 �fð1#$ð2 �fð3#$ð4 �fð5#$ð6 �fð7#$ð8 �fð9#$ð: �fð;#$ð< �fð=#$ð> �fð?#$ð@ �fðA#$ðB �fðC#$ðD �fñE#$€	ˆ5��c˜3�h‘Ñ ó #ðL ØØØñ	#€ˆ%��S˜#�X‘Ñ
ó ð,Ø	ˆXð,à
ˆXð,ð 	ˆXð,ð
 
ˆXð,ð 
ˆXð,ð ˆXð,ð 
ˆXð,ð ˆXð,ð 
ˆXð,ð ˆXð,ð ˆXð,ð 
ˆXð,ð 	ˆYð,ð 
ˆXð,ð  
ˆXð!,ð" 
ˆXð#,ð$ ˆXð%,ð& ØØØØØØØò5,Ð �5˜˜c 3˜h™Ñ(ó ð< ØØØñ	%€
ˆE�$�s˜C�x‘.Ñ!ó ð ØØñ)€��d˜3 ˜8‘nÑ%ó ð82Ø‡}�}˜Ò Ý0Ø)©H«JÑ6¸ÑAÑØ	�‰˜'Ò	!Û&à.�z×.Ñ.Ó0ˆØ˜;Ò&Ø 6ÑØ˜[Ò(Ø 4ÑØ˜WÒ$Ø 4ÑáÐ<¸\¸NÐKÓLÐLØ	�‰˜'Ò	!Ý0Ù‹:ÐFÑFØ 5Ñà -±³
Ñ :¸UÑ BÑáÐ=Ó>Ð>ãØ�H‰H×Ñ˜_×5Ñ5Ó6€EØ—‘—‘˜uÐ&7Ó8€JØˆ4�;‰;�zÓ"€Dð< %˜Ÿ™ T×%;Ñ%;Ó%=Ó>×EÑEÀgÈyÓYÐ Ø×$Ñ$ ]Ô3Ø3±C¸Ó4FÐ4GÐHÐð t}ØimØuyØ37ñ\Ð#ð \¨Sð \¸cð \ÈSÐSWÉZð \Ðgpð \Øð\Ø-2°T©\ð\ØGPÐS_ÑG_ÐbfÑGfð\à˜$‘Jð\à14°t±ð\àLOÐRVÉJð\àhkÐnrÑhrð\ð �d‘
ð\ð -1ð\ð =BÀ)ÈlÑBZÐ\_ÐB_Ñ<`ó\ðB <@Ø59Ø,0Ø%)ñ	9Ð$ð 9¨Ið 9À3ð 9Ø˜‘:ð9Ø.1°D©jð9à˜‘*ð9à.2ð9ð # T™\ð9ð ˜d™
ð	9ð /3ó	9ðv @DØ<=Ø7@Ø?CØQUØ=AØ<@Øñ:[Ð%ð :[°#¸±*ð :[Øð:[Ø%(ð:[Ø69ð:[à�t‘ð:[à+4ð:[ð ð:[ð 16¸±ð:[ð ˜LÑ(¨4Ñ/ð	:[ð EHÈ$ÁJð	:[ð
 ˜4‘Zð:[ð
 14°d±
ð:[ð ˜$‘Jð:[ð 03°T©zð:[ð ð:[ð %.¨i¸¸tÐ.CÑ$DÀyÐQ]Ð_cÐeiÐQiÑGjÑ$jó:[÷z1ñ 1ñh)Ð#ð )¨dð )¸~ó )ðF˜4  S ™>ó Fñ*D˜s T™zð D°T¸#¸s¸(±^ó Dð. 59Ø&*ñ˜ð  s¨T¡zð Ø˜t™ðØ/3óð&1˜Cð 1 C¨$¡Jó 1÷ Z[ñ Z[óz2òò@ò&ò6ò0ð *.×)AÑ)Aó Jò4òò	ô	�Yô 	ô	˜N¨Lô 	ô/Ð+õ /øð]. 	�˜iÐ(ò 2ð2Ù  Ó+ˆØÐÙÐTÓUÐUØˆt�{‰{˜8Ó$‰øàò 2à�=‰=˜HÒ$Ø 2ÑØ�]‰]˜gÒ%Ø 0ÑØ�]‰]˜gÒ%Ø /Ñàõ 	1Ø�=‰=˜HÒ$©«°wÒ)>Ø25·(±(·.±.ÐAUÔ2VÑ.Ø&ð à�4—;‘;˜sŸx™xŸ}™}¨[Ð:KÓLÓM‰Dà�4—;‘;Ð0Ó1ˆDùð'2ýð2ús8   ÊC8U ÕYÕ$U>Õ=YÕ>B9X:Ø7YØ9X:Ø:YÙ Y