Skip to content
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

Speech Noises 2: Quality of Life, New Sounds #8044

Merged
merged 10 commits into from
May 9, 2022
19 changes: 18 additions & 1 deletion Content.Server/Speech/SpeechNoiseSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Robust.Shared.Random;
using System;

namespace Content.Server.Speech
Expand All @@ -14,6 +15,7 @@ public sealed class SpeechSoundSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IPrototypeManager _protoManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;

public override void Initialize()
{
Expand All @@ -35,6 +37,7 @@ private void OnEntitySpoke(EntityUid uid, SharedSpeechComponent component, Entit
// Play speech sound
string contextSound;
var prototype = _protoManager.Index<SpeechSoundsPrototype>(component.SpeechSounds);
var message = args.Message;

// Different sounds for ask/exclaim based on last character
switch (args.Message[^1])
Expand All @@ -50,8 +53,22 @@ private void OnEntitySpoke(EntityUid uid, SharedSpeechComponent component, Entit
break;
}

// Use exclaim sound if most characters are uppercase.
int uppercaseCount = 0;
for (int i = 0; i < message.Length; i++)
{
if (char.IsUpper(message[i])) uppercaseCount++;
}
if (uppercaseCount > (message.Length / 2))
{
contextSound = contextSound = prototype.ExclaimSound.GetSound();
}

var scale = (float) _random.NextGaussian(1, prototype.Variation);
var pitchedAudioParams = component.AudioParams.WithPitchScale(scale);

component.LastTimeSoundPlayed = currentTime;
SoundSystem.Play(Filter.Pvs(uid, entityManager: EntityManager), contextSound, uid, component.AudioParams);
SoundSystem.Play(Filter.Pvs(uid, entityManager: EntityManager), contextSound, uid, pitchedAudioParams);
}
}
}
2 changes: 1 addition & 1 deletion Content.Shared/Speech/SharedSpeechComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public sealed class SharedSpeechComponent : Component
public string? SpeechSounds;

[DataField("audioParams")]
public AudioParams AudioParams = AudioParams.Default.WithVolume(5f);
public AudioParams AudioParams = AudioParams.Default.WithVolume(6f).WithRolloffFactor(4.5f);

[ViewVariables(VVAccess.ReadWrite)]
[DataField("soundCooldownTime")]
Expand Down
5 changes: 5 additions & 0 deletions Content.Shared/Speech/SpeechSoundsPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ public sealed class SpeechSoundsPrototype : IPrototype
[IdDataFieldAttribute]
public string ID { get; } = default!;

//Variation is here instead of in SharedSpeechComponent since some sets of
//sounds may require more fine tuned pitch variation than others.
[DataField("variation")]
public float Variation { get; set; } = 0.1f;

[DataField("saySound")]
public SoundSpecifier SaySound { get; set; } = new SoundPathSpecifier("/Audio/Voice/Talk/speak_2.ogg");

Expand Down
4 changes: 4 additions & 0 deletions Resources/Audio/Animals/license.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
monkey_scream.ogg from
https://github.com/goonstation/goonstation/blob/4059e4be90832b02b1228b1bee3db342094e4f1e/sound/voice/screams/monkey_scream.ogg
licensed under CC BY-NC-SA 3.0

The following sounds were used from freesound:

cat_meow.ogg: modified from "Meow 4.wav" by freesound user "TRNGLE" (https://freesound.org/people/TRNGLE/sounds/368006/) licensed under CCBY 3.0. The original audio was trimmed, split to mono, and converted from WAV to OGG format.
Expand Down
Binary file added Resources/Audio/Animals/monkey_scream.ogg
Binary file not shown.
Binary file modified Resources/Audio/Machines/vending_jingle.ogg
Binary file not shown.
4 changes: 4 additions & 0 deletions Resources/Audio/Voice/Talk/license.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
pai.ogg
pai_ask.ogg
pai_exclaim.ogg
all made by github.com/hubismal licensed under CC-BY-3.0
speak_1_ask.ogg
speak_1_exclaim.ogg
speak_1.ogg
Expand Down
Binary file added Resources/Audio/Voice/Talk/pai.ogg
Binary file not shown.
Binary file added Resources/Audio/Voice/Talk/pai_ask.ogg
Binary file not shown.
Binary file added Resources/Audio/Voice/Talk/pai_exclaim.ogg
Binary file not shown.
2 changes: 2 additions & 0 deletions Resources/Prototypes/Entities/Mobs/NPCs/animals.yml
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,8 @@
state: monkey
sprite: Mobs/Animals/monkey.rsi
- type: Hands
- type: Speech
speechSounds: Monkey
- type: Body
template: PrimateTemplate
preset: PrimatePreset
Expand Down
2 changes: 2 additions & 0 deletions Resources/Prototypes/Entities/Objects/Fun/pai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
- type: GhostRadio
- type: DoAfter
- type: Actions
- type: Speech
speechSounds: Pai
# This has to be installed because otherwise they're not "alive",
# so they can ghost and come back.
# Note that the personal AI never "dies".
Expand Down
17 changes: 17 additions & 0 deletions Resources/Prototypes/Voice/speech_sounds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,20 @@
exclaimSound:
path: /Audio/Machines/vending_jingle.ogg

- type: speechSounds
id: Pai
saySound:
path: /Audio/Voice/Talk/pai.ogg
askSound:
path: /Audio/Voice/Talk/pai_ask.ogg
exclaimSound:
path: /Audio/Voice/Talk/pai_exclaim.ogg

- type: speechSounds
id: Monkey
saySound:
path: /Audio/Animals/monkey_scream.ogg
askSound:
path: /Audio/Animals/monkey_scream.ogg
exclaimSound:
path: /Audio/Animals/monkey_scream.ogg