Skip to content

Commit 7b6123f

Browse files
authored
Merge pull request #14 from neocortex-link/feature/audio-receiver-fixes
Microphone Selection Logic Update
2 parents b03a731 + 93d72ae commit 7b6123f

File tree

5 files changed

+11
-13
lines changed

5 files changed

+11
-13
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
8+
## [0.3.5] - 26 April 2025
9+
- Neocortex Audio Receiver microphone picker improvements
10+
711
## [0.3.4] - 21 February 2025
812
- Webrequest progress property and cancellation support
913

Editor/AudioReceiverEditor.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ namespace Neocortex.Editor
66
[CustomEditor(typeof(AudioReceiver), true)]
77
public class AudioReceiverEditor : UnityEditor.Editor
88
{
9-
private const string MIC_INDEX_KEY = "neocortex-mic-index";
10-
119
private string[] microphoneOptions;
1210
private int selectedMicrophoneIndex;
1311

@@ -17,12 +15,7 @@ public class AudioReceiverEditor : UnityEditor.Editor
1715
private void OnEnable()
1816
{
1917
microphoneOptions = Microphone.devices;
20-
selectedMicrophoneIndex = PlayerPrefs.GetInt(MIC_INDEX_KEY, 0);
21-
22-
AudioReceiver audioReceiver = (AudioReceiver)target;
23-
24-
if(audioReceiver is NeocortexAudioReceiver neocortexAudioReceiver)
25-
neocortexAudioReceiver.SelectedMicrophone = microphoneOptions[selectedMicrophoneIndex];
18+
selectedMicrophoneIndex = PlayerPrefs.GetInt(AudioReceiver.MIC_INDEX_KEY, 0);
2619

2720
onAudioRecorded = serializedObject.FindProperty("OnAudioRecorded");
2821
onRecordingFailed = serializedObject.FindProperty("OnRecordingFailed");
@@ -34,11 +27,10 @@ public override void OnInspectorGUI()
3427

3528
AudioReceiver audioReceiver = (AudioReceiver)target;
3629

37-
if (microphoneOptions is { Length: > 0 } && audioReceiver is NeocortexAudioReceiver neocortexAudioReceiver)
30+
if (microphoneOptions is { Length: > 0 } && audioReceiver is NeocortexAudioReceiver)
3831
{
3932
selectedMicrophoneIndex = EditorGUILayout.Popup("Select Microphone", selectedMicrophoneIndex, microphoneOptions);
40-
PlayerPrefs.SetInt(MIC_INDEX_KEY, selectedMicrophoneIndex);
41-
neocortexAudioReceiver.SelectedMicrophone = microphoneOptions[selectedMicrophoneIndex];
33+
PlayerPrefs.SetInt(AudioReceiver.MIC_INDEX_KEY, selectedMicrophoneIndex);
4234
}
4335
else
4436
{

Runtime/AudioReceiver.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
using System;
21
using UnityEngine;
32
using UnityEngine.Events;
43

54
namespace Neocortex
65
{
76
public abstract class AudioReceiver: MonoBehaviour
87
{
8+
public const string MIC_INDEX_KEY = "neocortex-mic-index";
9+
910
[SerializeField] private bool usePushToTalk;
1011
public bool UsePushToTalk { get => usePushToTalk; protected set => usePushToTalk = value; }
1112
public float Amplitude { get; protected set; }

Runtime/NeocortexAudioReceiver.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public override void StartMicrophone()
2222
{
2323
try
2424
{
25+
SelectedMicrophone = Microphone.devices[PlayerPrefs.GetInt(MIC_INDEX_KEY, 0)];
2526
audioClip = NeocortexMicrophone.Start(SelectedMicrophone, true, 999, FREQUENCY);
2627
initialized = true;
2728
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "link.neocortex.sdk",
3-
"version": "0.3.4",
3+
"version": "0.3.5",
44
"displayName": "Neocortex Unity SDK",
55
"description": "Conversational AI for Games Simplified. With Neocortex SDK, create dynamic in-game conversations with AI-powered smart characters using our node-based editor and SDKs.",
66
"unity": "2021.3",

0 commit comments

Comments
 (0)