package net.mkonrad.synes.data.instruments;

import javax.vecmath.Point3f;

import net.mkonrad.synes.data.Beat;
import net.mkonrad.synes.data.Layer;
import net.mkonrad.synes.data.Modulator;
import net.mkonrad.synes.data.SynthInstrument;
import net.mkonrad.synes.data.SynthObj;
import net.mkonrad.synes.gui.elements.instruments.InstrumentShape;
import net.mkonrad.synes.gui.elements.instruments.PentagonShape;
import net.mkonrad.synes.gui.elements.instruments.TriangleShape;
import net.mkonrad.synes.gui.style.Colors;
import net.mkonrad.synes.util.Common3DTools;
import net.mkonrad.synes.util.DbgTools;
import net.mkonrad.synes.util.MusicTools;

public class Scratch extends SynthInstrument
{
  public Scratch()
  {
    super();
    _name = "synes_scratch";
    _iconName = "scratch.png";
    _texture = "triangle.png";
    _color = Colors.turquoise;
    _synthArgs = new String[] { "x", "y", "amp" };
    _modArgs = new String[] {  "x", "y", "amp", "modX", "modY", "modAmp" };
  }
  
  public boolean needsKeyboard()
  {
    return false;
  }
  
  public InstrumentShape createInstrumentShape(SynthObj synthData, Point3f pos)
  {
    return new TriangleShape(synthData, pos);
  }
  
  public float getModValueForArg(String argName, SynthObj synth, Modulator mod)
  {
    if (argName.equals("modX"))
    {
      return (MusicTools.getPanFromXCoord(mod.getAbsPos().x) + 1) / 2;
    }
    else if (argName.equals("modY"))
    {
      return (MusicTools.getPitchFromYCoord(mod.getAbsPos().y) + 1) / 2;
    }
    else if (argName.equals("modAmp"))
    {
      return mod.getAmp();
    }
    else
    {
      return getValueForArg(argName, synth);
    }
  }
  
  protected float getYArg(SynthObj synth)
  {
    return MusicTools.getPitchFromYCoord(synth.getInstrumentShape().getAbsPos().y);
  }
}
