Notices
Results 1 to 9 of 9
Like Tree1Likes
  • 1 Post By jrmonroe

Thread: Sound

  1. #1 Sound 
    Suspended
    Join Date
    Apr 2012
    Posts
    690
    I was creating an app the other day using sound and I noticed that when I rapidly changed the volume of the sound wave a popping sound occurred this is most likely interference and I wanted to know at what rate can I can volume to make the popping sound inaudible?


    Reply With Quote  
     

  2.  
     

  3. #2  
    Forum Radioactive Isotope MagiMaster's Avatar
    Join Date
    Jul 2006
    Posts
    3,440
    The simple answer would be to keep the rate of change about proportional to the frequency, but that leaves out a lot of details.


    Reply With Quote  
     

  4. #3  
    Forum Junior TridentBlue's Avatar
    Join Date
    Jan 2013
    Posts
    207
    Quote Originally Posted by fiveworlds View Post
    I was creating an app the other day using sound and I noticed that when I rapidly changed the volume of the sound wave a popping sound occurred this is most likely interference and I wanted to know at what rate can I can volume to make the popping sound inaudible?
    Its probably because the audio is read in as frames, and one volume coefficient is multiplied across an entire frame at a time, so there are audible pops between frames.

    If you are programming this, you need to multiply individual samples, or at least sets of samples much smaller than the frames, by linear quantities between the volume of each frame. (make it go down in a smooth line)
    Reply With Quote  
     

  5. #4  
    Suspended
    Join Date
    Apr 2012
    Posts
    690
    I am programming this myself and I did notice the faster the frame rate of the game the more audible the pops which would be a change in the frequency of the running track along with the drop in the amplitude of the sound wave over time(the rate of volume change). When i get the sprite to jump etc I change the volume of the track. Now since the frequency affects the rate of the volume change I need the program to be able to calculate a reasonable average for this as an algorithm in case I want to use a different audio track or change the games frame rate while keeping my audio as clear as possible. I have seen android games that can change the frame rate as a slider and I doubt each audio clip was individually programmed for each value so it is most likely changed algorithmically.
    Reply With Quote  
     

  6. #5  
    Forum Junior TridentBlue's Avatar
    Join Date
    Jan 2013
    Posts
    207
    Well, if you can get away with it, the easiest thing would probably be to install a "speed limit" thing that makes sure the volume doesn't jump too fast at any millisecond. So if its outputting say, 256 samples a frame, at 48000 htz audio that's 187 frames of audio a second. (probably less if its synced up with graphics frames) You need to figure out what these numbers are for your thing.

    Then you would pass changes in volume to a to a thread that moves the audio level toward your desired level, but only in increments small enough not to make the noises, and only every (256/48000) seconds, (or whatever) sleeping in between and it stops when it gets to the right level. A side effect of this would be a quick change in the game in audio levels might come through as a fade over like 1/3rd of a second, when it was supposed to be near instant, but it would sound better and there'd be no pops.
    Reply With Quote  
     

  7. #6  
    Forum Radioactive Isotope MagiMaster's Avatar
    Join Date
    Jul 2006
    Posts
    3,440
    I'm pretty sure you can get the volume to change faster than 1/3 of a second without popping. Also, while the frequency would affect what rate you would start hearing artifacts at, human hearing (and more specifically a single piece of audio) doesn't cover so wide of a range that you couldn't just guess at a decent average.

    A game should be running at a fixed frame rate, so use that to your advantage. Each frame adjust the volume by a given amount towards your target volume. You'd just need to keep a target number and a counter around. (Or you could try adjusting it by a percentage of the difference if you want to avoid the counter, but that'd need some tweaking.)
    Reply With Quote  
     

  8. #7  
    Forum Professor jrmonroe's Avatar
    Join Date
    Mar 2010
    Posts
    1,444
    A "sudden change in volume" is a "step function", and in frequency analysis, step functions are composed of a burst of frequencies, especially the higher frequencies. I think that you are hearing this burst of frequencies.

    Have you tried ramping up/down the volume instead of using a step function? This should lessen the intensity of the pops.

    Or, if your software can wait to change volume until at a "zero crossing", it might not pop. Zero crossings happen quite often, so the listener would probably not notice the wait. And this seems easier to implement than ramping.
    tk421 likes this.
    Grief is the price we pay for love. (CM Parkes) Our postillion has been struck by lightning. (Unknown) War is always the choice of the chosen who will not have to fight. (Bono) The years tell much what the days never knew. (RW Emerson) Reality is not always probable, or likely. (JL Borges)
    Reply With Quote  
     

  9. #8  
    Forum Isotope
    Join Date
    Feb 2012
    Location
    Western US
    Posts
    2,866
    Quote Originally Posted by fiveworlds View Post
    I was creating an app the other day using sound and I noticed that when I rapidly changed the volume of the sound wave a popping sound occurred this is most likely interference and I wanted to know at what rate can I can volume to make the popping sound inaudible?
    It's not "interference." As jmonroe correctly observed, this is a fundamental effect. A sudden change in volume is equivalent to multiplying a constant-amplitude signal by a "step" change in a coefficient. It is well-known from Fourier transforms that this multiplication generates an infinity of frequencies that you will hear as a pop.

    The cure is to multiply by something with less spectral content than a step. A ramp is better than a step (and easy to program). A half-sine is better still. The more you stretch out the volume change, the less of a pop you'll hear.
    Reply With Quote  
     

  10. #9  
    Forum Isotope
    Join Date
    Feb 2012
    Location
    Western US
    Posts
    2,866
    Quote Originally Posted by fiveworlds View Post
    I was creating an app the other day using sound and I noticed that when I rapidly changed the volume of the sound wave a popping sound occurred this is most likely interference and I wanted to know at what rate can I can volume to make the popping sound inaudible?
    It's not "interference." As jmonroe correctly observed, this is a fundamental effect. A sudden change in volume is equivalent to multiplying a constant-amplitude signal by a "step" change in a coefficient. It is well-known from Fourier transforms that this multiplication generates an infinity of frequencies that you will hear as a pop.

    The cure is to multiply by something with less spectral content than a step. A ramp is better than a step (and easy to program). A half-sine is better still. The more you stretch out the volume change, the less of a pop you'll hear.
    Reply With Quote  
     

Similar Threads

  1. Replies: 4
    Last Post: August 22nd, 2013, 01:45 AM
  2. Replies: 29
    Last Post: March 24th, 2013, 07:07 AM
  3. Sound
    By Robins Thomas John in forum Physics
    Replies: 1
    Last Post: December 16th, 2010, 12:02 PM
  4. about sound
    By ~James~ in forum Physics
    Replies: 7
    Last Post: April 11th, 2010, 11:11 PM
  5. Running multiple sound amplifiers off one sound card output?
    By MacGyver1968 in forum Computer Science
    Replies: 0
    Last Post: May 13th, 2007, 10:59 AM
Bookmarks
Bookmarks
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •