package vermilion;

/**
 * A distortion machine which places clipped audio from its 'A' buffer into
 * the output buffer.
 */
public class MachineDistortion extends MachineBase
{
    /**
     * The type for this machine is 'EFFECT'.
     */
    @Override
    public String getType()
    {
        return "EFFECT";
    }

    /**
     * The name for this machine is 'Distortion'.
     */
    @Override
    public String getName()
    {
        return "Distortion";
    }

    /**
     * The mixing algorithm for this plugin clips the input data and copies to
     * the output buffer.
     */
    @Override
    public void fillBuffer(int numSamples)
    {
        for (int x = 0; x < numSamples; x++)
        {
            output[0][x] = Math.min(0.99f, Math.max(-0.99f, aInput[0][x]));
            output[1][x] = Math.min(0.99f, Math.max(-0.99f, aInput[1][x]));
        }
    }

    /**
     * This machine has no parameters to change and does nothing.
     */
    @Override
    public void parameterChange(PlaybackEvent param)
    {
    }

    /**
     * This machine does no setup and has no parameters.
     */
    @Override
    public void setupMachine()
    {
    }

    /**
     * This machine has no parameters and returns an empty string for printing.
     */
    @Override
    public String printParameter(ParameterBase p)
    {
        return "";
    }
}