Playmusic freeze

Previous topic - Next topic

erico

Hello there, quick question:
I have been getting a quick computer freeze every time music is played with that command.
Mp3 is horrible as it takes more than a full second, raw wav takes 1/10 of a second. But all motion freezes.

What the heck, that did not happen on my old machine but happens on my new one, which was a lot of trouble taking win 10 out to use win 7, lots of drive problems.

So, is that only on my side? Is anyone experiencing problems with playmusic and loop?

Tried v16 steam and no good either, tried at 2 friends pc and wav raw had no problem, which leads me to think my drivers are bugged.
One could switch to playsound though. What do you guys think?

SnooPI

I remember that I had a lot of problems with the playmusic function (especially on mobile) and finally, I used the playsound function.

Moreover, at the time of launching this function, everything slows down (as in my demo with the music of 2001, when the music stops and restarts, the demo slows down).
Nevertheless, it is a bit normal because the music is not loaded in memory, unlike the playsound function.

Erico, you should convert all yours musics to be compatible with the playsound function. Personally, I think this is the best solution at the moment.

erico

Ok, I got some hints about doing that from the forum and will update my framework to use that for future games.
Thanks.

bigsofty

Quote from: Snoopy on 2019-Jul-21
I remember that I had a lot of problems with the playmusic function (especially on mobile) and finally, I used the playsound function.

Moreover, at the time of launching this function, everything slows down (as in my demo with the music of 2001, when the music stops and restarts, the demo slows down).
Nevertheless, it is a bit normal because the music is not loaded in memory, unlike the playsound function.

Erico, you should convert all yours musics to be compatible with the playsound function. Personally, I think this is the best solution at the moment.

Playmusic slows your code down, wow. This is a bit of a concern TBH. Have you tried this recently Snoopy?
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

SnooPI

Yes, as in my "2001 Demo" for a contest on the forum.
Or at least, that's the case on my old PC.

But I specify that it's when the music restarts.

bigsofty

So the music is streamed of the HD, I never knew that.
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

erico

Yes I noticed if the game is running from a slow speed drive or a pen drive, it struggles when streaming music.
I really wish the music I´m using was IT as I suspect I would not bring all that trouble that way.

SnooPI

Personally, I don't find it abnormal.
This allows to have a very good quality of music without cluttering the memory and for the rest there is the playsound function.

It's the same as for the playmovie function.

erico

I never had trouble with it, just now that I got this new computer with a very shitty on board sound, it renders games with playmusic unplayable if the music kicks in with action ongoing.

dreamerman

#9
It's not only Your pc problem erico, this is still a thing.. ofc will be dependent on file and mostly hard drive that's in use, surely more notable on hdd than on ssd, and this annoys me. Remember days that I wrote some mp3 player with VB6 that was using Win API precisely MCI stuff, there was no visible file loading time as file was read in chunks, and now this... :> So what is the best solution for now? As SnooPI mentioned use only PlaySound even for music (what sound format it currently supports fo have proper results? mp3 will work or only wav's or something :/) or maybe using threads and PlayMusic from separate thread (would that be safe for all platforms and so on)??

btw. any one has that multi-threading code as can't find working attachment on forum with any source..
Check my source code editor for GLBasic - link Update: 20.04.2020

erico

I´m sticking with playsound for now, loading only pure waves.
One thing though is that .IT files might work just fine on playmusic, haven´t tried that but since it is a super small file, it might just work.

dreamerman

#11
With playsound there is one problem that You need to load all music files into memory and wav's ale larger that ogg/mp3, so if I have couple music files they will take some time to load and will occupy precious ram :/
Yet I'm checking some other solutions, currently testing SDL2 mixer and it looks that this way mp3 files can be played without visible freezes during gameplay.

ps. *IT files, You mean mod music? this also may be an idea but will need to find such resources that would fit my project.
Check my source code editor for GLBasic - link Update: 20.04.2020

erico

Yep, it and mod files (trackers) works a charm last I tried a while ago.
I try to work with it, but brute force wav is always easier. :)

SnooPI

#13
Hey, this is important information Erico! Thks!  :good:

I put here a link to a portable ProTracker 2 and Fasttracker 2 clone https://16-bits.org/index.php

...and a ProTracker tutorial https://www.youtube.com/playlist?list=PLVoRT-Mqwas9gvmCRtOusCQSKNQNf6lTc

spacefractal

#14
Just to been Noticed SoundPool on Android (optional in newest beta) does not supports mods, but is more stable than sld mixer is. A least on Android. Yes its a bit strange on Windows as well.

There is some delays to open and fill the buffer when playing music. This is why im allways only start them on a scene change, so a delay does not matter and newer have used a ingame music change.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/