Author Topic: BassMix, set position  (Read 1756 times)

ken

  • Posts: 739
BassMix, set position
« on: 8 Nov '10 - 16:35 »
I add a few audio files with "BASS_Mixer_StreamAddChannelEx" with different start positions.

Code: [Select]
_channel1 = Bass.BASS_StreamCreateFile(filename, 0L, 0L, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT);
BassMix.BASS_Mixer_StreamAddChannelEx(Mixer, _channel1, BASSFlag.BASS_STREAM_AUTOFREE | BASSFlag.BASS_MIXER_END | BASSFlag.BASS_MIXER_NORAMPIN, start, length);

That works fine and plays, but I like to set new position when its playing (like jumping in the time line). I have tried:

Code: [Select]
BassMix.BASS_Mixer_ChannelSetPosition(Mixer, Bass.BASS_ChannelSeconds2Bytes(Mixer, pos.TotalSeconds));


but it gives me BASS_ERROR_POSITION.  How do I set position?

/Ken

radio42

  • Posts: 4576
Re: BassMix, set position
« Reply #1 on: 8 Nov '10 - 16:51 »
Use the mixer source stream instead of the mixer stream in your BASS_Mixer_ChannelSetPosition call.

ken

  • Posts: 739
Re: BassMix, set position
« Reply #2 on: 8 Nov '10 - 17:14 »
Use the mixer source stream instead of the mixer stream in your BASS_Mixer_ChannelSetPosition call.

Do you mean the channel from "BASS_StreamCreateFile" ? in that case I need to get with of my channels that are in use at that position.

Now I'm using channel from "BassMix.BASS_Mixer_StreamCreate"

Ian @ un4seen

  • Administrator
  • Posts: 20427
Re: BassMix, set position
« Reply #3 on: 9 Nov '10 - 15:34 »
It appears that you want to set the position of the entire mix, not an individual source? I'm afraid mixers don't currently support seeking, so a simple BASS_ChannelSetPosition call on the mixer isn't possible, but you could manipulate the position of each source according to the target mix position to achieve what you want. You can find an example of that here...

   www.un4seen.com/forum/?topic=9702

ken

  • Posts: 739
Re: BassMix, set position
« Reply #4 on: 9 Nov '10 - 16:03 »
It appears that you want to set the position of the entire mix, not an individual source? I'm afraid mixers don't currently support seeking, so a simple BASS_ChannelSetPosition call on the mixer isn't possible, but you could manipulate the position of each source according to the target mix position to achieve what you want. You can find an example of that here...

   www.un4seen.com/forum/?topic=9702

That's correct Ian. I will try doing like the example. Maybe in future versions it can be implemented..?

Ian @ un4seen

  • Administrator
  • Posts: 20427
Re: BassMix, set position
« Reply #5 on: 10 Nov '10 - 18:00 »
Mixers don't currently follow a predetermined sequence, eg. sources can be added/remove at any time and the sources' positions can be anything, which doesn't lend itself to seeking. Sequencing support may appear in future (it's on the "look into it" list), which would make seeking feasible, although there would still be limitations (see next paragraph).

For now, I can't see backward seeking being possible, but forward seeking could be possible to some extent. I say "some extent" because some sources won't be seekable at all (eg. custom streams), and some sources might not end up at exactly the position that they would if they were played up to the wanted mix position, eg. if they are using custom looping or they don't have accurate seeking (or accurate length in the case of looping). But "some extent" is better than "no extent", so here's an experimental update to try...

   www.un4seen.com/stuff/bassmix.dll

It adds this BASS_ChannelSetPosition "mode" option...

Code: [Select]
#define BASS_POS_MIXER_BYTE 3

Which you would use like this...

Code: [Select]
BASS_ChannelSetPosition(mixer, pos, BASS_POS_MIXER_BYTE);

Note that "pos" must not be behind the mixer's current decoding (not heard) position, otherwise BASS_ERROR_POSITION will result. To seek backwards, you could reset the mixer and sources to their initial state, and then use this new feature to seek to the wanted position. Btw, the current decoding position is available like this...

Code: [Select]
BASS_ChannelGetPosition(mixer, BASS_POS_BYTE|BASS_POS_DECODE);

One issue to note is that if a source has a BASS_MIXER_ENV_FREQ envelope set, the envelope's current position will be used to calculate the source's new position. The envelope will still advance, but its effect just won't be applied throughout the source position advancing.

This stuff hasn't been tested much yet, so if you do try it, please report how you get on.