+
   )cw                  *   ^ RI Ht ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHtH	t	H
t
HtHtHt ^ RIHt ^ RIHt  ! R R]4      t ! R R	]]4      t ! R
 R]]4      t ! R R]P0                  4      t ! R R4      t ! R R]4      t ! R R]4      tR# )    )annotationsN)c_boolc_bytec_intc_uintc_size_tc_void_p)find_library)Iterablec                      ] tR t^tRtRtR# )	BaseErrorzBase error raised by liblc3. N__name__
__module____qualname____firstlineno____doc____static_attributes__r       (/usr/lib/python3.14/site-packages/lc3.pyr   r      s    &r   r   c                      ] tR t^"tRtRtR# )InitializationErrorz/Error raised when liblc3 cannot be initialized.r   Nr   r   r   r   r   r   "   s    9r   r   c                      ] tR t^&tRtRtR# )InvalidArgumentErrorz*Error raised when a bad argument is given.r   Nr   r   r   r   r   r   &   s    4r   r   c                  &    ] tR t^*t^ t^t^t^tRtR# )
_PcmFormatr   N)	r   r   r   r   S16S24S24_3LEFLOATr   r   r   r   r   r   *   s    
C
CGEr   r   c                  l    ] tR t^1tRR R lltR R ltR R ltR R	 ltR
 R lt]	R R l4       t
