Author Topic: Millisec based sync w/ modules  (Read 10323 times)


  • Guest
Millisec based sync w/ modules
« on: 27 Aug '03 - 16:49 »
Is there any way to load a module, and then, while playing, have a millisecond based synchro-value, e.g. by retrieving the number of samples rendered/mixed?

My problem is that I want to use e.g. an XM in my demo, and the only way I can keep track with the music playing is using BASS_MusicPlay to play it, and then BASS_ChannelGetPosition for the pattern/row sync. Problem is, that due to the nature of modules this is only a very rarely updated value, and even with BASS_MusicSetPositionScaler, it's still very problematic to do "smooth" visuals, as opposed to a millisec based sync where you can e.g. interpolate linearly with the value.

An option obviously would be using timeGetTime() or so, but that's very inaccurate, and even a little jitter in the system could cause a gap between cue-points in the music and the visuals.

I would love to see an option for this, as I use BASS for most of my stuff.

Ian @ un4seen

  • Administrator
  • Posts: 25718
Re: Millisec based sync w/ modules
« Reply #1 on: 29 Aug '03 - 16:14 »
Have you tried setting syncs (BASS_ChannelSetSync) instead of periodically checking the position? It'd be more accurate, more efficient, and simpler too :)


  • Guest
Re: Millisec based sync w/ modules
« Reply #2 on: 29 Aug '03 - 18:20 »
Won't do. What I need is framerate-independent synchronization, with accurate values for every frame.
Sync-callbacks would work in some cases (like when switching scenes), but then I want something to move or fade or rotate or whatever smoothly, then I definetely need a value that is linearly rational with the time elapsed, and does not depend on the frequency of the frame updates.
For example, if I want to fade down the visuals to black after 10 seconds in 2 seconds, i could use linear interpolation for the fade-value, if I had a very exact and detailed timer.
If I would use a sync-callback (let's assume I can set the sync to the exact 10th second, but in most cases, we can't), which uses some increment that is added to the fade value, it would work, but it would most likely miss the exact 2 second interval, so if the framerate is low, it would take much more time to do the actual fade.

My idea would be fetching the number of samples played, just like in the case for MP3-s.

(Pleeeeeeease? ;D)

Ian @ un4seen

  • Administrator
  • Posts: 25718
Re: Millisec based sync w/ modules
« Reply #3 on: 31 Aug '03 - 12:36 »
So, basically, you want to treat a MOD music like a stream? :)

You can do that by using a decoding channel and a custom stream...
Code: [Select]
DWORD CALLBACK mystreamproc(HSTREAM handle,void *buffer,DWORD length,DWORD user)
     return BASS_ChannelGetData(user,buffer,length);


HMUSIC decoder;
HSTREAM stream;
DWORD flags,freq;
decoder=BASS_MusicLoad(FALSE,"a_file",0,0,BASS_MUSIC_DECODE); // decoding channel
stream=BASS_StreamCreate(freq,flags,&mystreamproc,decoder); // custom stream