Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » ALLEGRO SAMPLE INSTANCE set loop start and end points

This thread is locked; no one can reply to it. rss feed Print
ALLEGRO SAMPLE INSTANCE set loop start and end points
geecab
Member #23,749
April 2023

Hi there!

I'd like to load a 10 second audio sample and have many instances reference that same sample. I'd then like for each instance to loop a different section of the original sample when I play it back.

I can't seem to find a way to set the loop start and end points of an instance. Is this possible? I read the following in the docs and felt hopeful it might be:-

An ALLEGRO_SAMPLE_INSTANCE object represents a playable instance of a predefined sound effect. It holds information about how the effect should be played: These playback parameters consist of the looping mode, loop start/end points, playing position, speed, gain, pan and the playmode. Whether a sample instance is currently playing or paused is also one of its properties.

Many thanks!

Ben

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Yeah, I see that's what the docs say too, but I don't see where to set the loop points or loop mode.

I see a function to set sample instance length. That might control the end point, but not the beginning. You can set the sample position, but I don't think that affects the loop points.

geecab
Member #23,749
April 2023

Hi and thanks for the response!

I've just tried al_set_instance_position & al_set_sample_instance_length and am hearing some unexpected things.

When in LOOP playback mode:
The al_set_instance_position does start the sample at the appropriate position, but the al_set_sample_instance_length setting seems to be ignored. You hear the sample continue to the very end, and then it starts again right from the beginning.

When in ONCE playback mode:
The al_set_instance_position does start the sample at the appropriate position, al_set_sample_instance_length works as expected if I give it a position after the start position, rather than a length. If I give it a length I hear nothing. So its more like al_set_sample_instance_length should be called al_set_sample_instance_end_position.

I'm a bit confused :p

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Go to: