I am trying to express in real time by passing sound data

I am trying to express in real time by passing sound data.

  • Mode : JAVA Mode
  • Library : minim

//================================================================//
import ddf.minim.*;

Minim minim;
AudioInput in;
AudioRecorder recorder;
float[] samples = new float[2048*40];

boolean recorded;
int byte_n = 4410;
float waveSampleRate = 44100f;

long TIMER_SOUND = 0;
int sample_n = 0;
//================================================================//

//================================================================//
void setup()
{
size(512, 200, JAVA2D);

minim = new Minim(this);

waveSampleRate = 44100f;
in = minim.getLineIn(Minim.STEREO,byte_n,waveSampleRate,16);

}
//================================================================//

//================================================================//
void draw()
{
background(0);
stroke(255);

if(recorded){
if(TIMER_SOUND < millis()){ TIMER_SOUND = millis() + 100;
for(int i = 0; i < byte_n-1; i++)
{
line(i, 50 + in.left.get(i)*50, i+1, 50 + in.left.get(i+1)*50);
line(i, 150 + in.right.get(i)*50, i+1, 150 + in.right.get(i+1)*50);
sample_n++;
samples[sample_n]=in.left.get(i);

        if( sample_n == samples.length-1){
              recorded = false;
              recorder.endRecord();
              sample_n=0;
              i = byte_n;
              println("recorder_finish");
        }        
        
  }
 }

}

}
//================================================================//

//================================================================//
void keyReleased()
{
if ( key == ‘a’ ) {
recorded = true;
recorder.beginRecord();
sample_n = 0;
println(" start");
}
}
//================================================================//

This is related to what you asked before.

  1. ‘waveSampleRate = 44100’ means that ‘44100’ data is received per second.

  2. There are ‘4410’ buffers in ‘in’.

  3. That is, the time stored in the ‘in’ buffer is ‘100ms’.
    Buffer_t = 1s / (44100/4410) = 1/10s = 100ms

  4. After saving the actual data, the wav file format was created, and it played well.
    Youtube video :
    Recording and running test results - YouTube

Here is the question.

Q1) The amount of data will be transmitted, is there any way to reduce it?
Q2) Is the method I envision the best? Or is there a better way?
Q3) Wouldn’t it be faster to send a UDP file and execute it than to send a wav file?