package vermilion;

/**
 * A source machine that produces white-noise random output.
 */
public class MachineWhiteNoise extends MachineBase
{
    /**
     * The type for this machine is 'SOURCE'.
     */
    @Override
    public String getType()
    {
        return "SOURCE";
    }

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

    /**
     * The mixing algorithm for this plugin simply fills the output buffer
     * with random values.
     */
    @Override
    public void fillBuffer(int numSamples)
    {
        int baseAddr = 0;
        for (int x = 0; x < numSamples; x++)
        {
            output[baseAddr++] = (float) Math.random() * 0.3f;
            output[baseAddr++] = (float) Math.random() * 0.3f;
        }
    }

    /**
     * This machine has no parameters and does nothing.
     */
    @Override
    public void parameterChange(ParameterBase param, Object value)
    {
    }

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

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