Register    Login    Forum    FAQ    PinSimDB.org

Board index » Resources » Tutorials, how-to's, bug report and docs




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Creating a Sound Level Control Panel in the Script
 Post Posted: Fri Feb 16, 2018 1:13 pm 
Offline

Joined: Thu Aug 16, 2012 11:12 pm
Posts: 1685
Location: Arkansas, USA
This tutorial provides a method for creating what I call a Sound Level Control Panel. Although it is time consuming, this is the way to create the best sound mix for your table and it provides a way for the end user to make changes to the sound mix easily. Those of you that have formed a team could let a novice member create this because I think the instructions are specific enough. I have written the directions so anyone can do it. This would be a good first project for a novice that wants to get familiar with scripting.

I have used this method on three tables. The first was "Creature from the Black Lagoon". The second was "Masters of the Universe" and the third one was "Dragon's Keep". I have tried variations of the same process and found this method works the best.

If you are building a table from scratch, never add sounds to the objects on the table. Always add sounds to the script. When you click on an object on the table, there is often a section named "Sound Effects" at the bottom of the right pane. It might be slightly easier to add a sound there but the only way that the sound level can be adjusted is to edit the sound file. It is not desirable to change the volume this way because it can degrade the quality of the sound, especially if you clip the sound. It is best to adjust the sound level in the script without having to edit the sound file.

When building a table, you should be aware that the end user has the ability to make changes to Music volume and Sound volume separately by FP's controls. You should make an effort to add background music to the Music Manager and other sounds to the Sound Manager. However, there are a few differences in the way a sound and music is played back. Items in the Sound Manager are basically just played back without any controls other than the volume. Items in the Music Manager have more options like start delays, repeats and you can fade music in and out. So you may want to add something to the Music Manager that may not be considered music in order to take advantage of these options. However, you should try to keep music and other sounds separate so that that FP's volume controls work correctly.

You should note that there is no way to automatically delete unused sounds. Textures and models have a way to automatically delete unused items, but not sounds. Textures and models are not loaded into memory unless they are used. Unfortunately, this is not the case with audio. All sounds that have been added to the table are loaded into memory whether they are used or not. Having all the sounds in the script makes it easier to manually check if a sound is used. You can just search the script for the name of the sound. When sounds are added to table objects, you can only look at each table object to determine if a sound is used. You should delete all unused sounds to prevent loading unnecesary items into the memory which can slow the loading of the table.

I have found that it is best to use four basic categories of sounds:

1. Background Music – Most tables have music when you play the game. These are usually (but not always) added to the music manager.
2. Game Sound – These are the sounds of the pinball machine itself, like the sounds of flippers, slingshots, bumpers, diverters etc. The sounds of sounds of flippers and slingshots tend to be louder than other sounds. I sometimes split this category apart in to two categories of loud and soft sounds.
3. Sound Effects – These are sounds that are usually unique to the table like explosions, swords clanging, animals growling, lasers firing etc. Sometimes sound effects are used in place of or in combination with game sounds. When categorizing a sound, it can be a little bit difficult to differentiate game sounds and sound effects. If it sounds like a standard sound that any real world pinball table might make, I call it a game sound.
4. Voices – The sounds of a table often include recordings of human voices. It is important to be able to understand what these voices are saying and so I usually make them play a bit louder. Some tables have voices from several recognizable characters. I sometimes set these up so each character has its own volume control. Sometimes voice recordings may be combined with sound effects. When this is done, I usually add the sound to the voices category.

Part 1 (for both script writers and novices)

The first step is to add the code below to the script where you see other line items that start with the dark green text, "Const". I give my permission to use this exact code or edit it to use on any pinball table:

Code:
' ************************************ Sound Level Control Panel *************************************

' Sound levels (displayed in blue below) may be changed to values between 0 and 1.0.  A value of 
' zero (0) will produce no sound.  A value of 1.1 or higher won't produce any error messages when you
' play the table but will play the same as a value of 1.0.  The default levels are saved in the notes   
' in case you decide to change the values but want to change them back to the defaults later.

const BMV = 0.8    ' Background Music Volume (Default = 0.8)
const GSV = 0.5   ' Game Sound Volume, sounds with loud volume (Default = 0.5)
const SEV = 0.7    ' Sound Effects Volume (Default = 0.7)
const VOV = 1.0    ' Volume of Voices (Default = 1.0)

' ****************************************************************************************************


Script Writer Instructions

Part 2, Move Sounds from Table Objects into the Script

