com.amanotes.gdk 0.2.75 → 0.2.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/Editor/AmaGDKEditor.cs +24 -15
- package/Editor/Utils/GDKPackageInstaller.cs +116 -0
- package/Editor/Utils/GDKPackageInstaller.cs.meta +11 -0
- package/Extra/AmaGDKInstaller.unitypackage +0 -0
- package/Extra/AutoEventQC.unitypackage +0 -0
- package/{Runtime/GDKAudio/Plugins/iOS.meta → Extra/AutoEventQC.unitypackage.meta} +1 -2
- package/Extra/CheckDiskSpace.unitypackage +0 -0
- package/Extra/Consent.unitypackage +0 -0
- package/Extra/ForceUpdate.unitypackage +0 -0
- package/Extra/LegacyGDKUpdateHelper.unitypackage +0 -0
- package/Extra/PostProcessor.unitypackage +0 -0
- package/Packages/AmaGDKConfig.unitypackage +0 -0
- package/Packages/AmaGDKExample.unitypackage +0 -0
- package/Packages/AmaGDKTest.unitypackage +0 -0
- package/Packages/AppsFlyerAdapter.AdRevenue.AF6.14AndOlder.unitypackage +0 -0
- package/Packages/AppsFlyerAdapter.PurchaseConnector.unitypackage +0 -0
- package/Packages/AppsFlyerAdapter.unitypackage +0 -0
- package/Packages/FirebaseAnalyticsAdapter.unitypackage +0 -0
- package/Packages/FirebaseRemoteConfigAdapter.unitypackage +0 -0
- package/Packages/IronSourceAdapter.AdQuality.unitypackage +0 -0
- package/{Runtime/GDKAudio/Plugins/macOS.meta → Packages/IronSourceAdapter.AdQuality.unitypackage.meta} +1 -2
- package/Packages/IronSourceAdapter.unitypackage +0 -0
- package/Packages/MaxAdNetworkAdapter.unitypackage +0 -0
- package/Packages/RevenueCatAdapter.unitypackage +0 -0
- package/Packages/SqliteAnalyticsAdapter.unitypackage +0 -0
- package/Runtime/Ad/AdLogic.cs +52 -55
- package/Runtime/Ad/AdShowContext.cs +1 -1
- package/Runtime/AmaGDK.Analytics.cs +18 -15
- package/Runtime/AmaGDK.Consent.cs +3 -8
- package/Runtime/AmaGDK.Mono.cs +1 -1
- package/Runtime/AmaGDK.RemoteConfig.cs +12 -2
- package/Runtime/AmaGDK.UserProfile.cs +31 -23
- package/Runtime/AmaGDK.cs +76 -40
- package/Runtime/Core/GDKDebug.cs +12 -5
- package/Runtime/Core/GDKPrefabPool.cs +571 -0
- package/Runtime/Core/GDKPrefabPool.cs.meta +11 -0
- package/Runtime/Core/GDKRoutine.cs +48 -2
- package/Runtime/Internal/AmaGDK.Internal.cs +1 -1
- package/Runtime/UI/ScrollView/Editor/GDKScrollViewEditor.cs +50 -0
- package/Runtime/UI/ScrollView/Editor/GDKScrollViewEditor.cs.meta +11 -0
- package/Runtime/{GDKAudio/Resources.meta → UI/ScrollView/Editor.meta} +1 -1
- package/Runtime/UI/ScrollView/GDKScrollView.cs +702 -0
- package/Runtime/UI/ScrollView/GDKScrollView.cs.meta +12 -0
- package/Runtime/UI/ScrollView.meta +9 -0
- package/Runtime/UI/ScrollableText/GDKScrollableText.cs +68 -0
- package/Runtime/UI/ScrollableText/GDKScrollableText.cs.meta +3 -0
- package/Runtime/UI/ScrollableText/GDKScrollableText.prefab +806 -0
- package/Runtime/UI/ScrollableText/GDKScrollableText.prefab.meta +7 -0
- package/Runtime/UI/ScrollableText.meta +3 -0
- package/Runtime/{GDKAudio/Plugins.meta → UI.meta} +1 -1
- package/Runtime/Utils/GDKUtils.cs +18 -0
- package/package.json +1 -1
- package/Packages/AppsFlyerAdapter.AdRevenue.unitypackage +0 -0
- package/Runtime/GDKAudio/GDKAudio.cs +0 -483
- package/Runtime/GDKAudio/GDKAudio.cs.meta +0 -3
- package/Runtime/GDKAudio/Plugins/Android/atensor-release.aar +0 -0
- package/Runtime/GDKAudio/Plugins/Android/atensor-release.aar.meta +0 -32
- package/Runtime/GDKAudio/Plugins/Android.meta +0 -3
- package/Runtime/GDKAudio/Plugins/iOS/libatensor.a +0 -0
- package/Runtime/GDKAudio/Plugins/iOS/libatensor.a.meta +0 -68
- package/Runtime/GDKAudio/Plugins/iOS/libcrypto.a +0 -0
- package/Runtime/GDKAudio/Plugins/iOS/libcrypto.a.meta +0 -68
- package/Runtime/GDKAudio/Plugins/iOS/libssl.a +0 -0
- package/Runtime/GDKAudio/Plugins/iOS/libssl.a.meta +0 -68
- package/Runtime/GDKAudio/Plugins/macOS/libatensor.dylib +0 -0
- package/Runtime/GDKAudio/Plugins/macOS/libatensor.dylib.meta +0 -81
- package/Runtime/GDKAudio/Resources/GDKAudioMixer.mixer +0 -133
- package/Runtime/GDKAudio/Resources/GDKAudioMixer.mixer.meta +0 -8
- package/Runtime/GDKAudio.meta +0 -3
- /package/Packages/{AppsFlyerAdapter.AdRevenue.unitypackage.meta → AppsFlyerAdapter.AdRevenue.AF6.14AndOlder.unitypackage.meta} +0 -0
|
@@ -6,15 +6,25 @@ namespace Amanotes.Core.Internal
|
|
|
6
6
|
{
|
|
7
7
|
public static partial class GDKUtils
|
|
8
8
|
{
|
|
9
|
+
public static void SafeInvokeAndClear(ref Action action)
|
|
10
|
+
{
|
|
11
|
+
if (action == null) return;
|
|
12
|
+
Action temp = action;
|
|
13
|
+
action = null;
|
|
14
|
+
SafeInvoke(temp);
|
|
15
|
+
}
|
|
16
|
+
|
|
9
17
|
public static void SafeInvoke(Action action)
|
|
10
18
|
{
|
|
11
19
|
if (action == null) return;
|
|
12
20
|
|
|
21
|
+
#if UNITY_EDITOR
|
|
13
22
|
if (Application.isEditor)
|
|
14
23
|
{
|
|
15
24
|
action();
|
|
16
25
|
return;
|
|
17
26
|
}
|
|
27
|
+
#endif
|
|
18
28
|
|
|
19
29
|
try
|
|
20
30
|
{
|
|
@@ -29,11 +39,13 @@ namespace Amanotes.Core.Internal
|
|
|
29
39
|
{
|
|
30
40
|
if (action == null) return;
|
|
31
41
|
|
|
42
|
+
#if UNITY_EDITOR
|
|
32
43
|
if (Application.isEditor)
|
|
33
44
|
{
|
|
34
45
|
action(eventObject);
|
|
35
46
|
return;
|
|
36
47
|
}
|
|
48
|
+
#endif
|
|
37
49
|
|
|
38
50
|
try
|
|
39
51
|
{
|
|
@@ -46,11 +58,15 @@ namespace Amanotes.Core.Internal
|
|
|
46
58
|
|
|
47
59
|
public static void SafeInvoke<T1, T2>(Action<T1, T2> action, T1 p1, T2 p2)
|
|
48
60
|
{
|
|
61
|
+
if (action == null) return;
|
|
62
|
+
|
|
63
|
+
#if UNITY_EDITOR
|
|
49
64
|
if (Application.isEditor)
|
|
50
65
|
{
|
|
51
66
|
action(p1, p2);
|
|
52
67
|
return;
|
|
53
68
|
}
|
|
69
|
+
#endif
|
|
54
70
|
|
|
55
71
|
try
|
|
56
72
|
{
|
|
@@ -63,10 +79,12 @@ namespace Amanotes.Core.Internal
|
|
|
63
79
|
|
|
64
80
|
public static void ThrowExceptionInEditor<T>(string message, Func<string, T> exceptionCreator) where T: Exception
|
|
65
81
|
{
|
|
82
|
+
#if UNITY_EDITOR
|
|
66
83
|
if (Application.isEditor)
|
|
67
84
|
{
|
|
68
85
|
throw exceptionCreator(message);
|
|
69
86
|
}
|
|
87
|
+
#endif
|
|
70
88
|
|
|
71
89
|
LogWarning(message);
|
|
72
90
|
}
|
package/package.json
CHANGED
|
Binary file
|
|
@@ -1,483 +0,0 @@
|
|
|
1
|
-
#if UNITY_ANDROID || UNITY_IOS
|
|
2
|
-
#define UNITY_MOBILE
|
|
3
|
-
#endif
|
|
4
|
-
|
|
5
|
-
#if UNITY_2021_1_OR_NEWER && ((UNITY_MOBILE && !UNITY_EDITOR) || (UNITY_MOBILE && UNITY_EDITOR_OSX))
|
|
6
|
-
#define SUPPORTED_PLATFORMS
|
|
7
|
-
#endif
|
|
8
|
-
|
|
9
|
-
// GDKAudio is supported in the following environments:
|
|
10
|
-
// 1. On iOS devices.
|
|
11
|
-
// 2. On Android devices (excluding the Unity Editor).
|
|
12
|
-
// 3. In the Unity Editor running on macOS with Apple Silicon (M1, M2, etc.).
|
|
13
|
-
// For unsupported environments, GDKAudio will fallback to setting the AudioSource.pitch for time stretching.
|
|
14
|
-
|
|
15
|
-
using System;
|
|
16
|
-
using System.Runtime.InteropServices;
|
|
17
|
-
using Amanotes.Core.Internal;
|
|
18
|
-
using static Amanotes.Core.GDKDebug;
|
|
19
|
-
|
|
20
|
-
using UnityEngine;
|
|
21
|
-
|
|
22
|
-
#if !SUPPORTED_PLATFORMS
|
|
23
|
-
using UnityEngine.Audio;
|
|
24
|
-
#endif
|
|
25
|
-
|
|
26
|
-
namespace Amanotes.Core
|
|
27
|
-
{
|
|
28
|
-
public static class AudioSourceExtensions
|
|
29
|
-
{
|
|
30
|
-
public static GDKAudio ConvertToGDKAudio(this AudioSource legacyAudioSource)
|
|
31
|
-
{
|
|
32
|
-
GDKAudio.EnsureDecompressOnLoad(legacyAudioSource.clip);
|
|
33
|
-
if (legacyAudioSource.gameObject.GetComponents<AudioSource>().Length > 1)
|
|
34
|
-
{
|
|
35
|
-
GDKUtils.ThrowExceptionIfEditor("GDKAudio only allows the GameObject to contain a single AudioSource component.");
|
|
36
|
-
}
|
|
37
|
-
var instance = legacyAudioSource.gameObject.AddComponent<GDKAudio>();
|
|
38
|
-
if (legacyAudioSource.clip != null)
|
|
39
|
-
{
|
|
40
|
-
instance.LoadAudioInternal(legacyAudioSource.clip);
|
|
41
|
-
}
|
|
42
|
-
return instance;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
public static GDKAudio GetGDKAudio(this AudioSource legacyAudioSource)
|
|
46
|
-
{
|
|
47
|
-
return legacyAudioSource.GetComponent<GDKAudio>();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
public partial class GDKAudio // public API
|
|
52
|
-
{
|
|
53
|
-
public float speed { get; private set; } = 1f;
|
|
54
|
-
public bool loop { get; private set; } = true;
|
|
55
|
-
public bool mute { get; private set; } = false;
|
|
56
|
-
private float globalVolume = 1f;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
public bool isPlaying { get; private set; } = false;
|
|
60
|
-
public bool isInitialized => initialized;
|
|
61
|
-
|
|
62
|
-
/// <summary>
|
|
63
|
-
/// Set the audio playback speed.
|
|
64
|
-
/// The audio playback speed is capped in range 0.5x and 2x. Set `force` to true to disable this cap. Note: `speed` lower than 0.75 will create audio artifacts.
|
|
65
|
-
/// </summary>
|
|
66
|
-
/// <param name="speed">The desired audio speed. `speed` lower than 0.75 will create artifacts.</param>
|
|
67
|
-
/// <param name="force">Force setting the speed. this will affect the audio pitch on speed faster than 2x and below 0.5x.</param>
|
|
68
|
-
public GDKAudio SetSpeed(float speed, bool force = false)
|
|
69
|
-
{
|
|
70
|
-
if (!force)
|
|
71
|
-
{
|
|
72
|
-
speed = Mathf.Clamp(speed, 0.5f, 2.0f);
|
|
73
|
-
}
|
|
74
|
-
this.speed = speed;
|
|
75
|
-
SetSpeedInternal();
|
|
76
|
-
return this;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
public GDKAudio SetLoop(bool loop)
|
|
80
|
-
{
|
|
81
|
-
this.loop = loop;
|
|
82
|
-
audioSource.loop = this.loop;
|
|
83
|
-
return this;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
public GDKAudio SetMute(bool mute)
|
|
87
|
-
{
|
|
88
|
-
this.mute = mute;
|
|
89
|
-
audioSource.mute = this.mute;
|
|
90
|
-
return this;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
public GDKAudio Pause()
|
|
94
|
-
{
|
|
95
|
-
isPlaying = false;
|
|
96
|
-
audioSource.Pause();
|
|
97
|
-
return this;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
public GDKAudio Resume()
|
|
101
|
-
{
|
|
102
|
-
return Play();
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
public GDKAudio Stop()
|
|
106
|
-
{
|
|
107
|
-
isPlaying = false;
|
|
108
|
-
audioSource.Stop();
|
|
109
|
-
StopInternal();
|
|
110
|
-
return this;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
public GDKAudio Play()
|
|
114
|
-
{
|
|
115
|
-
isPlaying = true;
|
|
116
|
-
audioSource.loop = loop;
|
|
117
|
-
audioSource.Play();
|
|
118
|
-
return this;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
public GDKAudio PlayAudio(AudioClip audioClip)
|
|
122
|
-
{
|
|
123
|
-
LoadAudio(audioClip);
|
|
124
|
-
Play();
|
|
125
|
-
return this;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
public GDKAudio LoadAudio(AudioClip audioClip)
|
|
129
|
-
{
|
|
130
|
-
EnsureDecompressOnLoad(audioClip);
|
|
131
|
-
try
|
|
132
|
-
{
|
|
133
|
-
LoadAudioInternal(audioClip);
|
|
134
|
-
}
|
|
135
|
-
catch (Exception ex)
|
|
136
|
-
{
|
|
137
|
-
GDKUtils.ThrowExceptionIfEditor(ex.ToString());
|
|
138
|
-
}
|
|
139
|
-
return this;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
partial class GDKAudio : MonoBehaviour
|
|
144
|
-
{
|
|
145
|
-
private AudioSource audioSource;
|
|
146
|
-
|
|
147
|
-
private void Awake()
|
|
148
|
-
{
|
|
149
|
-
if (audioSource != null) return;
|
|
150
|
-
audioSource = GetComponent<AudioSource>();
|
|
151
|
-
if (audioSource == null)
|
|
152
|
-
{
|
|
153
|
-
audioSource = gameObject.AddComponent<AudioSource>();
|
|
154
|
-
}
|
|
155
|
-
if (gameObject.GetComponents<AudioSource>().Length > 1)
|
|
156
|
-
{
|
|
157
|
-
GDKUtils.ThrowExceptionIfEditor("GDKAudio only allows the GameObject to contain a single AudioSource component.");
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if (gameObject.GetComponents<GDKAudio>().Length > 1)
|
|
161
|
-
{
|
|
162
|
-
GDKUtils.ThrowExceptionIfEditor("GDKAudio only allows the GameObject to contain a single GDKAudio component.");
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
private void Update()
|
|
167
|
-
{
|
|
168
|
-
// NOTE: AudioListener.volume can only be called in Main-Thread
|
|
169
|
-
globalVolume = AudioListener.volume;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
private void OnDestroy()
|
|
173
|
-
{
|
|
174
|
-
Stop();
|
|
175
|
-
if (!initialized) return;
|
|
176
|
-
FreeMemory(ptrL, ptrR);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
internal static void EnsureDecompressOnLoad(AudioClip clip)
|
|
180
|
-
{
|
|
181
|
-
if (clip != null && clip.loadType != AudioClipLoadType.DecompressOnLoad)
|
|
182
|
-
{
|
|
183
|
-
GDKUtils.ThrowExceptionIfEditor("GDKAudio only supports AudioClips with Load Type set to Decompress On Load.");
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
#if SUPPORTED_PLATFORMS
|
|
189
|
-
partial class GDKAudio
|
|
190
|
-
{
|
|
191
|
-
public int numSamples { get; private set; }
|
|
192
|
-
public int numChannels { get; private set; }
|
|
193
|
-
public int sampleRate { get; private set; } = 44100;
|
|
194
|
-
public int numFrames { get; private set; } = 1;
|
|
195
|
-
public float time
|
|
196
|
-
{
|
|
197
|
-
get => timeSamples / (float)sampleRate;
|
|
198
|
-
set => timeSamples = (int)(value * sampleRate);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
private int timeSamples
|
|
202
|
-
{
|
|
203
|
-
get => idxFrame * hop;
|
|
204
|
-
set => SetPlaybackFrame(value / hop);
|
|
205
|
-
}
|
|
206
|
-
private float _volume = 1f;
|
|
207
|
-
|
|
208
|
-
public float volume
|
|
209
|
-
{
|
|
210
|
-
get => _volume;
|
|
211
|
-
set => _volume = Mathf.Clamp01(value);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
private float[] audioData;
|
|
216
|
-
|
|
217
|
-
private int bufferLength;
|
|
218
|
-
private int numBuffer;
|
|
219
|
-
|
|
220
|
-
private int nFFT = 2048;
|
|
221
|
-
private int hop = 512;
|
|
222
|
-
private int cntSave = 0;
|
|
223
|
-
private int idxFrame { get; set; } = 0;
|
|
224
|
-
private float[] hopFrame;
|
|
225
|
-
private float[] dataOut;
|
|
226
|
-
private float[] dataOutSave;
|
|
227
|
-
|
|
228
|
-
#if UNITY_IOS && !UNITY_EDITOR
|
|
229
|
-
private const string LIBRARY_NAME ="__Internal";
|
|
230
|
-
#else
|
|
231
|
-
private const string LIBRARY_NAME = "atensor";
|
|
232
|
-
#endif
|
|
233
|
-
|
|
234
|
-
[DllImport(LIBRARY_NAME, EntryPoint = "ptrResampleMulti")]
|
|
235
|
-
private static extern int ResampleMulti(float[] inData, ref IntPtr outData, float fs, float targetFs, int numSrcSamples, int numChannels, ref IntPtr ptrL);
|
|
236
|
-
|
|
237
|
-
[DllImport(LIBRARY_NAME, EntryPoint = "ptrTSM_Init")]
|
|
238
|
-
private static extern void TSM_Init(float[] firstFrame, float scale, float fs, int numChannel, int nFft, int hop, ref IntPtr ptrL, ref IntPtr ptrR);
|
|
239
|
-
|
|
240
|
-
[DllImport(LIBRARY_NAME, EntryPoint = "ptrTSM_Processing")]
|
|
241
|
-
private static extern int TSM_Processing(float[] inData, float[] outData, float scale, IntPtr ptrL, IntPtr ptrR);
|
|
242
|
-
|
|
243
|
-
[DllImport(LIBRARY_NAME, EntryPoint = "ptrFreeMemory")]
|
|
244
|
-
private static extern void FreeMemory(IntPtr ptrL, IntPtr ptrR);
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
private IntPtr ptrL;
|
|
248
|
-
private IntPtr ptrR;
|
|
249
|
-
private bool initialized = false;
|
|
250
|
-
|
|
251
|
-
internal void LoadAudioInternal(AudioClip audioClip)
|
|
252
|
-
{
|
|
253
|
-
AudioSettings.GetDSPBufferSize(out bufferLength, out numBuffer);
|
|
254
|
-
hop = Mathf.Min(bufferLength, 512);
|
|
255
|
-
numSamples = audioClip.samples;
|
|
256
|
-
numChannels = audioClip.channels;
|
|
257
|
-
sampleRate = audioClip.frequency;
|
|
258
|
-
|
|
259
|
-
if (numChannels < 2)
|
|
260
|
-
{
|
|
261
|
-
numChannels = 2;
|
|
262
|
-
audioData = new float[numSamples * numChannels];
|
|
263
|
-
audioClip.GetData(audioData, 0);
|
|
264
|
-
for (int i = numSamples - 1; i > 0; --i)
|
|
265
|
-
{
|
|
266
|
-
audioData[i * 2] = audioData[i];
|
|
267
|
-
audioData[(i * 2) - 1] = audioData[i];
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
else
|
|
271
|
-
{
|
|
272
|
-
audioData = new float[numSamples * numChannels];
|
|
273
|
-
audioClip.GetData(audioData, 0);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
// Do resampling
|
|
278
|
-
if (sampleRate != AudioSettings.outputSampleRate)
|
|
279
|
-
{
|
|
280
|
-
var audioDataResample = new IntPtr();
|
|
281
|
-
numSamples = ResampleMulti(
|
|
282
|
-
audioData,
|
|
283
|
-
ref audioDataResample,
|
|
284
|
-
sampleRate,
|
|
285
|
-
AudioSettings.outputSampleRate,
|
|
286
|
-
numSamples * numChannels,
|
|
287
|
-
numChannels,
|
|
288
|
-
ref ptrL
|
|
289
|
-
) / numChannels;
|
|
290
|
-
audioData = new float[numSamples * numChannels];
|
|
291
|
-
Marshal.Copy(audioDataResample, audioData, 0, numSamples * numChannels);
|
|
292
|
-
sampleRate = AudioSettings.outputSampleRate;
|
|
293
|
-
LogWarning(
|
|
294
|
-
$"Warning: The input AudioClip has a sample rate of {sampleRate} Hz," +
|
|
295
|
-
$" which does not match AudioSetting sample rate of {AudioSettings.outputSampleRate} Hz." +
|
|
296
|
-
" GDKAudio will resample the audio to match AudioSetting with high memory usage." +
|
|
297
|
-
" We recommend resampling the audio to 44100 Hz before using it in Unity."
|
|
298
|
-
);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
numFrames = (numSamples - nFFT) / hop;
|
|
302
|
-
|
|
303
|
-
Log(
|
|
304
|
-
$"[AAA] audioData: {audioData.Length}\n" +
|
|
305
|
-
$"[AAA] numSamples: {numSamples}\n" +
|
|
306
|
-
$"[AAA] numChannel: {numChannels}\n" +
|
|
307
|
-
$"[AAA] bufferLength: {bufferLength}\n" +
|
|
308
|
-
$"[AAA] numBuffer: {numBuffer}\n" +
|
|
309
|
-
$"[AAA] numFrames: {numFrames}"
|
|
310
|
-
);
|
|
311
|
-
|
|
312
|
-
// Initialize
|
|
313
|
-
Log("[AAA]TSM_Init");
|
|
314
|
-
TSM_Init(audioData, speed, sampleRate, numChannels, nFFT, hop, ref ptrL, ref ptrR);
|
|
315
|
-
|
|
316
|
-
initialized = true;
|
|
317
|
-
hopFrame = new float[hop * numChannels];
|
|
318
|
-
dataOut = new float[4 * numChannels * hop]; // minimum of scale is 0.25
|
|
319
|
-
dataOutSave = new float[numChannels * bufferLength];
|
|
320
|
-
|
|
321
|
-
audioSource.clip = audioClip;
|
|
322
|
-
audioSource.loop = loop;
|
|
323
|
-
Log($"[AAA]AudioSettings.outputSampleRate (later): {AudioSettings.outputSampleRate}");
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
private void OnAudioFilterRead(float[] data, int channels)
|
|
327
|
-
{
|
|
328
|
-
if (!isPlaying) return;
|
|
329
|
-
|
|
330
|
-
if (idxFrame >= numFrames)
|
|
331
|
-
{
|
|
332
|
-
if (!loop)
|
|
333
|
-
{
|
|
334
|
-
for (int i = 0; i < bufferLength * numChannels; i++)
|
|
335
|
-
{
|
|
336
|
-
data[i] = 0;
|
|
337
|
-
}
|
|
338
|
-
return;
|
|
339
|
-
}
|
|
340
|
-
idxFrame = 0;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
int lengthOut = 0;
|
|
345
|
-
int lengthOutOld = 0;
|
|
346
|
-
int idxSave = 0;
|
|
347
|
-
int muteModifier = mute ? 0 : 1;
|
|
348
|
-
float volumeModifier = muteModifier * volume * globalVolume;
|
|
349
|
-
|
|
350
|
-
for (; idxSave < cntSave; idxSave++)
|
|
351
|
-
{
|
|
352
|
-
data[idxSave] = dataOutSave[idxSave];
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
cntSave = 0;
|
|
356
|
-
|
|
357
|
-
while (lengthOut < bufferLength * numChannels - idxSave)
|
|
358
|
-
{
|
|
359
|
-
if (idxFrame >= numFrames) break;
|
|
360
|
-
|
|
361
|
-
Array.Copy(
|
|
362
|
-
audioData,
|
|
363
|
-
nFFT * numChannels + idxFrame * hop * numChannels,
|
|
364
|
-
hopFrame,
|
|
365
|
-
0,
|
|
366
|
-
hop * numChannels);
|
|
367
|
-
int temp = TSM_Processing(hopFrame, dataOut, speed, ptrL, ptrR);
|
|
368
|
-
lengthOut = lengthOutOld + temp;
|
|
369
|
-
for (int i = lengthOutOld; i < lengthOut; i++)
|
|
370
|
-
{
|
|
371
|
-
if (i < bufferLength * numChannels - idxSave)
|
|
372
|
-
{
|
|
373
|
-
data[i + idxSave] = dataOut[i - lengthOutOld] * volumeModifier;
|
|
374
|
-
}
|
|
375
|
-
else
|
|
376
|
-
{
|
|
377
|
-
dataOutSave[i + idxSave - bufferLength * numChannels] = dataOut[i - lengthOutOld] * volumeModifier;
|
|
378
|
-
cntSave++;
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
lengthOutOld = lengthOut;
|
|
382
|
-
idxFrame++;
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
private void SetSpeedInternal()
|
|
387
|
-
{
|
|
388
|
-
// This method is intentionally left empty;
|
|
389
|
-
return;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
private void StopInternal()
|
|
393
|
-
{
|
|
394
|
-
idxFrame = 0;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
private void SetPlaybackFrame(int frame)
|
|
398
|
-
{
|
|
399
|
-
frame = Mathf.Clamp(frame, 0, numFrames - 1);
|
|
400
|
-
idxFrame = frame;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
public float GetAudioDurationInSec()
|
|
404
|
-
{
|
|
405
|
-
return numFrames * hop / sampleRate;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
}
|
|
409
|
-
#else
|
|
410
|
-
#warning "GDKAudio is not supported on this platform. You can still use GDKAudio, but it will fallback to changing AudioSource.pitch"
|
|
411
|
-
partial class GDKAudio
|
|
412
|
-
{
|
|
413
|
-
public int numSamples => audioSource.clip.samples;
|
|
414
|
-
public int numChannels => audioSource.clip.channels;
|
|
415
|
-
public int sampleRate => audioSource.clip.frequency;
|
|
416
|
-
public int numFrames => numSamples;
|
|
417
|
-
|
|
418
|
-
public float time
|
|
419
|
-
{
|
|
420
|
-
get => audioSource.time;
|
|
421
|
-
set => audioSource.time = value;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
public float volume
|
|
425
|
-
{
|
|
426
|
-
get => audioSource.volume;
|
|
427
|
-
set => audioSource.volume = value;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
private AudioMixer audioMixer;
|
|
431
|
-
|
|
432
|
-
// These attributes are intentionally left unused for compatibility.
|
|
433
|
-
private readonly IntPtr ptrL;
|
|
434
|
-
private readonly IntPtr ptrR;
|
|
435
|
-
private bool initialized = false;
|
|
436
|
-
|
|
437
|
-
internal void LoadAudioInternal(AudioClip audioClip)
|
|
438
|
-
{
|
|
439
|
-
audioMixer = Resources.Load("GDKAudioMixer") as AudioMixer;
|
|
440
|
-
audioSource.clip = audioClip;
|
|
441
|
-
audioSource.loop = loop;
|
|
442
|
-
audioSource.outputAudioMixerGroup = audioMixer.FindMatchingGroups("PitchShifter")[0];
|
|
443
|
-
SetSpeedInternal();
|
|
444
|
-
initialized = true;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
#pragma warning disable IDE0060
|
|
448
|
-
private static void FreeMemory(IntPtr ptrL, IntPtr ptrR)
|
|
449
|
-
{
|
|
450
|
-
// This method is intentionally left empty.
|
|
451
|
-
return;
|
|
452
|
-
}
|
|
453
|
-
#pragma warning restore IDE0060
|
|
454
|
-
|
|
455
|
-
private void SetSpeedInternal()
|
|
456
|
-
{
|
|
457
|
-
audioSource.pitch = speed;
|
|
458
|
-
audioMixer.SetFloat("GDKAudioMixer_PitchShifter_Pitch", 1.0f / speed);
|
|
459
|
-
|
|
460
|
-
// Note: using AudioMixer's Pitch Shifter effect makes the audio a bit louder.
|
|
461
|
-
if (speed != 1.0f)
|
|
462
|
-
{
|
|
463
|
-
audioMixer.SetFloat("GDKAudioMixer_PitchShifter_Wet", 0.0f); // disable bypass
|
|
464
|
-
}
|
|
465
|
-
else
|
|
466
|
-
{
|
|
467
|
-
audioMixer.SetFloat("GDKAudioMixer_PitchShifter_Wet", -80.0f); // enable bypass
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
private void StopInternal()
|
|
472
|
-
{
|
|
473
|
-
// This method is intentionally left empty.
|
|
474
|
-
return;
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
public float GetAudioDurationInSec()
|
|
478
|
-
{
|
|
479
|
-
return audioSource.clip.length;
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
#endif
|
|
483
|
-
}
|
|
Binary file
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: cf93944c80cc4155b610a203aa4692ed
|
|
3
|
-
PluginImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
serializedVersion: 2
|
|
6
|
-
iconMap: {}
|
|
7
|
-
executionOrder: {}
|
|
8
|
-
defineConstraints: []
|
|
9
|
-
isPreloaded: 0
|
|
10
|
-
isOverridable: 0
|
|
11
|
-
isExplicitlyReferenced: 0
|
|
12
|
-
validateReferences: 1
|
|
13
|
-
platformData:
|
|
14
|
-
- first:
|
|
15
|
-
Android: Android
|
|
16
|
-
second:
|
|
17
|
-
enabled: 1
|
|
18
|
-
settings: {}
|
|
19
|
-
- first:
|
|
20
|
-
Any:
|
|
21
|
-
second:
|
|
22
|
-
enabled: 0
|
|
23
|
-
settings: {}
|
|
24
|
-
- first:
|
|
25
|
-
Editor: Editor
|
|
26
|
-
second:
|
|
27
|
-
enabled: 0
|
|
28
|
-
settings:
|
|
29
|
-
DefaultValueInitialized: true
|
|
30
|
-
userData:
|
|
31
|
-
assetBundleName:
|
|
32
|
-
assetBundleVariant:
|
|
Binary file
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: a3c265b10d9ed4cf6990662d42f4ac14
|
|
3
|
-
PluginImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
serializedVersion: 2
|
|
6
|
-
iconMap: {}
|
|
7
|
-
executionOrder: {}
|
|
8
|
-
defineConstraints: []
|
|
9
|
-
isPreloaded: 0
|
|
10
|
-
isOverridable: 0
|
|
11
|
-
isExplicitlyReferenced: 0
|
|
12
|
-
validateReferences: 1
|
|
13
|
-
platformData:
|
|
14
|
-
- first:
|
|
15
|
-
: Any
|
|
16
|
-
second:
|
|
17
|
-
enabled: 0
|
|
18
|
-
settings:
|
|
19
|
-
Exclude Android: 1
|
|
20
|
-
Exclude Editor: 1
|
|
21
|
-
Exclude Linux64: 1
|
|
22
|
-
Exclude OSXUniversal: 1
|
|
23
|
-
Exclude Win: 1
|
|
24
|
-
Exclude Win64: 1
|
|
25
|
-
Exclude iOS: 0
|
|
26
|
-
- first:
|
|
27
|
-
Any:
|
|
28
|
-
second:
|
|
29
|
-
enabled: 0
|
|
30
|
-
settings: {}
|
|
31
|
-
- first:
|
|
32
|
-
Editor: Editor
|
|
33
|
-
second:
|
|
34
|
-
enabled: 0
|
|
35
|
-
settings:
|
|
36
|
-
DefaultValueInitialized: true
|
|
37
|
-
- first:
|
|
38
|
-
Standalone: Linux64
|
|
39
|
-
second:
|
|
40
|
-
enabled: 0
|
|
41
|
-
settings:
|
|
42
|
-
CPU: None
|
|
43
|
-
- first:
|
|
44
|
-
Standalone: OSXUniversal
|
|
45
|
-
second:
|
|
46
|
-
enabled: 0
|
|
47
|
-
settings:
|
|
48
|
-
CPU: None
|
|
49
|
-
- first:
|
|
50
|
-
Standalone: Win
|
|
51
|
-
second:
|
|
52
|
-
enabled: 0
|
|
53
|
-
settings:
|
|
54
|
-
CPU: None
|
|
55
|
-
- first:
|
|
56
|
-
Standalone: Win64
|
|
57
|
-
second:
|
|
58
|
-
enabled: 0
|
|
59
|
-
settings:
|
|
60
|
-
CPU: None
|
|
61
|
-
- first:
|
|
62
|
-
iPhone: iOS
|
|
63
|
-
second:
|
|
64
|
-
enabled: 1
|
|
65
|
-
settings: {}
|
|
66
|
-
userData:
|
|
67
|
-
assetBundleName:
|
|
68
|
-
assetBundleVariant:
|
|
Binary file
|