RtR# )_BaseNc               4    V ^8  d   QhRRRRRRRRRRR	R
RR/# )   frame_duration_usintsample_rate_hznum_channelshrmodeboolpcm_sample_rate_hz
int | Nonelibpath
str | NonereturnNoner   )formats   "r   __annotate___Base.__annotate__3   sY     Y( Y(Y( Y( 	Y(
 Y( 'Y( Y( 
Y(r   c                	p  a W@n         Wn        W n        T;'       g    V P                  V n        W0n        V P                  R9  d/   \        RV P                   RV P                  R,          R R24      hV P                   '       g   . ROMRR.pV P                  V9  d   \        RV R	24      hVf   \        P                  ! \        P                  P                  \        P                  P                  \        4      RR4      4      pV'       d   V^ ,          pM\        R4      pV'       g   \        R4      h\        P                  P!                  V4      o\"        ;QJ d    V3R lR 4       F  '       d   K   RM	  RM! V3R lR 4       4      '       gj   V P                   '       d   \        R4      hV3R lp	V3R lp
V3R lpV3R lp\%        SRV	4       \%        SRV
4       \%        SRV4       \%        SRV4       \&        \(        \(        .SP*                  n        \&        \(        \(        \(        \(        .SP.                  n        \&        \(        \(        \(        .SP0                  n        \&        \(        \(        .SP2                  n        SV n        \        R4      ;p'       g   \        R4      h\        P                  P!                  V4      pVP6                  V n        \8        .V P6                  n        \:        V P6                  n        VP>                  V n        \:        .V P>                  n        R
# ) 	  zInvalid frame duration: z us (i  z.1fz ms)逻  i w zInvalid sample rate: z HzNz.lc3py.mesonpy.libsz*lc3*lc3zLC3 library not foundc              3  <   <"   T F  p\        SV4      x  K  	  R # 5iNhasattr.0funclibs   & r   	<genexpr>!_Base.__init__.<locals>.<genexpr>]   s&      
 C   lc3_hr_frame_sampleslc3_hr_frame_block_byteslc3_hr_resolve_bitratelc3_hr_delay_samplesFT'High-Resolution interface not availablec                &   < SP                  W4      # r:   )lc3_frame_samplesr*   dt_ussr_hzr@   s   &&&r   <lambda> _Base.__init__.<locals>.<lambda>i       @U@UAr   c                B   < VSP                  W^,          4      ,          # )r%   )lc3_frame_bytes)r*   rL   rM   r)   bitrater@   s   &&&&&r   rN   rO   m   s    L%%e\:E;r   c                &   < SP                  W4      # r:   )lc3_resolve_bitrate)r*   rL   rM   nbytesr@   s   &&&&r   rN   rO   q   s    S5L5L6r   c                &   < SP                  W4      # r:   )lc3_delay_samplesrK   s   &&&r   rN   rO   u   rP   r   czUnable to find libc)r6   i  iL  i'  )i@  i>  i]  i }  r7   )rD   rE   rF   rG   ) r*   r&   r(   r,   r)   r   globospathjoindirname__file__r
   r   ctypescdllLoadLibraryallsetattrr   r   rD   argtypesrE   rF   rG   r@   mallocr   r	   restypefree)selfr&   r(   r)   r*   r,   r.   allowed_sampleratemesonpy_librD   rE   rF   rG   	libc_pathlibcr@   s   &&&&&&&        @r   __init___Base.__init__3   s    !2,"4"K"K8K8K(!!)BB&*4+A+A*B%H^H^aeHefiGjjno 
 7;kkk.u~ 	 &88&)>~>Nc'RSS?))RWW__X68MwWK %a.&u-)*ABBkk%%g.s 

sss 

 
 
 {{{)*STT$ ; %
 #
$  C/1EFC35MNC13IJC/1EF-3UE,B  )17ue0T$$-/5ueU.K""+-3UE,B  ))#..	.%&;<<{{&&y1kk (z&II	&Z		r   c                   V ^8  d   QhRR/# r%   r0   r'   r   )r2   s   "r   r3   r4           	 	3 	r   c                    V P                   P                  V P                  V P                  V P                  4      pV^ 8  d   \        R4      hV# )z4
Returns the number of PCM samples in an LC3 frame.
Bad parameters)r@   rD   r*   r&   r,   r   ri   rets   & r   get_frame_samples_Base.get_frame_samples   I     hh++KK//1H1H
 7&'788
r   c                    V ^8  d   QhRRRR/# )r%   rS   r'   r0   r   )r2   s   "r   r3   r4      s      s s r   c                    V P                   P                  V P                  V P                  V P                  V P
                  V4      pV^ 8  d   \        R4      hV# )z
Returns the size of LC3 frame blocks, from bitrate in bit per seconds.
A target `bitrate` equals 0 or `INT32_MAX` returns respectively
the minimum and maximum allowed size.
rt   )r@   rE   r*   r&   r(   r)   r   )ri   rS   rv   s   && r   get_frame_bytes_Base.get_frame_bytes   sW     hh//KK""
 7&'788
r   c                    V ^8  d   QhRRRR/# )r%   	num_bytesr'   r0   r   )r2   s   "r   r3   r4      s     	 	 	 	r   c                    V P                   P                  V P                  V P                  V P                  V4      pV^ 8  d   \        R4      hV# )zG
Returns the bitrate in bits per seconds, from the size of LC3 frames.
rt   )r@   rF   r*   r&   r(   r   )ri   r   rv   s   && r   resolve_bitrate_Base.resolve_bitrate   sK     hh--KK//1D1Di
 7&'788
r   c                   V ^8  d   QhRR/# rq   r   )r2   s   "r   r3   r4      rr   r   c                    V P                   P                  V P                  V P                  V P                  4      pV^ 8  d   \        R4      hV# )z8
Returns the algorithmic delay, as a number of samples.
rt   )r@   rG   r*   r&   r,   r   ru   s   & r   get_delay_samples_Base.get_delay_samples   ry   r   c                    V ^8  d   QhRRRR/# )r%   	bit_depthr-   r0   zbtuple[_PcmFormat, type[ctypes.c_int16] | type[ctypes.Array[ctypes.c_byte]] | type[ctypes.c_float]]r   )r2   s   "r   r3   r4      s!     P PJ P < Pr   c                	   T;^8X  d"    \         P                  \        P                  3# ;^8X  d)    \         P                  ^\        P
                  ,          3# f!   \         P                  \        P                  3#  \        R4      h)   z!Could not interpret PCM bit_depth)	r   r   r`   c_int16r    r   r!   c_floatr   )clsr   s   &&r   _resolve_pcm_format_Base._resolve_pcm_format   sa    
 "77"**A,=>>"((&..99*+NOOr   )r&   rh   r*   r@   rf   r)   r,   r(   )FNN)r   r   r   r   rn   rw   r|   r   r   classmethodr   r   r   r   r   r#   r#   1   s3    Y(v	"		 P Pr   r#   c                     a  ] tR t^tRt ! R R]4      tRR V 3R llltR R lt]	P                  RR R	 ll4       t]	P                  R
 R l4       tRR R lltRtV ;t# )Encodera  
LC3 Encoder wrapper.

The `frame_duration_us`, in microsecond, is any of 2500, 5000, 7500, or 10000.
The `sample_rate_hz`, in Hertz, is any of 8000, 16000, 24000, 32000
or 48000, unless High-Resolution mode is enabled. In High-Resolution mode,
the `sample_rate_hz` is 48000 or 96000.

