Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » play_sample, delay in sound when looping

This thread is locked; no one can reply to it. rss feed Print
play_sample, delay in sound when looping
Jesse Shepherd
Member #1,320
May 2001
avatar

Hello,

Allegro (4.2) function in question:

play_sample(const SAMPLE *spl, int vol, int pan, int freq, int loop);

I call the following line to play my_sample, loaded from a wav file:

play_sample(my_sample, 255, 128, 1000, TRUE);

When the sample is about to loop, a slight delay occurs before the sample plays again from the start. Is there something I could be doing in regards to a more seamless sounding loop?

Thanks very much for any information

weapon_S
Member #7,859
October 2006
avatar

Jesse Shepherd
Member #1,320
May 2001
avatar

There was silence in the sample- I didn't look closely enough. I've lost all credibility to ask questions on here, ha. Thanks man

wolf_wolf17
Member #13,811
December 2011
avatar

I made a post like this too, I felt like you feel now. But then again, they say humiliation makes a humble man.

Arthur Kalliokoski
Second in Command
February 2005
avatar

The hardware guys say experience is directly proportional to the amount of equipment ruined, so I guess programming experience is proportional to the mistakes that were so embarrassing you're determined not to make them again. I myself just went through two hours of frustration trying to remember how to get UV coordinates in an OBJ file exported by Blender, and I'm pretty sure I'll remember next time.

“Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.”

― Robert A. Heinlein

Felix-The-Ghost
Member #9,729
April 2008
avatar

I guess programming experience is proportional to the mistakes that were so embarrassing you're determined not to make them again

For me, this caused headaches yesterday:
(Not actual code, simple example [I don't actually remember the problematic code])

for (int i = 0; i < 1337; i++);
{
   if (i % 2 = 0)
   some_var = i * i - i;
}

I never noticed such a problem, and there was no compiler warning.

==========================
<--- The ghost with the most!
---------------------------
[Website] [Youtube]

Arthur Kalliokoski
Second in Command
February 2005
avatar

I've done that a dozen or so times also, and I've read the compiler doesn't warn you because so many people use a bare loop for a delay. It's the muscle memory in your pinky that puts that colon there.

“Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.”

― Robert A. Heinlein

Thomas Fjellstrom
Member #476
June 2000
avatar

It's the muscle memory in your pinky that puts that colon there.

Heh, took me a moment to figure out what you meant. Didn't even see that. I did however see this: 'if (i % 2 = 0)'

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

weapon_S
Member #7,859
October 2006
avatar

Same as Thomas...

al_clear_to_color(al_map_rgb(255, 225, 255);
al_draw_rotated_tinted_bitmap(al_map_rgba(127, 127, 255, 255), 0.0f, 0.0f, 0.5f * BMP_WIDTH, 0.5f * BMP_HEIGHT, 0.5f * ALLEGRO_PI, 0);

Spent a couple of hours figuring out how a call to al_draw_rotated_tinted_bitmap could turn my screen pink.

gnolam
Member #2,030
March 2002
avatar

I never noticed such a problem, and there was no compiler warning.

Quote:

if (i % 2 = 0)

i % 2 isn't an lvalue (and as such can't be assigned to), so that can't compile...

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

Arthur Kalliokoski
Second in Command
February 2005
avatar

He didn't have that in there when I responded.

“Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.”

― Robert A. Heinlein

Go to: