Page 1 of 1
Waveform
Posted: Wed Jan 29, 2014 3:57 am
by XCaptain
There was no school to day and to kill some time, I made a waveform visualizer (it also plays the corresponding tone). It uses lines and a table of y positions. I was going to try and make one out of GLSL, but GLSL confuses me deeply
.
Re: Waveform
Posted: Sun Feb 02, 2014 4:24 pm
by iPoisonxL
This makes a cool song. I like it.
Re: Waveform
Posted: Sun Feb 02, 2014 6:20 pm
by Germanunkol
Neat little demo!
I noticed you draw all the lines individually, in a for loop. It works well and doesn't really matter much, but you might want to know that love.graphics.line can take a table as arguments as well. So if you'd save the y AND the x values into the wave table, you could simply call:
love.graphics.line(wave).
But it doesn't really matter...
Re: Waveform
Posted: Sun Feb 02, 2014 8:10 pm
by XCaptain
Germanunkol wrote:Neat little demo!
I noticed you draw all the lines individually, in a for loop. It works well and doesn't really matter much, but you might want to know that love.graphics.line can take a table as arguments as well. So if you'd save the y AND the x values into the wave table, you could simply call:
love.graphics.line(wave).
But it doesn't really matter...
The problem with using a table of both x and y values is the x value will always stay the same relative to the y value. The for loop uses the iterator for the x while removing the first Y value. When the 1st Y value is removed, all the remaining values shift down one (removed<-1st <- 2nd <- 3rd...). By doing this, the wave looks like it is moving.
I did fix two things though. The first point is know drawn in the right position and the height and width are corrected.
need to stop coding things at 2 a.m...
Re: Waveform
Posted: Sun Feb 02, 2014 10:22 pm
by Germanunkol
Uh, you're right. My bad, sorry, I didn't think it through...