-
Notifications
You must be signed in to change notification settings - Fork 72
Document sound features for table authors #531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fd0066f
doc: Document sound features for table authors
arthurkehrwald 8e2c49f
doc: Upscale editor screenshots and align them to the right.
freezy 9d8f8a1
doc: Add screenshot for coil sound component.
freezy 24a1a25
doc: Fix screenshot position.
freezy 4842ebf
Add sound to manual content list
arthurkehrwald bc32839
Suggestions from freezy
arthurkehrwald 91b1d72
doc: Add section on preparing sound files
arthurkehrwald File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file added
BIN
+13.2 KB
...nball.Unity/Documentation~/creators-guide/manual/common-sound-asset-options.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+110 KB
VisualPinball.Unity/Documentation~/creators-guide/manual/create-sound-asset.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+25.7 KB
VisualPinball.Unity/Documentation~/creators-guide/manual/editor-coil-sound.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,4 +6,5 @@ This section will document the following: | |
| - Pinball Mechanisms | ||
| - Scripting | ||
| - Physics | ||
| - Plugins | ||
| - Plugins | ||
| - Sound | ||
Binary file added
BIN
+6.05 KB
...nball.Unity/Documentation~/creators-guide/manual/sound-effect-asset-options.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
190 changes: 190 additions & 0 deletions
190
VisualPinball.Unity/Documentation~/creators-guide/manual/sound.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,190 @@ | ||
| --- | ||
| uid: sound | ||
| title: Sound | ||
| description: | ||
| VPE provides pinball specific sound features on top of Unity's built in audio | ||
| functions. | ||
| --- | ||
|
|
||
| # Sound | ||
|
|
||
| Unity, the game engine VPE is built on top of, provides many useful audio | ||
| features out of the box. It can import and play several common audio file | ||
| formats, it supports directional audio and surround sound and provides mixing | ||
| and mastering functionality. For a comprehensive overview, refer to the | ||
| [Unity documentation](https://docs.unity3d.com/6000.0/Documentation/Manual/Audio.html). | ||
| On top of this built-in functionality, VPE provides some features specific to | ||
| pinball. | ||
|
|
||
| ## Preparing Sound Files | ||
|
|
||
| Before you can use a sound file in your VPE table, you must import it into | ||
| Unity. This can be as simple as adding a file of a supported type (.aif, .wav, | ||
| .mp3, .ogg) to your project folder, but there are a few things you should | ||
| consider: | ||
|
|
||
| ### Encoding | ||
|
|
||
| No matter what format your file is on disk and no matter what settings you chose | ||
| when exporting it, Unity will transcode and compress your audio file differently | ||
| depending on the platform it runs on. This means you should prioritize audio | ||
| quality over small file size when creating your files. The standard practice | ||
| among Unity developers is to use uncompressed .wav files to avoid double | ||
| compression and achieve the highest possible quality on any platform. | ||
|
|
||
| ### Channels | ||
|
|
||
| Use a single channel (mono audio) for any spatial sounds. For example, do not | ||
| export the sound effect for your plunger with a louder right channel just | ||
| because the plunger is on the right side of your playfield. Unity can | ||
| dynamically change the volume per channel depending on the locations of the | ||
| listener and the audio source. If you already have mechanical sound effects in | ||
| stereo format, you can mix them down to mono in Unity's import settings. For | ||
| anything that would come out of the speakers in a real pinball machine, such as | ||
| music and callouts, you can use stereo sounds if you want. | ||
|
|
||
| ### Loudness | ||
|
|
||
| All your sound files should have a subjectively similar loudness relative to | ||
| each other so you don't have to mess around with volume sliders in Unity just to | ||
| equalize the volume. Any volume mixing you do in Unity should be done to make | ||
| certain sounds louder than others, not the other way around. The overall | ||
| loudness of your table should also be consistent with other VPE tables and other | ||
| software in general so that players don't have to fiddle around with their | ||
| volume controls every time they open your table. | ||
|
|
||
| Unity does not have the ability to normalize the loudness of your audio files, | ||
| but the free audio editing software [Audacity](https://www.audacityteam.org/) | ||
| does: | ||
|
|
||
| 1. Import your file(s) into Audacity | ||
| 2. Press `Ctrl + A` to select all | ||
| 3. In the toolbar at the top, select _Effect -> Volume and Compression -> | ||
| Loudness Normalization..._ | ||
| 4. Do not change the default settings (-23 LUFS) and click 'Apply' | ||
| 5. Press `Ctrl + Shift + E` to export | ||
|
|
||
| ## Sound Assets | ||
|
|
||
| After importing your a sound file into Unity, you get an | ||
| [Audio Clip](https://docs.unity3d.com/6000.0/Documentation/Manual/class-AudioClip.html). | ||
| You could create an | ||
| [Audio Source](https://docs.unity3d.com/6000.0/Documentation/Manual/class-AudioSource.html) | ||
| in your scene and play this clip directly, but VPE allows you to construct | ||
| different types of sound assets out of one or multiple of these audio clips to | ||
| produce variation and customize how the sound is played with pinball in mind. | ||
| VPE differentiates between **sound effects**, **music** and **callouts**. | ||
|
|
||
| To create a sound asset, navigate to the folder where you want to create it in | ||
| your Unity project panel, right click, select _Create -> Pinball -> Sound_ and | ||
| choose the type of sound asset you want to create. All sound asset types have | ||
| the following properties: | ||
|
|
||
| <img src="common-sound-asset-options.png" alt="Common sound asset options" width="367" class="img-fluid float-end" style="margin-left: 15px; margin-bottom: 10px"> | ||
|
|
||
| - **Description**: You can enter any text here. This field is only for diplay. | ||
| Use it to describe the sound, when it should be used, how it was recorded, or | ||
| just leave it blank. | ||
| - **Clips**: A list of audio clips that may be selected for playback. For | ||
| frequently played sounds, such as that of a bumper, you should provide | ||
| multiple samples here. | ||
| - **Clip Selection Method**: How VPE decides which clip to choose each time the | ||
| sound is played. | ||
| - Round Robin: The clips will be played first to last in a fixed order. | ||
| - Random: Clips are selected at random. | ||
| - **Audio Mixer Group**: The audio mixer group whose effects and settings will | ||
| be applied to the sound asset when played. VPE comes with a default audio | ||
| mixer group for each type of sound asset. This enables the VPE player | ||
| application to provide global volume settings to end users across all tables. | ||
| The default audio mixer is also responsible for reducing the volume of sound | ||
| effects and music whenever a callout plays. Your table will lose these | ||
| benefits if you use your own audio mixer groups. | ||
|
|
||
| ### Sound Effects | ||
|
|
||
| Sound effects are the most common type of sound asset. You should generally | ||
| choose this type for any sounds other than callouts and music. In addition to | ||
| those described above, sound effect assets have the following properties: | ||
|
|
||
| <img src="sound-effect-asset-options.png" alt="Common sound asset options" width="367" class="img-fluid float-end" style="margin-left: 15px; margin-bottom: 10px"> | ||
|
|
||
| - **Type**: In a real pinball machine, would this sound come from a mechanism | ||
| (Mechanical) or from the speakers (Synthetic)? When a mechanical sound effect | ||
| is played, VPE uses Unity's spatial audio system to position it in the scene | ||
| according to the object that triggered it. | ||
| - **Loop**: Causes the sound to loop until it is stopped according to table | ||
| logic. When enabled, additional options for fading in and out are available. | ||
| - **Volume Range** and **Pitch Range**: Two sliders with two control knobs each | ||
| that indicate a range within which volume and pitch will be randomized each | ||
| time the sound is played. This is a cheap way to produce variation if only one | ||
| audio clip is available, but it will not sound as good as multiple samples. | ||
| - **Cooldown**: If the sound effect is triggered again before the specified | ||
| number of seconds passes, it will not be played. This is to prevent sound | ||
| effects from playing twice at the same time, for example when the ball hits | ||
| two drop targets at once. | ||
|
|
||
| ### Callouts | ||
|
|
||
| Callouts are short voice lines that are typically triggered when the player does | ||
| something special, like starting multiball. The reason for the distinction | ||
| between callouts and sound effects is that callouts tend to be much more | ||
| significant to the player than other sounds. As such, their playback is managed | ||
| by a table-wide _Callout Coordinator_ component at the root of the table | ||
| hierarchy that ensures callouts are played one at a time. When triggering a | ||
| callout, you can select a priority. Whenever a callout is triggered while | ||
| another is playing, it will be placed in a queue to be played later. New | ||
| callouts will 'cut in line' in front of any lower priority callouts already in | ||
| the queue. Callouts also have their own audio mixer group that lowers the volume | ||
| of sound effects and music whenever a callout is played. (This is called | ||
| "ducking" in audio technician lingo.) | ||
|
|
||
| ### Music | ||
|
|
||
| Like callouts, music is played indirectly through requests to a table-wide | ||
| _Music Coordinator_ at the root of the table hierarchy. This ensures your table | ||
| never plays multiple tracks at once, so you don't have to worry about that in | ||
| your game logic. Requests to the music coordinator are made with a priority. If | ||
| multiple requests are active at the same time, the one with the highest priority | ||
| will play. If multiple requests have the same priority, the most recent one is | ||
| played. If a new track starts while another is playing, the music coordinator | ||
| will cross-fade between them according to the _Fade Duration_ setting on the | ||
| music coordinator component. Music assets always loop: When an audio clip from a | ||
| music asset finishes, the next clip is chosen according to the clip selection | ||
| method specified in the asset. This allows you to build playlists using music | ||
| assets. | ||
|
|
||
| ## Playback | ||
|
|
||
| <img src="editor-coil-sound.png" alt="Coil Sound Component on a bumper" width="367" class="img-fluid float-end" style="margin-left: 15px; margin-bottom: 10px"> | ||
|
|
||
| Regardless of which game logic engine you use, VPE provides a few Unity | ||
| components to trigger the playback of sound assets. _Hit Sound_, _Coil Sound_ | ||
| and _Switch Sound_ are intended to trigger mechanical sound effects when the | ||
| ball hits something, a coil is energized, or a switch is closed, respectively. | ||
| You can add these components to any game objects that have another component to | ||
| supply the appropriate events. For example, a bumper component supplies all | ||
| three, because bumpers can get hit and have both a coil and a switch. If the | ||
| coil or switch that should trigger the sound is part of a device with other | ||
| coils or switches, you must select it in the drop-down menu on the sound | ||
| component. You can have as many sound components on one object as you want. If | ||
| you expect a sound to be triggered in quick succession, you may be interested in | ||
| the _Multi Play Mode_ setting. It specifies what to do when the sound is still | ||
| playing when it is triggered again. These are the options: | ||
|
|
||
| - **Play In Parallel**: Keep playing the previous sound and start another one at | ||
| the same time. | ||
| - **Do Not Play**: Keep playing the previous sound and don't start another one. | ||
| - **Fade Out Previous**: Fade out the previous sound while starting a new one. | ||
| If the sound is not a looping sound or its fade out time is zero, this is the | ||
| same as _Stop Previous_. | ||
| - **Stop Previous**: Immediately stop the previous sound and start a new one. | ||
|
|
||
| Any sound that would come out of the speakers in a real pinball machine should | ||
| be driven by your game logic engine, but there is technically nothing stopping | ||
| you from triggering music or a callout when a switch is closed, for example. | ||
| Additionally, VPE provides the _Music Requester_ and _Callout Requester_ | ||
| components for testing purposes. These components will trigger callouts and | ||
| music as soon as they are enabled and cancel the request when they are disabled. | ||
| To get some music playing as quickly as possible, simply add a music requester | ||
| component to an enabled object in your table hierarchy and assign a reference to | ||
| the music asset you want to play. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New paragraph?