1

So, this has happened multiple times now. It first happened with Inform and I figured it an odity of the program, but now it has also happened with libaudioverse. What ever is being used for the looping algorithm has an issue that causes a pause in the loop before it starts over again. In libaudioverse, this pause has only really occured on longer sounds like music. What could be causing this, and does anyone have a good solution?

Thumbs up

2

Since you say it only happens on longer sounds, my guess is that the developer is reloading the data into memory every time they want to loop the clip, instead of using the memory already allocated.

Thumbs up

3 (edited by Jaseoffire 2018-04-08 12:30:36)

So, does that mean I would have to perhaps cache the buffer? If I were to do so, how  would I go about doing that?

Thumbs up

4

@Jaseoffire, I'd highly recommend you use Fmod as your sound library. I've used it before; looping is very simple. Here's a good example on how to do it:

// ... init code
// Create a function that displays errors in case FMOD failed to do something.
template<typename funcname, typename linenumber> void errcheck(funcname function, linenumber ln, FMOD_RESULT result) {
if(result!=FMOD_OK) {
MessageBox (NULL, FMOD_ErrorString(result), "Error", MB_OK);
}
}

// Initialize FMOD
FMOD::System     *system;
// Do verification, ensure our FMOD version is correct.
unsigned int version = 0;
errcheck(__func__, __LINE__, FMOD::System_Create (&system)); // Create the system object.
errcheck(__func__, __LINE__, system->getVersion(&version)); // Get the version of FMOD we're running.
if (version<FMOD_VERSION) {
MessageBox (NULL, "The sound system version is less than the required version.", "Error", MB_OK);
}
// Initialize the audio system with 4093 virtual channels.
errcheck(__func__, __LINE__, system->init(4093, FMOD_INIT_NORMAL, (void*)0));
// Load a new sound, let's call it music.ogg.
FMOD::Sound *sound;
errcheck(__func__, __LINE__, system->createSound("music.ogg", FMOD_DEFAULT, 0, &sound));
sound->setMode(FMOD_LOOP_NORMAL);
// Play the sound.
FMOD::Channel *channel=0; // This is the channel we're going to be playing the sound on.
// Now, play our sound on this channel.
errcheck(__func__, __LINE__, system->playSound("music.ogg", 0, false, &channel));
// Set the sound volume to a lower volume so it doesn't blow out our ears! :)
errcheck(__func__, __LINE__, channel->setVolume(0.50));
// And then, when you want to unload the sound...
errcheck(__func__, __LINE__, channel->stop());
errcheck(__func__, __LINE__, sound->release());
// And now, release the system.
errcheck(__func__, __LINE__, system->close());
errcheck(__func__, __LINE__, system->release());

That's all! It may seem like a lot of code, but in C/C++ you do this kind of thing every day. You could certainly trivialize this into functions, too.

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.

Thumbs up

5

While I am getting into c/c++, something  tells me there's going to be a bit more python in my future to go. Not to mension whatever they decide to teach the computer graphics courses in. Probably either java or c++, honestly. That being said, python is still a better choice when you've only got a weekend to work with. That being said, I would investigate fmod later on. For now, libaudioverse is what most of my projects are written with in mind. If there is a good python library for fmod, I might look at it over the summer, though.

Thumbs up