Re: bgt, sound pool, refering to individual sounds?

2015-06-15 Thread AudioGames . net Forum — Developers room : coltonhill01 via Audiogames-reflector


  


Re: bgt, sound pool, refering to individual sounds?

Yes, great move CAE. It is a good idea to track it either way, but occasionally I use the folowing method. I never got this at first, but there is an array in the sound_pool of course you know, and you may access items like this, say, change the volume, you would do this.int slot=pool.play_stationary(sounds/thing.wav,false,true); //persistant from what somebody else said earlier here.for(double x=0; x-40; x--){pool.items[slot].handle.volume=x;wait(20);}and that would make a sound fader, no point in using update_sound_start_values if you can just modify the handle directly.You see, Omar, the sound pool is simply an array of sound_pool_item objects, which in turn hold sound handles, and use sound_positioning for the movement.So if you access the pools items array directly, you can have say int amb, and do something like this for a quick change.int amb; //ambience for later use.amb=pool.play_stati
 onary(ambience.ogg,true);wait(5000); //it wont really do this but it needs to play.//now we access the pool items array, and change the soundpool.items[amb].handle.stop();pool.items[amb].handle.stream(ambience2.ogg);pool.items[amb].handle.play_looped();And there.

URL: http://forum.audiogames.net/viewtopic.php?pid=220149#p220149




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: bgt, sound pool, refering to individual sounds?

2015-06-15 Thread AudioGames . net Forum — Developers room : Victorious via Audiogames-reflector


  


Re: bgt, sound pool, refering to individual sounds?

When you play a sound through the sound pool, it gives you a way to manage the sound through a slot ID. You need to keep this ID around if you want to do other things to that particular sound in the future. Just remember that by default, after that sound finishes playing, the original sound in that slot is deleted. If you try accessing the sound after that happens, you may get unexpected results.

URL: http://forum.audiogames.net/viewtopic.php?pid=220031#p220031




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: bgt, sound pool, refering to individual sounds?

2015-06-15 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: bgt, sound pool, refering to individual sounds?

Victorious is correct.The sound pool helps with fire-and-forget sounds, it helps position sounds and move the listener with minimal effort, and it cleans up after itself.There are two ways to access individual sounds in the sound pool: use the slot variable returned by the play methods, and pass it to other methods for updating sounds, or hunt down the sound objects that the pool uses directly. You almost never need to do the latter--the only case I can think of off the top of my head is if you need to do something like fade or pitch bend all of the sounds in the pool at once, since there arent already methods for that.As for the pool cleaning up sounds that have finished playing, the play methods do have an optional persistent parameter, with which you can prevent sounds from being automatically destroyed. You generally wouldnt need this, unless its to let another object keep track of a sound that can change--for example, if you w
 anted an enemy to be able to say a variety of things, but only one at a time.So, you might have an enemy or vehicle class with a slot property, to keep track of its sound.sound_pool pool; // Global pool.
int player_x=0, player_y=0; // These are global for this example. In practice, a class for the player is usually a good idea, so I usually have a global vector for the camera instead.

class moving_object {
int x=0, y=0;
int slot=-1; // This will be used to move sounds in the sound pool.
string[] sounds; // play one of these at random

moving_object() {}
moving_object(int xx, int yy) {
this.x=xx;
this.y=yy;
}

void move(int dx, int dy) {
this.x+=dx;
this.y+=dy;
if(this.slot0 or pool.sound_is_playing(this.slot)==false)
{
if(this.slot=0) pool.destroy_sound(this.slot);
this.slot=pool.play_2d(this.sounds[random(0, this.sounds.length()-1)], player_x, player_y, this.x, this.y, false, true);
}
pool.update_sound_2d(this.slot, this.x, this.y);
}
}

timer time;
void main() {
// Set up sound pool properties, maybe play some looping ambience.


// Set up the moving objects:
moving_object@[] objects(4);
string[] sounds={sounds/growl1.wav, sounds/growl2.wav, sounds/growl3.wav, sounds/growl4.wav};
for(uint i=0; iobjects.length(); i++) {
moving_object mo(random(-30, 30), random(-30, 30));
mo.sounds=sounds;

[ a-t ](objects[i])=mo;

}

// Create the window and start the main loop:
show_game_window(Sound pool example);
while(true) {
if(key_pressed(KEY_ESCAPE)) exit();
else if(key_pressed(KEY_LEFT)) player_move(-1, 0);
else if(key_pressed(KEY_RIGHT)) player_move(1, 0);
else if(key_pressed(KEY_UP)) player_move(0, 1);
else if(key_pressed(KEY_DOWN)) player_move(0, -1);

// Update the moving objects:
if(time.elapsed500) {
for(uint i=0; iobjects.length(); i++) {
int dx=0;
if(objects[i].xplayer_x) dx=1;
else if(objects[i].xplayer_x) dx=-1;
if(objects[i].yplayer_y) dy=1;
else if(objects[i].yplayer_y) dy=-1;
objects[i].move(dx, dy);
}
time.restart();
time.resume(); // I can never remember if this is necessary after restart.
}

wait(5);
}
}

// Move the player, updating the listener position in the process.
void player_move(int dx, int dy) {
if(player_x+dx-30 or player_x+dx30) pool.play_stationary(sounds/bump.wav, false);
else player_x+=dx;
if(player_y+dy-30 or player_y+dy30) play_stationary(sounds/bump.wav, false);
else player_y+=dy;
pool.play_stationary(sounds/step + random(1, 3) + .wav, false);
pool.update_listener_2d(player_x, player_y);
}If this only made things more confusing, let me know so I can try to fix it.

URL: http://forum.audiogames.net/viewtopic.php?pid=220037#p220037




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector