Open Organicdareal opened 3 years ago
I ended up making my own custom spatializer in c#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Syntacts;
using static VibrationManager;
public class CustomSpatializer : MonoBehaviour
{
public Vector2 target;
public Vector2 interval;
public float radius;
public float generalVolume;
public AnimationCurve rollOffCurve;
public SyntactsHub hub;
private Dictionary<SyntactsChannel, Vector2> positions = new Dictionary<SyntactsChannel, Vector2>();
public void setChannelPosition(SyntactsChannel channel, Vector2 position) {
this.positions.Add(channel, position);
}
void Update() {
foreach (SyntactsChannel channel in this.positions.Keys) {
Vector2 v;
v.x = this.interval.x > 0
? this.wrappedDifference(this.positions[channel].x, this.target.x, this.interval.x)
: this.positions[channel].x - this.target.x;
v.y = this.interval.y > 0
? this.wrappedDifference(this.positions[channel].y, this.target.y, this.interval.y)
: this.positions[channel].y - this.target.y;
float d = Mathf.Sqrt(v.x * v.x + v.y * v.y);
float vol = 1.0f - Mathf.Clamp01(d / this.radius);
vol = this.rollOffCurve.Evaluate(vol);
vol *= this.generalVolume;
this.hub.session.SetVolume((int)channel, vol);
}
}
private float wrappedDifference(float p1, float p2, float interval) {
return p1 - p2 - Mathf.Floor(((p1 - p2) + interval * 0.5f) / interval) * interval;
}
public void Play(Signal signal) {
foreach (SyntactsChannel channel in this.positions.Keys) {
this.hub.session.Play((int)channel, signal);
}
}
public void Stop() {
foreach (SyntactsChannel channel in this.positions.Keys) {
this.hub.session.Stop((int)channel);
}
}
public void SetPitch(float pitch) {
foreach (SyntactsChannel channel in this.positions.Keys) {
this.hub.session.SetPitch((int)channel, pitch);
}
}
}
Hi, i work on a unity project (2019.4.28) and i use the latest version of Syntacts (1.3.0). I want to create 2 spatializers with my 8 channels sound card. I use the syntactsHub as in the documentation and examples, but whenever i want to create a grid on a spatializer, it works one time and crashes the next launch with this stack trace:
GUI works fine with the spatializer.