+
    ~j                    Z    ^ RI Ht ^RIHtHt ^RIHt ^RIH	t	 ^RI
Ht  ! R R4      tR# )	    )annotations)	FfiClient	FfiHandle)ffi_pb2)get_address)
AudioFramec                  ^    ] tR t^	tRtRRRRRRRR/R R lltR	 R
 ltR R ltR R ltRt	R# )AudioProcessingModulez
Provides WebRTC audio processing capabilities including echo cancellation, noise suppression,
high-pass filtering, and gain control.
echo_cancellationFnoise_suppressionhigh_pass_filterauto_gain_controlc          
     ,    V ^8  d   QhRRRRRRRRRR/# )   r   boolr   r   r   returnNone )formats   "d/Users/mitch_tango/dev/rabbit-r1-livekit/agent/.venv/lib/python3.14/site-packages/livekit/rtc/apm.py__annotate__"AudioProcessingModule.__annotate__   sE     A A  A  	A
 A  A 
A    c               ^   \         P                  ! 4       pWP                  n        W%P                  n        W5P                  n        WEP                  n        \        P                  P                  V4      p\        VP                  P                  P                  P                  4      V n        R# )a  
Initialize an AudioProcessingModule instance with the specified audio processing features.

Args:
    echo_cancellation (bool, optional): Whether to enable echo cancellation.
    noise_suppression (bool, optional): Whether to enable noise suppression.
    high_pass_filter (bool, optional): Whether to enable a high-pass filter.
    auto_gain_control (bool, optional): Whether to enable auto gain control.
N)	proto_ffi
FfiRequestnew_apmecho_canceller_enablednoise_suppression_enabledhigh_pass_filter_enabledgain_controller_enabledr   instancerequestr   apmhandleid_ffi_handle)selfr   r   r   r   reqresps   &$$$$  r   __init__AudioProcessingModule.__init__   ss    " ""$->*0A-/?,.?+!!))#.$T\\%5%5%<%<%?%?@r   c                    V ^8  d   QhRRRR/# r   datar   r   r   r   )r   s   "r   r   r   )   s     > >: >$ >r   c                   \        VP                  \        4      '       g=   \        VP                  \        4      '       d7   VP                  P                  '       d   \        VP                  4      Vn        \        P                  ! 4       pV P                  P                  VP                  n        \        VP                  4      VP                  n        \        VP                  4      VP                  n        VP                   VP                  n        VP"                  VP                  n        \$        P&                  P)                  V4      pVP                  P*                  '       d    \-        VP                  P*                  4      hR# )a,  
Process the provided audio frame using the configured audio processing features.

The input audio frame is modified in-place (if applicable) by the underlying audio
processing module (e.g., echo cancellation, noise suppression, etc.).

Important:
    Audio frames must be exactly 10 ms in duration.
N)
isinstance_databytes
memoryviewreadonly	bytearrayr   r   r'   r%   apm_process_stream
apm_handler   data_ptrlensizesample_ratenum_channelsr   r"   r#   errorRuntimeErrorr(   r/   r)   r*   s   &&  r   process_stream$AudioProcessingModule.process_stream)   s    djj%((tzz:..4::3F3F3F"4::.DJ""$,0,<,<,C,C)*5djj*A'&)$**o#-1-=-=*.2.?.?+!!))#.""(((t66<<== )r   c                    V ^8  d   QhRRRR/# r.   r   )r   s   "r   r   r   D   s     F F: F$ Fr   c                   \        VP                  \        4      '       g=   \        VP                  \        4      '       d7   VP                  P                  '       d   \        VP                  4      Vn        \        P                  ! 4       pV P                  P                  VP                  n        \        VP                  4      VP                  n        \        VP                  4      VP                  n        VP                   VP                  n        VP"                  VP                  n        \$        P&                  P)                  V4      pVP                  P*                  '       d    \-        VP                  P*                  4      hR# )a  
Process the reverse audio frame (typically used for echo cancellation in a full-duplex setup).

In an echo cancellation scenario, this method is used to process the "far-end" audio
prior to mixing or feeding it into the echo canceller. Like `process_stream`, the
input audio frame is modified in-place by the underlying processing module.

Important:
    Audio frames must be exactly 10 ms in duration.
N)r1   r2   r3   r4   r5   r6   r   r   r'   r%   apm_process_reverse_streamr8   r   r9   r:   r;   r<   r=   r   r"   r#   r>   r?   r@   s   &&  r   process_reverse_stream,AudioProcessingModule.process_reverse_streamD   s    djj%((tzz:..4::3F3F3F"4::.DJ""$484D4D4K4K&&12=djj2I&&/.1$**o&&+595E5E&&26:6G6G&&3!!))#.**000t>>DDEE 1r   c                    V ^8  d   QhRRRR/# )r   delay_msintr   r   r   )r   s   "r   r   r   `   s     @ @C @D @r   c                N   \         P                  ! 4       pV P                  P                  VP                  n        WP                  n        \        P                  P                  V4      pVP                  P                  '       d    \        VP                  P                  4      hR# )a  
This must be called if and only if echo processing is enabled.

Sets the `delay` in ms between `process_reverse_stream()` receiving a far-end
frame and `process_stream()` receiving a near-end frame containing the
corresponding echo. On the client-side this can be expressed as
    delay = (t_render - t_analyze) + (t_process - t_capture)
where,
    - t_analyze is the time a frame is passed to `process_reverse_stream()` and
    t_render is the time the first sample of the same frame is rendered by
    the audio hardware.
    - t_capture is the time the first sample of a frame is captured by the
    audio hardware and t_process is the time the same frame is passed to
    `process_stream()`.
N)r   r   r'   r%   apm_set_stream_delayr8   rI   r   r"   r#   r>   r?   )r(   rI   r)   r*   s   &&  r   set_stream_delay_ms)AudioProcessingModule.set_stream_delay_ms`   s|      ""$.2.>.>.E.E  +,4  )!!))#.$$***t88>>?? +r   )r'   N)
__name__
__module____qualname____firstlineno____doc__r+   rA   rF   rM   __static_attributes__r   r   r   r
   r
   	   sP    
A #(A #(	A
 "'A #(A4>6F8@ @r   r
   N)
__future__r   _ffi_clientr   r   _protor   r   _utilsr   audio_framer   r
   r   r   r   <module>rZ      s"    " - (  #n@ n@r   