By default, one channel is processed. When `num_channels` is greater than one,
the PCM input stream is read interleaved and consecutives LC3 frames are
output, for each channel.

Optional arguments:
    hrmode               : Enable High-Resolution mode, default is `False`.
    input_sample_rate_hz : Input PCM samplerate, enable downsampling of input.
    libpath              : LC3 library path and name
c                      ] tR t^tRtR# )Encoder.c_encoder_tr   Nr   r   r   r   r   r   r   r   c_encoder_tr          r   r   c               4    V ^8  d   QhRRRRRRRRRRR	R
RR/# )r%   r&   r'   r(   r)   r*   r+   input_sample_rate_hzr-   r.   r/   r0   r1   r   )r2   s   "r   r3   Encoder.__annotate__   sb     DG DGDG DG 	DG
 DG )DG DG 
DGr   c                	  <a a \         SS `  VVVVVV4       S P                  o\        ;QJ d    V3R  lR
 4       F  '       d   K   RM	  RM! V3R  lR
 4       4      '       gD   S P                  '       d   \        R4      hV3R lpV3R lp\        SRV4       \        SRV4       \        \        \        .SP                  n
        \        SP                  n        \        \        \        \        \        .SP                  n
        S P                  SP                  n        S P                  \        \        \        \        \        .SP                   n
        VV 3R lp	\#        V4       U
u. uF	  q! 4       NK  	  up
S n        R	# u up
i )c              3  <   <"   T F  p\        SV4      x  K  	  R # 5ir:   r;   r=   s   & r   rA   #Encoder.__init__.<locals>.<genexpr>   "      
G CGrC   lc3_hr_encoder_sizelc3_hr_setup_encoderFTrH   c                &   < SP                  W4      # r:   )lc3_encoder_sizerK   s   &&&r   rN   "Encoder.__init__.<locals>.<lambda>      s?S?S@r   c                (   < SP                  WW44      # r:   )lc3_setup_encoderr*   rL   rM   	sr_pcm_hzmemr@   s   &&&&&r   rN   r         S=R=R)>r   c                    < S P                  SP                  SP                  SP                  SP                  SP                  S P                  SP                  SP                  SP                  4      4      4      # r:   )r   r*   r&   r(   r,   rf   r   r@   ri   s   r   new_encoder%Encoder.__init__.<locals>.new_encoder  i    ++&&##''++T%;%;T=T=T
 
r   N)r   r   )superrn   r@   rc   r*   r   rd   r   r   r   re   r   rg   r	   r   r   
lc3_encoderange_Encoder__encoders)ri   r&   r(   r)   r*   r   r.   r   r   r   _r@   	__class__s   f&&&&&&    @r   rn   Encoder.__init__   sF    	 	
 hhs 
G
sss 
G
 
 
 {{{)*STT#
 !
 C.0CDC/1EF,2E5+A(*0'-3UE5(,S  )+/+;+;  ( #
	 382EF2EQ;=2EFF   *Fc                   V ^8  d   QhRR/# r%   r0   r1   r   )r2   s   "r   r3   r   ,         r   c                	F   a   V 3R  lS P                    4        R#     R# ; i)c              3  F   <"   T F  pSP                  V4      x  K  	  R # 5ir:   rh   )r>   encoderri   s   & r   rA   "Encoder.__del__.<locals>.<genexpr>/       ?GTYYw   !N)r   ri   s   fr   __del__Encoder.__del__,      	?t?F     c               (    V ^8  d   QhRRRRRRRR/# )	r%   pcmz0bytes | bytearray | memoryview | Iterable[float]r   r'   r   r1   r0   bytesr   )r2   s   "r   r3   r   4  s2      =  	
 
r   c                	    R # r:   r   ri   r   r   r   s   &&&&r   encodeEncoder.encode3  s     r   c               (    V ^8  d   QhRRRRRRRR/# )r%   r   bytes | bytearray | memoryviewr   r'   r   r0   r   r   )r2   s   "r   r3   r   <  s,      1>ANQ	r   c                	    R # r:   r   r   s   &&&&r   r   r   ;  s     r   c               $    V ^8  d   QhRRRRRR/# )r%   r   r'   r   r-   r0   r   r   )r2   s   "r   r3   r   @  s!     3" 3"S 3"Z 3"5 3"r   c           
        V P                   pV P                  4       pV P                  V4      w  rgWE,          pVf   \        P                  ! RV4      p	\	        \        V	4      4      V,          ^8  g   \        R4      h\        W,
          ^ 4      p
V	P                  \        P                  ! R^ .V
,          4      4       MR\        V\        P                  ! V4      ,          \        V4      ,
          ^ 4      p
\        V4      \        V
4      ,           p	\        V,          ! 4       p^ p\        V P                  4       F  w  rV\        P                  ! V4      ,          pWxV,
          ,          P!                  W4      pW$,          \#        WV,          8  4      ,           p\        V,          P!                  W4      pVV,          pV P$                  P'                  WW\        V4      V4      pV^ 8  g   K  \        R4      h	  \)        V4      # )a^  
Encodes LC3 frame(s), for each channel.

The `pcm` input is given in two ways. When no `bit_depth` is defined,
it's a vector of floating point values from -1 to 1, coding the sample
levels. When `bit_depth` is defined, `pcm` is interpreted as a byte-like
object, each sample coded on `bit_depth` bits (16 or 24).
The machine endianness, or little endian, is used for 16 or 24 bits
width, respectively.
In both cases, the `pcm` vector data is padded with zeros when
its length is less than the required input samples for the encoder.
Channels concatenation of encoded LC3 frames, of `nbytes`, is returned.
fzOut of range PCM inputrt   )r)   rw   r   arrayabssumr   maxextendr`   sizeoflen	bytearrayr   	enumerater   from_bufferr'   r@   r   r   )ri   r   r   r   	nchannelsframe_samplespcm_fmtpcm_tpcm_len
pcm_bufferpaddingdata_bufferdata_offsetichr   
pcm_offset	data_sizedatarv   s   &&&&               r   r   r   @  s    %%	..033I>+S#.J s:'-7!;*+CDD'115Gekk#sW}=> 'FMM%$883s8CQGG"3)G*<<J	),%doo6LCv}}U33JcM*77
OC!.Sy;P5P1QQIY&33KMD9$K((%%gD	SWXCQw*+;<< 7 [!!r   )
__encoders   FNNr:   )r   r   r   r   r   r	   r   rn   r   typingoverloadr   r   __classcell__r   s   @r   r   r      sb    $h DG DGL __  __ 3" 3"r   r   c                     a  ] tR tRtRt ! R R]4      tRR V 3R llltR R lt]	P                  RR	 R
 ll4       t]	P                  R R l4       tRR R lltRtV ;t# )Decoderiv  a  
