Cycling74 / rnbo.unity.audioplugin

RNBO Adapter for Unity's Native Audio Plugin
MIT License
40 stars 8 forks source link

helper having trouble parsing parameters from polyphonic RNBO devices #8

Closed jinpavg closed 1 year ago

jinpavg commented 1 year ago

Export the feedback-synth from the RNBO tour, which has @polyphony 8 In Unity, try to use .GetParamIndexById("poly/delay/fb")

You'll get the following error:

ArgumentException: An item with the same key has already been added. Key: cutoff
System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <612a2c65aaf843d698f8d38b2ad7654a>:0)
System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) (at <612a2c65aaf843d698f8d38b2ad7654a>:0)
FeedbackPolyphonyGroupHandle.GetParamIndexById (System.String id) (at /Users/alexvangils/rnbo.unity.audioplugin/build/FeedbackPolyphonyGroup/Assets/Scripts/FeedbackPolyphonyGroupHelper.cs:297)
ExceptionTest..ctor () (at Assets/ExceptionTest.cs:9)

Which leads here:

    private static Dictionary<string, int> parameterIdToIndex;
    public static int? GetParamIndexById(string id) {
        if (parameterIdToIndex == null) {
            parameterIdToIndex = new Dictionary<string, int>();
            foreach (var p in Parameters) {
                parameterIdToIndex.Add(p.name, p.index);
            }
        }
        int index = 0;
        if (parameterIdToIndex.TryGetValue(id, out index)) {
            return index;
        }
        return null;
    }

plugin and script included below:

FeedbackPolyphonyGroup.zip

ExceptionTest.cs.zip

x37v commented 1 year ago

should be fixed if you pull main now and rebuild