@Override
    public void paintComponent(Graphics g) {
        super.paintComponent(g);

        g.setColor(Color.BLACK);
        g.fillRect(0, 0, this.getWidth(), this.getHeight());
        g.setColor(Color.GREEN);

        ArrayList frame = synth.outputHistory;
        //we cannot use frame.size() here because it is (briefly) oversized before
        //it removed the first element and will give an ArrayIndexOutOfBounds sooner or later
        int[] xs = new int[Synthesizer.HISTORY_LENGTH], ys = new int[Synthesizer.HISTORY_LENGTH];
        //try {
        for (int i = 0; i < Synthesizer.HISTORY_LENGTH; i++) {
            xs[i] = i * this.getWidth() / (Synthesizer.HISTORY_LENGTH - 1);
                //this needs to be tried because the frame is empty until the first keystroke occurs
            //and will throw an IndexOutOfBounds until then
            try {
                ys[i] = (this.getHeight() / 2) - (byte) frame.get(i) * 2;  //subtract because y axis starts at top and goes down
            } catch (Exception e) {
                ys[i] = 0;
            }

        }
        //} catch (NullPointerException npe) {
        //System.out.println("bad things");
        //}

        g.drawPolyline(xs, ys, Synthesizer.HISTORY_LENGTH);
    }