generated from RageAgainstThePixel/upm-template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
com.utilities.encoder.wav 1.2.0 (#7)
- Updated com.utilities.audio -> 1.2.0 - Fixed microphone always using "default" recording device (Now properly uses the device set by RecordingManager) - Added support for WebGL microphone recording - Adds ability to stream recording without saving to disk - Updated sample scene (now requires TextMeshPro)
- Loading branch information
1 parent
aed4164
commit 7fb8364
Showing
16 changed files
with
2,545 additions
and
490 deletions.
There are no files selected for viewing
This file contains 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains 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,61 @@ | ||
using System.Linq; | ||
using TMPro; | ||
using UnityEngine; | ||
using Utilities.Audio; | ||
using Microphone = Utilities.Audio.Microphone; | ||
|
||
namespace Utilities.Encoder.Wav.Samples.Recording | ||
{ | ||
[RequireComponent(typeof(TMP_Dropdown))] | ||
public class MicrophoneDropdownSelector : MonoBehaviour | ||
{ | ||
[SerializeField] | ||
private TMP_Dropdown dropdown; | ||
|
||
private void OnValidate() | ||
{ | ||
if (dropdown == null) | ||
{ | ||
dropdown = GetComponent<TMP_Dropdown>(); | ||
} | ||
} | ||
|
||
private void Awake() | ||
{ | ||
dropdown.onValueChanged.AddListener(OnDeviceSelected); | ||
} | ||
|
||
private void OnEnable() | ||
{ | ||
RefreshDeviceList(); | ||
} | ||
|
||
private void Update() | ||
{ | ||
if (Microphone.devices.Length != dropdown.options.Count) | ||
{ | ||
RefreshDeviceList(); | ||
} | ||
} | ||
|
||
private void OnDestroy() | ||
{ | ||
dropdown.onValueChanged.RemoveListener(OnDeviceSelected); | ||
} | ||
|
||
public void RefreshDeviceList() | ||
{ | ||
dropdown.ClearOptions(); | ||
var dropdownOptions = Microphone.devices.Select(device => new TMP_Dropdown.OptionData(device)).ToList(); | ||
dropdown.AddOptions(dropdownOptions); | ||
} | ||
|
||
private void OnDeviceSelected(int index) | ||
{ | ||
if (index < 0) { return; } | ||
var selectedDevice = Microphone.devices[index]; | ||
Debug.Log(selectedDevice); | ||
RecordingManager.DefaultRecordingDevice = selectedDevice; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.