Question about movable sound channels

BlitzMax Forums/BlitzMax Programming/Question about movable sound channels

Takis76(Posted 2015) [#1]
Hello my friends,

I have one new strange issue with sound channels.

I use the nice Channel Pool library and is working perfectly. I have one new question about sounds.

I have one movable fireball which does a fire whoosh when it travels.
And I have a fireball launcher which fires the fireball.

The fireball launcher is a projectile trap.
The code below works perfectly.

When the Fireball launcher fires one fireball you hear the shooting sound and
when players are near and far , they hear the shooting sound panned and louder or quieter.

The code example for the Projectile Trap (Fireball launcher) which plays only the shooting sound and works correct.

The type of the Projectile Trap.

Type My_Projectile_Trap

	Field X:Byte 'position X on the map
	Field Y:Byte 'position Y on the map

	Field Direction:Byte 'Direction of the projectile trap
	Field Firing_Spell_number:Byte '1= Fireball 2=Magic Missile 3=Electric bolt 4=blob
	Field Shoot:Byte 'Shoots the spell
	
	'Field Spell_list:TList = CreateList() 'How many spells fired
	
	Field Spell_Damage_Dice:String '"1d4" hit dice of the spell
	
	
	Field Graphic:String '"01" = graphic1 "02" = graphic2
	Field State:Byte 'Activated Deactivated
	
	
	Field Distance_x:Int 'Distance X from Player
	Field Distance_y:Int 'Distance Y from Player
	Field Sound_Distance:Int
	Field Sound_Direction:Int 'Direction from Player
	
	Field Sound_Pan:Float
	Field Sound_Volume:Float

	Field Shoot_Time_Delay:Int 'Delay before shoot some spell
	Field Shoot_Deadline_time:Int
		
	'This initialize the spell speed for the spell
	Field Spell_Speed_Time_Delay:Int 'Delay for spell Speed
	Field Spell_Speed_Deadline_time:Int

End Type
Global Projectile_Trap:My_Projectile_Trap[max_levels + 1, Max_Projectile_Traps + 1]
For LVL = 1 To Max_Levels
	For All_Projectile_Traps = 0 To Max_Projectile_Traps
		Projectile_Trap[LVL, All_Projectile_Traps] = New My_Projectile_Trap
	Next
Next


The sound code of the Projectile trap according to the distance of the player.
Works well.

	For All_Levels = 1 To Max_Levels
		
		For All_Projectile_Traps = 1 To Max_Projectile_Traps

				If Projectile_Trap[All_Levels, All_Projectile_Traps].x <= 0 Or Projectile_Trap[All_Levels, All_Projectile_Traps].y <= 0 Then Continue
			
				Projectile_Trap[all_levels, All_Projectile_Traps].Distance_x = Projectile_Trap[all_levels, All_Projectile_Traps].x - Party.x
				Projectile_Trap[all_levels, All_Projectile_Traps].Distance_y = Projectile_Trap[all_levels, All_Projectile_Traps].y - Party.y
				Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Distance = Sqr((Projectile_Trap[all_levels, All_Projectile_Traps].Distance_x * Projectile_Trap[all_levels, All_Projectile_Traps].Distance_x) + (Projectile_Trap[all_levels, All_Projectile_Traps].Distance_y * Projectile_Trap[all_levels, All_Projectile_Traps].Distance_y))
				Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction = ATan2(Projectile_Trap[all_levels, All_Projectile_Traps].y - Party.y, Projectile_Trap[all_levels, All_Projectile_Traps].x - Party.x)
			
				'3D Sound effects
				'Distance sound
				If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Distance = 0 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].X + "," + Projectile_Trap[all_levels, All_Projectile_Traps].Y + "]").SetVolume(1 * Background_Transfering_Sound_Volume)
				If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Distance = 1 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].X + "," + Projectile_Trap[all_levels, All_Projectile_Traps].Y + "]").SetVolume(1 * Background_Transfering_Sound_Volume)
				If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Distance = 2 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].X + "," + Projectile_Trap[all_levels, All_Projectile_Traps].Y + "]").SetVolume(0.35 * Background_Transfering_Sound_Volume)
				If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Distance = 3 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].X + "," + Projectile_Trap[all_levels, All_Projectile_Traps].Y + "]").SetVolume(0.10 * Background_Transfering_Sound_Volume)
				If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Distance = 4 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].X + "," + Projectile_Trap[all_levels, All_Projectile_Traps].Y + "]").SetVolume(0.03 * Background_Transfering_Sound_Volume)
				If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Distance > 4 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].x + "," + Projectile_Trap[all_levels, All_Projectile_Traps].y + "]").SetVolume(0)

				'NORTH
				If Party.Direction = 1 Then
					'The projectile trap is FRONT CENTER
					If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction = -90 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].x + "," + Projectile_Trap[all_levels, All_Projectile_Traps].y + "]").SetPan(0)
					'The projectile trap is FRONT LEFT
					If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction >= - 165 And Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction <= - 135 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].x + "," + Projectile_Trap[all_levels, All_Projectile_Traps].y + "]").SetPan(-1)
					'The projectile trap is FRONT RIGHT
					If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction >= - 45 And Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction <= - 14 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].x + "," + Projectile_Trap[all_levels, All_Projectile_Traps].y + "]").SetPan(1)

					'The projectile trap is BACK CENTER
					If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction = 90 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].x + "," + Projectile_Trap[all_levels, All_Projectile_Traps].y + "]").SetPan(0)
					'The projectile trap is BACK LEFT
					If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction >= 135 And Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction <= 165 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].x + "," + Projectile_Trap[all_levels, All_Projectile_Traps].y + "]").SetPan(-1)
					'The projectile trap is BACK RIGHT
					If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction >= 14 And Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction <= 45 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].x + "," + Projectile_Trap[all_levels, All_Projectile_Traps].y + "]").SetPan(1)
				End If
				'SOUTH
				If Party.Direction = 2 Then
					'The projectile trap is FRONT CENTER
					If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction = 90 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].x + "," + Projectile_Trap[all_levels, All_Projectile_Traps].y + "]").SetPan(0)
					'The projectile trap is FRONT LEFT
					If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction >= 14 And Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction <= 45 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].x + "," + Projectile_Trap[all_levels, All_Projectile_Traps].y + "]").SetPan(-1)
					'The projectile trap is FRONT RIGHT
					If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction >= 135 And Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction <= 165 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].x + "," + Projectile_Trap[all_levels, All_Projectile_Traps].y + "]").SetPan(1)

					'The projectile trap is BACK CENTER
					If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction = -90 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].x + "," + Projectile_Trap[all_levels, All_Projectile_Traps].y + "]").SetPan(0)
					'The projectile trap is BACK LEFT
					If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction >= - 45 And Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction <= - 14 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].x + "," + Projectile_Trap[all_levels, All_Projectile_Traps].y + "]").SetPan(-1)
					'The projectile trap is BACK RIGHT
					If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction >= - 165 And Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction <= - 135 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].x + "," + Projectile_Trap[all_levels, All_Projectile_Traps].y + "]").SetPan(1)
				End If
				'WEST
				If Party.Direction = 3 Then
					'The projectile trap is FRONT CENTER
					If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction = 180 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].x + "," + Projectile_Trap[all_levels, All_Projectile_Traps].y + "]").SetPan(0)
					'The projectile trap is FRONT LEFT
					If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction >= 104 And Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction <= 135 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].x + "," + Projectile_Trap[all_levels, All_Projectile_Traps].y + "]").SetPan(-1)
					'The projectile trap is FRONT RIGHT
					If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction >= - 135 And Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction <= - 104 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].x + "," + Projectile_Trap[all_levels, All_Projectile_Traps].y + "]").SetPan(1)

					'The projectile trap is BACK CENTER
					If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction = 0 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].x + "," + Projectile_Trap[all_levels, All_Projectile_Traps].y + "]").SetPan(0)
					'The projectile trap is BACK LEFT
					If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction >= 45 And Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction <= 75 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].x + "," + Projectile_Trap[all_levels, All_Projectile_Traps].y + "]").SetPan(-1)
					'The projectile trap is BACK RIGHT
					If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction >= - 75 And Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction <= - 45 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].x + "," + Projectile_Trap[all_levels, All_Projectile_Traps].y + "]").SetPan(1)
				End If
				'EAST
				If Party.Direction = 4 Then
					'The projectile trap is FRONT CENTER
					If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction = 0 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].x + "," + Projectile_Trap[all_levels, All_Projectile_Traps].y + "]").SetPan(0)
					'The projectile trap is FRONT LEFT
					If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction >= - 75 And Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction <= - 45 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].x + "," + Projectile_Trap[all_levels, All_Projectile_Traps].y + "]").SetPan(-1)
					'The projectile trap is FRONT RIGHT
					If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction >= 45 And Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction <= 75 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].x + "," + Projectile_Trap[all_levels, All_Projectile_Traps].y + "]").SetPan(1)

					'The projectile trap is BACK CENTER
					If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction = 180 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].x + "," + Projectile_Trap[all_levels, All_Projectile_Traps].y + "]").SetPan(0)
					'The projectile trap is BACK LEFT
					If Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction >= - 135 And Projectile_Trap[all_levels, All_Projectile_Traps].Sound_Direction <= - 104 Then GetPooledChannel("projectile_trap[" + all_levels + "," + Projectile_Trap[all_levels, All_Projectile_Traps].x + "," + Projectile_Trap[all_levels, All_Projectile_Traps].y + "]").SetPan(-1)
					'The projectile trap is BACK RIGHT
					If Projectile_Trap[All_Levels, All_Projectile_Traps].Sound_Direction >= 104 And Projectile_Trap[All_Levels, All_Projectile_Traps].Sound_Direction <= 135 Then GetPooledChannel("projectile_trap[" + All_Levels + "," + Projectile_Trap[All_Levels, All_Projectile_Traps].x + "," + Projectile_Trap[All_Levels, All_Projectile_Traps].y + "]").SetPan(1)
				End If

		Next
	Next