If you are building a new table, just save all the sounds into the script. On "Creature from the Black Lagoon", I didn't move the sounds into the script at first but ended up determining that I had to if I wanted a good sound mix.

Part 3, Categorize Each Sound

Listen to each sound in both the music and sound managers and categorize them. You may decide to add more categories than I defined in Part 1. I set up a Word document with columns of each category of sound with a sub-column of "Loud" and "Soft" for each category. After I listen to each sound in the Future Pinball editor, I click on the "Rename" button in but I don't rename it. I just hold down the "Ctrl" key and type "C" to copy the name and paste it into the appropriate column in the Word document. After I finish a sound, I bold or underline the name of the sound to keep track of what I completed in the list. I listen to each sound and categorize it without regard as to whether it is in the music manager or sound manager.

After you have categorized each sound, you need to compare the columns of loud and soft sounds. Game sounds often have a wide range of volumes, although other sounds often have less range. You can take 2 different approaches to address loud and soft sounds in the same category.

1. You can make the soft sounds louder by adding a +0.1 or +0.2 to the constant like I show below.

PlaySound "triggersound", GSV+0.2

2. The other approach is to simply break the category into two groups like GSVloud and GSVsoft (basically form two categories).

You can subtract a value from a constant also to reduce the volume but I don't usually do that because it is possible to reduce the sound to 0 without realizing it. I usually use approach 1 when I have 2 or 3 soft sounds and the rest loud. When I have 4 or more soft sounds, I usually use approach 2.

Copy each name of a sound to the clipboard from your Word document and paste it into the find option in the script. Then just add the correct constant to each sound in the script. It is important to use the same constant for different occurrences in the script for the same sound. Don't forget that the "effectmusic" code can fade a music up and it has a sound level that is defined also where you will want to add a constant.

Part 4, Check to See if You Missed Transferring Some Sounds from the Table Objects

The best way to check to see if you failed to move all the sounds from the table objects to the script is to change all the constants so they are 0. If you set some sounds to be a constant+.02 just change the value of the constant to a negative number. Then play the table. The table should produce no sound unless you missed transferring some of the sounds from the table objects to the script. If you hear music playing, you may have missed an item for "effectmusic" in the script. After you fix the table so it plays no sound, change the constants back to the default setting.

Part 5, Play the Table and Listen to the Sounds

You need to play the table to adjust the values for the constants. After playing the table a few times and making adjustments, you should be able to get a balanced sound mix. It is possible that some sounds may still be louder than others even though you listened to them in Part 3. You can still make adjustments by using approach 1 in Part 3.

Novice Instructions

Part 2, Move Sounds from Table Objects into the Script

What I call a control panel is actually a set of constants. To my surprise, I could find no guide that explains them. Fortunately, their set up is quite simple. These are defined at the beginning of the script and are formatted as follows:

const BMV = 0.8 ' comment

The line starts with "const" which defines the line as a constant. BMV is the name of the constant which you can change to any name that you like. In this case, I made up the code BMV to mean "Background Music Volume". An equal sign comes next and is followed by a numeric value. After you add this to the script, you can add BMV to a location in the script where you would normally add a number. When you play a game, Future Pinball will see BMV in the script and it knows to use the number that is defined in your list of constants. In this case, Future Pinball will use 0.8. You can add BMV in multiple locations in the script. If you want the numeric value in all these locations to be something other than 0.8, you can change 0.8 in your constant to another number and Future Pinball will use the new number in all the locations where you have added the code BMV. Wherever you add BMV in the script, the numeric value in your constant (in this case 0.8) needs to follow the requirements for format of the number in the place were you add BMV. We are using these constants for sound and music volume and so the format of the number needs to be between 0.0 and 1.0. Most table authors will add a comment after the number in the constant to describe the purpose of the constant. Comments always start with a single quotation mark and are followed by the text.

If you are editing an existing table and want to add this panel, you need to move the sounds from the table objects into the script. You might start with the flippers. When you click on the flipper object on the table, there may be 2 sounds listed at the bottom of the right pane. One is for the sound when the flipper is raised or moves up and the other sound is when the flipper is lowered or moved down. If these 2 fields are blank, then you don't need to do anything to the flippers. If you find an entry for the "Flipper Up" field, locate a line in the script similar to the following line:

Sub FuturePinball_KeyPressed(ByVal KeyCode)

When you see "Sub" at the beginning of a line, it means it is the start of a subroutine. This subroutine senses when a key is pressed on the keyboard when you play a game. This is where the actions are defined when you press a key. The end of the subroutine will simply state "End Sub".

