Aller au contenu

Photo

PlayMusic() function - need help


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

#1
DarkJin83

DarkJin83
  • Members
  • 37 messages
 I see that it calls for the variable string sMusicName.  Where can I find the names of variables associated with the music that's already in the OC?  What includes do I need?

What I want to do is plain and simple have a trigger and an associated script.  When a player walks into the trigger polygon I want the script to play music  that is specified in the script by sMusicName.  Anyone know?

#2
Craig Graff

Craig Graff
  • Members
  • 608 messages
You need to refer to the music by it's full path, including the folder names. For instance you could play Leliana's song with:
PlayMusic("leliana_sings/song/leliana_sings");
It seems that the released toolset is missing the sound player tool, which is generally the easiest way to get the path (and also to play the various sounds). I'll file a bug to see if that can be added.

Modifié par Craig Graff, 15 décembre 2009 - 03:44 .


#3
DarkJin83

DarkJin83
  • Members
  • 37 messages
Thanks for the help Craig, that worked out perfectly.

#4
Challseus

Challseus
  • Members
  • 1 032 messages
@ DarkJin83

So, Craig's example worked for you? Interesting... I tried it, and I get nothing.

@ Craig

Now, when you say refer to the music by its full path, well, where exactly are they stored? For instance, under the Sounds section of the palette, there is a music folder, and under that you can find all the music for the game, filtered by the place it is used in. Are these the paths?

Also, I have created some custom music for my game, and integrated it into my module via FMOD. It even appears in the Sounds section of the palette. Where would that path be defined, if not from the palette.

Thanks. Music is definitely one of the more tricky things I have come across.

#5
RecklezzRogue

RecklezzRogue
  • Members
  • 193 messages
does PlayMusic() queue up the next song, or does it immediately replace any other music that may be playing?

#6
Craig Graff

Craig Graff
  • Members
  • 608 messages
The switch time depends on the music track itself, I believe. (The properties are determined in FMOD).

#7
RecklezzRogue

RecklezzRogue
  • Members
  • 193 messages
Hmph....I am using an existing area from the main campaign for a standalone module - I am not sure if that is relevent -- thinking it might. I have tried PlayMusic("abc") and I know it is being executed but no music will play. That said - the main background music from single player does play continiously through nothing I have done to make that happen....

I am pretty stuck - there is really nothing specific about using the original campain music in standalone modules documented in the wiki (or I missed it?).  Do I need to get into FMOD just to use existing music resources? Looking through the wiki on FMOD it really seems more about sound effects and ambient sounds, not just playing music in cutscenes, or just as area music.

Modifié par RecklezzRogue, 09 mai 2010 - 06:54 .


#8
RecklezzRogue

RecklezzRogue
  • Members
  • 193 messages
I figured it out - I was not setting intensity.

SetMusicIntensity (1);

Modifié par RecklezzRogue, 11 mai 2010 - 12:55 .


#9
Kilrogg_

Kilrogg_
  • Members
  • 296 messages
How did you get the file paths for the music tracks? Neither the fmod eventplayer or musicplayer want to open any of the .fev or .fsb files. It's either saying the version number is incorrect or that a header file is missing.

#10
RecklezzRogue

RecklezzRogue
  • Members
  • 193 messages
Drill down in the toolset --
- Click on the Musical Note Icon
- open the music folder
- trial and error

There is a tool which works really good for listening to the music directly from .erf files (I think it will open FSB files directly as well), however, the naming conventions do not align with what you will see in the toolset (arrghhh). It's called DAExtractor (Dragon Age Extractor), and it's the only tool I've personally been able to play FSB files with. That said - I just looked for the link for you and it appears to be MIA...weird.....

Modifié par RecklezzRogue, 20 mai 2010 - 12:49 .


#11
Kilrogg_

Kilrogg_
  • Members
  • 296 messages
I tried using the file paths from the toolset but its not working for me.



Do you use /music/ first or start with the subfolder? For example, either of these don't work for me:



PlayMusic("music/BC_tower_1/desire_demon");

SetMusicIntensity(1);



PlayMusic("BC_tower_1/desire_demon");

SetMusicIntensity(1);



I also tried the filepath Craig mentioned above (I assume it was just an example).



Can you give me an example of a working filepath that you found so I can see if it plays for me?



Thanks!

#12
RecklezzRogue

RecklezzRogue
  • Members
  • 193 messages
if (!WR_GetPlotFlag(PLT_DMO001_DAFL001D_PLOT,38))
{
string sMusic = ("music/dalish_k/main");
SetMusicIntensity (1);
PlayMusic(sMusic);
PlayCutscene();
}


