Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Explaining audio samples  (Read 2527 times)

0 Members and 1 Guest are viewing this topic.

Doodlemeat

  • Guest
Explaining audio samples
« on: May 02, 2014, 11:56:29 am »
Hi.

I have seen that other people can manipulate the audio samples to create effects like reverb, echo, temp and so on...
But there is no real explanation of what audio samples really is. What does 1 sample representate? Is volume affecting audiosamples? Can I manipulate audio samples in real time without recharing the soundbuffer with a new manipulated file?

I have looked onto the sin wave tutorial at github but it does'nt cover as much of what the audiosamples really is. Would anyone want to explain? It would be really helpful because we will use many sounds in our game which should be affected in some ways. :)


I know SFML uses OpenAL and I have looked a little bit into that but it does'nt give me a clear explanation of what sound is.
For me right now, sound is just anything that output sound in speakers^^. I want to grasp sounds much like  how images are made eg. (pixels with 3 color and alpha)
« Last Edit: May 02, 2014, 12:00:05 pm by Doodlemeat »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10821
    • View Profile
    • development blog
    • Email
Re: Explaining audio samples
« Reply #1 on: May 02, 2014, 12:18:03 pm »
Google is your friend. ;)

An audio sample is nothing specific to SFML or OpenAL, but it's how audio is kept digitally. There's a nice Wikipedia article about Sampling.

Programming wise a "sample" is just a number that gets processed and output through your speakers.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Explaining audio samples
« Reply #2 on: May 02, 2014, 12:25:53 pm »
A sound is an accumulation of frequencies. For example, if you play a single note (= single frequency), your audio signal will look like this, a regular sine wave:



In a more complicated sound, many frequencies contribute to the final sound over time, and you end up with something like this:



An audio sample is one point of this representation of the sound. In other words, it is the sound amplitude at a given point in time. Then a sound is nothing more than the set of audio samples that compose it, from beginning to end.

Quote
Is volume affecting audiosamples?
Yes. The absolute value of one sample is the volume of the sound at this point in time. For example, if you look at the sound above, you can see that it begins very quietly, and then it suddenly becomes loud, etc.

Quote
Can I manipulate audio samples in real time without recharing the soundbuffer with a new manipulated file?
It depends on what you want to do exactly.

I don't know if these explanations make things clearer for you, I did my best but I admit that it is not simple to understand. I also hope that I didn't say incorrect things ;D
Laurent Gomila - SFML developer