Not far below the key pressed code but before you see "End Sub", you will see a line similar to this:

If (KeyCode = GetKeyCode(LeftFlipperKey)) Then

This is the section of the script that tells what actions are taken when you press the left flipper key. Note that the section in yellow is the name of the flipper that appears at the top of the right pane when you click on a flipper on the table.

Add the following directly below the line for the left flipper only replace "FlipperUp" with the name of the flipper sound on your table:

PlaySound "FlipperUp", GSV

Note that "GSV" is the name of the one of the constants that you added in Part 1. It stand for Game Sound Volume.

Now do the same thing for the right flipper which will have a code similar to:

If (KeyCode = GetKeyCode(RightFlipperKey)) Then

Now find the following subroutine:

Sub FuturePinball_KeyReleased(ByVal KeyCode)

This subroutine defines what happens when you release a key on the keyboard. Not far below the key released code but before you see "End Sub", you will see a line similar to this:

If (KeyCode = GetKeyCode(LeftFlipperKey)) Then

This is the section of the script that tells what actions are taken when you release the left flipper key. Add the following directly below the line for the left flipper only replace "FlipperDown" with the name of the flipper sound on your table:

PlaySound "FlipperDown", GSV

Now do the same thing for the right flipper which will have a code similar to:

If (KeyCode = GetKeyCode(RightFlipperKey)) Then

The key released subroutine will also have an entry for the plunger shown below. Add a "playsound" line item directly below the following line. The key pressed subroutine usually has an entry for the plunger but it usually has no sound.

If KeyCode = GetKeyCode(PlungerKey)

In addition to the previously mentioned flippers and plunger, kickers including drains, bumpers, rubbers including the slingshots, autoplungers and all the different shapes of triggers all have "Sound Effects" where a sound can be added to the table object. Kickers have several different shapes and may be round, triangular or square shaped with a ramp model on top. When you find an object that has a sound, the object has a name at the top of the right pane. You can highlight the name with your mouse and copy it to the clipboard. Perform a search of the script for the name of the object by using the find function and holding down the Ctrl key and typing "V" to paste the name of the object into the search.

Autoplungers are activated by a solenoid pulse which usually has a sound. The line in the script will look this the following:

autoplunger.SolenoidPulse()

The name of the autoplunger appears in yellow above. Add a line for the sound like the following where the red text is the name of the sound followed by the GSV constant.

PlaySound "autoplungersound", GSV

Kickers, bumpers, rubbers and triggers can have sounds added to the table object that produce a sound when hit by the ball. They can have a subroutine that looks like this:

Sub Bumper1_hit()

Note that "Sub" identifies the start of the subroutine and the green text is the name of the table object. Add a line for the sound like the following where the red text is the name of the sound followed by the GSV constant.

PlaySound "bumpersound",GSV

It is possible that kickers, bumpers, rubbers and triggers may not have any entries in the script. If that is the case, you can create a simple subroutine to add it. Add the following to a section named "Table Object Script Events". If you can't find this section, then just search for "_Hit()" and add your new subroutines near it. The following is an example of the subroutine where the yellow text is the name of the table object and the red text is the name of the sound:

Sub Trigger1_Hit()
PlaySound "triggersound", GSV
End Sub

Part 3, Categorize Each Sound

Listen to each sound in both the music and sound managers and categorize them. You may decide to add more categories than I defined in Part 1. I set up a Word document with columns of each category of sound with a sub-column of "Loud" and "Soft" for each category. After I listen to each sound in the Future Pinball editor, I click on the "Rename" button in but I don't rename it. I just hold down the "Ctrl" key and type "C" to copy the name and paste it into the appropriate column in the Word document. After I finish a sound, I bold or underline the name of the sound to keep track of what I completed in the list. This method ensures you record the exact name of the sound. Just because a sound has been added to the music manager, does not mean I would categorize it as Background Music. I just listen to each sound and categorize it without regard as to whether it is in the music manager or sound manager.

After you have categorized each sound, you need to look at the columns of loud and soft sounds. The game sounds often have loud and soft sounds. Most of the other sounds may have about the same volume. You can take 2 different approaches to address loud and soft sounds in the same category.

