コード例 #1
0
        void Start()
        {
            // Check if total OUTPUTS correspond to existing OUTPUTS
            // outSources = FindObjectsOfType<JackSourceSend>();
            // Debug.Assert(outSources.Length == OUTPUTS, "Tracks (" + outSources.Length + ") dont correspond to total multiplexed OUTPUTS, adjusting total OUTPUTS.");
            // OUTPUTS = outSources.Length;

            // TODO: Check if assigned track number is unique


            // TODO: Check if source number exceeds OUTPUTS

            /*
             * var faultSources = outSources.Where(g => g.trackNumber > OUTPUTS);
             * foreach (var src in faultSources) {
             *  src.enabled = false;
             * }
             */

            /* Allocate memory for streams */
            combinedBuffers = new float[OUTPUTS][];
            for (int i = 0; i < OUTPUTS; i++)
            {
                combinedBuffers[i] = new float[BUFFER_SIZE];
            }

            mixedBufferOut = new float[OUTPUTS * BUFFER_SIZE];
            mixedBufferIn  = new float[INPUTS * BUFFER_SIZE];

            // Start Engine
            JackWrapper.StartJackClient(INPUTS, OUTPUTS);
            started = true;
        }
コード例 #2
0
        /// <summary>
        /// Main Audio mixer
        /// </summary>
        /// <param name="buffer"></param>
        /// <param name="channels"></param>
        void OnAudioFilterRead(float[] buffer, int channels)
        {
            if (!started || useEffects)
            {
                return;
            }

            // We need to convert the jagged array to a one dimesional array
            // float[] mixedBufferIn = combinedBuffers.SelectMany(x => x).ToArray();
            // JackWrapper.SetAudioBuffer(ref combinedBuffers[0][0]);
            // float[] debugbuffer = combinedBuffers[0];

            // TODO: It is possible to send planar data instead.
            // That would spare iterating over the samples

            for (int j = 0; j < OUTPUTS; j++)
            {
                for (int i = 0; i < BUFFER_SIZE; i++)
                {
                    mixedBufferOut[(i * OUTPUTS) + j] = combinedBuffers[j][i];
                }
            }

            JackWrapper.SetMixedData(mixedBufferOut);
            JackWrapper.GetMixedData(mixedBufferIn);

            // System.Array.Clear(buffer, 0, buffer.Length);
        }
コード例 #3
0
 public static void Initialize()
 {
     if (!installed)
     {
         JackWrapper.RegisterLogCallback(OnLogCallback);
         installed = true;
     }
 }
コード例 #4
0
 void Start()
 {
     bufferSize      = JackWrapper.GeBufferSize();
     monodata        = new float[bufferSize]; //this has to be set from options
     monodataHandler = GCHandle.Alloc(monodata, GCHandleType.Pinned);
     generateDummyClip();
     started = true;
 }
コード例 #5
0
        void Start()
        {
            bufferSize = JackWrapper.GeBufferSize();
            monodata   = new float[bufferSize];

            // The buffer passed to jack must be pinned to memory otherwise it is possible that the GC
            // will free the buffer while jack is still using it
            monodataHandler = GCHandle.Alloc(monodata, GCHandleType.Pinned);
            System.Array.Clear(monodata, 0, monodata.Length);
            started = true;
        }
コード例 #6
0
        void OnGUI()
        {
            if (!activated)
            {
                GUI.backgroundColor = Color.red;
            }
            else
            {
                GUI.backgroundColor = Color.green;
            }

            GUILayout.BeginVertical(GUI.skin.box);
            GUILayout.EndVertical();
            GUI.backgroundColor = Color.white;

            if (GUILayout.Button("Connect to Jack Server"))
            {
                int numbuffers;
                int bufferSize;
                AudioSettings.GetDSPBufferSize(out bufferSize, out numbuffers);
                AudioConfiguration config = AudioSettings.GetConfiguration();

                JackLogger.Initialize();
                if (JackWrapper.CreateClient((uint)bufferSize, (uint)config.sampleRate))
                {
                    JackWrapper.RegisterPorts((uint)inputs, (uint)outputs);
                    activated = JackWrapper.ActivateClient();
                }
            }

            if (GUILayout.Button("Disconnect from Jack Server"))
            {
                if (JackWrapper.DestroyClient())
                {
                    activated = false;
                }
            }

            GUILayout.Label("Base Settings", EditorStyles.boldLabel);
            inputs  = Mathf.Clamp(EditorGUILayout.IntField("Inputs", inputs), inputsRange.start, inputsRange.end);
            outputs = Mathf.Clamp(EditorGUILayout.IntField("Outputs", outputs), outputsRange.start, outputsRange.end);

            // groupEnabled = EditorGUILayout.BeginToggleGroup("Optional Settings", groupEnabled);
            // inputs = EditorGUILayout.IntField("Inputs", inputs);
            // outputs = EditorGUILayout.IntField("Outputs", outputs);
            // EditorGUILayout.EndToggleGroup();
        }
コード例 #7
0
        void OnAudioFilterRead(float[] buffer, int channels)
        {
            if (!started)
            {
                return;
            }
            if (buffer.Length != bufferSize)
            {
                Debug.LogError("buffer size does not match jack"); return;
            }
            if (channels != 1)
            {
                Debug.LogError("jack can only accept mono"); return;
            }

            JackWrapper.ReadBuffer(port, buffer, bufferSize);
            // System.Array.Copy(monodata,buffer,bufferSize);
        }
コード例 #8
0
        void OnAudioFilterRead(float[] buffer, int channels)
        {
            if (!started)
            {
                return;
            }
            if (buffer.Length != bufferSize)
            {
                Debug.LogError("buffer size does not match jack"); return;
            }
            if (channels != 1)
            {
                Debug.LogError("jack can only accept mono"); return;
            }

            // It is neccesary to make a copy here because the data is managed and will be deleted
            // after the call is finished or before
            System.Array.Copy(buffer, monodata, buffer.Length);
            JackWrapper.WriteBuffer(port, monodata, monodata.Length);
            System.Array.Clear(buffer, 0, buffer.Length);
        }
コード例 #9
0
 void OnDestroy()
 {
     System.Array.Clear(monodata, 0, bufferSize);
     JackWrapper.WriteBuffer(port, monodata, bufferSize);
     monodataHandler.Free();
 }
コード例 #10
0
 void OnDestroy()
 {
     // if (!useEffects) JackWrapper.DestroyJackClient();
     JackWrapper.DestroyJackClient();
 }