Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access Violation with Spatializer #8

Open
Organicdareal opened this issue Oct 25, 2021 · 1 comment
Open

Access Violation with Spatializer #8

Organicdareal opened this issue Oct 25, 2021 · 1 comment

Comments

@Organicdareal
Copy link

Organicdareal commented Oct 25, 2021

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:

Unity Editor by Unity Technologies [version: Unity 2019.4.28f1_1381962e9d08]

Unknown caused an Access Violation (0xc0000005)
  in module Unknown at 0033:5c95c387.

Error occurred at 2021-10-25_150152.
C:\Program Files\Unity\Hub\Editor\2019.4.28f1\Editor\Unity.exe, run by .

44% physical memory in use.
16307 MB physical memory [9079 MB free].
2319 MB process peak paging file [1879 MB used].
946 MB process peak working set [945 MB used].
System Commit Total/Limit/Peak: 13312MB/18739MB/16204MB
System Physical Total/Available: 16307MB/9079MB
System Process Count: 211
System Thread Count: 2811
System Handle Count: 105342
Disk space data for 'C:\Users\\AppData\Local\Temp\Unity\Editor\Crashes\Crash_2021-10-25_130147719\': 294663950336 bytes free of 511451328512 total.

Write to location 0000000000000080 caused an access violation.

Context:
RDI:    0x0000000000000000  RSI: 0x000001d88cd19bd0  RAX:   0x0000000000000080
RBX:    0x000001d65b8ab300  RCX: 0x0000000000000001  RDX:   0x000001d82ebfce20
RIP:    0x000001d65c95c387  RBP: 0x0000001c6f96f310  SegCs: 0x000001d800000033
EFlags: 0x0000000000010202  RSP: 0x0000001c6f96f280  SegSs: 0x000001d80000002b
R8:     0x0000000000000000  R9:  0x0000000000000040  R10:   0x00000000000000c0
R11:    0x0000680000100000  R12: 0x0000000000000000  R13:   0x0000000000000000
R14:    0x000001d887cf73c0  R15: 0x000001d7e2b64240


Bytes at CS:EIP:
48 b8 50 ca 66 fc ff 7f 00 00 8b 00 85 c0 0f 84 

Mono DLL loaded successfully at 'C:\Program Files\Unity\Hub\Editor\2019.4.28f1\Editor\Data\MonoBleedingEdge\EmbedRuntime\mono-2.0-bdwgc.dll'.


Stack Trace of Crashed Thread 3848:
0x000001D65C95C387 (Assembly-CSharp) Syntacts.Dll.Spatializer_delete()
0x000001D65C95C1EB (Assembly-CSharp) Syntacts.Spatializer.Dispose()
0x000001D65C95C001 (Assembly-CSharp) Syntacts.Spatializer.Finalize()
0x000001D65B8AB46C (mscorlib) System.Object.runtime_invoke_virtual_void__this__()
0x00007FFFFC2E4E09 (mono-2.0-bdwgc) mono_gc_reference_queue_new
0x00007FFFFC2E3A8E (mono-2.0-bdwgc) mono_callspec_parse
0x00007FFFFC2E3CF5 (mono-2.0-bdwgc) mono_callspec_parse
0x00007FFFFC2A6BD8 (mono-2.0-bdwgc) mono_unity_managed_callstack
0x00007FFFFC2A6966 (mono-2.0-bdwgc) mono_unity_managed_callstack
0x00007FF877D07034 (KERNEL32) BaseThreadInitThunk
0x00007FF879D22651 (ntdll) RtlUserThreadStart

GUI works fine with the spatializer.

@Organicdareal
Copy link
Author

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);
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant