Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8675467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:57:22+00:00 2026-06-12T19:57:22+00:00

First off this is for homework or… project. I’m having trouble understanding the idea

  • 0

First off this is for homework or… project.

I’m having trouble understanding the idea behind how to draw the sound data waves on to a graph in Java for a project.
I have to make this assignment entirely from scratch with a UI and everything so basically making a .wav file editor.
The main issue I’m having is getting the sound data into the graph to be drawn. Currently I have a randomly generated array of values just being drawn right now.

So far I have a mini-program running and validating the wav file for it to actually be a wav file.

I’m reading it in with a FileInputStream and validating: the RIFF bytes(0-3), FileLength(4-7), WAVE bytes(8-11), then the format chunk format(starting from the end of the RIFF chunk; and positioning the index to the end of it and giving format 0-3, length of format chunk 4-7, then the next 16 bytes for all the specifications of the wave file and storing those in their appropriate named variables.

Once I get to the DATA chunk and its length past that is all my sound data and that is what I’m unsure of how to store each byte for byte of sound data or even translate it to be value that’s related to the amplitude of the sound. I thought validating was similar so it would be the same but it doesn’t seem to be that way… Either that or I’ve been complicating something super simple since I’ve been staring at this for a few days now.

Any help is appreciated thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:57:24+00:00Added an answer on June 12, 2026 at 7:57 pm

    I’m not a Java programmer, but I know a fair bit about rendering audio so hopefully the following might be of some help…

    Given that you will almost always have a much larger number of samples than available pixels the sensible thing to do would be to draw from a cached reduction or ‘summary’ of the sample data. This is typically how audio editors (such as Audacity) render audio data. In fact the most common strategy is to compute the number of samples per pixel, then find the maximum and minimum samples for each block of size SamplesPerPixel, then draw a vertical line between each max-min pair. You might want to cache this reduction, or perhaps a series of such reductions for different zoom levels. Audacity caches to temporary files (‘block files’) on disk.

    The above is perhaps something of an oversimplification, however, because in reality you will want to compute the initial max-min pairs from a chunk of fixed size – say 256 samples – rather than from one of size SamplesPerPixel. Then you can compute further ‘on the fly’ reductions from that cached reduction. The point is that SamplesPerPixel will typically be a dynamic quantity – since the user might resize the canvas at any time (hope that makes sense…).

    Also remember that when you are drawing to your canvas you will need to scale the sample values by the width and height of the canvas. The best way to do this (in the vertical direction, at least) is to normalize the samples, then multiply by the canvas height. 16-bit audio consists of samples in the range [-32768, 32767], so to normalize just do a floating-point division by 32768. Then reverse the sign (to flip the waveform to the canvas coordinates), add 1 (to compensate for the negative values) and multiply by half the canvas height. That’s how I do it, anyway.

    This page shows how to build a rudimentary waveform display with Java Swing. I haven’t looked at it in detail, but I think it just downsamples the data rather than computing max-min pairs. This will, of course, not provide as accurate a reduction as the max-min method, but it’s easier to calculate.

    If you want to know how to do things properly you should dig into the Audacity source code (be warned, however – it’s fairly gnarly C++). To get a general overview you might look at ‘A Fast Data Structure for Disk-Based Audio Editing’, by the original author of Audacity, Dominic Mazzoni. You will need to purchase that from CMJ, however.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First off, this is part of an extra credit homework, so please do not
First off, this isn't homework ;). I'm trying to create a wordsearch game from
So first off, this is a homework assignment, so please don't write any code
First off, this is homework. I'm trying to read a 5 digit number into
First off, this is my first project using SQLAlchemy, so I'm still fairly new.
So, first off, this is homework, albeit not mine. It's my brother-in-law's. He asked
First off, this is a homework question so vector libraries and string libraries are
First off, let me say that this is not homework (I am an A-Level
First off this question has been helpful in my understanding of how to subclass
First off this isn't for any homework question, it's just on a general type

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.