How can I use the sound_pool functions with packages?
What do you mean by packages? Also, sound pool documentation is already available, with the exception of no examples for now in the documentation.
How can I protect my sound files within the package, like it was done before in BGT?
It is currently not possible to add pack encryption. I don't know if pack set identifier functions could help for now, which is in the pack documentation within Data Manipulation category.
If you need anything beyond it or do not understand, feel free to post a comment.
What I mean is this part here:
2. int sound_pool::play_stationary(string filename, pack@ packfile, bool looping, bool persistent = false);
I didn’t understand how to use the package because when I try, the code throws an error. Could you provide an example to clarify?
The play_stationary function plays the sound without using coordinates, another word, entire speaker.
The differents between 1 and 2 etc is the function with pack and the function without. The pack object parameter can be omitted in case you want to just use the default sound pack, which is enough unless you're doing with another sound pack.
For example, you can call like:
int sound_pool::play_stationary(string filename, pack@ packfile, bool looping, bool persistent = false);
Or you can call it like:
int sound_pool::play_stationary(string filename, bool looping, bool persistent = false);
#include "sound_pool.nvgt"
sound_pool p;
void main() {
int s = p.play_stationary("something.ogg", false); // S is the variable to get the slot returned by the function.
show_window("Playing");
while(p.sound_is_playing(s)) {
wait(5); // Continue while the sound is playing
}
exit();
}
Hi,
so what you need to do is you need to create your pack file with all your sounds, and you can do a couple of things.
Set the sound storage and configure the sound pool yourself
#include"sound_pool.nvgt"
void main() {
sound_pool p;
pack package;
package.open("sounds.dat", PACK_OPEN_MODE_READ);
@p.pack_file = @package;
//feel free to play any sounds in this script with your new sounds pack.
}
What we just did here was open a pack file and told sound pool to use this pack. Everything seems fine, however you will soon realize that this solution just fixed sounds played with this new pool that we're using, but new sound pools or other sound objects will attempt to play the raw audio files. This solution could be great for games that utilize multiple pack files, such as one for game assets, one for background loops, another for music, so on and so on.
But what if I want one single pack throughout the entire game, without worrying about the pack variables?
This brings me to the next solution, simple and to the point.
and that's it, we're done. Any sounds loaded by nvgt will attempt to load through the sound default pack variable if it's handle is not null, unless otherwise stated in the functions like play_2d play_3d, etc or the pack is set through the load function on a sound object. I feel like I just through a lot of information out there, so if you're confused on any of this feel free to post on here and I'll try to clear anything up.