Author Topic: How to show progress of BASS_Musicload ?  (Read 7782 times)


  • Posts: 8
How to show progress of BASS_Musicload ?
« on: 7 Apr '15 - 21:03 »
I develop a cross-platform application with Delphi XE7 and BASS. Quite happy so far (cheers to Ian) but now I have a somewhat weird problem with my Android app and specifically BASS_Musicload

My MO3 files are VERY large, around 5-10 MB. The process of decompression takes up to half a minute on a Lenovo Vibe Z. If there is any input during that time, for example from the hardware volume buttons or the screen, the app will not respond. Android interprets that as a crash and kills it. The length of the Android time-out limits the size of files I can load, depending on the device. Guess that's bad.

First of all, I'd like to process input during the decompression. That would fix the time-out problem killing my app. Secondly, I'd like to show a progress bar or some fancy animation meanwhile. Unfortunately, BASS_Musicload seems to freeze the machine.

Any ideas how to tackle this?


  • Posts: 8
Re: How to show progress of BASS_Musicload ?
« Reply #1 on: 8 Apr '15 - 18:37 »
One idea I had was to do the loading (and respective decompression) in a separate thread. I'm a little scared of that because I have no experience with it and could run into a dozen more problems later on. So I'd appreciate any suggestions that go a different way.

Ian @ un4seen

  • Administrator
  • Posts: 19819
Re: How to show progress of BASS_Musicload ?
« Reply #2 on: 9 Apr '15 - 16:47 »
That's quite a delay. I think you would indeed need to make the BASS_MusicLoad call in another thread in that case. Unfortunately there isn't currently any way to know the progress of a BASS_MusicLoad call, so you wouldn't be able to have a progress bar for it, but you could still have an animation to show that loading is in progress.

For a demonstration of this sort of thing, you could have a look at the NETRADIO example included in the BASS package; it calls BASS_StreamCreateURL (rather than BASS_MusicLoad) in another thread.


  • Posts: 8
Re: How to show progress of BASS_Musicload ?
« Reply #3 on: 10 Apr '15 - 20:22 »
Thanks, Ian, will try that.

In the future, could you imagine to touch the mod stuff again and make a slight change to _Musicload? For example, if there was a notification that a sample has finished decompression, one could count the samples and get a rough estimate of the whole process that could be fed to a progress bar.



  • Posts: 8
Re: How to show progress of BASS_Musicload ?
« Reply #4 on: 13 May '15 - 08:48 »
Works as suggested, thanks for the NETRADIO hint.

Now I can express that there is a process going on without freezing the application. But I'm loading other stuff as well and showing the overall state in a most conventional loading bar. On slower mobile machines, artwork is loaded quickly, then the bar remains unchanged for a long time, then suddenly snaps to full.

That somehow contradicts the idea of a loading bar - or limits usage of the MO3 format. I'm actually working to make that very format more adaptable to professional music production. My problem doesn't exist for streaming formats, obviously.

Something like that would come in very handy:

Code: [Select]
Sync when a compressed module's sample has finished decompression

BASS_SYNC_DECODED(param: bool, data: int)

param : 0 = return % of current decompression process, 1 = return sample number
data : percentage or sample number

or even just

Code: [Select]

data : sample number

I understand there is a problem in that I cannot SETSYNC before the channel has finished loading, so it probably won't work that way but has to come from MUSICLOAD instead. No way for me to properly fix it myself.

There is a large number of samples, >100, so any feedback about the current sample number would be sufficient. The only other way I see is to benchmark the system before decompression and then guess-calculate the average process duration. At least that would fix the frozen loading bar issue.

But it would be even more dirty than multi-threaded loading, at least if for the sake of music decompression alone. The whole issue appears to be a stronger candidate for a library function. Maybe you can cannibalize code from MO3 Encoder for this? Anything lib-side, no matter how troublesome, would be highly appreciated.

I guess in the past, nobody cared for it because modules are rather small, with insignificant loading times. But on modern machines and with better quality recordings, this becomes a missing function.

Though I admit that I feel a little bad being the only one requesting it.  :-[