Everything above works perfectly because the projectile trap is a static object in space and when the players move near and far you hear the surround sound

Now a new issue generates.

When this launches launch one fireball and the fireball will start to move in the level. (The fireballs moves only in one direction. For example if the launcher faces to the North , the fireball will travel to opposite direction SOUTH)

I have one new type which stores the data of the movable object the fireball.

The code of the fireball type:

Type My_Fired_spells

	Field Level:Byte
	Field X:Byte
	Field Y:Byte
	Field Direction:Byte

	Field Spell_Frame:Byte 'Animation of the spell
	Field Spell_Explode_Frame:Byte 'Animation of the spell explosion

	Field Position_On_Square:Byte 'The position in the square when it travels
	
	Field Spell_number:Int 'Spell number 1=Fireball
	Field Damage_Dice:String '1d4 - 1d6 - 1d8 - 1d10 - 1d12 - 1d20 - 2d12 - 3d8 - 3d10 - 3d12 - 2d20
	
	Field Distance_x:Int 'Distance X from Player
	Field Distance_y:Int 'Distance Y from Player
	Field Sound_Distance:Int
	Field Sound_Direction:Int 'Direction from Player
	
	Field Sound_Pan:Float
	Field Sound_Volume:Float
	
	Field Spell_Frame_Time_Delay:Int
	Field Spell_Frame_Deadline_time:Int

	'Receives the spell speed from mother generator projectile trap
	Field Spell_Speed_Time_Delay:Int
	Field Spell_Speed_Deadline_time:Int
		
	Field Explodes:Byte 'Indicates if the spell collided with something and it will be exploded
	
	Field Launched:Byte
	
