Minim library: trying to make beautiful representations of chords but getting glitchy output

Hey everybody, hope you’re all doing swell.

I’m working on using the minim library’s oscillator generators to create static shapes with sounds by manipulating the note intervals. However, I’m running into a bit of an issue. I’m routing one oscillator to the x-axis and another to the y-axis to create an oscilloscope essentially in order to get these shapes. When I run the code, I do get the intended output of the shape of the interval by the two sine waves interfering in 2d space. However, it fluctuates back and forth into a “glitchy” state, which I’ve found looks like it’s reverting back and forth between a projection from a different view of the shape, which I’m not sure how that works since it’s being constructed solely on 2 axes.

I’ve tried switching the output channels, introducing balance to isolate channels, changing the buffer and sample rates, and I’m not sure what else there is for me to try and resolve in order to get somewhere. At this point, I’m trying to figure out if it’s something happening in the minim operators, like with how its deconstructing each oscillator into data for me to then create a point at those x-y values, or if it’s something I’m doing wrong.

Attached I have a simplified version of the code with an interval of a fifth being made between the two oscillators, and also images of one instance where it’s working correctly, and one with an instance of this glitch happening. If there’s anything else I can attach that would be of help, let me know. Thanks so much in advance.

import ddf.minim.*;
import ddf.minim.ugens.*;

Minim       minim;
AudioOutput out1;
AudioOutput out2;
Oscil       wave1;
Oscil       wave2;

int         buffer = 1024;
float       sample = 44100;

float frequency1 = 174.417;
float frequency2 = 261.626;


void setup()
{

  size(1600, 900, P3D);

  minim = new Minim(this);

  out1 = minim.getLineOut(Minim.STEREO, buffer, sample);
  wave1 = new Oscil( frequency1, 0.5f, Waves.SINE );
  wave1.patch(out1);

  out2 = minim.getLineOut(Minim.STEREO, buffer, sample);
  wave2 = new Oscil( frequency2, 0.5f, Waves.SINE );
  wave2.patch( out2 );
}

void draw()
{
  translate(width/2, height/2);
  background(0);
  stroke(255);
  strokeWeight(3);

  for(int i = 0; i < out1.bufferSize() - 1; i++)
  {
    //point(out1.left.get(i)*600, out2.right.get(i)*600);
    line(out1.left.get(i)*600, out2.right.get(i)*600, out1.left.get(i+1)*600, out2.right.get(i+1)*600);
  }



}


An instance of the intended correct projection on the left, and one of the “glitchy” projection on the right.

New to Minim, just playing around.

import ddf.minim.*;
import ddf.minim.ugens.*;

Minim       minim;
AudioOutput out1;
AudioOutput out2;
Oscil       wave1;
Oscil       wave2;

int         buffer = 1024;
float       sample = 44100;

float frequency1 = 174.417;
float frequency2 = 261.626;
float loc;

void setup() {
  size(1600, 900, P3D);
  loc = 15;
  minim = new Minim(this);
  out1 = minim.getLineOut(Minim.STEREO, buffer, sample);
  wave1 = new Oscil( frequency1, 0.5f, Waves.SINE );
  wave1.patch(out1);
  out2 = minim.getLineOut(Minim.STEREO, buffer, sample);
  wave2 = new Oscil( frequency2, 0.5f, Waves.SINE );
  wave2.patch( out2 );
}

void draw() {
  push();
  translate(width/2, height/2);
  background(255);
  stroke(0);
  strokeWeight(3);
  for (int i = 0; i < out1.bufferSize() - 1; i++) {
    line(out1.left.get(i)*600, out2.right.get(i)*600, out1.left.get(i+1)*600, out2.right.get(i+1)*600);
  }
  pop();
  drawSlider();
}

void drawSlider() {
  push();
  noStroke();
  frequency2 = map(loc-10.55, 0.0, width, 0.0, 1000);
  fill(255);
  rect(0, height-30, width, 30); 
  fill(200, 200, 255);
  rect(10, height-15, width-20, 5); 
  fill(150, 150, 255);
  ellipse(loc, height-13, 15, 15);
  pop();
}  

void mouseDragged() {
  loc = mouseX;
  if (loc < 15) loc = 15;
  if (loc > width-15) loc = width-15;
}

void mouseReleased() {
  minim = new Minim(this);
  out1 = minim.getLineOut(Minim.STEREO, buffer, sample);
  wave1 = new Oscil( frequency1, 0.5f, Waves.SINE );
  wave1.patch(out1);
  out2 = minim.getLineOut(Minim.STEREO, buffer, sample);
  wave2 = new Oscil( frequency2, 0.5f, Waves.SINE );
  wave2.patch( out2 );
}

I appreciate it though! I didn’t think of using a slider to create new instances of notes so that’s a cool take

1 Like