0
0

hi,

can anyone help me with setting the speed of a sample.
with music its easy, but with samples?

is it SetFrequency?

thanks.

  • You must to post comments
0
0

You don’t have to SetPaused the channel before (and after) changing the frequency, just call the function alone.

  • You must to post comments
0
0

You don’t have to SetPaused the channel before (and after) changing the frequency, just call the function alone.

  • You must to post comments
0
0

or is it not possible?

if so, please tell me.

thanks.

  • You must to post comments
0
0

Yes, use FSOUND_SetFrequency.

  • You must to post comments
0
0

ok, anything else i should know about this?

cause i tried it right before Play() but it didnt work.

  • You must to post comments
0
0

You need to call it after you play the sound :

[code:3cx3u97m]int chan = FSOUND_PlaySoundEx(FSOUND_FREE, sample, 0, TRUE);
FSOUND_SetFrequency(chan, 8000);
FSOUND_SetPaused(chan, FALSE);[/code:3cx3u97m]

What this does is start the sound paused, set the frequency for the channel that the sound is playing on and then unpause the sound.

  • You must to post comments
0
0

ok, so far this works. thanks!

what is the standard frequency of a sound? (1 in the music)

can i also set the sound speed dynamically?
what i want to do is simulate the sound of a car’s motor.
when the car accelerates the sound gets played faster, when it decelerates it gets slower. depending on the speed variable of the car.

is this possible?

  • You must to post comments
0
0

Usually, a sample is 44100 kHz (correct me if I’m wrong). And yes, you can change the playback frequency dynamically, just call the function FSOUND_SetFrequency whenever you like and the frequency will change.

Example:

If your car speed go from 0 to 100, you can do that the frequency of the sample will be: SPEED * 1000

Or something like that, and you refresh that frequency during the game loop.

  • You must to post comments
0
0

Usually, a sample is 44100 kHz (correct me if I’m wrong). And yes, you can change the playback frequency dynamically, just call the function FSOUND_SetFrequency whenever you like and the frequency will change.

Example:

If your car speed go from 0 to 100, you can do that the frequency of the sample will be: SPEED * 1000

Or something like that, and you refresh that frequency during the game loop.

  • You must to post comments
0
0

thanks i found out, that it works, when i turn the music off.
cant i have both at a time? music and sound?

im loading the music with:

FSOUND_Init(44100, 32, 0);
mymusic=FMUSIC_LoadSong("up.xm");
if(mymusic) {
    FMUSIC_PlaySong(mymusic);
}

after that comes the looping function with the sound and the variable speed.

if(FSOUND_IsPlaying(0) == 0) {
    motorsound=FSOUND_Sample_Load(FSOUND_FREE,"engine.wav",FSOUND_LOOP_NORMAL,0);
    chan = FSOUND_PlaySoundEx(FSOUND_FREE, motorsound, 0, 1); 
}
FSOUND_SetPaused(chan, 1);
FSOUND_SetFrequency(chan, -speed*10000+20000); 
FSOUND_SetPaused(chan, 0);
  • You must to post comments
Showing 10 results
Your Answer

Please first to submit.