EndType
Global Fired_spells:My_Fired_spells = New My_Fired_spells



The fireball generated in front the the Fireball Launcher (The projectile Trap)
There is one list with name Fired_Spell_List:TList

And I add one fireball object to this list. Before I add the object I prepares the variables of the type "Fired_spells"

			'If the Projectile trap will shoot a spell
			If Projectile_Trap[All_Levels, All_Projectile_Traps].Shoot = 1 Then

				'If the Projectile trap faces to the NORTH
				If Projectile_Trap[All_Levels, All_Projectile_Traps].Direction = 1 Then
					Fired_spells = New My_Fired_spells
					Fired_spells.Level = Party.Level

					'Fires spells to the SOUTH (Opposite)
					Fired_spells.Direction = 2
					'Fires the spell number 1 Fireball
					Fired_spells.Spell_number = 1
					'The spell receives the damage dice value from its mother generator the projectile trap
					Fired_spells.Damage_Dice = Projectile_Trap[All_Levels, All_Projectile_Traps].Spell_Damage_Dice
					'The spell receives the speed value from its mother generator the projectile trap
					Fired_spells.Spell_Speed_Time_Delay = Projectile_Trap[All_Levels, All_Projectile_Traps].Spell_Speed_Time_Delay
					'The X Position of the Spell is the same as the projectile trap
					Fired_spells.X = Projectile_Trap[All_Levels, All_Projectile_Traps].X
					'The Y Position of the Spell is in front of the projectile trap at spell position in square 1
					Fired_spells.Y = Projectile_Trap[All_Levels, All_Projectile_Traps].Y + 1
					'spell position in square 1
					Fired_spells.Position_On_Square = 0
					'Adds the spell in the list
					'The spell is a separated entity
					''PlaySound(Projectile_Fireball_Whoosh, GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.X + "," + Fired_spells.Y + "]"))
					
					PlaySound(Projectile_Fireball_Shoot, GetPooledChannel("projectile_trap[" + Party.Level + "," + Projectile_Trap[Party.Level, All_Projectile_Traps].X + "," + Projectile_Trap[Party.Level, All_Projectile_Traps].Y + "]"))
					ListAddLast(Fired_Spell_List, Fired_spells)
					'The projectile trap doesn't shoots anymore
					Projectile_Trap[All_Levels, All_Projectile_Traps].Shoot = 0
					
				End If
				'=================================================================================================

			EndIf			



