Skip to content

Commit

Permalink
Chore: Remove interfaces, and add files for packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
legoeruro committed Oct 24, 2024
1 parent ff40ec9 commit dc011a1
Show file tree
Hide file tree
Showing 39 changed files with 95 additions and 187 deletions.
4 changes: 3 additions & 1 deletion unity/Assets/ARFlowPackage/ARFlow/ARFlow.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"GUID:c3bc0afe4a069b54aa23296f3c18a871",
"GUID:21b0c8d1703a94250bfac916590cea4f",
"GUID:75469ad4d38634e559750d17036d5f7c",
"GUID:92703082f92b41ba80f0d6912de66115"
"GUID:92703082f92b41ba80f0d6912de66115",
"GUID:8a68004c08665e8449ab651ffdc7bee0",
"GUID:1504f36c4fe570349afad1ff2291fbd0"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
12 changes: 5 additions & 7 deletions unity/Assets/ARFlowPackage/ARFlow/ARFlowClientManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public class ARFlowClientManager
private bool _isStreaming = false;

// Interfaces for implementations using other packages
private IAudioStreaming _audioStreaming;
private IMeshEncoder _meshEncoder;
private AudioStreaming _audioStreaming;
private MeshEncoder _meshEncoder;

//TODO
//private Dictionary<string, Dictionary<string, Any>> _modalityConfig
Expand Down Expand Up @@ -76,9 +76,7 @@ public ARFlowClientManager(
ARCameraManager cameraManager = null,
AROcclusionManager occlusionManager = null,
ARPlaneManager planeManager = null,
ARMeshManager meshManager = null,
IAudioStreaming audioStreaming = null,
IMeshEncoder meshEncoder = null
ARMeshManager meshManager = null
)
{
if (UnityEngine.InputSystem.Gyroscope.current != null)
Expand All @@ -103,8 +101,8 @@ public ARFlowClientManager(
_planeManager = planeManager;
_meshManager = meshManager;

_audioStreaming = audioStreaming;
_meshEncoder = meshEncoder;
_audioStreaming = new AudioStreaming();
_meshEncoder = new MeshEncoder();

#if UNITY_ANDROID
if (!Permission.HasUserAuthorizedPermission(Permission.Microphone))
Expand Down
54 changes: 54 additions & 0 deletions unity/Assets/ARFlowPackage/ARFlow/AudioStreaming.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

using Pv.Unity;

namespace ARFlow
{
public class AudioStreaming
{
private List<float> _unsentFrames;

public List<float> GetFrames()
{
return _unsentFrames;
}

public AudioStreaming()
{
_unsentFrames = new List<float>();
}

/// <summary>
/// Since Unity's microphone implementation requires calling "start" and "end", we need
/// a call to start microphone recording
/// </summary>
public void InitializeAudioRecording(int sampleRate, int frameLength)
{
VoiceProcessor.Instance.StartRecording(frameLength, sampleRate);
VoiceProcessor.Instance.AddFrameListener(UpdateCurrentAudioFrame);
}

/// <summary>
/// Our point is that we only want to send the current frame, not all frames that might be sent.
/// </summary>
/// <param name="frame"></param>
private void UpdateCurrentAudioFrame(float[] frame)
{
_unsentFrames.AddRange(frame);
}

public void ClearFrameList()
{
_unsentFrames.Clear();
}

public void DisposeAudioRecording()
{
VoiceProcessor.Instance.StopRecording();
}
}


}
36 changes: 0 additions & 36 deletions unity/Assets/ARFlowPackage/ARFlow/Interfaces/IAudioStreaming.cs

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions unity/Assets/ARFlowPackage/ARFlow/Interfaces/IMeshEncoder.cs

This file was deleted.

11 changes: 0 additions & 11 deletions unity/Assets/ARFlowPackage/ARFlow/Interfaces/IMeshEncoder.cs.meta

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"name": "MeshingEncoderAssembly",
"rootNamespace": "",
"references": [
"GUID:411961ebab96043d8a061c656d3a461c",
"GUID:32105e0090382574e9f663b4802eb134"
"GUID:411961ebab96043d8a061c656d3a461c"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
25 changes: 25 additions & 0 deletions unity/Assets/ARFlowPackage/ARFlow/MeshingEncode/MeshEncoder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

using Draco.Encoder;
using Unity.Collections;

namespace ARFlow
{
public class MeshEncoder
{
public List<NativeArray<byte>> EncodeMesh(Mesh mesh)
{
EncodeResult[] result = DracoEncoder.EncodeMesh(mesh);
List<NativeArray<byte>> ret = new();
foreach (EncodeResult item in result)
{
ret.Add(item.data);
}
return ret;
}
}

}

21 changes: 0 additions & 21 deletions unity/Assets/ARFlowPackage/ARFlowDependencies/package.json

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions unity/Assets/Scenes/DeviceData.unity
Original file line number Diff line number Diff line change
Expand Up @@ -7334,7 +7334,7 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 518653703}
m_HandleRect: {fileID: 518653702}
m_Direction: 2
m_Value: -0.000014345874
m_Value: -0.000003912511
m_Size: 0.9417186
m_NumberOfSteps: 0
m_OnValueChanged:
Expand Down Expand Up @@ -13482,7 +13482,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 0}
m_AnchoredPosition: {x: -0.000076293945, y: -177.35057}
m_AnchoredPosition: {x: -0.000076293945, y: -177.35083}
m_SizeDelta: {x: -4.7499847, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &6234637625898487408
Expand Down
9 changes: 1 addition & 8 deletions unity/Assets/Scripts/ARFlowDeviceSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,17 @@ public class ARFlowDeviceSample : MonoBehaviour
private bool _isConnected = false;
private Task connectTask = null;

private IAudioStreaming _audioStreaming;
private IMeshEncoder _meshEncoder;
// Start is called before the first frame update
void Start()
{
connectButton.onClick.AddListener(OnConnectButtonClick);
startPauseButton.onClick.AddListener(OnStartPauseButtonClick);

_audioStreaming = new AudioStreaming();
_meshEncoder = new MeshEncoder();

_clientManager = new ARFlowClientManager(
cameraManager: cameraManager,
occlusionManager: occlusionManager,
planeManager: planeManager,
meshManager: meshManager,
audioStreaming: _audioStreaming,
meshEncoder: _meshEncoder
meshManager: meshManager
);

AddModalityOptionsToConfig();
Expand Down
51 changes: 0 additions & 51 deletions unity/Assets/Scripts/Utils/AudioStreaming.cs

This file was deleted.

22 changes: 0 additions & 22 deletions unity/Assets/Scripts/Utils/MeshingEncode/MeshingEncoder.cs

This file was deleted.

0 comments on commit dc011a1

Please sign in to comment.