play arbitrary sounds into code, help please

Freeform discussion about anything related to modding Transcendence.
Post Reply
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

If you create a Virtual Weapon, then you can call it everywhere with sysCreateWeaponFire, so why don't call a virtual weapon in order to play a sound ?

If you look into trascendence.xml under <Effects> some of the standard effects have sounds built in like:

Code: Select all

<Effect UNID="&efStargateOut;"
			sound="&snStargate;"
			>
So I added a sound inside an <Effect> tag into a virtual <ItemType> in order to play it, but it doesn't work.
I wanted a working Neuros media player (Bobby already did a brilliant hack in order to play 1 audio file) with multiple random audios.

So here the code:

Code: Select all

<?xml version="1.0" ?>
<!DOCTYPE TranscendenceExtension
	[
	
	<!ENTITY unidExtension				"0xD25C0801">
	
	<!ENTITY itNeurosPMP				"0x00004161">
		
	<!ENTITY virtual1				"0xD25C0802">
	<!ENTITY virtual2				"0xD25C0803">
	<!ENTITY virtual3				"0xD25C0804">
	<!ENTITY virtual4				"0xD25C0805">
	<!ENTITY virtual5				"0xD25C0806">
	<!ENTITY virtual6				"0xD25C0807">
	<!ENTITY virtual7				"0xD25C0808">
	<!ENTITY virtual8				"0xD25C0809">
	<!ENTITY virtual9				"0xD25C080A">
	<!ENTITY virtual10				"0xD25C080B">
	
	<!ENTITY snaudio1				"0xD25C080C">
	<!ENTITY snaudio2				"0xD25C080D">
	<!ENTITY snaudio3				"0xD25C080E">
	<!ENTITY snaudio4				"0xD25C080F">
	<!ENTITY snaudio5				"0xD25C0810">
	<!ENTITY snaudio6				"0xD25C0811">
	<!ENTITY snaudio7				"0xD25C0812">
	<!ENTITY snaudio8				"0xD25C0813">
	<!ENTITY snaudio9				"0xD25C0814">
	<!ENTITY snaudio10				"0xD25C0815">

]>
<TranscendenceExtension UNID="&unidExtension;" version="0.98d">

<Sound UNID="&snaudio1;"			filename="1.wav"/>

