0

I want to plot a waveform from a wave file. I have already parsed the data from the .wav file in terms of amplitudes(in range -32767 to 32767) based on this article ("http://soundfile.sapp.org/doc/WaveFormat/").

Now I want to plot the waveform in Java using JavaFX but I have to achieve it by drawing it pixel by pixel. Therefore, I cannot use the Line object in the JavaFX shape class("https://www.tutorialspoint.com/javafx/2dshapes_line.htm").

I tried researching but I cannot come up with an idea or where to start plotting the waveform using just pixels.

Can anyone guide me in the right direction, please?

Aaron
  • 23
  • 2
  • 1
    Can also add some sample waveform data? – Tanuj Jun 26 '20 at 16:57
  • What exactly does "I have to achieve it by drawing pixel by pixel" mean? Why do you have to do it like that? Can you use graphics commands on a [`Canvas`](https://openjfx.io/javadoc/14/javafx.graphics/javafx/scene/canvas/Canvas.html)? Or do you literally have to create a raster (e.g. using a [`WritableImage`](https://openjfx.io/javadoc/14/javafx.graphics/javafx/scene/image/WritableImage.html)? – James_D Jun 26 '20 at 17:41
  • Look at these two answers. I hope one helps. https://stackoverflow.com/questions/54925007/high-refreshing-rate-in-javafx/54928375#54928375. Beyond that, this question to too broad for StackOverflow. – SedJ601 Jun 26 '20 at 18:18
  • @James_D Suppose I have an array of pixel values i.e. RGB values. How can I draw the image with this data? I probably have to iterate and decide the location where the pixels will go on the X and Y axis but how do I actually put a single pixel on the screen. Thanks in advance – Aaron Jun 27 '20 at 18:40
  • Just use a `WritableImage`; all the methods you need are available via its `pixelWriter`. (Or create a `WritableImage` using a `PixelBuffer` and write the array to the buffer). – James_D Jun 27 '20 at 18:43
  • @James_D I could understand how the writable image work with pixel writer after much research through the documentation(can you please recommend me an easier source with example?) so I tried to create my own pixels using the rectangle shape class and giving them colour as well as position. It works for certain xValues(position of rectange in the x co-ordinate) but after a certain value everything blurs out. Idk why? – Aaron Jun 28 '20 at 00:01
  • @Aaron I just use the documentation - I’m not aware of any other sources for using `WritableImage`. Can’t comment on why it “blurs out”. See if you can recreate that in a new example (I.e. a [mre]) and post it in a new question. – James_D Jun 28 '20 at 00:04
  • @James_D Thanks for the suggestion, James. I have added my question here, please take a look. https://stackoverflow.com/questions/62625348/javafx-writing-bmp-image-pixel-by-pixel – Aaron Jun 28 '20 at 16:55

0 Answers0