LC3 Decoder wrapper.

The `frame_duration_us`, in microsecond, is any of 2500, 5000, 7500, or 10000.
The `sample_rate_hz`, in Hertz, is any of 8000, 16000, 24000, 32000
or 48000, unless High-Resolution mode is enabled. In High-Resolution mode,
the `sample_rate_hz` is 48000 or 96000.

By default, one channel is processed. When `num_chanels` is greater than one,
the PCM input stream is read interleaved and consecutives LC3 frames are
output, for each channel.

Optional arguments:
    hrmode                : Enable High-Resolution mode, default is `False`.
    output_sample_rate_hz : Output PCM sample_rate_hz, enable upsampling of output.
    libpath               : LC3 library path and name
c                      ] tR tRtRtR# )Decoder.c_decoder_ti  r   Nr   r   r   r   c_decoder_tr     r   r   r   c               4    V ^8  d   QhRRRRRRRRRRR	R
RR/# )r%   r&   r'   r(   r)   r*   r+   output_sample_rate_hzr-   r.   r/   r0   r1   r   )r2   s   "r   r3   Decoder.__annotate__  sb     DG DGDG DG 	DG
 DG  *DG DG 
DGr   c                	  <a a \         SS `  VVVVVV4       S P                  o\        ;QJ d    V3R  lR
 4       F  '       d   K   RM	  RM! V3R  lR
 4       4      '       gD   S P                  '       d   \        R4      hV3R lpV3R lp\        SRV4       \        SRV4       \        \        \        .SP                  n
        \        SP                  n        \        \        \        \        \        .SP                  n
        S P                  SP                  n        S P                  \        \        \        \        \        .SP                   n
        VV 3R lp	\#        V4       U
u. uF	  q! 4       NK  	  up
S n        R	# u up
i )c              3  <   <"   T F  p\        SV4      x  K  	  R # 5ir:   r;   r=   s   & r   rA   #Decoder.__init__.<locals>.<genexpr>  r   rC   lc3_hr_decoder_sizelc3_hr_setup_decoderFTrH   c                &   < SP                  W4      # r:   )lc3_decoder_sizerK   s   &&&r   rN   "Decoder.__init__.<locals>.<lambda>  r   r   c                (   < SP                  WW44      # r:   )lc3_setup_decoderr   s   &&&&&r   rN   r    r   r   c                    < S P                  SP                  SP                  SP                  SP                  SP                  S P                  SP                  SP                  SP                  4      4      4      # r:   )r   r*   r&   r(   r,   rf   r   r   s   r   new_decoder%Decoder.__init__.<locals>.new_decoder  r   r   N)r   r   )r   rn   r@   rc   r*   r   rd   r   r   r   re   r   rg   r	   r   r   
lc3_decoder   _Decoder__decoders)ri   r&   r(   r)   r*   r   r.   r   r   r  ir@   r   s   f&&&&&&    @r   rn   Decoder.__init__  sF    	!	
 hhs 
G
sss 
G
 
 
 {{{)*STT#
 !
 C.0CDC/1EF,2E5+A(*0'-3UE5(,S  )+/+;+;  ( #
	 382EF2EQ;=2EFFr   c                   V ^8  d   QhRR/# r   r   )r2   s   "r   r3   r     r   r   c                	F   a   V 3R  lS P                    4        R#     R# ; i)c              3  F   <"   T F  pSP                  V4      x  K  	  R # 5ir:   r   )r>   decoderri   s   & r   rA   "Decoder.__del__.<locals>.<genexpr>  r   r   N)r  r   s   fr   r   Decoder.__del__  r   r   c               $    V ^8  d   QhRRRRRR/# )r%   r   r   r   r1   r0   zarray.array[float]r   )r2   s   "r   r3   r     s$     ! !2!?C!	!r   c                	    R # r:   r   ri   r   r   s   &&&r   decodeDecoder.decode  s     !r   c               $    V ^8  d   QhRRRRRR/# )r%   r   r   r   r'   r0   r   r   )r2   s   "r   r3   r     s    XX9XcXeXr   c                	    R # r:   r   r  s   &&&r   r  r    s    UXr   c               $    V ^8  d   QhRRRRRR/# )r%   r   r   r   r-   r0   zbytes | array.array[float]r   )r2   s   "r   r3   r     s)     )X )X2)X?I)X	#)Xr   c           	        V P                   pV P                  V4      w  rEW0P                  4       ,          pWV,          ! 4       p\        V4      p^ p	\	        V P
                  4       F  w  rV
\        P                  ! V4      ,          pWVV
,
          ,          P                  W|4      p\        V4      V,          \        V
\        V4      V,          8  4      ,           p\        V,          P                  W4      pW,          p	V P                  P                  W\        V4      WMV P                   4      pV^ 8  g   K  \        R4      h	  Vf   \        P                  ! RV4      # \!        V4      # )a  
Decodes an LC3 frame.

The input `data` is the channels concatenation of LC3 frames in a
byte-like object. Interleaved PCM samples are returned according to
the `bit_depth` indication.
When no `bit_depth` is defined, it's a vector of floating point values
from -1 to 1, coding the sample levels. When `bit_depth` is defined,
it returns a byte array, each sample coded on `bit_depth` bits.
The machine endianness, or little endian, is used for 16 or 24 bits
width, respectively.
rt   r   )r)   r   rw   r   r   r  r`   r   r   r   r'   r   r@   r  r   r   r   )ri   r   r   r)   r   r   r   r   r   r   r   r  r   r   r   bufrv   s   &&&              r   r  r    s4     ((33I>!7!7!99o(
o%doo6LCv}}U33JcM*77
OCK(L83c+&55< I I%22;LC$K((%%c#hd6G6GC Qw*+;<< 7  09/@u{{3
+WeJFWWr   )
__decodersr   r:   )r   r   r   r   r   r	   r   rn   r   r   r   r  r   r   r   s   @r   r   r   v  s`    $h DG DGL __! ! __X X)X )Xr   r   )
__future__r   r   r`   enumrZ   r[   r   r   r   r   r   r   r	   ctypes.utilr
   collections.abcr   	Exceptionr   RuntimeErrorr   
ValueErrorr   IntEnumr   r#   r   r   r   r   r   <module>r$     s     #     	  D D $ $'	 ':,	 :5:y 5 \P \P~c"e c"LTXe TXr   