Minim
minim.loadFile() doesn't work in my processing sketch when I specify a file path. I've included the sketch that refuses to run, I get
unexpected char 'p' as an error. The sketch runs when I use the default path with minim.loadFile(). I don't know if this is a known problem as I haven't found the bug list for minim.
import ddf.minim.spi.*;
import ddf.minim.signals.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.ugens.*;
import ddf.minim.effects.*;
/**
* This sketch demonstrates the difference between linearly spaced averages and logarithmically spaced averages
* (averages that are grouped by octave). It also draw the full spectrum so you can see how each set of averages
* compares to it.
* <p>
* From top to bottom:
* <ul>
* <li>The full spectrum.</li>
* <li>The spectrum grouped into 30 linearly spaced averages.</li>
* <li>The spectrum grouped logarithmically into 10 octaves, each split into 3 bands.</li>
I've been trying to understand the use of (this) when referring to the current object. Does (this) reference the sketch that is being written or does it refer to the last object encountered in the sketch? What is the current object, I'm new to the use of objects.
When I read an audio buffer with a FOR loop (L, R, Mixed) I get a corrupt wave forms. I looks like processing/minim gets part way through the buffer and it's overwritten by the audio card hardware. I think processing/minim can't read 16 bit words fast enough. The buffers are being overwritten about 4 times with a 1024 length buffer. The 16 bit words in the buffer represent samples at a 44100 Hz rate so if i pick a waveform frequency that's a multiple of 2 the buffer will always have the same data and the waveform will look correct even while the buffer has been overwritten. When I use a 344.5313 Hz (44100/128) the waveform in the buffer is static and uncorrupted. (Note 128 = 2^7)
My question is if processing/minim can read all 1024 16 bit words with a
read array buffer command? This may be faster than by reading each element with the FOR loop. What do you think? As I am very new to minim could you include some code with your comments.
My next question is if minim can take raw 16 bit data from processing to generate periodic sounds? Can you
write to the audio buffers. What do you think? Please include some code with your comments.
The following screen shots are from sketch that shows a finite number of Fourier series sums. Originally the sketch had no gui and produced sums continuously. I then used the G4PTool 1.1.0, Processing 1.5.1, and G4P 1.7.6 and was then able to add a text box, slider control and link these to code in my sketch. Having completed use of the Tool, the sketch ran perfectly on Processing 1.5.1 and Processing 2.0b6 both using G4P 1.7.6.
Just paste the following sketch into Processing, hit run and move the slider control to show a varying number of sums:
import guicomponents.*;
int t=0;
int k=1;
int n=1;
float f=.0025;
int height=200;
int width=1000;
float[] x = new float[width+1];
float[] y = new float[width+1];
float[] y_sum = new float[width+1];
void setup()
{
size(800, 200);
stroke(0, 0, 0);
createGUI();
}
void draw()
{
zero_arrays();
for (k=1; k<=n; k++) {
background(122, 232, 90);
fourier();
sum();
plot();
}
}
int t1=0;
void delay()
{
t1=millis();
while (millis()-t1 < 1){
}
}
/*
Using Fourier expansion with cycle frequency f over time t,
we can write an ideal square wave as an infinite series of
the form: x(t)=[k=1..00] (4/pi)(sin(2pi(2k-1)ft))/(2k-1)
When I try to install G4PTool I get "could not move tool to sketchbook". I'm not sure if it's a permission problem, I tried to change the sketchbook to read write but it always goes back to read only.