I’m using FMOD v375 since a little.
I’m using Free Basic on Windows and I have problems with loops playing incorrectly.
The function [color=cyan:3fglv45r]Sample_SetLoopPoints[/color:3fglv45r] works great to me! I can change the loop definition "on the fly" and FMOD will take care of this new selection from the next iteration… very good!
The problem is, once started, I can change the loop selection [u:3fglv45r][b:3fglv45r]but I cant stop the loop[/b:3fglv45r] mode from playing[/u:3fglv45r]!
My code is quite simple:
[color=cyan:3fglv45r]DIM[/color:3fglv45r] snd_effect [color=cyan:3fglv45r]AS[/color:3fglv45r] FSOUND_SAMPLE [color=cyan:3fglv45r]PTR [/color:3fglv45r] ‘[color=black:3fglv45r][b:3fglv45r]sample handler[/b:3fglv45r][/color:3fglv45r]
snd_effect = FSOUND_Sample_Load( 1,"LOGOFF.WAV",0,0,0 ) ‘[color=black:3fglv45r] [b:3fglv45r]I load the sample[/b:3fglv45r][/color:3fglv45r]
FSOUND_PlaySound( FSOUND_FREE,snd_effect )[/color] ‘[color=black:3fglv45r][b:3fglv45r] It starts playing in loop mode -> it works good![/b:3fglv45r][/color:3fglv45r]
…now I wait for a key pressed from the user and then I issue the command:
but, instead of stop playing, the sample keep to loop forever!
Also, I tried to issue the command:
..but no result! the loop mode keep to play forever!
Looking around in the forum, I found this old post:
May be it is the same problem I’m facing?
…but what is the solution? How can I esclude the hardware channels?
My program need to keep a sound looping for the desired time.
Then, when I disable the loop, I need the let the sample "play to the end" and "naturally" finish…
Please give me a little help.
greetings from Italy,
- Seven_Legion asked 8 years ago
Somebody can tell me, at least, what you usually do when need looping sounds?
Assume we have have a machine gun to play.
The wav file has a starting part (RA), a loop part (TA) and an "ending" part (SHHH).
The complete sound will be RA-TA-TA-TA-TA-SHHH, were the loop part will last while the player is firing…
Of course, every part must be played entirely because the gun can fire only "entire" bullets.
I.E: RA-TA-T_-SHHH is not good!
How can I achieve this?
tanks for the reply.
After your suggestion, I managed to catch the result… but it was a bit more tricky than it was supposed…
At first, i went into the "channel" approach you said:
1) load the sample and set the loop part:
[color=cyan:13a63g50]snd_effect = FSOUND_Sample_Load( 1,"LOGOFF.WAV",0,0,0 )
2) when the user press the fire button, I start to to play the sound (and it would be copied into channel "1": )
[color=cyan:13a63g50]FSOUND_PlaySound( 1,snd_effect )[/color:13a63g50]
3) at the same time, I also set the loop mode for channel "1":
4) now I wait for the user releasing the "fire button", meanwhile the sound loops on the TA-TA sequence…
5) then I exit the loop mode with:
…unfortunately, as is, this system not works.
The effect of the last command is a sound truncation.
The result is: RA-TA-TA-T_ and the ending part is completely lost…
I also tryed to put a "SetPaused=TRUE" / "=FALSE" before and after the
SetLoopMode command, but the result is the same: sound truncation…
At last, I discovered the solution: when you change the loop mode for the channel, you must also restore the loop points to the end of the sample to avoid the play truncation…
The command: [color=cyan:13a63g50]FSOUND_Sample_SetLoopPoints(snd_effect,0,FSOUND_Sample_GetLength(snd_effect))[/color:13a63g50]
makes everything play correctly and I finally have my RA-TA-TA-SHHH effect!
Please login first to submit.