questions about drawing waveform lines (java)
<p>Given these instructions, I'd be very grateful if someone could help undestand
the questions written as comments.</p>

<p>My purpose is to build an audio tool , in java, whose main feature is :
- displaying a signal waveform while an audio file is being played.</p>

<p>Thank you very much..Ulrike</p>

<pre><code>// here the list lines , does it store points (line coordinates) ???


     List&lt;Byte&gt; audioBytes;
     List&lt;Line2D.Double&gt; lines;




    public void addAudioByte(byte b) {
                audioBytes.add(b);
            }




public void createWaveForm() {

       if (audioBytes.size() == 0) {
            return;
        }

        AudioFormat format = audioInputStream.getFormat();


        Dimension d = getSize();
        int w = d.width;
        int h = d.height - 15;



            // calculate number of frames per pixel 


int frames_per_pixel = audioBytes.size() / format.getFrameSize() / w;
        byte my_byte = 0;
        double y_last = 0;
        int numChannels = format.getChannels();
        for (double x = 0; x &lt; w &amp;&amp; audioData != null; x++) {
            // here what happens???
            int idx = (int) (frames_per_pixel * numChannels * x);

            if (format.getSampleSizeInBits() == 8) {
                my_byte = (byte) audioData[idx];
            } else {
                    // here what happens???


my_byte = (byte) (128 * audioData[idx] / 32768);
            }
                // does this code draw the line ???
                // Y samples values


double y_new = (double) (h * (128 - my_byte) / 256);
            lines.add(new Line2D.Double(x, y_last, x, y_new));
            y_last = y_new;
        }


        repaint();
    }
    // does this method draw the lines??? what does it do?  
        public void paint(Graphics g) {
            // component dimensions
            Dimension d = getSize();
            g.setColor(getBackground());
            g.fillRect(0, 0, d.width, d.height);

            if (audioBytes.size() == 0) {
                return;
            }

            // I suppose this is where the lines are actually drawn 
        // The lines (so the waveform) are points and here they get connected based on the content
        // of the list lines (declared above) ..is my reasoning correct?        
            g.setColor(Color.LIGHT_GRAY);
            for (int i = 1; i &lt; lines.size(); i++) {
                Line2D.Double line = lines.get(i);
                g.drawLine((int) line.x1, (int) line.y1, (int) line.x2, (int) line.y2);
            }
        }
    }
</code></pre>
