Jump to content

New WeiDu HANDLE_AUDIO and multiple soundsets


cmorgan

Recommended Posts

Hey there - I have been using an interactive install to allow only certain sets of sounds to be copied over. I have also been avoiding multi-platform issues by distributing wavc format audio.

 

Sample code:

BEGIN ~Install Only Soundset~
   FORCED_SUBCOMPONENT ~Install Audio Files~
   REQUIRE_COMPONENT ~setup-aranw.tp2~ ~0~ ~Aran Whitehand must be installed for this to work.~
   COPY ~aranw/media/g3blank.mus~         ~music~
   COPY_EXISTING ~songlist.2da~         ~override~
       SET_2DA_ENTRY 0 2 3 ~g3blank.mus~
       BUT_ONLY

   LAUNCH_ACTION_MACRO ~chooseasoundtrack~

   /* set up what sounds need to be installed for this component to be covered */
   ACTION_CLEAR_ARRAY ~sounds~
   ACTION_DEFINE_ARRAY ~sounds~ BEGIN
       ~c-aws001~
       ~c-aws044~
       ~c-aws045~
   END

   /* look for the resulting .wavc files and copy them into the game */
   ACTION_PHP_EACH ~sounds~ AS ~index~ => ~sound~ BEGIN
       ACTION_IF (NOT FILE_EXISTS_IN_GAME ~%sound%.wav~) BEGIN
           COPY ~aranw/media/wavc/%sound%.wav~ ~override~
       END
   END

 

If I wanted to use the oggdec sounds and let weidu do the work, I see this:

LAF HANDLE_AUDIO
 STR_VAR
   audio_path = ~mymod/audio/vo~
   oggdec_path = ~mymod/audio~
   sox_path = ~mymod/audio~
END
LAF HANDLE_AUDIO
 INT_VAR
   music = 1
 STR_VAR
   audio_path = ~mymod/audio/music~
   oggdec_path = ~mymod/audio~
   sox_path = ~mymod/audio~
END

I am pretty sure I have the most efficient way of dealing with audio right now, for my mod, but I do like the simplicity of oggdec .wav instead of wavc.... so, if I have multiple user choices, it looks like what I need to do is separate the actual audio files into separate subdirectories, right?

 

So an example of .tp2 code that allows for multiple soundsets might look like this:

/* define all macros */
DEFINE_ACTION_MACRO ~chooseasoundtrack~ BEGIN

OUTER_SPRINT ~soundchoice~ ~placeholder_value~
OUTER_WHILE (!(IS_AN_INT ~soundchoice~) OR (~soundchoice~ > 0x3) OR (~soundchoice~ < 0x1)) BEGIN
	PRINT ~Music choices:
	[1] JSayles unaccompanied guitar, Early Music
	[2] Renaissance brass
	[3] Vox Vulgaris (midaevil wih a twist)
	Please type 1, 2, or 3, and press enter.~
	ACTION_READLN ~soundchoice~
END
ACTION_IF ("soundchoice" = 1) THEN BEGIN
LAF HANDLE_AUDIO // install songs that replace voicing
 STR_VAR
   audio_path = ~aranw/media/soundset1/~
   oggdec_path = ~aranw/media~
   sox_path = ~aranw/media/~
END
LAF HANDLE_AUDIO
 INT_VAR
   music = 1
 STR_VAR
   audio_path = ~aranw/media/soundset1/~
   oggdec_path = ~aranw/media~
   sox_path = ~aranw/media/~
END
LAF HANDLE_AUDIO // add voiceover for lines that have it
 STR_VAR
   audio_path = ~aranw/media/voiceover/~
   oggdec_path = ~aranw/media~
   sox_path = ~aranw/media/~
END
LAF HANDLE_AUDIO
 INT_VAR
   music = 1
 STR_VAR
   audio_path = ~aranw/media/voiceover/~
   oggdec_path = ~aranw/media~
   sox_path = ~aranw/media/~
