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

Author Topic: Play parts of many soundBuffers as one audio  (Read 2627 times)

0 Members and 2 Guests are viewing this topic.

sfUser

  • Newbie
  • *
  • Posts: 12
    • View Profile
Play parts of many soundBuffers as one audio
« on: January 31, 2016, 05:08:30 pm »
Hi there,

I would like to have a sound class that allows me to specify a certain number of soundBuffers and a specific duration on that sound buffer.

ex:

class Audio2 {
 // ((start time / stop time) /  buffer)
  std::vector<std::pair<std::pair<sf::Time, sf::time>, const sf::soundBuffer*>> buffers;
}

where the length of the audio would be the sum of the vector's time members  (difference between start and stop) and where soundbuffers could be repeated.

This would allow me to load 1/n sound buffers of dialogs and construct sentences using parts of those buffers.

So, If I had a buffer that played the sound of "hello" and another that played a sentence with the word "and" in the middle and a third that played "welcome", I could reproduce the sentence "Hello, and welcome" by adding 3 elements to the buffers with the soundBuffers of the tracks and a start and stop position in each buffer to play the part of the sound that corresponds to each word.

What would be the best approach I should take to implement this?
From what I saw, my best bet would probably be to implement this in SFML, to take advantage of private data that could facilitate this.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Play parts of many soundBuffers as one audio
« Reply #1 on: February 01, 2016, 12:59:20 am »
It would depend on how quickly you need these results.
It's possible to create a new sound buffer that is built from copying and appending the parts of the other buffers.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything