Custom waveforms in beads

hey I’m new to the forum so please apologize when this is answered elsewhere, but i couldnt find any help online.

I’m trying to change the waveform buffer of a beads, i can change the array directly but as soon as I’m trying to change the input outside of the class it just gives me a straight line, could you tell me what I’m doing wrong?

// Custom_Beads_01.pde
// this program demonstrates how to create and use custom
// Beads objects in Processing
import beads.*; // import the beads library
AudioContext ac; // create our AudioContext
// declare our unit generators
WavePlayer wavetableSynthesizer;
Glide frequencyGlide;
// our envelope and gain objects
Envelope gainEnvelope;

Gain synthGain;
void setup()
{
 size(800, 600);
 // initialize our AudioContext
 ac = new AudioContext();

 // create our Buffer
 Buffer wavetable = new
 DiscreteSummationBuffer().generateBuffer(4096, 15, 0.8);
 frequencyGlide = new Glide(ac, 200, 10);
 wavetableSynthesizer = new WavePlayer(ac,
 frequencyGlide,
 new DiscreteSummationBuffer().generateBuffer(44100));
 // create the envelope object that will control the gain
 gainEnvelope = new Envelope(ac, 0.0);
 // create a Gain object, connect it to the gain envelope
 synthGain = new Gain(ac, 1, gainEnvelope);
 // connect the synthesizer to the gain
 synthGain.addInput(wavetableSynthesizer);
 // connect the Gain output to the AudioContext
 ac.out.addInput(synthGain);
 // start audio processing
 ac.start();

 background(0);
 drawBuffer(wavetable.buf);
 text("Click to trigger the wavetable synthesizer.",
 100, 120);
}
void draw()
{
 // set the fundamental frequency
 frequencyGlide.setValue(mouseX);
}
// this routine is triggered whenever a mouse button
// is pressed
void mousePressed()
{
 // when the mouse button is pressed, at a 50ms attack
 // segment to the envelope
 // and a 300 ms decay segment to the envelope
 gainEnvelope.addSegment(0.8, 50); // over 50 ms rise to 0.8
 gainEnvelope.addSegment(0.0, 200); // in 300ms go to 0.0
}
// draw a buffer on screen
void drawBuffer(float[] buffer)
{
 float currentIndex = 0.0;

 float stepSize = buffer.length / (float)width;

 color c = color(255, 0, 0);
 stroke(c);
 for( int i = 0; i < width; i++ )
 {
 set(i, (int)(buffer[(int)currentIndex] *
 (height / 2.0)) + (int)(height / 2.0), c);
 currentIndex += stepSize;
 }
}
// DiscreteSummationBuffer.pde
// This is a custom Buffer class that implements the Discrete
// Summation equations as outlines by Moorer, with the Dodge
// & Jerse modification.
// if you want this code to compile within the Beads source,
// then you would use these includes
//import net.beadsproject.beads.data.Buffer;
//import net.beadsproject.beads.data.BufferFactory;
import beads.Buffer;
import beads.BufferFactory;
public class DiscreteSummationBuffer extends BufferFactory
{
 // this is the generic form of generateBuffer that is
 // required by Beads
 public Buffer generateBuffer(int bufferSize)
 {
 // are these good default values?
 return generateBuffer(bufferSize, 10, 0.9f);
 }
 // this is a fun version of generateBuffer that will allow
 // us to really employ the Discrete Summation equation
 public Buffer generateBuffer(int bufferSize,
 int numberOfHarmonics,
float amplitude)
 {
 Buffer b = new Buffer(bufferSize);

 for( int j = 0; j < b.buf.length; j++ )
 {

 float newValue = random(1);

 // set the value for the new buffer
 b.buf[j] = newValue;
 }
 return b;
 }
 // we must implement this method when we inherit from
 // BufferFactory
 public String getName() {
 return "DiscreteSummation";
 }
};

forgot to add:

this is how I tried changing it before:

void changeSignal(float newSignal) {
signal = newSignal;
wavetableSynthesizer.setBuffer(new DiscreteSummationBuffer().generateBuffer(44100, 15, 0.8, signal));
}