0
0

Hi,

1) Is there any way of altering a streams pitch through fmod??

2) Ive read the documentation on spectrum analysis and have put a very simple function into my code to test that im getting the array of 512 floats.

Firstly i asked for the sizeof the array returned by fmod but it always returned “4”. I then tried adding all the 512 values together but it always returns the value 9.6689594… – surely the value should change every time its called due to the change in sound??

[code:3a2sm7c3]

float doDsp()
{
int i;
float total;

FSOUND_DSP_SetActive(FSOUND_DSP_GetFFTUnit(), TRUE);

float* array = (FSOUND_DSP_GetSpectrum());

//int size = sizeof(array);

for (i=0; i < 200; i++)
{
total = (total + array[i]);
}

FSOUND_DSP_SetActive(FSOUND_DSP_GetFFTUnit(), FALSE);

return total;
}

[/code:3a2sm7c3]

  • You must to post comments
0
0

1) Are you searching for FSOUND_SetFrequency?

2) I don’t know C, but it seems to me, that you try to get the size of the pointer (= 4).

The result of GetSpectum() is not an array, but a pointer on it.
In PB I just peek the memory from the point given by the GetSpectum-pointer 512 times for a 4-Byte-FLOAT.

  • You must to post comments
0
0

thanks for the tips on the pointer, ive seen the error of my ways!

but as for the pitch/frequency – im writing an mp3 mixer program so i wanna be able to change the pitch of the stream at the users request.

whereas fmod seems to only allow change of frequency when the streams set-up and init, not while its playing.

is this kind of speed change possible during playback??

cheers, jon

  • You must to post comments
0
0

[quote:1ct98ysy]is this kind of speed change possible during playback?? [/quote:1ct98ysy]

Just try!

mini-example in PB:

[code:1ct98ysy]screenY = GetSystemMetrics_(#SM_CYSCREEN)

FSOUND_Init(44100,32,0)
hStream = FSOUND_Stream_OpenFile(OpenFileRequester("Load a Soundfile","C:\","All files (.)|.",0,0),$2,0)

If hStream
MessageRequester("!","Move the mouse up/down to toggle speed."+Chr(13)+Chr(10)+"Move to upperleft to end.",0)
FSOUND_Stream_Play(1, hStream)
Repeat
GetCursorPos_(position.POINT)
fq = Int(88100 * (position\y / screenY) + 100)
FSOUND_SetFrequency(1, fq)
Until position\y = 0 And position\x = 0
FSOUND_Stream_Stop(hStream)
MessageRequester("","Ciao ;-)",0)
Else
MessageRequester("!","Cannot load the specified file.",0)
EndIf

FSOUND_Close()
End[/code:1ct98ysy]

I think, it’s self-explaining. Just move the mouse up and down and pitch the sound.
You can download the exe here. The ZIP is called ‘realtimepitcher.zip’:
http://www.fmod.2mal2mal.de
😉

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.