Author Topic: Playmusic freeze  (Read 1142 times)

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4310
    • View Profile
    • Portfolio
Playmusic freeze
« on: 2019-Jul-17 »
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?

Offline SnooPI

  • Dr. Type
  • ****
  • Posts: 343
    • View Profile
Re: Playmusic freeze
« Reply #1 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.

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4310
    • View Profile
    • Portfolio
Re: Playmusic freeze
« Reply #2 on: 2019-Jul-22 »
Ok, I got some hints about doing that from the forum and will update my framework to use that for future games.
Thanks.

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2672
    • View Profile
Re: Playmusic freeze
« Reply #3 on: 2019-Jul-22 »
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)

Offline SnooPI

  • Dr. Type
  • ****
  • Posts: 343
    • View Profile
Re: Playmusic freeze
« Reply #4 on: 2019-Jul-23 »
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.

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2672
    • View Profile
Re: Playmusic freeze
« Reply #5 on: 2019-Jul-24 »
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)

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4310
    • View Profile
    • Portfolio
Re: Playmusic freeze
« Reply #6 on: 2019-Jul-24 »
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.

Offline SnooPI

  • Dr. Type
  • ****
  • Posts: 343
    • View Profile
Re: Playmusic freeze
« Reply #7 on: 2019-Jul-25 »
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.

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4310
    • View Profile
    • Portfolio
Re: Playmusic freeze
« Reply #8 on: 2019-Jul-26 »
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.

Offline dreamerman

  • Global Moderator
  • Dr. Type
  • *******
  • Posts: 349
    • View Profile
    • my personal website
Re: Playmusic freeze
« Reply #9 on: 2020-Apr-29 »
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..
« Last Edit: 2020-Apr-29 by dreamerman »
Check my source code editor for GLBasic - link Update: 20.04.2020

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4310
    • View Profile
    • Portfolio
Re: Playmusic freeze
« Reply #10 on: 2020-Apr-29 »
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.

Offline dreamerman

  • Global Moderator
  • Dr. Type
  • *******
  • Posts: 349
    • View Profile
    • my personal website
Re: Playmusic freeze
« Reply #11 on: 2020-Apr-29 »
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.
« Last Edit: 2020-Apr-29 by dreamerman »
Check my source code editor for GLBasic - link Update: 20.04.2020

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4310
    • View Profile
    • Portfolio
Re: Playmusic freeze
« Reply #12 on: 2020-Apr-29 »
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. :)

Offline SnooPI

  • Dr. Type
  • ****
  • Posts: 343
    • View Profile
Re: Playmusic freeze
« Reply #13 on: 2020-Apr-29 »
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
« Last Edit: 2020-Apr-29 by SnooPI »

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3918
    • View Profile
    • Space Fractal
Re: Playmusic freeze
« Reply #14 on: 2020-Apr-29 »
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.
« Last Edit: 2020-Apr-29 by spacefractal »
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation and The beagle Jam.