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 8161047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:24:52+00:00 2026-06-06T18:24:52+00:00

I developed a script in php to draw the sound wave of a wav

  • 0

I developed a script in php to draw the sound wave of a wav file. Althoug it works well sounds long about 20 minutes take 2-3 minutes to draw the image. I am using the peak value of group of samples to represent the wave in certain pixel. Also I get long values i.e 4 bytes at same time to get left, right, both negative and positive values. Also one improvement is that i take 4 long values at same iteration.

The wav is a-law stereo 16-bit but i use decoding algoritm to get pcm value so 16 bits go to 8 bit.

8000Hz, 8 bits per sample, 64 Kbps,
stereo, A-law

I need to generate 1500 pixels wide image.

It would be helpfull also some alghoritm or web page how to improve performance of the script.

Audacity generates image of the same sound in about 2-3 seconds 🙂

thanks. I will post some code if needed.

Here is the for cycle for reading the blocks of sound data

for ($i = 0; $i < $this->blocktotal / 4; $i+=4) 
    {
        // unpack 32 bit numbers from the sound data in groups of 4
        $blocks[] = @unpack('L', substr($this->data, $i * 4, 4));
        $blocks[] = @unpack('L', substr($this->data, ($i + 1) * 4, 4));
        $blocks[] = @unpack('L', substr($this->data, ($i + 2) * 4, 4));
        $blocks[] = @unpack('L', substr($this->data, ($i + 3) * 4, 4));
    }

32 bit = 4 * 8 bit, each bit is left right left right channel. So I take 2 values for left and two for right channel for one line of the above cycle. But i get that $this->blocktotal= 20147456 for 20 MB file so the above cycle will repeat about 5 milion times. Any idea for improvement? I tried to read 8 Long values at same time, but that gives other image than expected, I dont know why.

  • 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-06T18:24:53+00:00Added an answer on June 6, 2026 at 6:24 pm

    solved the problem. When the file is big like 20 MB i dont read some bytes at all i.e i jump them because anyway i need aproximation. I take every 10-th long number from the sound data. For smaller file I take every secodnd long number. So this way I solved this.

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

Sidebar

Related Questions

I have a PHP-script originally developed on Ubuntu, which now has to run on
I have over 1000 clients and I developed a simple PHP script to loop
I have developed code on a m-file script in Matlab that communicates with a
I have developed a PHP script that uses $_REQUEST[] superglobal. A typical client request
I have developed a membership script with php for learning and I have confused
I am testing a php script that has been developed on an OS-X system
I developed a little cross domains population script with query and php. The population
I have developed a script that uses php's imap_search and when it gets to
I've developed a Flash quiz app for facebook, which calls for a php script
I have some code written in PHP, but I have also developed a script

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.