public void generateCode(SpinFXBlock sfxb) {

    // Iterate through mem and equ statements, allocate accordingly

    sfxb.comment(getName());

    SpinCADPin sp = null;

    // Iterate through pin definitions and connect or assign as needed
    sp = this.getPin("Input 1").getPinConnection();
    int inp1 = -1;
    if (sp != null) {
      inp1 = sp.getRegister();
    }
    sp = this.getPin("Input 2").getPinConnection();
    int inp2 = -1;
    if (sp != null) {
      inp2 = sp.getRegister();
    }
    sp = this.getPin("Fade").getPinConnection();
    int input0 = -1;
    if (sp != null) {
      input0 = sp.getRegister();
    }

    // finally, generate the instructions
    output1 = sfxb.allocateReg();
    if (this.getPin("Input 1").isConnected() == true) {
      if (this.getPin("Input 2").isConnected() == true) {
        sfxb.readRegister(inp1, -gain1);
        sfxb.readRegister(inp2, gain2);
        if (this.getPin("Fade").isConnected() == true) {
          sfxb.mulx(input0);
        }

        sfxb.readRegister(inp1, gain1);
      } else {
        sfxb.readRegister(inp1, gain1);
        if (this.getPin("Fade").isConnected() == true) {
          sfxb.mulx(input0);
        }
      }

    } else {
      sfxb.readRegister(inp2, gain2);
      if (this.getPin("Fade").isConnected() == true) {
        sfxb.mulx(input0);
      }
    }

    sfxb.writeRegister(output1, 0);
    this.getPin("Audio Output").setRegister(output1);
  }
  public void generateCode(SpinFXBlock sfxb) {
    // at this moment, code implements a low pass.
    // and not a very good one at that!
    // coefficients

    // need to figure out how to map these coefficients to freq/resonance
    sfxb.comment(sfxb.getName());
    double kfl = 1.0 - Math.exp((-6.283 * f0) / getSamplerate());
    double kql = -0.13;

    int input = this.getPin("Audio Input").getPinConnection().getRegister();

    int lpal = sfxb.allocateReg();
    int lpbl = sfxb.allocateReg();
    int lpoutl = sfxb.allocateReg();

    //		int rmixl = sfxb.allocateReg();
    //		int kfx = sfxb.allocateReg();

    //		;now do the low pass.

    sfxb.skip(RUN, 3);
    sfxb.clear();
    sfxb.writeRegister(lpal, 0);
    sfxb.writeRegister(lpbl, 0);

    // ------------- start of filter code
    //		rdax	lpal,1
    sfxb.readRegister(lpal, kfl);
    //		mulx	kfl
    //		sfxb.mulx(kfl);
    //		rdax	lpbl,1
    sfxb.readRegister(lpbl, 1.0);
    //		wrax	lpbl,-1
    sfxb.writeRegister(lpbl, -1.0);
    //		rdax	lpal,kql
    sfxb.readRegister(lpal, kql);
    //		rdax	input,1
    sfxb.readRegister(input, 1.0);
    //		wrax	lpoutl,1	;lp output
    sfxb.writeRegister(lpoutl, kfl);
    //		mulx	kfl
    //		sfxb.mulx(kfl);
    //		rdax	lpal,1
    sfxb.readRegister(lpal, 1.0);
    //		wrax	lpal,0
    sfxb.writeRegister(lpal, 0);

    //		rdax	lpbl,-1
    sfxb.readRegister(lpbl, -1.0);
    //		rdax	rmixl,1
    sfxb.readRegister(input, 1.0);
    //		rdax	lpbl,1
    sfxb.readRegister(lpbl, 1.0);

    this.getPin("Audio Output").setRegister(lpoutl);
    System.out.println("BPF code gen!");
  }