1. You can make the soft sounds louder by adding a +0.1 or +0.2 (or even higher) to the constant like I show below. In this case if the constant GSV is set to 0.5, then 0.2 is added and the sound volume will end up playing at 0.7. If someone sets GSV to 1.0, the sound will be changed to 1.2 but the sound will only play at maximum volume (which is the same as 1.0). Any sounds that end up calculated as greater than 1.0 will play as 1.0 and sound that is calculated as negative number will play as 0. Neither will produce any error messages.

PlaySound "triggersound", GSV+0.2

2. The other approach is to simply break the category into two groups like GSVloud and GSVsoft (basically form 2 categories). This way you can individually adjust the sound in the control panel.

You can subtract a value from a constant also to reduce the volume but I don't usually do that because it is possible to reduce the sound to 0 without realizing it. I usually use approach 1 when I have 2 or 3 soft sounds and the rest loud. When I have 4 or more soft sounds, I usually use approach 2.

Be aware that a sound can have many occurrences in the script. You need to use the same constant for each sound and the same plus factor that you used in approach 1 above.

Copy each name of a sound to the clipboard from your Word document and paste it into the find option in the script. If the sound is not unique, it may find unwanted places in the script. If this is the case, you can add double quotes before and after the name of the sound in your search. You may see items like either of the following:

PlaySound "bumpersound", 0.8
PlaySound "bumpersound"

The first has a volume defined as 0.8. Replace 0.8 with your constant. The second example has no volume defined. It plays the sound at maximum volume which is the same as a value of 1.0. When you see sounds like this, add a comma to the end of the line followed by your constant.

Items in the Music Manager use a little different format;

Playmusic 1,"musicsound", True, 0.9
Playmusic 1,"musicsound", True

The 1 above is a channel number which you don't need to be concerned about. The part of the line that says "True" may also say "False" and refers to whether the music repeats or not. There is no need to change the "True" or "False" statement either. The volume is defined in this case as 0.9. Replace 0.9 with your constant. As in the second example above, there may be nothing after the "True" or "False" statement which means the music plays at maximum volume. When you see this, add a comma to the end of the line followed by your constant.

Music can have a separate line that has additional controls and does not list the name of the music. It is normally used for fading the music in and out but may have other functions. It affects music that is defined to play elsewhere in the subroutine. The following is an example. The section in yellow may have different options listed like "fadeoutandstop". The most important option is the "playandfadein" because it has volume that is always set to something other than 0.

effectmusic 1, playandfadein, 1.0, 150

The number 1 above is the channel number followed by the music effect. The volume is defined next and is shown in the example as 1.0. Change the 1.0 to your constant for the music that is defined in the playmusic command elsewhere in the subroutine. The final number (150) is the time it takes to process the effect (don't change this).

Part 4, Check to See if You Missed Transferring Some Sounds from the Table Objects

The best way to check to see if you failed to move some sounds from the table objects to the script is to change all the constants so they are 0. If you set some sounds to be +.02 just change the value of the constant to a negative number. Then play the table. The table should produce no sound unless you missed transferring some of the sounds from the table objects to the script. If you hear music playing, you may have missed an item for "effectmusic" in the script.

Part 5, Play the Table and Listen to the Sounds

You need to play the table to adjust the values for the constants. After playing the table a few times and making adjustments, you should be able to get a balanced sound mix. It is possible that some sounds may still be louder than others even though you listened to them in Part 3. You can still make adjustments by using approach 1 in Part 3.


Last edited by GeorgeH on Fri Jun 22, 2018 1:30 pm, edited 3 times in total.

Top 
 Profile  
 
 Post subject: Re: Creating a Sound Level Control Panel in the Script
 Post Posted: Sat Feb 17, 2018 8:07 pm 
Offline

Joined: Mon Jan 27, 2014 12:36 pm
Posts: 2111
Location: Ontario, Canada
Awesome thanks George!


Top 
 Profile  
 
 Post subject: Re: Creating a Sound Level Control Panel in the Script
 Post Posted: Sat Feb 17, 2018 11:59 pm 
Offline

Joined: Thu Aug 16, 2012 11:12 pm
Posts: 1685
Location: Arkansas, USA
Thanks, I guess I had to get this out of my system. I have seen examples of poor implementation of the sound constants on several tables so I wrote this so that new people would at least know what the best method is even if they may not use it. If you are going to add a constant to every sound in the script, this method won't take much longer and I promise it is the best method.

George


Top 
 Profile  
 
Display posts from previous:  Sort by  
 
Post new topic Reply to topic  [ 3 posts ] 

Board index » Resources » Tutorials, how-to's, bug report and docs


Who is online

Users browsing this forum: No registered users and 4 guests

 
 

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to: