0

I know how to make a sf::SoundBuffer and stuff like that, but how do I, for example, create a short pitch noise programmatically that SFML would be able to read. Or how would I go over creating a noise that gradually increases in volume or gets higher/lower pitched?

Jeroen
  • 15,257
  • 12
  • 59
  • 102

1 Answers1

1

You could use sf::SoundBuffer with loadFromSamples (see the documentation).

The representation of a sound in memory is basically a large array of integers that gives the amplitude of the signal at a given time. You can provide your own array to a sf::SoundBuffer with the correct parameters, and that would give you your programmatically generated sound.

For manipulation of sound, volume etc I can't help you though, you'll have to search for the maths behind signal processing and such.

  • So if I create a stereo sample, would that mean that I should pass samples and set it to half the size of the array? – Jeroen Aug 07 '13 at 15:14
  • And which data would represent the left speaker, and which data the right? – Jeroen Aug 07 '13 at 15:37
  • 1
    The `channelCount` parameter tells wether it's a mono, stereo sound or whatever. I bet that if it's provided with stereo, SFML will assume that 2 contiguous samples represent the left/right output. But you'd better ask on the forums (http://en.sfml-dev.org/forums/) to be sure. – teh internets is made of catz Aug 07 '13 at 15:59