o
    pi                     @   sD   d dl mZ d dlmZ ddlmZ ddlmZ G dd deZdS )	    )Tensor)Optional   )BaseWaveformTransform
ObjectDictc                       s   e Zd ZdZh dZdZdZdZdZ						dde	d	e
d
ee	 dee dee dee	 f fddZ				ddedee dee dee def
ddZ  ZS )PolarityInversionad  
    Flip the audio samples upside-down, reversing their polarity. In other words, multiply the
    waveform by -1, so negative values become positive, and vice versa. The result will sound
    the same compared to the original when played back in isolation. However, when mixed with
    other audio sources, the result may be different. This waveform inversion technique
    is sometimes used for audio cancellation or obtaining the difference between two waveforms.
    However, in the context of audio data augmentation, this transform can be useful when
    training phase-aware machine learning models.
    >   	per_batchper_channelper_exampleTFr         ?Nmodepp_modesample_ratetarget_rateoutput_typec                    s   t  j||||||d d S )N)r   r   r   r   r   r   )super__init__)selfr   r   r   r   r   r   	__class__ j/home/ubuntu/.local/lib/python3.10/site-packages/torch_audiomentations/augmentations/polarity_inversion.pyr      s   	
zPolarityInversion.__init__samplestargetsreturnc                 C   s   t | |||dS )N)r   r   r   r   r   )r   r   r   r   r   r   r   r   apply_transform-   s   z!PolarityInversion.apply_transform)r   r   NNNN)NNNN)__name__
__module____qualname____doc__supported_modessupports_multichannelrequires_sample_ratesupports_targetrequires_targetstrfloatr   intr   r   r   r   __classcell__r   r   r   r   r      sR    
r   N)	torchr   typingr   core.transforms_interfacer   utils.object_dictr   r   r   r   r   r   <module>   s
    