0
0

Hi readers,

I’m using FMOD for some weeks now, it’s a great thing to have.

Now I want to implement some kind of intelligent autoskip functionality to one of my projects.
I thought about using a second stream, opened from the same file that’s actually played back, and scan for the optimal skip point.

I want(ed) to set the second stream to somewhere about 10 sek from the file’s end and then collect some positions and their volumes and after that go through this data to find the point which is best for skip. In some way comparable to SQR’s Winamp plugin.
The problem I have now is, that I can’t get the sources volume at a given point. When muting the channel with SetVolume, the GetLevel function returns 0, when I play the stream back with volume it’s audible.

So, to make things short: How can I get the volume of my source (stream) at a given point (in ms from start or end or…)?

As fair as I’ve seen on the forum, this is not yet supportet as is. Do someone know of any workarounds to get this solved?

Code snippets much appreciated.

  • You must to post comments
0
0

I read about the DSP somewhere before, but I don’t have an idea how to work with it.

At the moment I use a simple while-loop to get the levels, but at full volume. Some cracks occur during the process, so I would use something like virtual audio cable as output for this procedure and send the sound nowhere.

Do you have some tips on how to accomplish the task with a DSP unit?

I know I can connect a DSP callback with the stream, but that is all. How can I access the level in this function and how often is it called?

  • You must to post comments
0
0

a dsp callback on the stream should do the trick shouldn’t it?

It will give you all the audio data of the stream, no matter what the volume is set to, and you can even play the stream at double speed by using setFrequency to speed up the scanning.

  • You must to post comments
0
0

And now my stupid question:
How do I create the DSP callback and – more important – how do I access the stream data in the function?

  • You must to post comments
0
0

Thank you for this, I think I’m going to use my workaround to this problem first and will concentrate on this solution later.

The workaround looks like this:
First, I’m using a second audio output or the demo of Virtual Audio Cable as kind of NULL Output for the stream that is to be analyzed.

Then I have a simple Loop:

[code:3myae58s]
FSOUND_SetVolume(predictionchannel, 0);
FSOUND_SetPaused(predictionchannel, FALSE);

while (currposition < length-500)
{
  FSOUND_Stream_SetTime(prediction, currposition);
  FSOUND_SetVolume(predictionchannel, 255);
  FSOUND_GetCurrentLevels(predictionchannel, &l, &r);
  FSOUND_SetVolume(predictionchannel, 0);
  if (l > min_level)     // quick'n'dirty: only left is compared  
  {
positions[arraycount].pos = currposition;
positions[arraycount].l = l;
positions[arraycount].r = r;
arraycount++;
  }

  currposition = currposition + interval;
  count++;
}

[/code:3myae58s]
Then I have the last point which is above a certain threshold in the last value of the array.
This procedure takes about max 3 sek for a 10 sek range, depending on the interval and gives quite good results. On fast machines, you hear nothing, but on slower ones there are one or two short noise peaks audible, therefore the NULL output.

  • You must to post comments
0
0

Now I got things sorted. By coincedence I read in the help that providing a value <0 to FSOUND_SetDriver will mute the output, but still play the file through a NOSOUND device. That’s what solves the problem, now I can search a part of my stream (ie end of it) with GetLevels for volume (like in the code above, but without setting volumes to 0 while jumping through the file) and have no noise on the speakers. Very easy.

  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.