Skip to content

Commit cd6da94

Browse files
committed
Merge branch 'feature/naudio' into develop
2 parents 5de3987 + 03b6ac9 commit cd6da94

30 files changed

Lines changed: 667 additions & 699 deletions

SpeechResponder/CustomFunctions/Humanise.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Cottle;
22
using EddiSpeechResponder.ScriptResolverService;
3-
using EddiSpeechService;
3+
using EddiSpeechService.SpeechConversions;
44
using JetBrains.Annotations;
55
using System;
66

@@ -13,6 +13,6 @@ public class Humanise : ICustomFunction
1313
public FunctionCategory Category => FunctionCategory.Utility;
1414
public string description => Properties.CustomFunctions_Untranslated.Humanise;
1515
public Type ReturnType => typeof( string );
16-
public IFunction function => Function.CreateNative1( ( runtime, input, writer ) => Translations.Humanize( (decimal?)Convert.ToDecimal( input.AsNumber ) ) );
16+
public IFunction function => Function.CreateNative1( ( runtime, input, writer ) => SpeechConversions.Humanize( (decimal?)Convert.ToDecimal( input.AsNumber ) ) );
1717
}
1818
}

SpeechResponder/CustomFunctions/ICAO.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Cottle;
22
using EddiSpeechResponder.ScriptResolverService;
3-
using EddiSpeechService;
3+
using EddiSpeechService.SpeechConversions;
44
using JetBrains.Annotations;
55
using System;
66

@@ -20,7 +20,7 @@ public class ICAO : ICustomFunction
2020
if (string.IsNullOrEmpty(value)) { return ""; }
2121

2222
// Translate to ICAO, removing anything that isn't alphanumeric
23-
return Translations.ICAO( value.ToUpperInvariant().Replace( "[^A-Z0-9]", "" ) );
23+
return SpeechConversions.ICAO( value.ToUpperInvariant().Replace( "[^A-Z0-9]", "" ) );
2424
});
2525
}
2626
}

SpeechResponder/CustomFunctions/P.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Cottle;
22
using EddiSpeechResponder.ScriptResolverService;
33
using EddiSpeechService;
4+
using EddiSpeechService.SpeechConversions;
45
using JetBrains.Annotations;
56
using System;
67

@@ -18,7 +19,7 @@ public class P : ICustomFunction
1819
var val = values[0].AsString;
1920
var type = values.Count > 1 ? values[1].AsString : null;
2021
var useICAO = SpeechServiceConfiguration.FromFile().EnableIcao;
21-
return Translations.GetTranslation(val, useICAO, type);
22+
return SpeechConversions.GetTranslation(val, useICAO, type);
2223
}, 1, 2);
2324
}
2425
}

SpeechResponder/CustomFunctions/ShipCallsign.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using EddiCore;
44
using EddiDataDefinitions;
55
using EddiSpeechResponder.ScriptResolverService;
6-
using EddiSpeechService;
6+
using EddiSpeechService.SpeechConversions;
77
using JetBrains.Annotations;
88
using System;
99
using System.Linq;
@@ -102,7 +102,7 @@ internal static string phoneticCallsign(Ship ship, string id)
102102
private static string Get3LeadingCharacters(string input)
103103
{
104104
// Obtain the first three characters of the input string, zero padded and converted to ICAO (e.g. "A" becomes "Alpha Zero Zero")
105-
return Translations.ICAO(new Regex("[^a-zA-Z0-9]")
105+
return SpeechConversions.ICAO(new Regex("[^a-zA-Z0-9]")
106106
.Replace(input, "")
107107
.ToUpperInvariant()
108108
.PadRight(3, '0')

SpeechResponder/CustomFunctions/Spacialise.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Cottle;
22
using EddiSpeechResponder.ScriptResolverService;
33
using EddiSpeechService;
4+
using EddiSpeechService.SpeechConversions;
45
using JetBrains.Annotations;
56
using System;
67

@@ -17,7 +18,7 @@ public class Spacialise : ICustomFunction
1718
{
1819
if ( string.IsNullOrEmpty( input.AsString ) ) { return ""; }
1920
var useICAO = SpeechServiceConfiguration.FromFile().EnableIcao;
20-
return Translations.sayAsLettersOrNumbers( input.AsString, false, useICAO );
21+
return SpeechConversions.sayAsLettersOrNumbers( input.AsString, false, useICAO );
2122
});
2223
}
2324
}

