0
0

I am trying to find out the length (in seconds or milliseconds) of a sound that is of type FSOUND_SAMPLE*

I can get the number of samples in the sample by calling FSOUND_Sample_GetLength()

Now I need to know how to covert that into a time based figure…

Is there a way of getting the sample rate for a sample? – I am assuming that I need to calculate the number of samples per second in order to work out the length of the sample.

Thanks for any help

• You must to post comments
0
0

If you need a value in milliseconds, and you’re running at 44,100 Hz, here’s some code (let’s pretend lSamples is the variable holding your sample count):

float fSeconds,fMillisecs;

fSeconds = (float)lSamples / 44100;
fMillisecs = fSeconds * 1000;

It’s important that at least fSeconds be floating-point, or you will end up with an integer, which can’t represent fractions of a second. fMillisecs CAN be integer, but if it is, you need to typecast, and that’s why I made it floating-point.

• You must to post comments
0
0

The thing is, I don’t want to have to restrict the sounds I am using to be 44100 or any other fixed sample rate.

In fact because of the context, some of the sounds being used are sampled at 22050

What I want is a function to tell me what the sample rate of the sample is, which I can then substitute into a formula like the one you provided.

p.s. I know C++ quite well

• You must to post comments
0
0

Thanks Brett that’s exactly what I was looking for

• You must to post comments
0
0

How would you get the length of a Module file using the FMUSIC type???

• You must to post comments
Showing 4 results