END
PRINT ~Default unaccompanied guitar soundtrack chosen.~
PRINT ~Voiced lines installed.~
END
ACTION_IF ("soundchoice" = 2) THEN BEGIN
etc. etc. with the only change being the directory soundset1, soundset2, soundset3...

END // of macro

?

 

Or is there a slick way of variablizing sounds from within the same file and still calling HANDLE_AUDIO...

Link to comment

You'd do it by organising your files into subdirectories, yes.

 

However, you can factor out the differences pretty easily, to cut down on the typing. Example:

DEFINE_ACTION_FUNCTION mymod_audio
 STR_VAR
audio_path = ~~
BEGIN
 LAF HANDLE_AUDIO
STR_VAR
  audio_path
  oggdec_path = ~mymod/whatever~
  sox_path = ~mymod/whatever~
 END
END

// Elsewhere...

LAF mymod_audio
 STR_VAR
audio_path = ~mymod/foo/audio~
END

// Somewhere else...

LAF mymod_audio
 STR_VAR
audio_path = ~mymod/bar/audio~
END

 

If your needs are less demanding, you can of course also omit the wrapper function and just conditionally SPRINT audio_path somewhere before you call HANDLE_AUDIO.

 

Please note that in your example code you are calling HANDLE_AUDIO twice on each directory, and you are using music = 1 on what appears to be voice audio. As an aside, you'd only use music = 1 when you want the audio to have an ACM extension on BGEE. I don't know if that's ever desirable, but it is technically suported by BGEE. The music variable has no other effect. In your particular example, you can also move the HANDLE_AUDIO for ~aranw/meda/voiceover~ outside the conditional for soundset[1-3], since that part is apparently something you want to do regardless.

Link to comment

Thanks! Follow-up questions - and then I'll clean up and repost with working code, so folks don't replicate my errors...

 

I know I am using HANDLE_AUDIO twice - once for each subdirectory I want to have included (I can't select only certain files within the subdirectory, so instead of one big directory of different names, I sort them into building blocks and then put them together in different orders). So if one subcomponent (or READLN choice if I go that way) uses

../mymod/soundset1/ and ../mymod/voiceover2/

and another one uses

../mymod/soundset2/ and ../mymod/voiceover3/

then I need to do the LAF twice, I think... or can I do multiple calls, so that

LAF mymod_audio
 STR_VAR
	audio_path = ~mymod/foo/voiceover_1~ ~mymod/foo/soundset_2~ ~mymod/foo/musicset_1~
END

Would that pull from each of the three subdirectories?

 

Looking for ways of letting players mix and match two or so "voiceovers" which are spoken lines and character sounds, with three or so different "soundsets" which are played for things that do not have voiceovers recorded (like BG1NPC does with PlaySong(). In architecture terms,

 

../audio/

 

../audio/soundsets/soundset1

../audio/soundsets/soundset2

 

../audio/voiceover/voiceover1

../audio/voiceover/voiceover2

../audio/voiceover/voiceover3

Link to comment

I know I am using HANDLE_AUDIO twice - once for each subdirectory I want to have included

I meant you were calling it twice on each, for a total of four times. As you say, you only need to call HANDLE_AUDIO once for each directory.

 

LAF mymod_audio
 STR_VAR
	audio_path = ~mymod/foo/voiceover_1~ ~mymod/foo/soundset_2~ ~mymod/foo/musicset_1~
END

Would that pull from each of the three subdirectories?

You can't do that, no. The syntax for the function construct does not allow it.

 

Looking for ways of letting players mix and match two or so "voiceovers" which are spoken lines and character sounds, with three or so different "soundsets" which are played for things that do not have voiceovers recorded (like BG1NPC does with PlaySong().

The easiest way would be by asking about voices and sounds separately, so you don't need to consider the combinations. So you ask the user about which voice set to install, call HANDLE_AUDIO (or mymod_audio or whatever) on that directory. Then you ask about which sound set to use, and call HANDLE_AUDIO on that directory.

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...