The code above creates one fireball from "Fired_spells" type and add it to the "Fired_Spell_List" list.

I use the code bellow to do the 3D surround effect as usually to with Channel Pool with the same way.

A similar code like the Projectile Traps above.

						'Fast routines sounds
						Fired_spells.Distance_x = Fired_spells.x - Party.x
						Fired_spells.Distance_y = Fired_spells.y - Party.y
						Fired_spells.Sound_Distance = Sqr((Fired_spells.Distance_x * Fired_spells.Distance_x) + (Fired_spells.Distance_y * Fired_spells.Distance_y))
						Fired_spells.Sound_Direction = ATan2(Fired_spells.y - Party.y, Fired_spells.x - Party.x)
				
						'3D Sound effects
						'Distance sound
						If Fired_spells.Sound_Distance = 0 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.X + "," + Fired_spells.Y + "]").SetVolume(1 * Background_Transfering_Sound_Volume)
						If Fired_spells.Sound_Distance = 1 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.X + "," + Fired_spells.Y + "]").SetVolume(0.7 * Background_Transfering_Sound_Volume)
						If Fired_spells.Sound_Distance = 2 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.X + "," + Fired_spells.Y + "]").SetVolume(0.35 * Background_Transfering_Sound_Volume)
						If Fired_spells.Sound_Distance = 3 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.X + "," + Fired_spells.Y + "]").SetVolume(0.10 * Background_Transfering_Sound_Volume)
						If Fired_spells.Sound_Distance = 4 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.X + "," + Fired_spells.Y + "]").SetVolume(0.03 * Background_Transfering_Sound_Volume)
						If Fired_spells.Sound_Distance > 4 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.x + "," + Fired_spells.y + "]").SetVolume(0)


				'NORTH
				If Party.Direction = 1 Then
					'The projectile spell is FRONT CENTER
					If Fired_spells.Sound_Direction = -90 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.x + "," + Fired_spells.y + "]").SetPan(0)
					'The projectile spell is FRONT LEFT
					If Fired_spells.Sound_Direction >= - 165 And Fired_spells.Sound_Direction <= - 135 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.x + "," + Fired_spells.y + "]").SetPan(-1)
					'The projectile spell is FRONT RIGHT
					If Fired_spells.Sound_Direction >= - 45 And Fired_spells.Sound_Direction <= - 14 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.x + "," + Fired_spells.y + "]").SetPan(1)

					'The projectile spell is BACK CENTER
					If Fired_spells.Sound_Direction = 90 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.x + "," + Fired_spells.y + "]").SetPan(0)
					'The projectile spell is BACK LEFT
					If Fired_spells.Sound_Direction >= 135 And Fired_spells.Sound_Direction <= 165 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.x + "," + Fired_spells.y + "]").SetPan(-1)
					'The projectile spell is BACK RIGHT
					If Fired_spells.Sound_Direction >= 14 And Fired_spells.Sound_Direction <= 45 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.x + "," + Fired_spells.y + "]").SetPan(1)
				End If
				'SOUTH
				If Party.Direction = 2 Then
					'The projectile spell is FRONT CENTER
					If Fired_spells.Sound_Direction = 90 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.x + "," + Fired_spells.y + "]").SetPan(0)
					'The projectile spell is FRONT LEFT
					If Fired_spells.Sound_Direction >= 14 And Fired_spells.Sound_Direction <= 45 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.x + "," + Fired_spells.y + "]").SetPan(-1)
					'The projectile spell is FRONT RIGHT
					If Fired_spells.Sound_Direction >= 135 And Fired_spells.Sound_Direction <= 165 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.x + "," + Fired_spells.y + "]").SetPan(1)

					'The projectile spell is BACK CENTER
					If Fired_spells.Sound_Direction = -90 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.x + "," + Fired_spells.y + "]").SetPan(0)
					'The projectile spell is BACK LEFT
					If Fired_spells.Sound_Direction >= - 45 And Fired_spells.Sound_Direction <= - 14 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.x + "," + Fired_spells.y + "]").SetPan(-1)
					'The projectile spell is BACK RIGHT
					If Fired_spells.Sound_Direction >= - 165 And Fired_spells.Sound_Direction <= - 135 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.x + "," + Fired_spells.y + "]").SetPan(1)
				End If
				'WEST
				If Party.Direction = 3 Then
					'The projectile spell is FRONT CENTER
					If Fired_spells.Sound_Direction = 180 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.x + "," + Fired_spells.y + "]").SetPan(0)
					'The projectile spell is FRONT LEFT
					If Fired_spells.Sound_Direction >= 104 And Fired_spells.Sound_Direction <= 135 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.x + "," + Fired_spells.y + "]").SetPan(-1)
					'The projectile spell is FRONT RIGHT
					If Fired_spells.Sound_Direction >= - 135 And Fired_spells.Sound_Direction <= - 104 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.x + "," + Fired_spells.y + "]").SetPan(1)

					'The projectile spell is BACK CENTER
					If Fired_spells.Sound_Direction = 0 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.x + "," + Fired_spells.y + "]").SetPan(0)
					'The projectile spell is BACK LEFT
					If Fired_spells.Sound_Direction >= 45 And Fired_spells.Sound_Direction <= 75 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.x + "," + Fired_spells.y + "]").SetPan(-1)
					'The projectile spell is BACK RIGHT
					If Fired_spells.Sound_Direction >= - 75 And Fired_spells.Sound_Direction <= - 45 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.x + "," + Fired_spells.y + "]").SetPan(1)
				End If
				'EAST
				If Party.Direction = 4 Then
					'The projectile spell is FRONT CENTER
					If Fired_spells.Sound_Direction = 0 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.x + "," + Fired_spells.y + "]").SetPan(0)
					'The projectile spell is FRONT LEFT
					If Fired_spells.Sound_Direction >= - 75 And Fired_spells.Sound_Direction <= - 45 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.x + "," + Fired_spells.y + "]").SetPan(-1)
					'The projectile spell is FRONT RIGHT
					If Fired_spells.Sound_Direction >= 45 And Fired_spells.Sound_Direction <= 75 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.x + "," + Fired_spells.y + "]").SetPan(1)

					'The projectile spell is BACK CENTER
					If Fired_spells.Sound_Direction = 180 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.x + "," + Fired_spells.y + "]").SetPan(0)
					'The projectile spell is BACK LEFT
					If Fired_spells.Sound_Direction >= - 135 And Fired_spells.Sound_Direction <= - 104 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.x + "," + Fired_spells.y + "]").SetPan(-1)
					'The projectile spell is BACK RIGHT
					If Fired_spells.Sound_Direction >= 104 And Fired_spells.Sound_Direction <= 135 Then GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.x + "," + Fired_spells.y + "]").SetPan(1)
				End If




