Aller au contenu

Photo

Turning off music with scripting... "Solved"


  • Veuillez vous connecter pour répondre
2 réponses à ce sujet

#1
FergusM

FergusM
  • Members
  • 460 messages
So I know that music has been the subject of much gnashing of teeth for everyone, but here goes.

I want to be able to stop the music playing in an area through a script, and then restart it in a later script. I want to do this for a lot of areas, so preferably I'm looking for something general.

Now, I thought my solution would be

SetMusicIntensity(0);
and
SetMusicIntensity(1);

However, the music never actually stops when the intensity is set to 0. I should note, if it matters, that my music volume has an enter state of 1 and an exit state of 0 (which I guess means 'set it to this intensity when you enter/exit').

I'm interested in perhaps PlayMusic and StopMusic, as well as SetMusicVolumeByTag, but I don't know the tags for any of the music and, again, I would prefer to have a general solution, rather than specifying the music in every area. Not to mention that a lot of people have reported problems with PlayMusic().

Modifié par FergusM, 07 août 2010 - 11:41 .


#2
FergusM

FergusM
  • Members
  • 460 messages
Okay, so, doing this:

PlayMusic("music/Paragon/main");
SetMusicIntensity(1);

Will play music. However, when we run this:

StopMusic("music/Paragon/main");
SetMusicIntensity(0);

The music we started playing above does not cease. This is crazy. :/ Any ideas?

EDIT: A correction. PlayMusic in fact does nothing in the above, it was merely playing the area music when I set the intensity to 1.

Modifié par FergusM, 07 août 2010 - 09:25 .


#3
FergusM

FergusM
  • Members
  • 460 messages
Well, I'm pretty smug about this right now.



My goal was to basically turn off all music on command and then re-enable it later. I achieved it in the following very convoluted fashion:



1) I noticed that cutscenes play a sound called "music_duck" (in slo_blows) to turn off music.

2) I got the .fdp source files from BryanDerksen's project and took a look at slo_blows

3) I deleted all the sounds except for "music_duck" out of the project, then renamed the project, the group and the sound to "stopmusic".

4) I then deleted all the wavs except for the one that "music_duck" uses.

5) In the event editor, I set the wav length to a very very long time (several hours maybe?) and set it to loop and cutoff. I had to do both these things to get it to work.

6) When I went to build it, it wanted to know where the wav was. So I just used fsb extractor to grab this wav from the core/audio directory. I'm not sure if there is anything special about it or if any wav would work.

7) Copied the exported files to my override folder.

8) Put the sound in my area. By calling ActivateSoundByTag("musicstop") with TRUE or FALSE, the music can be turned off and on respectively. There is a lag of a few seconds when turning it back on.