Page 1 of 1

Importing my own comments

Posted: Mon Jan 01, 2007 9:53 pm
by stage7
Hi,

I am planning to add new comments to the game, but not the chants, whistles and all that stuff, but making the game saying the scorer's name when he makes a goal, for instance.

The idea I have is recording several files named, for example, "GOAL_RONALDINHO.ogg", "GOAL_NEDVED.ogg" or "GOAL_SHEARER.ogg", and via modifying the code, make them sound when they score. The problem is that I'm still a total newbie with BlitzBasic and I don't know how to make it properly. As far as I've seen I could modify some arrays through the code, but it seems tricky. I have been checking if I could modify this starting from line ~1985 at match.bmx:

Code: Select all

			If ( ball.poss_last * team_side = side )
 PlaySound(comm_goal[Rand(0,comm_goal.length-1)], chn_comm)
			Else
				PlaySound(comm_owngoal[Rand(0,comm_owngoal.length-1)], chn_comm)
			EndIf
but it seems that the PlaySound funcion uses arrays and channels (I have to allocate a channel to play sound). I'd like to know if there is a way to make this with a format like

Code: Select all

//Pseudocode follows
Play (dir, "GOAL_" + scorer + ".ogg", False)
without allocating channels, or the way to properly allocate channels and make it work.

I hope you get the idea, my explanation may look weird :oops: I'm planning nice things if I manage to complete this challenge!

Thank you very much in advance for any help given.

Re: Importing my own comments

Posted: Tue Jan 02, 2007 11:32 pm
by Massimo32
stage7 wrote:Hi,

I am planning to add new comments to the game, but not the chants, whistles and all that stuff, but making the game saying the scorer's name when he makes a goal, for instance.

The idea I have is recording several files named, for example, "GOAL_RONALDINHO.ogg", "GOAL_NEDVED.ogg" or "GOAL_SHEARER.ogg", and via modifying the code, make them sound when they score. The problem is that I'm still a total newbie with BlitzBasic and I don't know how to make it properly. As far as I've seen I could modify some arrays through the code, but it seems tricky.

...
It's quite a challenging task, you need:
1) to download the sounds for each 'special' player before each match
2) decide how to identify the player (name, surname, number..?)
3) associate the sound wiht the player and modify the If test

You don't need a new channel, you can use chn_comm, which is already allocated.

Posted: Wed Jan 03, 2007 8:53 pm
by stage7
I somehow made it just for testing purposes. I created some test comments named GOAL_KUBO.ogg, GOAL_YAMASE.ogg, GOAL_OKU.ogg, GOAL_UENO.ogg and GOAL_KAWAI.ogg so when any of these players score, the sound is played. The comment is loaded in realtime, i.e., not like 101-106.ogg, when a player scores, and then the game follows.

This is first step and only works for players who have an associated file to them, and only if it is named after their surname, this means, players who have no associated surname won't play a sound at all with my current code and the game will freeze, as it happens now with players which have no sound.

My idea, which I hope to have ready soon, would be:

Code: Select all

//Pseudocode follows

if (fopen("GOAL_" + player.surname + ".ogg")==false AND fopen("GOAL_" + player.name + ".ogg")==false)
	PlaySound(generic_random_goal_sound, False) // if no sound associated to scorer, play 10x.ogg where x=1 to 6
else if (fopen("GOAL_" + player.surname + ".ogg")==true)
	PlaySound("GOAL_" + player.surname + ".ogg", False) // if a sound with the surname of the scorer exists, play it
	else PlaySound("GOAL_" + player.name + ".ogg", False) // if the player has no surname, try with its name
end if
This is not the only way to do it, of course. I have taken notes on how the player data type works in Yoda and I think I will be able to do it. I will try to post some video clips and the code soon :D

Greetings.

UPDATE: I've upgraded my own code so the program checks if a surname for a scorer exists (if so, play it), if not, search for the name (and play), and if not, play a generic goal sound. I'll show the improvements ASAP.

Posted: Sat Jan 06, 2007 5:11 am
by stage7
I've been completely unable to record video+audio to prove I did it, but at least I have uploaded the code so you can check by yourselves.

http://www.sendspace.com/file/ep56lx

This includes:
- YS 0.73 modified source that allows comments the way I explained above.
- Some comments to try it. Play with or againts Yokohama F. Marinos and let any of the players who have a sound score. Put them in /sfx/commentary/.
- A pair of "welcome to this match" sounds just for test. There must be two of them for the game to work, named "welcome#.ogg" (# = 1 or 2) and placed inside /sfx/commentary/.
- Modified main menu structure. Well, it's the layout I use because I find it easier to navigate...
- Working main.debug.exe for instant action.

I think everything's OK. Please give some feedback if you liked it or hated it :D (but don't tell the goal sounds are horrble - I already know that ;))