playMaker

Author Topic: Music change, Audio Play causing multiples  (Read 1703 times)

Lamb

  • Playmaker Newbie
  • *
  • Posts: 8
Music change, Audio Play causing multiples
« on: May 25, 2016, 09:17:44 PM »
I'm setting up a music change system.
I want a track to play between scenes but then change to a different track on a couple of scenes.

I have an object that sets audio, compares a float, leads to states using play audio, then a stop audio upon float changed, compare float again, change track etc

I can get it all to work but when I enter a previous scene that had a different track that had played before, it sounds like it's adding another instance of the song playing. So switching between two scenes with different tracks led to really distorted sounding audio of what seemed like layers and layers of the same song.

I was trying to put together another approach where both play from the start and a float compare sets the volume from 0 to 1 depending on the scene but I couldn't get sound to happen that way.

Anyone having a similar issue or know a more elegant way to accomplish this?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Music change, Audio Play causing multiples
« Reply #1 on: May 26, 2016, 03:31:48 AM »
Hi,

 If you have one manager for this audio system, make sure you deal with it when loading scenes.

use "dontdestroyonload" so that you keep the audio manager from scenes to scenes without loosing your current datat

use "Singleton" approach so that when you load a scene with the manager, it checks that it exists already and if it does only keep one instance ( the current).


http://hutonggames.com/playmakerforum/index.php?topic=12092.msg59859#msg59859

Bye,

 Jean

Lamb

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Music change, Audio Play causing multiples
« Reply #2 on: May 26, 2016, 03:05:45 PM »
I've been reading a little about singleton but I'm also not a coder/just using Playmaker.

Are there singleton actions in playmaker I can get a hold of or do I need to do it all with a variable system or code only?

Lamb

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Music change, Audio Play causing multiples
« Reply #3 on: May 26, 2016, 08:14:33 PM »
I tried having the music manager spawn in a scene that is never repeated to try and find a work around but it seems to me like it's using the Audio Play function [even after stopping audio] causing multiple instances of the song to play.

I dug around more and it seemed like there was a Singleton action set for PlayMaker posted in the past but I haven't been able to locate that.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Music change, Audio Play causing multiples
« Reply #4 on: June 08, 2016, 04:47:17 AM »
Hi,

 Yeah, it's on the Ecosystem, search for "singleton".

Bye,

 Jean