
    ]i                         S r SSKJrJr  SSKrSSKJr  SSKJr  SSK	J
r
   " S S	\R                  R                  5      r   SS
\R                  S\S\\   S\\\      S\S\S\\   4S jjrg)zH
Decomposition of a signal over frequency bands in the waveform domain.
    )OptionalSequenceN   )mel_frequencies)LowPassFilters)simple_reprc                      ^  \ rS rSrSr   SS\S\\   S\\\      S\	S\S\\	   4U 4S	 jjjr
S
 r\S 5       rS rSrU =r$ )
SplitBands   a  
Decomposes a signal over the given frequency bands in the waveform domain using
a cascade of low pass filters as implemented by `julius.lowpass.LowPassFilters`.
You can either specify explicitely the frequency cutoffs, or just the number of bands,
in which case the frequency cutoffs will be spread out evenly in mel scale.

Args:
    sample_rate (float): Sample rate of the input signal in Hz.
    n_bands (int or None): number of bands, when not giving them explictely with `cutoffs`.
        In that case, the cutoff frequencies will be evenly spaced in mel-space.
    cutoffs (list[float] or None): list of frequency cutoffs in Hz.
    pad (bool): if True, appropriately pad the input with zero over the edge. If `stride=1`,
        the output will have the same length as the input.
    zeros (float): Number of zero crossings to keep. See `LowPassFilters` for more informations.
    fft (bool or None): See `LowPassFilters` for more info.

..note::
    The sum of all the bands will always be the input signal.

..warning::
    Unlike `julius.lowpass.LowPassFilters`, the cutoffs frequencies must be provided in Hz along
    with the sample rate.

Shape:

    - Input: `[*, T]`
    - Output: `[B, *, T']`, with `T'=T` if `pad` is True.
        If `n_bands` was provided, `B = n_bands` otherwise `B = len(cutoffs) + 1`

>>> bands = SplitBands(sample_rate=128, n_bands=10)
>>> x = torch.randn(6, 4, 1024)
>>> list(bands(x).shape)
[10, 6, 4, 1024]
sample_raten_bandscutoffspadzerosfftc                   > [         TU ]  5         US L US L -   S:w  a  [        S5      eXl        X l        Ub  [        U5      OS U l        X@l        XPl        X`l	        Uc:  Uc  [        S5      eUS:  d  [        SU S35      e[        US-   SUS-  5      SS nO[        U5      S	U-  :  a  [        S
5      e[        U5      S:  a$  [        U Vs/ s H  owU-  PM	     snXEUS9U l        g S U l        g s  snf )Nr   z;You must provide either n_bands, or cutoffs, but not boths.z+You must provide one of n_bands or cutoffs.z&n_bands must be greater than one (got )r      g      ?z1A cutoff above sample_rate/2 does not make sense.)r   r   r   )super__init__
ValueErrorr   r   list_cutoffsr   r   r   r   maxlenr   lowpass)	selfr   r   r   r   r   r   c	__class__s	           I/mnt/rpi/tmp/demucs-venv-sys/lib/python3.13/site-packages/julius/bands.pyr   SplitBands.__init__2   s	    	tO40A5Z[[&)0)<W$
? !NOOa< #I'RS!TUU%gk1kAoFqLG7|cK// !TUUw<!)*12'Q['2cSDL
  DL	 3s   C0c                     U R                   c  US    $ U R                  U5      nUS   nU/nUSS   H  nXS-
  nUR                  U5        UnM     UR                  X-
  5        [        R                  " U5      $ )Nr   r   )r   appendtorchstack)r   inputlowslowbandslow_and_bandbands          r!   forwardSplitBands.forwardQ   s|    <<;||E"1g HL%DLLC	 % 	U[!{{5!!    c                     U R                   b  U R                   $ U R                  b3  U R                  R                   Vs/ s H  oU R                  -  PM     sn$ / $ s  snf )N)r   r   r   r   )r   r   s     r!   r   SplitBands.cutoffs`   sU    ==$== \\%26,,2F2FG2FQ(((2FGGI Hs   Ac                 .    [        U SU R                  0S9$ )Nr   )	overrides)r   r   )r   s    r!   __repr__SplitBands.__repr__i   s    4It}}+EFFr/   )r   r   r   r   r   r   r   NNT   N)__name__
__module____qualname____firstlineno____doc__floatr   intr   boolr   r-   propertyr   r4   __static_attributes____classcell__)r    s   @r!   r
   r
      s    !F EIHL9= E  HSM  "8E?3 AE  (0   >"  G Gr/   r
   signalr   r   r   r   r   r   c                 F    [        XX4XV5      R                  U 5      " U 5      $ )z
Functional version of `SplitBands`, refer to this class for more information.

>>> x = torch.randn(6, 4, 1024)
>>> list(split_bands(x, sample_rate=64, cutoffs=[12, 24]).shape)
[3, 6, 4, 1024]
)r
   to)rC   r   r   r   r   r   r   s          r!   split_bandsrF   m   s$     kG%EHHPQWXXr/   r6   )r<   typingr   r   r%   corer   r   r   utilsr   nnModuler
   Tensorr=   r>   r?   rF    r/   r!   <module>rN      s    &  ! # \G \G~ TXGK8<
Y 
Y5 
Y8C= 
Y!(5/2
Y@D
Y
Y'/~
Yr/   