ps - if you want DAExtractor, shoot me a private message with your email addy, it's not too big...I'll send it over.

Modifié par RecklezzRogue, 20 mai 2010 - 01:30 .


#13
Kilrogg_

Kilrogg_
  • Members
  • 296 messages
I tried your music path and don't get any music when walking over my trigger.

Here's my trigger script... based on the 'run cutscene' sample script from the wiki. It definitely fires because i see the floaty text.

Keep in mind I started looking at scripting like 3 days ago so I am not very knowledgable :(

#include "events_h"
#include "global_objects_h"
#include "utility_h"

void main ()
{
event ev = GetCurrentEvent();
int nEventType = GetEventType(ev);
int bEventHandled = FALSE;
switch (nEventType)
{
case EVENT_TYPE_ENTER:
{
object oCreature = GetEventCreator(ev);
if(GetObjectActive(OBJECT_SELF)
&& IsPartyMember(oCreature))
{
string sMusic = ("music/dalish_k/main");
SetMusicIntensity (1);
PlayMusic(sMusic);
DisplayFloatyMessage(GetHero(), "--------------", FLOATY_MESSAGE, 16777215, 20.0);
}
}
break;
}
if (!bEventHandled) //If this event wasn't handled by this script, let the core script try
{
HandleEvent(ev, RESOURCE_SCRIPT_TRIGGER_CORE);
}
}

Modifié par Kilrogg_, 20 mai 2010 - 01:39 .


#14
RecklezzRogue

RecklezzRogue
  • Members
  • 193 messages
hrmph................ya got me there..........and you see this path in the toolset as well? Mine is a standalone module...(under hierarchy the only thing checked in core_game_resources, but it's grayed out).I supposed the key difference is that you are using a trigger...try just starting the music in your area script (preload exit) and see if that works.



Here's another example from my_module_core script, this is how I am starting and stopping combat music:



switch(nEventType)

{



// combat music on gamemode change to combat mode

//

case EVENT_TYPE_GAMEMODE_CHANGE:

{

string sMusic = ("music/Lothering/combat");

int nNewGameMode = GetEventInteger(ev,0);

if (nNewGameMode == GM_COMBAT)

{

SetMusicIntensity (1);

PlayMusic(sMusic);

}

else if (nNewGameMode != GM_COMBAT)

{

StopMusic(sMusic);

}

break;

}




#15
Kilrogg_

Kilrogg_
  • Members
  • 296 messages
Tried loading the music with the area preload exit, doesnt work.

Also tried your script in my module load script and same result :(

Mod is also standalone and only has core resources checked in hierarchy. I only ever get music if i set a music preset in the area properties, but obviously that is not the triggered music, its just the normal music.



I guess I'll revisit this problem when I am further along.

#16
Proleric

Proleric
  • Members
  • 2 343 messages
Has anyone bottomed this out?

PlayMusic and StopMusic don't do anything for me, period.

I've tried the above examples, and many different combinations of preset, music volume and event, to no avail.

These functions are not used in the OC (apart from a line in area_core, which is demonstrably redundant).

I have music presets working fine, so the outstanding question is how to change the music.

Following examples in the OC, I find that in the area post-load event (only)
SetMusicVolumeStateByTag can be used to change track within the current music preset. In all examples tested to date, music volume state 4 stops the music, while 1 plays the default track.

Once the music is stopped, SetMusicIntensity(1) can be used in a plot script to restart the default track.

Does anyone know (a) how to change track during gameplay (B) how to switch to a different preset?

I'd prefer not to have to use FMOD at this stage.

#17
Karma

Karma
  • Members
  • 391 messages
Several months ago, I used something similar to

string sMusic = ("music/dalish_k/main");
SetMusicIntensity (1);
PlayMusic(sMusic);

in a trigger, and it worked for me. However, if I remember correctly, it didn't stop the preset music; they were playing simultaneously. I never bothered to find a fix to it.

At one point last year, I was having sound issues after I installed one of the patches. I couldn't hear any music whatsoever in-game. Not just in areas that I created but in vanilla areas as well. I had to transfer the music files to packages/core/override to be able to hear anything. I haven't tested to see if this issue has been fixed with the latest patch.

#18
Proleric

Proleric
  • Members
  • 2 343 messages
I just tried doing exactly what you describe, but it doesn't seem to work for me.

Putting the music in packages core override makes no difference.

If I turn the preset music off (as described above), SetMusicIntensity (1) turns it on again - otherwise, the trigger does nothing.

So, it's still a mystery...