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

**URL:** <https://discourse.processing.org/t/i-am-trying-to-express-in-real-time-by-passing-sound-data/34291>\
**Category:** Libraries\
**Created:** [December 26, 2021, 12:30am UTC](https://discourse.processing.org/t/i-am-trying-to-express-in-real-time-by-passing-sound-data/34291 "2021-12-26T00:30:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [December 26, 2021, 12:30am UTC](https://discourse.processing.org/t/i-am-trying-to-express-in-real-time-by-passing-sound-data/34291/1 "2021-12-26T00:30:50Z")

</div>

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.

> [@How can I convert voice data to a .wav file?](https://discourse.processing.org/t/how-can-i-convert-voice-data-to-a-wav-file/16893/2):
>
> Reference site address: [https://crystalcube.co.kr/123](https://crystalcube.co.kr/123) It is said that raw data can be converted to .wav through ‘Goldwave Tool’ program. Couldn’t it be implemented through ‘processing program’?

> [@Is it possible to convert arduino ADC value to wav file?](https://discourse.processing.org/t/is-it-possible-to-convert-arduino-adc-value-to-wav-file/15931):
>
> Is it possible to convert arduino ADC value to wav file? Hi. The flowchart is as follows: Receive the sound signal from the microphone. It is delivered to Arduino analog pins through the amplifier. Get the ADC value. Align the ADC value and receive data from PC through wireless communication. At this time, is there a way to convert wav file through ADC value? Or is there a library file provided for processing?

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 :  
[https://youtu.be/8gi91Qm-eNQ](https://youtu.be/8gi91Qm-eNQ)

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?