The above code , should work but it doesn't because the channels above are static channels and the fireball is moving and when the Fired_spells.x variable and Fired_spells.y changes , means the channel changes too , so I loose the channel and the
surround sounds doesn't work you cant hear the fireball near and far or louder or quieter or left speaker and right speaker because the variables of Fired_spells.x and Fired_spells.y are the channel name not the coordinates of fireball.

GetPooledChannel("projectile_fireball[" + Fired_spells.Level + "," + Fired_spells.x + "," + Fired_spells.y + "]").SetPan(1)


In fact I cant move the channel I try to describe the problem. This channel code work for static object only in relation of the distance , because the channels are static. Who is this similar effect can be implemented with animated channels or animated object.
You understand what I try to explain.

:) Thank you...


Takis76(Posted 2015) [#2]
I think I made it.
I added a serial number to each fireball spell and I use the channel with fireball serial number instead of position x and y. The serial number is static for each fireball , but the x , y positions change. So now you can hear the sound of each fireball louder or quieter if you are near or far. It needs little correction when I am adding second fireball the sound changes to the second fireball.


I am almost near to correct it.


Takis76(Posted 2015) [#3]
Is it possible to take the index number of the object in the list?
For example if the list have 5 fireballs , how do I select some object with index.
I would like to find this list index and store is as a serial number of the fireball.

Every time I am creating a new fireball , each fireball have one serial number. This
serial number is the channel number too.

If I have 5 fireballs each fireball have its unique number.
Fireball SN: 01
Fireball SN: 02
Fireball SN: 03
Fireball SN: 04
Fireball SN: 05

When some of these fireballs collide with something wall or player or any object is destroyed.
If we assume there are 5 fireballs in queue and the last fireball will be destroyed , the rest 4 continue to move. But if I will create new one , it takes the same serial number of the last destroyed fireball.
For example if the fireball 05 will be destroyed , the fireball 05 will be generated again. With this queue.

Fireball SN: 05
Fireball SN: 01
Fireball SN: 02
Fireball SN: 03
Fireball SN: 04

How is it possible when there are live fireball the next fireball not take the serial number of the last destroyed but continue to increase the serial number.
For example number 06. Only when all fireballs will be destroyed the serial number counter will start from the beginning.

I try to do this , because the destroyed fireballs are stopped channels and if I will create the same serial number of a previous fireball , the previous fireball sound channel was stopped and the new one will not have sound. If the new one have new number then it will have sound. Only when all fireballs will be destroyed all serial number counter start from beginning and the new sound channels start again.


UPDATE:
OK Guys I made it , I just added one global fireball counter and I increase it , so always when there are fireballs the channel is unique for each fireball and only when all fireballs are destroyed I reset the counter , so the problem solved.
Everything work perfect :)