<!--<Sound UNID="&snaudio2;"			filename="2.mp3"/>
<Sound UNID="&snaudio3;"			filename="3.mp3"/>
<Sound UNID="&snaudio4;"			filename="4.mp3"/>
<Sound UNID="&snaudio5;"			filename="5.mp3"/>
<Sound UNID="&snaudio6;"			filename="6.mp3"/>
<Sound UNID="&snaudio7;"			filename="7.mp3"/>
<Sound UNID="&snaudio8;"			filename="8.mp3"/>
<Sound UNID="&snaudio9;"			filename="9.mp3"/>
<Sound UNID="&snaudio10;"			filename="10.mp3"/>-->



	<!-- Neuros Personal Media Player-->

	<ItemType UNID="&itNeurosPMP;"
			name=				"Neuros personal media player"
			level=				"7"
			value=				"1200"
			mass=				"1"
			frequency=			"common"
			numberAppearing=	"1"
			modifiers=			"Consumable; Lux"

			description=		"The Neuros personal media player is a portable device that feeds signals directly into the sensory branches of the brain."
			>

		<Image imageID="&rsItems1;" imageX="288" imageY="0" imageWidth="96" imageHeight="96"/>

	


	<Invoke>
	(sysCreateWeaponFire &virtual1; gSource (objGetPos gSource ) 0 0 Nil)
	
	<!--	(block (randsound) 
			(setq randsound (random 0 9))
			
			(switch
				(eq randsound 0)
					(sysCreateWeaponFire &virtual1; gSource (objGetPos gSource ) 0 0 Nil)
				(eq randsound 1)
					(sysCreateWeaponFire &virtual2; gSource (objGetPos gSource ) 0 0 Nil)
				(eq randsound 2)
					(sysCreateWeaponFire &virtual3; gSource (objGetPos gSource ) 0 0 Nil)
				(eq randsound 3)
					(sysCreateWeaponFire &virtual4; gSource (objGetPos gSource ) 0 0 Nil)
				(eq randsound 4)
					(sysCreateWeaponFire &virtual5; gSource (objGetPos gSource ) 0 0 Nil)
				(eq randsound 5)
					(sysCreateWeaponFire &virtual6; gSource (objGetPos gSource ) 0 0 Nil)
				(eq randsound 6)
					(sysCreateWeaponFire &virtual7; gSource (objGetPos gSource ) 0 0 Nil)
				(eq randsound 7)
					(sysCreateWeaponFire &virtual8; gSource (objGetPos gSource ) 0 0 Nil)
				(eq randsound 8)
					(sysCreateWeaponFire &virtual9; gSource (objGetPos gSource ) 0 0 Nil)
				(eq randsound 9)
					(sysCreateWeaponFire &virtual10; gSource (objGetPos gSource ) 0 0 Nil)
				
			)
		-->
		
	
	
	</Invoke>

</ItemType>

<!-- Virtual audio1 -->

<ItemType UNID="&virtual1;"
		name=				"virtual1"
		virtual=			"true"
		level=				"5"
		>

	<Weapon
			type=				"area"

			damage=				"dark acid:2d8; WMD1"
			fireRate=			"30"
			expansionSpeed=		"1"
			missileSpeed=		"0"
			lifetime=			"1"
			powerUse=			"200"
			>

		<Effect sound="&snaudio1;">
			<Shockwave>
				<Image imageID=				"&rsShockwave1;"
						imageX=				"0" 
						imageY=				"128" 
						imageWidth=			"512" 
						imageHeight=		"64"
						imageFrameCount=	"1"
						imageTicksPerFrame=	"1"/>
			</Shockwave>
		</Effect>

	</Weapon>

</ItemType>

</TranscendenceExtension>
That's a test, with 1 virtual audio item, code already prepared to implement 10 audio files/virtual items

[EDIT]
Tested also the <Fireeffect> tag, not working.

[EDIT2]
Changed the title of the topic, because it was misleading, I don't know how to do it. :oops:
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

I did some testing with sysCreateEffect but, as Betel stated in the other topic, it seems that new effects cannot be created in extension, so I'm stuck again.

In theory:
1.create a new effect with the desidered sound built in.
2.call the effect with syscreateeffect anywere into code.
george moromisato
Developer
Developer
Posts: 2998
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Try this as a workaround:

Code: Select all

<!-- Virtual audio1 -->

<ItemType UNID="&virtual1;"
		name=				"virtual1"
		virtual=			"true"
		level=				"5"
		>

	<Weapon
			type=				"area"

			damage=				"dark acid:2d8; WMD1"
			fireRate=			"30"
			expansionSpeed=		"1"
			missileSpeed=		"0"
			lifetime=			"1"
			powerUse=			"200"



			sound=				"&snaudio1;"


			>

		<Effect>
			<Shockwave>
				<Image imageID=				"&rsShockwave1;"
						imageX=				"0" 
						imageY=				"128" 
						imageWidth=			"512" 
						imageHeight=		"64"
						imageFrameCount=	"1"
						imageTicksPerFrame=	"1"/>
			</Shockwave>
		</Effect>

	</Weapon>

</ItemType>

</TranscendenceExtension>
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

tested: unfortunately doesn't work either.
thanks George for your help
george moromisato
Developer
Developer
Posts: 2998
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Try this. This seemed to work better.

In (sysCreateWeaponFire...) I added True at the end to get the missile to explode right away (that triggers the HitEffect). And I added a HitEffect with sound.

Unfortunately, I don't think this will work with .mp3 file--I think it only works with .wav file.

I'll add a feature to allow you to play .mp3 files.

Code: Select all

<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE TranscendenceExtension 
   [ 
   <!ENTITY unidExtension            "0xD25C0801"> 
    
   <!ENTITY itNeurosPMP            "0x00004161"> 
       
   <!ENTITY virtual1            "0xD25C0802"> 
   <!ENTITY virtual2            "0xD25C0803"> 
   <!ENTITY virtual3            "0xD25C0804"> 
   <!ENTITY virtual4            "0xD25C0805"> 
   <!ENTITY virtual5            "0xD25C0806"> 
   <!ENTITY virtual6            "0xD25C0807"> 
   <!ENTITY virtual7            "0xD25C0808"> 
   <!ENTITY virtual8            "0xD25C0809"> 
   <!ENTITY virtual9            "0xD25C080A"> 
   <!ENTITY virtual10            "0xD25C080B"> 
    
   <!ENTITY snaudio1            "0xD25C080C"> 
   <!ENTITY snaudio2            "0xD25C080D"> 
   <!ENTITY snaudio3            "0xD25C080E"> 
   <!ENTITY snaudio4            "0xD25C080F"> 
   <!ENTITY snaudio5            "0xD25C0810"> 
   <!ENTITY snaudio6            "0xD25C0811"> 
   <!ENTITY snaudio7            "0xD25C0812"> 
   <!ENTITY snaudio8            "0xD25C0813"> 
   <!ENTITY snaudio9            "0xD25C0814"> 
   <!ENTITY snaudio10            "0xD25C0815"> 

]> 

<TranscendenceExtension UNID="&unidExtension;" version="0.98d"> 

<!--<Sound UNID="&snaudio2;"         filename="2.mp3"/> 
<Sound UNID="&snaudio3;"         filename="3.mp3"/> 
<Sound UNID="&snaudio4;"         filename="4.mp3"/> 
<Sound UNID="&snaudio5;"         filename="5.mp3"/> 
<Sound UNID="&snaudio6;"         filename="6.mp3"/> 
<Sound UNID="&snaudio7;"         filename="7.mp3"/> 
<Sound UNID="&snaudio8;"         filename="8.mp3"/> 
<Sound UNID="&snaudio9;"         filename="9.mp3"/> 
<Sound UNID="&snaudio10;"         filename="10.mp3"/>--> 



   <!-- Neuros Personal Media Player--> 

   <ItemType UNID="&itNeurosPMP;" 
         name=            "Neuros personal media player" 
         level=            "7" 
         value=            "1200" 
         mass=            "1" 
         frequency=         "common" 
         numberAppearing=   "1" 
         modifiers=         "Consumable; Lux" 

         description=      "The Neuros personal media player is a portable device that feeds signals directly into the sensory branches of the brain." 
         > 

      <Image imageID="&rsItems1;" imageX="288" imageY="0" imageWidth="96" imageHeight="96"/> 

    


   <Invoke> 
   (sysCreateWeaponFire &virtual1; gSource (objGetPos gSource ) 0 0 Nil True) 
    
   <!--   (block (randsound) 
         (setq randsound (random 0 9)) 
          
         (switch 
            (eq randsound 0) 
               (sysCreateWeaponFire &virtual1; gSource (objGetPos gSource ) 0 0 Nil) 
            (eq randsound 1) 
               (sysCreateWeaponFire &virtual2; gSource (objGetPos gSource ) 0 0 Nil) 
            (eq randsound 2) 
               (sysCreateWeaponFire &virtual3; gSource (objGetPos gSource ) 0 0 Nil) 
            (eq randsound 3) 
               (sysCreateWeaponFire &virtual4; gSource (objGetPos gSource ) 0 0 Nil) 
            (eq randsound 4) 
               (sysCreateWeaponFire &virtual5; gSource (objGetPos gSource ) 0 0 Nil) 
            (eq randsound 5) 
               (sysCreateWeaponFire &virtual6; gSource (objGetPos gSource ) 0 0 Nil) 
            (eq randsound 6) 
               (sysCreateWeaponFire &virtual7; gSource (objGetPos gSource ) 0 0 Nil) 
            (eq randsound 7) 
               (sysCreateWeaponFire &virtual8; gSource (objGetPos gSource ) 0 0 Nil) 
            (eq randsound 8) 
               (sysCreateWeaponFire &virtual9; gSource (objGetPos gSource ) 0 0 Nil) 
            (eq randsound 9) 
               (sysCreateWeaponFire &virtual10; gSource (objGetPos gSource ) 0 0 Nil) 
             
         ) 
      --> 
       
    
    
   </Invoke> 

</ItemType> 

<!-- Virtual audio1 --> 

<ItemType UNID="&virtual1;" 
      name=            "virtual1" 
      virtual=         "true" 
      level=            "5" 
      > 

	<Weapon
			type=				"missile"
			damage=				"kinetic:0"
			>

		<Fragment
				count=			"1"
				type=			"radius"
				damage=			"kinetic:0"
				>
		</Fragment>

		<HitEffect
				sound="&snArmorHit1;"
				>
			<Image imageID="&rsExplosion2AG128;"
					imageX="0"
					imageY="0"
					imageWidth="0"
					imageHeight="0"/>
		</HitEffect>
		
	</Weapon>

</ItemType> 

</TranscendenceExtension>
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

i replaced the image with

Code: Select all

  <HitEffect
            sound="&snArmorHit1;"
            >
         
		<Image imageID="&rsMediumExplosions;" 
				imageX="0" 
				imageY="0" 
				imageWidth="64" 
				imageHeight="64"
				imageFrameCount="16"
				imageTicksPerFrame="2"/>
	
      </HitEffect>
crashed the game (going to recheck however, maybe it's my fault)

cough cough....rsExplosion2AG128 is a new image in 0.99 ? :shock: :shock:
george moromisato
Posted: Sat Jan 26, 2008 5:40 pm

I'll add a feature to allow you to play .mp3 files.
Cool! :D :D
george moromisato
Developer
Developer
Posts: 2998
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Oops, my fault. I tested in a newer (unreleased) version...

I think the crash problem is because the fragment has no effect. [In the new build I check for that...]

Add an effect inside the <Fragment> element:

Code: Select all

<Effect>
   <Image imageID="&rsMediumExplosions;"
      imageX="0"
      imageY="0"
      imageWidth="0"
      imageHeight="0"
      />
</Effect>
Let me know if that works or not...

[p.s.: I think it is OK that use imageWidth="0" to essentially set an empty image.]
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

awesome! it works ! It's possible to call .wav sounds in code. :)

Thanks George ! :)
Bobby
Militia Captain
Militia Captain
Posts: 675
Joined: Wed Jul 25, 2007 7:39 pm

so it works now!
all that's needed is a good source of .wav music.

EDIT: the sort criteria feature allows sorting by length. one is > 9 minuts.
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

exactly was i was looking for ! thanks bobby :D
User avatar
Charon Mass of Goo
Militia Lieutenant
Militia Lieutenant
Posts: 245
Joined: Wed Jan 02, 2008 12:26 am
Location: Creating Inappropriate "Signature Dialouge" since yestermorrow!
Contact:

Bobby wrote:so it works now!
all that's needed is a good source of .wav music.

EDIT: the sort criteria feature allows sorting by length. one is > 9 minuts.
Hmmm haven't been around for a few days, I haven't.

You can also try Here, thats where I get tons of awesome music. It's also where I got my substitution for my Transcendencemarch file :D[/url]
Charon Fizz-Soda! It's Red! It tastes like Awesomness! AND PIRATES MADE IT! Better than Eridani Mineral Water too!
Image
Post Reply