0
0

I have a continuous sound with a varying timbre. I’ve found all the wave lengths. What I want is to play the sound so that I can loop any wavelength continuously, but so that I could pick any wavelength while the sound is playing. Moving the mouse horizontally would change the start and end point of the loop.

This is a part of my code:
[code:2ame7y59]
do
{
x = mouse_x;
np1 = mynodes->point(x); // this returns one zero cross from the sample
np2 = mynodes->point(x+1); // this returns the next zero cross

    channel->getPosition(&pos, FMOD_TIMEUNIT_PCM);
    if (pos >= p2) // p2 is the end position of the current wave length
    {
        channel->setPosition(np1, FMOD_TIMEUNIT_PCM);
         p2 = np2;

    }

}
while (!key[KEY_ESC]);

[/code:2ame7y59]
In short: it continuously updates the next start and end points (np1 and np2) and when the playing position of the current wave length is past the end, the position is set to the new wave start.

It works almost, but obviously Fmod deals with chunks of samples, not discrete samples. My wave lengths are about 330 samples, but whatever I do, I seem to get a sound with a wave length of about 500 samples (my guess is 512).

For my project I really need a way to control the looping of exact wavelengths of the sound. I tried first to set up some callback system with syncpoints, but failed there, too. I might go back there and get it work. Would Fmod be more precise with syncpoints? Could I get the callback to run exactly when the syncpoint is reached or only with a 256 or 512 sample accuracy?

  • You must to post comments
0
0

How about
Channel::setLoopPoints

  • You must to post comments
0
0

Guess I could try the looping thing. Guess I first have to set the points, then play the loop once and when isPlaying() returns false, I set new points and start the sound. But to make it work, isPlaying() [i:3w0ia072]really[/i:3w0ia072] would have to return false [i:3w0ia072]exactly[/i:3w0ia072] when the last sample of the loop has played, not only one, two or ten time units later. Or 256 or 512 units after last system update whatever.

  • You must to post comments
0
0

[quote="jotti":2uq2040i]Guess I could try the looping thing. Guess I first have to set the points, then play the loop once and when isPlaying() returns false, I set new points and start the sound. But to make it work, isPlaying() [i:2uq2040i]really[/i:2uq2040i] would have to return false [i:2uq2040i]exactly[/i:2uq2040i] when the last sample of the loop has played, not only one, two or ten time units later. Or 256 or 512 units after last system update whatever.[/quote:2uq2040i]

You can set the loop count and get the loop count (returns the remaining loops)… that should replace the isPlaying call.

I have a feeling you might have to use the lower level features such making a dsp or something.

I figure you will need to sychronize you application so to match the timing of a sample.

Or I guess you would need to do this in a tight loop (no sleep) between each update.

  • You must to post comments
0
0

If I do
channel->setMode(FMOD_LOOP_OFF);
…I can read the position and set the position, only getPosition() doesn’t return accurate values.

But if I do
channel->setMode(FMOD_LOOP_NORMAL);
…the sound refuses to loop the section I set with setLoopPoints(). Instead it plays the whole sound from 0 to getLength().

  • You must to post comments
0
0

One more thing: If I do
channel->setLoopCount(-1);
…I can get one wave length to loop forever by setting the loop points. But if I do
channel->setLoopCount(0);
…or any other positive value, the damn thing plays the whole sound looped, not just the wave length I marked with setLoopPoints(); Is this a bug or something? One loop count setting allows me to loop the marked section, another loop count setting forces the whole sound to be looped, not the marked section.

[edit]
So far I explore both Fmod and Allegro sound routines and how they fit into my project. I just managed to get a kind of looping work in Allegro by using a streaming technique. I guess I could try something similar in Fmod. It might work even better.

  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.