We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
I would like to draw the waveform of an entire sound file.
I have seen the example from the documentation, but this is an osciloscope, which works with a buffer, whereas I would like to draw the waveform for the entire file, like in audacity for example
import ddf.minim.*;
Minim minim;
AudioPlayer sound;
void setup() {
size(300, 200);
minim = new Minim(this);
sound = minim.loadFile("mySound.wav");
println(sound.length());
for (int i=0; i < sound.length()-1024; i+=16) {
println( sound.mix.get(i));
}
exit();
}
this did not work because get(i)
"Gets the i sample in the buffer", wich size is 1024...
how to have all the sample value inside the file ?
==> answer is getChannel()
with AudioSample (cf AudioSample )
thx.
Answers
ok, so we need to do FFT, event if we not draw spectra...
this old post help https://forum.processing.org/one/topic/how-to-generate-a-simple-waveform-of-an-entire-sound-file.html
so, not really easy. to be cotinued.
You can get the waveform without needing to run it through fft. The problem is processing the whole file before drawing - these things are typically run in real time and only draw the current frame's worth of data.
You might be better off writing something, or finding something, that parsed wav files. They are generally quite simple, just raw values.
thx for answering.
good idea, I forget FFT, and did it. not so far of I wanted..
(it is not the real waveform since we only have positiv value...)
the question now is, how to play hat sound with a scrollbar, sync to this view :)
i think this is just a problem with how you are drawing them. you are using abs() in the average calculations so the positive and negative don't cancel each other out (which is correct imo), you should draw them so that half the line is above the axis, half below.
I have made this
it works. but... the problem is that it is not really sync :/
maybe its because the buffer size of the AudioPlayer is not the same that the one I use for drawing the waveform (1024 versus 16384)
What do you mean?
Kf
@kfrajer what we ear is not what we see.
there is an offset between the lecture of the "waveform" which I made- what we see - and the lecture of sound - what we ear.
the lecture of the sound is in advance.