SpeechService/EddiSpeech.cs

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,63 @@ namespace EddiSpeechService
55
public class EddiSpeech
66
{
77
public string message { get; private set; }
8-
public Ship ship { get; private set; }
98
public int priority { get; private set; }
109
public string voice { get; private set; }
1110
public bool radio { get; private set; }
1211
public string eventType { get; private set; }
1312

1413
// Calculated SpeechFX data
15-
public int echoDelay { get; set; }
16-
public int chorusLevel { get; set; }
17-
public int reverbLevel { get; set; }
18-
public int distortionLevel { get; set; }
19-
public int compressionLevel { get; set; }
14+
public int echoDelay { get; }
15+
public int distortionLevel { get; }
2016

21-
public EddiSpeech(string message, Ship ship = null, int priority = 3, string voice = null, bool radio = false, string eventType = null)
17+
public EddiSpeech ( string message, string voice = null, int priority = 3,
18+
string eventType = null, LandingPadSize shipSize = null,
19+
decimal? shipHealth = 100M, bool radio = false, bool distortOnDamage = false )
2220
{
2321
this.message = message;
24-
this.ship = ship;
2522
this.priority = priority;
2623
this.voice = voice;
2724
this.radio = radio;
2825
this.eventType = eventType;
2926

30-
EddiSpeech speech = SpeechService.Instance.GetSpeechFX(this);
31-
this.echoDelay = speech.echoDelay;
32-
this.chorusLevel = speech.chorusLevel;
33-
this.reverbLevel = speech.reverbLevel;
34-
this.distortionLevel = speech.distortionLevel;
35-
this.compressionLevel = speech.compressionLevel;
27+
// Resolve the SpeechFX settings
28+
echoDelay = GetEchoDelay( shipSize );
29+
distortionLevel = GetDistortionLevel( distortOnDamage, shipHealth );
30+
}
31+
32+
private static int GetDistortionLevel ( bool distortOnDamage, decimal? shipHealth )
33+
{
34+
// This is affected by ship health
35+
var distortionLevel = 0;
36+
if ( shipHealth != null && distortOnDamage )
37+
{
38+
distortionLevel = ( 100 - (int)shipHealth );
39+
}
40+
41+
return distortionLevel;
42+
}
43+
44+
private static int GetEchoDelay ( LandingPadSize size )
45+
{
46+
// this is affected by ship size
47+
var echoDelayMs = 0; // Default
48+
if ( size != null )
49+
{
50+
if ( size == LandingPadSize.Small )
51+
{
52+
echoDelayMs = 100;
53+
}
54+
else if ( size == LandingPadSize.Medium )
55+
{
56+
echoDelayMs = 200;
57+
}
58+
else if ( size == LandingPadSize.Large )
59+
{
60+
echoDelayMs = 300;
61+
}
62+
}
63+
64+
return echoDelayMs;
3665
}
3766
}
3867
}

SpeechService/EddiSpeechService.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
</ItemGroup>
4040
<ItemGroup>
4141
<ProjectReference Include="..\CompanionAppService\EddiCompanionAppService.csproj" />
42+
<ProjectReference Include="..\ConfigService\EddiConfigService.csproj" />
4243
<ProjectReference Include="..\DataDefinitions\EddiDataDefinitions.csproj" />
4344
<ProjectReference Include="..\Utilities\Utilities.csproj" />
4445
</ItemGroup>
@@ -62,19 +63,18 @@
6263
</EmbeddedResource>
6364
</ItemGroup>
6465
<ItemGroup>
65-
<PackageReference Include="CSCore">
66-
<Version>1.2.1.2</Version>
67-
</PackageReference>
6866
<PackageReference Include="JetBrains.Annotations">
6967
<Version>2024.3.0</Version>
7068
</PackageReference>
7169
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
7270
<PackageReference Include="Microsoft.Windows.SDK.Contracts">
7371
<Version>10.0.26100.4188</Version>
7472
</PackageReference>
73+
<PackageReference Include="NAudio" Version="2.2.1" />
7574
<PackageReference Include="Newtonsoft.Json">
7675
<Version>13.0.3</Version>
7776
</PackageReference>
77+
<PackageReference Include="NWaves" Version="0.9.6" />
7878
<PackageReference Include="System.Runtime">
7979
<Version>4.3.1</Version>
8080
</PackageReference>

SpeechService/ExtendedDurationWaveSource.cs

Lines changed: 0 additions & 45 deletions
This file was deleted.

SpeechService/Humanize.cs renamed to SpeechService/SpeechConversions/Humanize.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
using System.Globalization;
33
using Utilities;
44

5-
namespace EddiSpeechService
5+
namespace EddiSpeechService.SpeechConversions
66
{
7-
public static partial class Translations
7+
public static partial class SpeechConversions
88
{
99
/// <summary>
1010
/// Present a number's approximate value in a format suitable for text-to-speech

SpeechService/PhoneticBody.cs renamed to SpeechService/SpeechConversions/PhoneticBody.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
using System.Collections.Generic;
22
using System.Text.RegularExpressions;
33

4-
namespace EddiSpeechService
4+
namespace EddiSpeechService.SpeechConversions
55
{
6-
public static partial class Translations
6+
public static partial class SpeechConversions
77
{
88
/// <summary>Fix up body names</summary>
99
private static string getPhoneticBody(string body, bool useICAO = false)

0 commit comments

Comments
 (0)