+
    ~j                    N    ^ RI Ht ^ RIHt ^RIHt RR.tR R ltRR R	 lltR
# )    )annotations)AsyncIterator)
AudioFramecombine_audio_framessine_wave_generatorc                    V ^8  d   QhRRRR/# )   bufferzAudioFrame | list[AudioFrame]returnr    )formats   "f/Users/mitch_tango/dev/rabbit-r1-livekit/agent/.venv/lib/python3.14/site-packages/livekit/rtc/utils.py__annotate__r      s     L L!> L: L    c                   \        V \        4      '       g   V # V '       g   \        R4      hV ^ ,          P                  pV ^ ,          P                  p^ p^ pV  F  pVP                  V8w  d   \        RV RVP                   24      hVP                  V8w  d   \        RV RVP                   24      hV\        VP                  4      ,          pWEP                  ,          pK  	  \        V4      p^ pV  FC  pVP                  P                  R4      pWWw\        V4      ,           % V\        V4      ,          pKE  	  \        VVVVR7      # )a  
Combines one or more `rtc.AudioFrame` objects into a single `rtc.AudioFrame`.

This function concatenates the audio data from multiple frames, ensuring that
all frames have the same sample rate and number of channels. It efficiently
merges the data by preallocating the necessary memory and copying the frame
data without unnecessary reallocations.

Args:
    buffer: A single `rtc.AudioFrame` or a list of `rtc.AudioFrame`
        objects to be combined.

Returns:
    rtc.AudioFrame: A new `rtc.AudioFrame` containing the combined audio data.

Raises:
    ValueError: If the buffer is empty.
    ValueError: If frames have differing sample rates.
    ValueError: If frames have differing numbers of channels.

Example:
    >>> frame1 = rtc.AudioFrame(
    ...     data=b"", sample_rate=48000, num_channels=2, samples_per_channel=1
    ... )
    >>> frame2 = rtc.AudioFrame(
    ...     data=b"", sample_rate=48000, num_channels=2, samples_per_channel=1
    ... )
    >>> combined_frame = combine_audio_frames([frame1, frame2])
    >>> combined_frame.data
    b''
    >>> combined_frame.sample_rate
    48000
    >>> combined_frame.num_channels
    2
    >>> combined_frame.samples_per_channel
    2
zbuffer is emptyzSample rate mismatch: expected z, got z!Channel count mismatch: expected b)datasample_ratenum_channelssamples_per_channel)
isinstancelist
ValueErrorr   r   lenr   r   	bytearraycastr   )	r
   r   r   total_data_lengthtotal_samples_per_channelframer   offset
frame_datas	   &        r   r   r      sL   L fd##*++)''K!9))L !+1+fUEVEVDWX  -3L>HZHZG[\  	S_,!%>%>>!  &'DFZZ__S)
2<Vs:./#j/! 
 !5	 r   c          
     ,    V ^8  d   QhRRRRRRRRRR/# )	r	   freqfloatdurationr   int	amplituder   zAsyncIterator[AudioFrame]r   )r   s   "r   r   r   Z   s:     0 0
00 0 	0
 0r   c                 "    ^ RI pT^
,          p\        Y,          T,          4      pTP                  T4      T,          p\	        T4       F  pYxT,          T,          ,           p	Y4P                  ^TP                  ,          T ,          T	,          4      ,          p
TP                  T
R,          4      p\        TP                  4       T^T4      pT5x  K  	  R#   \         d    \        R4      hi ; i5i)a  
Generate sine wave audio frames.

Useful for testing audio pipelines and generating test signals.

Args:
    freq: Frequency of the sine wave in Hz.
    duration: Duration of the audio in seconds.
    sample_rate: Sample rate in Hz (default: 48000).
    amplitude: Amplitude of the sine wave, range [0.0, 1.0] (default: 0.3).

Yields:
    AudioFrame: Audio frames containing sine wave data.

Example:
    >>> import asyncio
    >>> async def generate_audio():
    ...     async for frame in sine_wave_generator(440, 1.0):
    ...         print(f"Generated frame with {frame.samples_per_channel} samples")
    >>> asyncio.run(generate_audio())
NzMnumpy is required for sine_wave_generator. Install it with: pip install numpyi  )
numpyImportErrorr&   arangerangesinpiint16r   tobytes)r#   r%   r   r'   np	blocksizetotal_framest_frameitsignalsignal_int16r   s   &&&&         r   r   r   Z   s     6
 r!I.9<=Lii	"[0G< )mk11VVAI$4q$899xx/  "	
  !  
[
 	

s   C4C CC4C11C4N)i  g333333?)	
__future__r   typingr   audio_framer   __all__r   r   r   r   r   <module>r=      s,    "   # "#8
9L^0 0r   