text:
using OscJack;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

namespace OscJack.VisualScripting {

[UnitCategory("OSC"), UnitTitle("OSC Input (float)")]
[RenamedFrom("Bolt.Addons.OscJack.OscFloatInput")]
public sealed class OscFloatInput
  : Unit, IGraphElementWithData, IGraphEventListener
{
    #region Data class

    public sealed class Data : IGraphElementData
    {
        public System.Action<EmptyEventArgs> UpdateAction { get; set; }
        public float LastValue { get; private set; }
        public bool IsOpened => _port != 0;
        public bool HasNewValue => _queue.Count > 0;

        int _port;
        string _address;
        Queue<float> _queue = new Queue<float>();

        public void Dequeue()
          => LastValue = _queue.Dequeue();

        public void UpdateConnection(OscConnection connection, string address)
        {
            if (IsOpened)
            {
                if (connection?.port == _port && address == _address)
                {
                    // The current connection is okay.
                }
                else
                {
                    // The destination was changed. Reopen the connection.
                    Close();
                    TryOpen(connection, address);
                }
            }
            else
            {
                // No connection. Open the connection.
                TryOpen(connection, address);
            }
        }

        void TryOpen(OscConnection connection, string address)
        {
            if (connection == null || string.IsNullOrEmpty(address)) return;

            _port = connection.port;
            _address = address;

            var server = OscMaster.GetSharedServer(_port);
            server.MessageDispatcher.AddCallback(_address, OnDataReceive);
        }

        public void Close()
        {
            var server = OscMaster.GetSharedServer(_port);
            server.MessageDispatcher.RemoveCallback(_address, OnDataReceive);

            _port = 0;
            _address = null;
            _queue.Clear();
        }

        void OnDataReceive(string address, OscDataHandle data)
        {
            lock (_queue) _queue.Enqueue(data.GetElementAsFloat(0));
        }
    }

    public IGraphElementData CreateData() => new Data();

    #endregion

    #region Unit I/O

    [DoNotSerialize]
    public ValueInput Connection { get; private set; }

    [DoNotSerialize]
    public ValueInput Address { get; private set; }

    [DoNotSerialize, PortLabelHidden]
    public ControlOutput Received { get; private set; }

    [DoNotSerialize, PortLabelHidden]
    public ValueOutput Value { get; private set; }

    #endregion

    #region Unit implementation

    protected override void Definition()
    {
        isControlRoot = true;
        Connection = ValueInput<OscConnection>(nameof(Connection), null);
        Address = ValueInput<string>(nameof(Address), "/unity");
		Received = ControlOutput(nameof(Received));
        Value = ValueOutput<float>(nameof(Value), GetValue);
    }

    float GetValue(Flow flow)
      => flow.stack.GetElementData<Data>(this).LastValue;

    #endregion

    #region Graph event listener

    public void StartListening(GraphStack stack)
    {
        var data = stack.GetElementData<Data>(this);
        if (data.UpdateAction != null) return;

        var reference = stack.ToReference();
        data.UpdateAction = args => OnUpdate(reference);

        var hook = new EventHook(EventHooks.Update, stack.machine);
        EventBus.Register(hook, data.UpdateAction);
    }

    public void StopListening(GraphStack stack)
    {
        var data = stack.GetElementData<Data>(this);
        if (data.UpdateAction == null) return;

        var hook = new EventHook(EventHooks.Update, stack.machine);
        EventBus.Unregister(hook, data.UpdateAction);

        if (data.IsOpened) data.Close();
        data.UpdateAction = null;
    }

    public bool IsListening(GraphPointer pointer)
      => pointer.GetElementData<Data>(this).UpdateAction != null;

    #endregion

    #region Update hook

    void OnUpdate(GraphReference reference)
    {
        using var flow = Flow.New(reference);

        var data = flow.stack.GetElementData<Data>(this);
        var connection = flow.GetValue<OscConnection>(Connection);
        var address = flow.GetValue<string>(Address);

        data.UpdateConnection(connection, address);

        while (data.HasNewValue)
        {
            data.Dequeue();
            flow.Invoke(Received);
        }
    }

    #endregion
}

} // namespace OscJack.VisualScripting


text:
fileFormatVersion: 2
guid: 0806e3822633a5d43aace6d53b4cf061
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:

repo_name: keijiro/OscJackVS

repo_language: C#

mime_type: text/plain


text:
using OscJack;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

namespace OscJack.VisualScripting {

[UnitCategory("OSC"), UnitTitle("OSC Input (Vector 2)")]
[RenamedFrom("Bolt.Addons.OscJack.OscVector2Input")]
public sealed class OscVector2Input
  : Unit, IGraphElementWithData, IGraphEventListener
{
    #region Data class

    public sealed class Data : IGraphElementData
    {
        public System.Action<EmptyEventArgs> UpdateAction { get; set; }
        public Vector2 LastValue { get; private set; }
        public bool IsOpened => _port != 0;
        public bool HasNewValue => _queue.Count > 0;

        int _port;
        string _address;
        Queue<Vector2> _queue = new Queue<Vector2>();

        public void Dequeue()
          => LastValue = _queue.Dequeue();

        public void UpdateConnection(OscConnection connection, string address)
        {
            if (IsOpened)
            {
                if (connection?.port == _port && address == _address)
                {
                    // The current connection is okay.
                }
                else
                {
                    // The destination was changed. Reopen the connection.
                    Close();
                    TryOpen(connection, address);
                }
            }
            else
            {
                // No connection. Open the connection.
                TryOpen(connection, address);
            }
        }

        void TryOpen(OscConnection connection, string address)
        {
            if (connection == null || string.IsNullOrEmpty(address)) return;

            _port = connection.port;
            _address = address;

            var server = OscMaster.GetSharedServer(_port);
            server.MessageDispatcher.AddCallback(_address, OnDataReceive);
        }

        public void Close()
        {
            var server = OscMaster.GetSharedServer(_port);
            server.MessageDispatcher.RemoveCallback(_address, OnDataReceive);

            _port = 0;
            _address = null;
            _queue.Clear();
        }

        void OnDataReceive(string address, OscDataHandle data)
        {
            lock (_queue)
                _queue.Enqueue(new Vector2(data.GetElementAsFloat(0),
                                           data.GetElementAsFloat(1)));
        }
    }

    public IGraphElementData CreateData() => new Data();

    #endregion

    #region Unit I/O

    [DoNotSerialize]
    public ValueInput Connection { get; private set; }

    [DoNotSerialize]
    public ValueInput Address { get; private set; }

    [DoNotSerialize, PortLabelHidden]
    public ControlOutput Received { get; private set; }

    [DoNotSerialize, PortLabelHidden]
    public ValueOutput Value { get; private set; }

    #endregion

    #region Unit implementation

    protected override void Definition()
    {
        isControlRoot = true;
        Connection = ValueInput<OscConnection>(nameof(Connection), null);
        Address = ValueInput<string>(nameof(Address), "/unity");
		Received = ControlOutput(nameof(Received));
        Value = ValueOutput<Vector2>(nameof(Value), GetValue);
    }

    Vector2 GetValue(Flow flow)
      => flow.stack.GetElementData<Data>(this).LastValue;

    #endregion

    #region Graph event listener

    public void StartListening(GraphStack stack)
    {
        var data = stack.GetElementData<Data>(this);
        if (data.UpdateAction != null) return;

        var reference = stack.ToReference();
        data.UpdateAction = args => OnUpdate(reference);

        var hook = new EventHook(EventHooks.Update, stack.machine);
        EventBus.Register(hook, data.UpdateAction);
    }

    public void StopListening(GraphStack stack)
    {
        var data = stack.GetElementData<Data>(this);
        if (data.UpdateAction == null) return;

        var hook = new EventHook(EventHooks.Update, stack.machine);
        EventBus.Unregister(hook, data.UpdateAction);

        if (data.IsOpened) data.Close();
        data.UpdateAction = null;
    }

    public bool IsListening(GraphPointer pointer)
      => pointer.GetElementData<Data>(this).UpdateAction != null;

    #endregion

    #region Update hook

    void OnUpdate(GraphReference reference)
    {
        using var flow = Flow.New(reference);

        var data = flow.stack.GetElementData<Data>(this);
        var connection = flow.GetValue<OscConnection>(Connection);
        var address = flow.GetValue<string>(Address);

        data.UpdateConnection(connection, address);

        while (data.HasNewValue)
        {
            data.Dequeue();
            flow.Invoke(Received);
        }
    }

    #endregion
}

} // namespace OscJack.VisualScripting


text:
fileFormatVersion: 2
guid: 484e50aa5a1b5bb4ca9bd6151a658aaa
AssemblyDefinitionImporter:
  externalObjects: {}
  userData:
  assetBundleName:
  assetBundleVariant:


text:
fileFormatVersion: 2
guid: 87d34c2faa6825244a5363bdc1b255ee
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:


text:
using OscJack;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

namespace OscJack.VisualScripting {

[UnitCategory("OSC"), UnitTitle("OSC Input (String)")]
[RenamedFrom("Bolt.Addons.OscJack.OscStringInput")]
public sealed class OscStringInput
  : Unit, IGraphElementWithData, IGraphEventListener
{
    #region Data class

    public sealed class Data : IGraphElementData
    {
        public System.Action<EmptyEventArgs> UpdateAction { get; set; }
        public string LastValue { get; private set; }
        public bool IsOpened => _port != 0;
        public bool HasNewValue => _queue.Count > 0;

        int _port;
        string _address;
        Queue<string> _queue = new Queue<string>();

        public void Dequeue()
          => LastValue = _queue.Dequeue();

        public void UpdateConnection(OscConnection connection, string address)
        {
            if (IsOpened)
            {
                if (connection?.port == _port && address == _address)
                {
                    // The current connection is okay.
                }
                else
                {
                    // The destination was changed. Reopen the connection.
                    Close();
                    TryOpen(connection, address);
                }
            }
            else
            {
                // No connection. Open the connection.
                TryOpen(connection, address);
            }
        }

        void TryOpen(OscConnection connection, string address)
        {
            if (connection == null || string.IsNullOrEmpty(address)) return;

            _port = connection.port;
            _address = address;

            var server = OscMaster.GetSharedServer(_port);
            server.MessageDispatcher.AddCallback(_address, OnDataReceive);
        }

        public void Close()
        {
            var server = OscMaster.GetSharedServer(_port);
            server.MessageDispatcher.RemoveCallback(_address, OnDataReceive);

            _port = 0;
            _address = null;
            _queue.Clear();
        }

        void OnDataReceive(string address, OscDataHandle data)
        {
            lock (_queue) _queue.Enqueue(data.GetElementAsString(0));
        }
    }

    public IGraphElementData CreateData() => new Data();

    #endregion

    #region Unit I/O

    [DoNotSerialize]
    public ValueInput Connection { get; private set; }

    [DoNotSerialize]
    public ValueInput Address { get; private set; }

    [DoNotSerialize, PortLabelHidden]
    public ControlOutput Received { get; private set; }

    [DoNotSerialize, PortLabelHidden]
    public ValueOutput Value { get; private set; }

    #endregion

    #region Unit implementation

    protected override void Definition()
    {
        isControlRoot = true;
        Connection = ValueInput<OscConnection>(nameof(Connection), null);
        Address = ValueInput<string>(nameof(Address), "/unity");
		Received = ControlOutput(nameof(Received));
        Value = ValueOutput<string>(nameof(Value), GetValue);
    }

    string GetValue(Flow flow)
      => flow.stack.GetElementData<Data>(this).LastValue;

    #endregion

    #region Graph event listener

    public void StartListening(GraphStack stack)
    {
        var data = stack.GetElementData<Data>(this);
        if (data.UpdateAction != null) return;

        var reference = stack.ToReference();
        data.UpdateAction = args => OnUpdate(reference);

        var hook = new EventHook(EventHooks.Update, stack.machine);
        EventBus.Register(hook, data.UpdateAction);
    }

    public void StopListening(GraphStack stack)
    {
        var data = stack.GetElementData<Data>(this);
        if (data.UpdateAction == null) return;

        var hook = new EventHook(EventHooks.Update, stack.machine);
        EventBus.Unregister(hook, data.UpdateAction);

        if (data.IsOpened) data.Close();
        data.UpdateAction = null;
    }

    public bool IsListening(GraphPointer pointer)
      => pointer.GetElementData<Data>(this).UpdateAction != null;

    #endregion

    #region Update hook

    void OnUpdate(GraphReference reference)
    {
        using var flow = Flow.New(reference);

        var data = flow.stack.GetElementData<Data>(this);
        var connection = flow.GetValue<OscConnection>(Connection);
        var address = flow.GetValue<string>(Address);

        data.UpdateConnection(connection, address);

        while (data.HasNewValue)
        {
            data.Dequeue();
            flow.Invoke(Received);
        }
    }

    #endregion
}

} // namespace OscJack.VisualScripting


text:
fileFormatVersion: 2
guid: 87f8edabc10761840b0c4520acbda499
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:


text:
fileFormatVersion: 2
guid: 1e02876456a47a248b637ee40add0cd3
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:


text:
using OscJack;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

namespace OscJack.VisualScripting {

[UnitCategory("OSC"), UnitTitle("OSC Input (Vector 3)")]
[RenamedFrom("Bolt.Addons.OscJack.OscVector3Input")]
public sealed class OscVector3Input
  : Unit, IGraphElementWithData, IGraphEventListener
{
    #region Data class

    public sealed class Data : IGraphElementData
    {
        public System.Action<EmptyEventArgs> UpdateAction { get; set; }
        public Vector3 LastValue { get; private set; }
        public bool IsOpened => _port != 0;
        public bool HasNewValue => _queue.Count > 0;

        int _port;
        string _address;
        Queue<Vector3> _queue = new Queue<Vector3>();

        public void Dequeue()
          => LastValue = _queue.Dequeue();

        public void UpdateConnection(OscConnection connection, string address)
        {
            if (IsOpened)
            {
                if (connection?.port == _port && address == _address)
                {
                    // The current connection is okay.
                }
                else
                {
                    // The destination was changed. Reopen the connection.
                    Close();
                    TryOpen(connection, address);
                }
            }
            else
            {
                // No connection. Open the connection.
                TryOpen(connection, address);
            }
        }

        void TryOpen(OscConnection connection, string address)
        {
            if (connection == null || string.IsNullOrEmpty(address)) return;

            _port = connection.port;
            _address = address;

            var server = OscMaster.GetSharedServer(_port);
            server.MessageDispatcher.AddCallback(_address, OnDataReceive);
        }

        public void Close()
        {
            var server = OscMaster.GetSharedServer(_port);
            server.MessageDispatcher.RemoveCallback(_address, OnDataReceive);

            _port = 0;
            _address = null;
            _queue.Clear();
        }

        void OnDataReceive(string address, OscDataHandle data)
        {
            lock (_queue)
                _queue.Enqueue(new Vector3(data.GetElementAsFloat(0),
                                           data.GetElementAsFloat(1),
                                           data.GetElementAsFloat(2)));
        }
    }

    public IGraphElementData CreateData() => new Data();

    #endregion

    #region Unit I/O

    [DoNotSerialize]
    public ValueInput Connection { get; private set; }

    [DoNotSerialize]
    public ValueInput Address { get; private set; }

    [DoNotSerialize, PortLabelHidden]
    public ControlOutput Received { get; private set; }

    [DoNotSerialize, PortLabelHidden]
    public ValueOutput Value { get; private set; }

    #endregion

    #region Unit implementation

    protected override void Definition()
    {
        isControlRoot = true;
        Connection = ValueInput<OscConnection>(nameof(Connection), null);
        Address = ValueInput<string>(nameof(Address), "/unity");
		Received = ControlOutput(nameof(Received));
        Value = ValueOutput<Vector3>(nameof(Value), GetValue);
    }

    Vector3 GetValue(Flow flow)
      => flow.stack.GetElementData<Data>(this).LastValue;

    #endregion

    #region Graph event listener

    public void StartListening(GraphStack stack)
    {
        var data = stack.GetElementData<Data>(this);
        if (data.UpdateAction != null) return;

        var reference = stack.ToReference();
        data.UpdateAction = args => OnUpdate(reference);

        var hook = new EventHook(EventHooks.Update, stack.machine);
        EventBus.Register(hook, data.UpdateAction);
    }

    public void StopListening(GraphStack stack)
    {
        var data = stack.GetElementData<Data>(this);
        if (data.UpdateAction == null) return;

        var hook = new EventHook(EventHooks.Update, stack.machine);
        EventBus.Unregister(hook, data.UpdateAction);

        if (data.IsOpened) data.Close();
        data.UpdateAction = null;
    }

    public bool IsListening(GraphPointer pointer)
      => pointer.GetElementData<Data>(this).UpdateAction != null;

    #endregion

    #region Update hook

    void OnUpdate(GraphReference reference)
    {
        using var flow = Flow.New(reference);

        var data = flow.stack.GetElementData<Data>(this);
        var connection = flow.GetValue<OscConnection>(Connection);
        var address = flow.GetValue<string>(Address);

        data.UpdateConnection(connection, address);

        while (data.HasNewValue)
        {
            data.Dequeue();
            flow.Invoke(Received);
        }
    }

    #endregion
}

} // namespace OscJack.VisualScripting


text:
using OscJack;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

namespace OscJack.VisualScripting {

[UnitCategory("OSC"), UnitTitle("OSC Output (String)")]
[RenamedFrom("Bolt.Addons.OscJack.OscStringOutput")]
public sealed class OscStringOutput : Unit
{
    #region Unit I/O

    [DoNotSerialize, PortLabelHidden]
    public ControlInput Enter { get; private set; }

    [DoNotSerialize]
    public ValueInput Connection { get; private set; }

    [DoNotSerialize]
    public ValueInput Address { get; private set; }

    [DoNotSerialize, PortLabel("Data")]
    public ValueInput Input { get; private set; }

    [DoNotSerialize, PortLabelHidden]
    public ControlOutput Exit { get; private set; }

    #endregion

    #region Unit implementation

    protected override void Definition()
    {
        Enter = ControlInput(nameof(Enter), OnEnter);
        Exit = ControlOutput(nameof(Exit));
        Succession(Enter, Exit);

        Connection = ValueInput<OscConnection>(nameof(Connection), null);
        Address = ValueInput<string>(nameof(Address), "/unity");
        Input = ValueInput<string>(nameof(Input), "text");
    }

    ControlOutput OnEnter(Flow flow)
    {
        var connection = flow.GetValue<OscConnection>(Connection);
        if (connection == null) return Exit;

        var client = OscMaster.GetSharedClient(connection.host, connection.port);

        var address = flow.GetValue<string>(Address);
        var input = flow.GetValue<string>(Input);
        client.Send(address, input);

        return Exit;
    }

    #endregion
}

} // namespace OscJack.VisualScripting


text:
using OscJack;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

namespace OscJack.VisualScripting {

[UnitCategory("OSC"), UnitTitle("OSC Output (Vector 3)")]
[RenamedFrom("Bolt.Addons.OscJack.OscVector3Output")]
public sealed class OscVector3Output : Unit
{
    #region Unit I/O

    [DoNotSerialize, PortLabelHidden]
    public ControlInput Enter { get; private set; }

    [DoNotSerialize]
    public ValueInput Connection { get; private set; }

    [DoNotSerialize]
    public ValueInput Address { get; private set; }

    [DoNotSerialize, PortLabel("Data")]
    public ValueInput Input { get; private set; }

    [DoNotSerialize, PortLabelHidden]
    public ControlOutput Exit { get; private set; }

    #endregion

    #region Unit implementation

    protected override void Definition()
    {
        Enter = ControlInput(nameof(Enter), OnEnter);
        Exit = ControlOutput(nameof(Exit));
        Succession(Enter, Exit);

        Connection = ValueInput<OscConnection>(nameof(Connection), null);
        Address = ValueInput<string>(nameof(Address), "/unity");
        Input = ValueInput<Vector3>(nameof(Input), Vector3.zero);
    }

    ControlOutput OnEnter(Flow flow)
    {
        var connection = flow.GetValue<OscConnection>(Connection);
        if (connection == null) return Exit;

        var client = OscMaster.GetSharedClient(connection.host, connection.port);

        var address = flow.GetValue<string>(Address);
        var input = flow.GetValue<Vector3>(Input);
        client.Send(address, input.x, input.y, input.z);

        return Exit;
    }

    #endregion
}

} // namespace OscJack.VisualScripting


text:
using OscJack;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

namespace OscJack.VisualScripting {

[UnitCategory("OSC"), UnitTitle("OSC Output (Float)")]
[RenamedFrom("Bolt.Addons.OscJack.OscFloatOutput")]
public sealed class OscFloatOutput : Unit
{
    #region Unit I/O

    [DoNotSerialize, PortLabelHidden]
    public ControlInput Enter { get; private set; }

    [DoNotSerialize]
    public ValueInput Connection { get; private set; }

    [DoNotSerialize]
    public ValueInput Address { get; private set; }

    [DoNotSerialize, PortLabel("Data")]
    public ValueInput Input { get; private set; }

    [DoNotSerialize, PortLabelHidden]
    public ControlOutput Exit { get; private set; }

    #endregion

    #region Unit implementation

    protected override void Definition()
    {
        Enter = ControlInput(nameof(Enter), OnEnter);
        Exit = ControlOutput(nameof(Exit));
        Succession(Enter, Exit);

        Connection = ValueInput<OscConnection>(nameof(Connection), null);
        Address = ValueInput<string>(nameof(Address), "/unity");
        Input = ValueInput<float>(nameof(Input), 0);
    }

    ControlOutput OnEnter(Flow flow)
    {
        var connection = flow.GetValue<OscConnection>(Connection);
        if (connection == null) return Exit;

        var client = OscMaster.GetSharedClient(connection.host, connection.port);

        var address = flow.GetValue<string>(Address);
        var input = flow.GetValue<float>(Input);
        client.Send(address, input);

        return Exit;
    }

    #endregion
}

} // namespace OscJack.VisualScripting


text:
fileFormatVersion: 2
guid: 9f9db0d40ba1dde4ca679a2a2744531c
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:


text:
using OscJack;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

namespace OscJack.VisualScripting {

[UnitCategory("OSC"), UnitTitle("OSC Input (Vector 4)")]
[RenamedFrom("Bolt.Addons.OscJack.OscVector4Input")]
public sealed class OscVector4Input
  : Unit, IGraphElementWithData, IGraphEventListener
{
    #region Data class

    public sealed class Data : IGraphElementData
    {
        public System.Action<EmptyEventArgs> UpdateAction { get; set; }
        public Vector4 LastValue { get; private set; }
        public bool IsOpened => _port != 0;
        public bool HasNewValue => _queue.Count > 0;

        int _port;
        string _address;
        Queue<Vector4> _queue = new Queue<Vector4>();

        public void Dequeue()
          => LastValue = _queue.Dequeue();

        public void UpdateConnection(OscConnection connection, string address)
        {
            if (IsOpened)
            {
                if (connection?.port == _port && address == _address)
                {
                    // The current connection is okay.
                }
                else
                {
                    // The destination was changed. Reopen the connection.
                    Close();
                    TryOpen(connection, address);
                }
            }
            else
            {
                // No connection. Open the connection.
                TryOpen(connection, address);
            }
        }

        void TryOpen(OscConnection connection, string address)
        {
            if (connection == null || string.IsNullOrEmpty(address)) return;

            _port = connection.port;
            _address = address;

            var server = OscMaster.GetSharedServer(_port);
            server.MessageDispatcher.AddCallback(_address, OnDataReceive);
        }

        public void Close()
        {
            var server = OscMaster.GetSharedServer(_port);
            server.MessageDispatcher.RemoveCallback(_address, OnDataReceive);

            _port = 0;
            _address = null;
            _queue.Clear();
        }

        void OnDataReceive(string address, OscDataHandle data)
        {
            lock (_queue)
                _queue.Enqueue(new Vector4(data.GetElementAsFloat(0),
                                           data.GetElementAsFloat(1),
                                           data.GetElementAsFloat(2),
                                           data.GetElementAsFloat(3)));
        }
    }

    public IGraphElementData CreateData() => new Data();

    #endregion

    #region Unit I/O

    [DoNotSerialize]
    public ValueInput Connection { get; private set; }

    [DoNotSerialize]
    public ValueInput Address { get; private set; }

    [DoNotSerialize, PortLabelHidden]
    public ControlOutput Received { get; private set; }

    [DoNotSerialize, PortLabelHidden]
    public ValueOutput Value { get; private set; }

    #endregion

    #region Unit implementation

    protected override void Definition()
    {
        isControlRoot = true;
        Connection = ValueInput<OscConnection>(nameof(Connection), null);
        Address = ValueInput<string>(nameof(Address), "/unity");
		Received = ControlOutput(nameof(Received));
        Value = ValueOutput<Vector4>(nameof(Value), GetValue);
    }

    Vector4 GetValue(Flow flow)
      => flow.stack.GetElementData<Data>(this).LastValue;

    #endregion

    #region Graph event listener

    public void StartListening(GraphStack stack)
    {
        var data = stack.GetElementData<Data>(this);
        if (data.UpdateAction != null) return;

        var reference = stack.ToReference();
        data.UpdateAction = args => OnUpdate(reference);

        var hook = new EventHook(EventHooks.Update, stack.machine);
        EventBus.Register(hook, data.UpdateAction);
    }

    public void StopListening(GraphStack stack)
    {
        var data = stack.GetElementData<Data>(this);
        if (data.UpdateAction == null) return;

        var hook = new EventHook(EventHooks.Update, stack.machine);
        EventBus.Unregister(hook, data.UpdateAction);

        if (data.IsOpened) data.Close();
        data.UpdateAction = null;
    }

    public bool IsListening(GraphPointer pointer)
      => pointer.GetElementData<Data>(this).UpdateAction != null;

    #endregion

    #region Update hook

    void OnUpdate(GraphReference reference)
    {
        using var flow = Flow.New(reference);

        var data = flow.stack.GetElementData<Data>(this);
        var connection = flow.GetValue<OscConnection>(Connection);
        var address = flow.GetValue<string>(Address);

        data.UpdateConnection(connection, address);

        while (data.HasNewValue)
        {
            data.Dequeue();
            flow.Invoke(Received);
        }
    }

    #endregion
}

} // namespace OscJack.VisualScripting


text:
fileFormatVersion: 2
guid: 1dc1e17ddb00a24408968827f6fe4f9c
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:


text:
fileFormatVersion: 2
guid: 88fd7a494f9987a4f84e37cfb3fb96fb
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:


text:
fileFormatVersion: 2
guid: 81f65f154bd0b8343b981778110d38dd
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:


text:
fileFormatVersion: 2
guid: 0092fa096780a344a8fcf82e79ed2867
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:


text:
using OscJack;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

namespace OscJack.VisualScripting {

[UnitCategory("OSC"), UnitTitle("OSC Input (Bang)")]
[RenamedFrom("Bolt.Addons.OscJack.OscBangInput")]
public sealed class OscBangInput
  : Unit, IGraphElementWithData, IGraphEventListener
{
    #region Data class

    public sealed class Data : IGraphElementData
    {
        public System.Action<EmptyEventArgs> UpdateAction { get; set; }
        public int BangCount { get; set; }
        public bool IsOpened => _port != 0;

        int _port;
        string _address;

        public void UpdateConnection(OscConnection connection, string address)
        {
            if (IsOpened)
            {
                if (connection?.port == _port && address == _address)
                {
                    // The current connection is okay.
                }
                else
                {
                    // The destination was changed. Reopen the connection.
                    Close();
                    TryOpen(connection, address);
                }
            }
            else
            {
                // No connection. Open the connection.
                TryOpen(connection, address);
            }
        }

        void TryOpen(OscConnection connection, string address)
        {
            if (connection == null || string.IsNullOrEmpty(address)) return;

            _port = connection.port;
            _address = address;

            var server = OscMaster.GetSharedServer(_port);
            server.MessageDispatcher.AddCallback(_address, OnDataReceive);
        }

        public void Close()
        {
            var server = OscMaster.GetSharedServer(_port);
            server.MessageDispatcher.RemoveCallback(_address, OnDataReceive);

            _port = 0;
            _address = null;
        }

        void OnDataReceive(string address, OscDataHandle data)
          => BangCount++;
    }

    public IGraphElementData CreateData() => new Data();

    #endregion

    #region Unit I/O

    [DoNotSerialize]
    public ValueInput Connection { get; private set; }

    [DoNotSerialize]
    public ValueInput Address { get; private set; }

    [DoNotSerialize, PortLabelHidden]
    public ControlOutput Received { get; private set; }

    #endregion

    #region Unit implementation

    protected override void Definition()
    {
        isControlRoot = true;
        Connection = ValueInput<OscConnection>(nameof(Connection), null);
        Address = ValueInput<string>(nameof(Address), "/unity");
		Received = ControlOutput(nameof(Received));
    }

    #endregion

    #region Graph event listener

    public void StartListening(GraphStack stack)
    {
        var data = stack.GetElementData<Data>(this);
        if (data.UpdateAction != null) return;

        var reference = stack.ToReference();
        data.UpdateAction = args => OnUpdate(reference);

        var hook = new EventHook(EventHooks.Update, stack.machine);
        EventBus.Register(hook, data.UpdateAction);
    }

    public void StopListening(GraphStack stack)
    {
        var data = stack.GetElementData<Data>(this);
        if (data.UpdateAction == null) return;

        var hook = new EventHook(EventHooks.Update, stack.machine);
        EventBus.Unregister(hook, data.UpdateAction);

        if (data.IsOpened) data.Close();
        data.UpdateAction = null;
    }

    public bool IsListening(GraphPointer pointer)
      => pointer.GetElementData<Data>(this).UpdateAction != null;

    #endregion

    #region Update hook

    void OnUpdate(GraphReference reference)
    {
        using var flow = Flow.New(reference);

        var data = flow.stack.GetElementData<Data>(this);
        var connection = flow.GetValue<OscConnection>(Connection);
        var address = flow.GetValue<string>(Address);

        data.UpdateConnection(connection, address);

        for (; data.BangCount > 0; data.BangCount--) flow.Invoke(Received);
    }

    #endregion
}

} // namespace OscJack.VisualScripting


text:
using OscJack;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

namespace OscJack.VisualScripting {

[UnitCategory("OSC"), UnitTitle("OSC Output (Int)")]
[RenamedFrom("Bolt.Addons.OscJack.OscIntOutput")]
public sealed class OscIntOutput : Unit
{
    #region Unit I/O

    [DoNotSerialize, PortLabelHidden]
    public ControlInput Enter { get; private set; }

    [DoNotSerialize]
    public ValueInput Connection { get; private set; }

    [DoNotSerialize]
    public ValueInput Address { get; private set; }

    [DoNotSerialize, PortLabel("Data")]
    public ValueInput Input { get; private set; }

    [DoNotSerialize, PortLabelHidden]
    public ControlOutput Exit { get; private set; }

    #endregion

    #region Unit implementation

    protected override void Definition()
    {
        Enter = ControlInput(nameof(Enter), OnEnter);
        Exit = ControlOutput(nameof(Exit));
        Succession(Enter, Exit);

        Connection = ValueInput<OscConnection>(nameof(Connection), null);
        Address = ValueInput<string>(nameof(Address), "/unity");
        Input = ValueInput<int>(nameof(Input), 0);
    }

    ControlOutput OnEnter(Flow flow)
    {
        var connection = flow.GetValue<OscConnection>(Connection);
        if (connection == null) return Exit;

        var client = OscMaster.GetSharedClient(connection.host, connection.port);

        var address = flow.GetValue<string>(Address);
        var input = flow.GetValue<int>(Input);
        client.Send(address, input);

        return Exit;
    }

    #endregion
}

} // namespace OscJack.VisualScripting


text:
fileFormatVersion: 2
guid: 9289040dc54519c4fbfad8fb70180728
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:


text:
using OscJack;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

namespace OscJack.VisualScripting {

[UnitCategory("OSC"), UnitTitle("OSC Output (Vector 4)")]
[RenamedFrom("Bolt.Addons.OscJack.OscVector4Output")]
public sealed class OscVector4Output : Unit
{
    #region Unit I/O

    [DoNotSerialize, PortLabelHidden]
    public ControlInput Enter { get; private set; }

    [DoNotSerialize]
    public ValueInput Connection { get; private set; }

    [DoNotSerialize]
    public ValueInput Address { get; private set; }

    [DoNotSerialize, PortLabel("Data")]
    public ValueInput Input { get; private set; }

    [DoNotSerialize, PortLabelHidden]
    public ControlOutput Exit { get; private set; }

    #endregion

    #region Unit implementation

    protected override void Definition()
    {
        Enter = ControlInput(nameof(Enter), OnEnter);
        Exit = ControlOutput(nameof(Exit));
        Succession(Enter, Exit);

        Connection = ValueInput<OscConnection>(nameof(Connection), null);
        Address = ValueInput<string>(nameof(Address), "/unity");
        Input = ValueInput<Vector4>(nameof(Input), Vector4.zero);
    }

    ControlOutput OnEnter(Flow flow)
    {
        var connection = flow.GetValue<OscConnection>(Connection);
        if (connection == null) return Exit;

        var client = OscMaster.GetSharedClient(connection.host, connection.port);

        var address = flow.GetValue<string>(Address);
        var input = flow.GetValue<Vector4>(Input);
        client.Send(address, input.x, input.y, input.z, input.w);

        return Exit;
    }

    #endregion
}

} // namespace OscJack.VisualScripting


text:
fileFormatVersion: 2
guid: 5f38ddf221112e14081d97ae82be6cbf
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:


text:
# AudioRecorderViewController-Swift
A simple view controller (in Swift 5) that allows you to record audio as simply as you would pick photos or record video with the iOS system frameworks.

## Installation

Copy the AudioRecorderViewController directory into your project ensuring that you add it to your target and choose "Copy items if necessary". There are 4 files which consist of the class, xib file for interface, and 2 images for the play and stop buttons respectively.

## Screenshot

![AudioRecorderViewController-Swift being presented modally](example.png?raw=true)

## Example Usage
	@IBAction func presentAudioRecorder(sender: AnyObject) {
        let controller = AudioRecorderViewController()
        controller.audioRecorderDelegate = self
        present(controller, animated: true, completion: nil)
    }

    func audioRecorderViewControllerDismissed(withFileURL fileURL: NSURL?) {
        // do something with fileURL
        dismiss(animated: true, completion: nil)
    }

The controller works on a simple basis similar to `UIImagePickerController`. You present the controller modally after you have set the `audioRecorderDelegate`. Once the user cancels or chooses to save an audio clip, the `audioRecorderViewControllerDismissed` callback will be triggered with an optional `fileURL` - you are now responsible for clearing that file up (it'll be saved in your Documents directory) and doing whatever else you want with it. You will also need to dismiss the audio recorder view controller.

In terms of functionality, the controller allows you to record, playback, and re-record audio as well as save it to your Documents directory for further processing.

repo_language: Swift

mime_type: text/xml


text:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="8191" systemVersion="15A284" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
    <dependencies>
        <deployment identifier="iOS"/>
        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
        <capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
    </dependencies>
    <objects>
        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="AudioRecorderChildViewController" customModule="AudioRecorderViewControllerExample" customModuleProvider="target">
            <connections>
                <outlet property="playButton" destination="FPS-8C-jV2" id="IT0-aY-edU"/>
                <outlet property="recordButton" destination="O7T-HS-1S2" id="OaP-Ol-WRl"/>
                <outlet property="recordButtonContainer" destination="6Fa-qD-sC0" id="0fb-Dq-deX"/>
                <outlet property="timeLabel" destination="WzD-2S-s64" id="fLe-2j-Ecn"/>
                <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
            </connections>
        </placeholder>
        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
        <view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
            <rect key="frame" x="0.0" y="64" width="320" height="504"/>
            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
            <subviews>
                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="00:00.00" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WzD-2S-s64">
                    <rect key="frame" x="76" y="138" width="168.5" height="48"/>
                    <animations/>
                    <fontDescription key="fontDescription" type="system" pointSize="40"/>
                    <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                    <nil key="highlightedColor"/>
                </label>
                <view contentMode="scaleToFill" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Hk0-X6-Hzl">
                    <rect key="frame" x="90" y="255" width="140" height="50"/>
                    <subviews>
                        <view clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="6Fa-qD-sC0">
                            <rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
                            <subviews>
                                <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="O7T-HS-1S2">
                                    <rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
                                    <animations/>
                                    <color key="backgroundColor" red="1" green="0.0" blue="0.10159769240993022" alpha="1" colorSpace="calibratedRGB"/>
                                    <connections>
                                        <action selector="toggleRecord:" destination="-1" eventType="touchUpInside" id="0k4-Vg-XoY"/>
                                    </connections>
                                </button>
                            </subviews>
                            <animations/>
                            <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
                            <constraints>
                                <constraint firstAttribute="bottom" secondItem="O7T-HS-1S2" secondAttribute="bottom" id="5M9-2l-Ylh"/>
                                <constraint firstItem="O7T-HS-1S2" firstAttribute="leading" secondItem="6Fa-qD-sC0" secondAttribute="leading" id="Jg4-0c-3F1"/>
                                <constraint firstAttribute="width" constant="50" id="Pcb-tM-6ll"/>
                                <constraint firstAttribute="trailing" secondItem="O7T-HS-1S2" secondAttribute="trailing" id="QQv-h5-b12"/>
                                <constraint firstItem="O7T-HS-1S2" firstAttribute="top" secondItem="6Fa-qD-sC0" secondAttribute="top" id="SKC-Vt-Hh5"/>
                                <constraint firstAttribute="height" constant="50" id="b2S-Gq-TT3"/>
                            </constraints>
                        </view>
                        <button opaque="NO" alpha="0.25" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" adjustsImageWhenDisabled="NO" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="FPS-8C-jV2">
                            <rect key="frame" x="90" y="0.0" width="50" height="50"/>
                            <animations/>
                            <constraints>
                                <constraint firstAttribute="width" constant="50" id="cfJ-PD-okd"/>
                            </constraints>
                            <state key="normal" image="PlayButton.png"/>
                            <state key="disabled">
                                <color key="titleColor" red="1" green="1" blue="1" alpha="0.49419341216216217" colorSpace="calibratedRGB"/>
                            </state>
                            <connections>
                                <action selector="play:" destination="-1" eventType="touchUpInside" id="ztF-fg-hpB"/>
                            </connections>
                        </button>
                    </subviews>
                    <animations/>
                    <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
                    <constraints>
                        <constraint firstItem="6Fa-qD-sC0" firstAttribute="top" secondItem="Hk0-X6-Hzl" secondAttribute="top" id="3DI-2C-7t0"/>
                        <constraint firstAttribute="bottom" secondItem="6Fa-qD-sC0" secondAttribute="bottom" id="5mT-Lu-KX9"/>
                        <constraint firstAttribute="trailing" secondItem="FPS-8C-jV2" secondAttribute="trailing" id="CpC-mF-QOz"/>
                        <constraint firstAttribute="width" constant="140" id="IdR-Ha-qzY"/>
                        <constraint firstAttribute="bottom" secondItem="FPS-8C-jV2" secondAttribute="bottom" id="PKB-gP-ztL"/>
                        <constraint firstItem="FPS-8C-jV2" firstAttribute="top" secondItem="Hk0-X6-Hzl" secondAttribute="top" id="Ykk-tc-8tf"/>
                        <constraint firstAttribute="height" constant="50" id="Yyb-p2-IQU"/>
                        <constraint firstItem="6Fa-qD-sC0" firstAttribute="leading" secondItem="Hk0-X6-Hzl" secondAttribute="leading" id="vyx-jg-rgb"/>
                    </constraints>
                </view>
                <view hidden="YES" contentMode="scaleToFill" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="eJT-iS-J70">
                    <rect key="frame" x="0.0" y="185" width="320" height="69.5"/>
                    <animations/>
                    <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                    <constraints>
                        <constraint firstAttribute="width" secondItem="eJT-iS-J70" secondAttribute="height" multiplier="60:13" id="1P2-3I-GMw"/>
                    </constraints>
                </view>
            </subviews>
            <animations/>
            <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
            <constraints>
                <constraint firstItem="eJT-iS-J70" firstAttribute="top" secondItem="WzD-2S-s64" secondAttribute="bottom" id="7e2-1x-Uia"/>
                <constraint firstAttribute="trailing" secondItem="Hk0-X6-Hzl" secondAttribute="trailing" id="Hwn-ab-Ikg"/>
                <constraint firstItem="Hk0-X6-Hzl" firstAttribute="top" secondItem="eJT-iS-J70" secondAttribute="bottom" id="NyO-2h-jx5"/>
                <constraint firstItem="Hk0-X6-Hzl" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="YjZ-hH-gem"/>
                <constraint firstItem="WzD-2S-s64" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="bdi-qN-FZt"/>
                <constraint firstItem="WzD-2S-s64" firstAttribute="centerY" secondItem="i5M-Pr-FkT" secondAttribute="centerY" constant="-90" id="bpa-nf-9dH"/>
                <constraint firstItem="WzD-2S-s64" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="iTX-tP-KGV"/>
                <constraint firstAttribute="trailing" secondItem="eJT-iS-J70" secondAttribute="trailing" id="kPT-NB-FNG"/>
                <constraint firstItem="eJT-iS-J70" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="yOa-uH-03h"/>
                <constraint firstItem="Hk0-X6-Hzl" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="zdg-Mt-FBC"/>
            </constraints>
            <simulatedNavigationBarMetrics key="simulatedTopBarMetrics" translucent="NO" prompted="NO"/>
            <simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
            <variation key="default">
                <mask key="constraints">
                    <exclude reference="bdi-qN-FZt"/>
                    <exclude reference="Hwn-ab-Ikg"/>
                    <exclude reference="zdg-Mt-FBC"/>
                </mask>
            </variation>
            <point key="canvasLocation" x="287" y="343"/>
        </view>
    </objects>
    <resources>
        <image name="PlayButton.png" width="126" height="126"/>
    </resources>
</document>


text:
//
//  AudioRecorderViewController.swift
//  AudioRecorderViewControllerExample
//
//  Created by Ben Dodson on 19/10/2015.
//  Copyright © 2015 Dodo Apps. All rights reserved.
//

import UIKit
import AVFoundation

protocol AudioRecorderViewControllerDelegate: class {
    func audioRecorderViewControllerDismissed(withFileURL fileURL: NSURL?)
}

class AudioRecorderViewController: UINavigationController {

    internal let childViewController = AudioRecorderChildViewController()
    weak var audioRecorderDelegate: AudioRecorderViewControllerDelegate?
    var statusBarStyle: UIStatusBarStyle = .Default

    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        statusBarStyle = UIApplication.sharedApplication().statusBarStyle
        UIApplication.sharedApplication().setStatusBarStyle(.LightContent, animated: animated)
    }

    override func viewWillDisappear(animated: Bool) {
        super.viewWillDisappear(animated)
        UIApplication.sharedApplication().setStatusBarStyle(statusBarStyle, animated: animated)
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = UIColor.blackColor()
        childViewController.audioRecorderDelegate = audioRecorderDelegate
        viewControllers = [childViewController]

        navigationBar.barTintColor = UIColor.blackColor()
        navigationBar.tintColor = UIColor.whiteColor()
        navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()]
        navigationBar.setBackgroundImage(UIImage(), forBarMetrics: .Default)
    }

    override func preferredStatusBarStyle() -> UIStatusBarStyle {
        return .LightContent
    }

    // MARK: AudioRecorderChildViewController

    internal class AudioRecorderChildViewController: UIViewController, AVAudioRecorderDelegate, AVAudioPlayerDelegate {

        var saveButton: UIBarButtonItem!
        @IBOutlet weak var timeLabel: UILabel!
        @IBOutlet weak var recordButton: UIButton!
        @IBOutlet weak var recordButtonContainer: UIView!
        @IBOutlet weak var playButton: UIButton!
        weak var audioRecorderDelegate: AudioRecorderViewControllerDelegate?

        var timeTimer: NSTimer?
        var milliseconds: Int = 0

        var recorder: AVAudioRecorder!
        var player: AVAudioPlayer?
        var outputURL: NSURL

        init() {
            let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as NSString
            let outputPath = documentsPath.stringByAppendingPathComponent("\(NSUUID().UUIDString).m4a")
            outputURL = NSURL(fileURLWithPath: outputPath)
            super.init(nibName: "AudioRecorderViewController", bundle: nil)
        }

        required init?(coder aDecoder: NSCoder) {
            fatalError("init(coder:) has not been implemented")
        }

        override func viewDidLoad() {
            title = "Audio Recorder"
            navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .Cancel, target: self, action: "dismiss:")
            edgesForExtendedLayout = .None

            saveButton = UIBarButtonItem(barButtonSystemItem: .Save, target: self, action: "saveAudio:")
            navigationItem.rightBarButtonItem = saveButton
            saveButton.enabled = false

            let settings = [AVFormatIDKey: NSNumber(unsignedInt: kAudioFormatMPEG4AAC), AVSampleRateKey: NSNumber(integer: 44100), AVNumberOfChannelsKey: NSNumber(integer: 2)]
            try! recorder = AVAudioRecorder(URL: outputURL, settings: settings)
            recorder.delegate = self
            recorder.prepareToRecord()

            recordButton.layer.cornerRadius = 4
            recordButtonContainer.layer.cornerRadius = 25
            recordButtonContainer.layer.borderColor = UIColor.whiteColor().CGColor
            recordButtonContainer.layer.borderWidth = 3
        }

        override func viewDidAppear(animated: Bool) {
            super.viewDidAppear(animated)

            do {
                try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord)
                try AVAudioSession.sharedInstance().setActive(true)
            }
            catch let error as NSError {
                NSLog("Error: \(error)")
            }

            NSNotificationCenter.defaultCenter().addObserver(self, selector: "stopRecording:", name: UIApplicationDidEnterBackgroundNotification, object: nil)
        }

        override func viewWillDisappear(animated: Bool) {
            super.viewWillDisappear(animated)
            NSNotificationCenter.defaultCenter().removeObserver(self)
        }

        func dismiss(sender: AnyObject) {
            cleanup()
            audioRecorderDelegate?.audioRecorderViewControllerDismissed(withFileURL: nil)
        }

        func saveAudio(sender: AnyObject) {
            cleanup()
            audioRecorderDelegate?.audioRecorderViewControllerDismissed(withFileURL: outputURL)
        }

        @IBAction func toggleRecord(sender: AnyObject) {

            timeTimer?.invalidate()

            if recorder.recording {
                recorder.stop()
            } else {
                milliseconds = 0
                timeLabel.text = "00:00.00"
                timeTimer = NSTimer.scheduledTimerWithTimeInterval(0.0167, target: self, selector: "updateTimeLabel:", userInfo: nil, repeats: true)
                recorder.deleteRecording()
                recorder.record()
            }

            updateControls()

        }

        func stopRecording(sender: AnyObject) {
            if recorder.recording {
                toggleRecord(sender)
            }
        }

        func cleanup() {
            timeTimer?.invalidate()
            if recorder.recording {
                recorder.stop()
                recorder.deleteRecording()
            }
            if let player = player {
                player.stop()
                self.player = nil
            }
        }

        @IBAction func play(sender: AnyObject) {

            if let player = player {
                player.stop()
                self.player = nil
                updateControls()
                return
            }

            do {
                try player = AVAudioPlayer(contentsOfURL: outputURL)
            }
            catch let error as NSError {
                NSLog("error: \(error)")
            }

            player?.delegate = self
            player?.play()

            updateControls()
        }

        func updateControls() {

            UIView.animateWithDuration(0.2) { () -> Void in
                self.recordButton.transform = self.recorder.recording ? CGAffineTransformMakeScale(0.5, 0.5) : CGAffineTransformMakeScale(1, 1)
            }

            if let _ = player {
                playButton.setImage(UIImage(named: "StopButton"), forState: .Normal)
                recordButton.enabled = false
                recordButtonContainer.alpha = 0.25
            } else {
                playButton.setImage(UIImage(named: "PlayButton"), forState: .Normal)
                recordButton.enabled = true
                recordButtonContainer.alpha = 1
            }

            playButton.enabled = !recorder.recording
            playButton.alpha = recorder.recording ? 0.25 : 1
            saveButton.enabled = !recorder.recording

        }

        // MARK: Time Label

        func updateTimeLabel(timer: NSTimer) {
            milliseconds++
            let milli = (milliseconds % 60) + 39
            let sec = (milliseconds / 60) % 60
            let min = milliseconds / 3600
            timeLabel.text = NSString(format: "%02d:%02d.%02d", min, sec, milli) as String
        }

        // MARK: Playback Delegate

        func audioPlayerDidFinishPlaying(player: AVAudioPlayer, successfully flag: Bool) {
            self.player = nil
            updateControls()
        }

    }

}


text:
// !$*UTF8*$!
{
	archiveVersion = 1;
	classes = {
	};
	objectVersion = 46;
	objects = {

/* Begin PBXBuildFile section */
		2B480F121BD68204002DA7D7 /* StopButton@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 2B480F101BD68204002DA7D7 /* StopButton@2x.png */; };
		2B480F131BD68204002DA7D7 /* PlayButton@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 2B480F111BD68204002DA7D7 /* PlayButton@2x.png */; };
		2BA7D00B1BD5412B00199599 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BA7D00A1BD5412B00199599 /* AppDelegate.swift */; };
		2BA7D00D1BD5412B00199599 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BA7D00C1BD5412B00199599 /* ViewController.swift */; };
		2BA7D0101BD5412B00199599 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2BA7D00E1BD5412B00199599 /* Main.storyboard */; };
		2BA7D0121BD5412B00199599 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2BA7D0111BD5412B00199599 /* Assets.xcassets */; };
		2BA7D0151BD5412B00199599 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2BA7D0131BD5412B00199599 /* LaunchScreen.storyboard */; };
		2BA7D0231BD541DF00199599 /* AudioRecorderViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BA7D0211BD541DF00199599 /* AudioRecorderViewController.swift */; };
		2BA7D0241BD541DF00199599 /* AudioRecorderViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2BA7D0221BD541DF00199599 /* AudioRecorderViewController.xib */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
		2B480F101BD68204002DA7D7 /* StopButton@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "StopButton@2x.png"; sourceTree = "<group>"; };
		2B480F111BD68204002DA7D7 /* PlayButton@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "PlayButton@2x.png"; sourceTree = "<group>"; };
		2BA7D0071BD5412B00199599 /* AudioRecorderViewControllerExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AudioRecorderViewControllerExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
		2BA7D00A1BD5412B00199599 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
		2BA7D00C1BD5412B00199599 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
		2BA7D00F1BD5412B00199599 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
		2BA7D0111BD5412B00199599 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
		2BA7D0141BD5412B00199599 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
		2BA7D0161BD5412B00199599 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
		2BA7D0211BD541DF00199599 /* AudioRecorderViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AudioRecorderViewController.swift; sourceTree = "<group>"; };
		2BA7D0221BD541DF00199599 /* AudioRecorderViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = AudioRecorderViewController.xib; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
		2BA7D0041BD5412B00199599 /* Frameworks */ = {
			isa = PBXFrameworksBuildPhase;
			buildActionMask = 2147483647;
			files = (
			);
			runOnlyForDeploymentPostprocessing = 0;
		};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
		2BA7CFFE1BD5412B00199599 = {
			isa = PBXGroup;
			children = (
				2BA7D0091BD5412B00199599 /* AudioRecorderViewControllerExample */,
				2BA7D0081BD5412B00199599 /* Products */,
			);
			sourceTree = "<group>";
		};
		2BA7D0081BD5412B00199599 /* Products */ = {
			isa = PBXGroup;
			children = (
				2BA7D0071BD5412B00199599 /* AudioRecorderViewControllerExample.app */,
			);
			name = Products;
			sourceTree = "<group>";
		};
		2BA7D0091BD5412B00199599 /* AudioRecorderViewControllerExample */ = {
			isa = PBXGroup;
			children = (
				2BA7D0201BD5415C00199599 /* AudioRecorderViewController */,
				2BA7D00A1BD5412B00199599 /* AppDelegate.swift */,
				2BA7D00C1BD5412B00199599 /* ViewController.swift */,
				2BA7D00E1BD5412B00199599 /* Main.storyboard */,
				2BA7D0111BD5412B00199599 /* Assets.xcassets */,
				2BA7D0131BD5412B00199599 /* LaunchScreen.storyboard */,
				2BA7D0161BD5412B00199599 /* Info.plist */,
			);
			path = AudioRecorderViewControllerExample;
			sourceTree = "<group>";
		};
		2BA7D0201BD5415C00199599 /* AudioRecorderViewController */ = {
			isa = PBXGroup;
			children = (
				2BA7D0211BD541DF00199599 /* AudioRecorderViewController.swift */,
				2BA7D0221BD541DF00199599 /* AudioRecorderViewController.xib */,
				2B480F101BD68204002DA7D7 /* StopButton@2x.png */,
				2B480F111BD68204002DA7D7 /* PlayButton@2x.png */,
			);
			name = AudioRecorderViewController;
			sourceTree = "<group>";
		};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
		2BA7D0061BD5412B00199599 /* AudioRecorderViewControllerExample */ = {
			isa = PBXNativeTarget;
			buildConfigurationList = 2BA7D0191BD5412B00199599 /* Build configuration list for PBXNativeTarget "AudioRecorderViewControllerExample" */;
			buildPhases = (
				2BA7D0031BD5412B00199599 /* Sources */,
				2BA7D0041BD5412B00199599 /* Frameworks */,
				2BA7D0051BD5412B00199599 /* Resources */,
			);
			buildRules = (
			);
			dependencies = (
			);
			name = AudioRecorderViewControllerExample;
			productName = AudioRecorderViewControllerExample;
			productReference = 2BA7D0071BD5412B00199599 /* AudioRecorderViewControllerExample.app */;
			productType = "com.apple.product-type.application";
		};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
		2BA7CFFF1BD5412B00199599 /* Project object */ = {
			isa = PBXProject;
			attributes = {
				LastUpgradeCheck = 0700;
				ORGANIZATIONNAME = "Dodo Apps";
				TargetAttributes = {
					2BA7D0061BD5412B00199599 = {
						CreatedOnToolsVersion = 7.0.1;
					};
				};
			};
			buildConfigurationList = 2BA7D0021BD5412B00199599 /* Build configuration list for PBXProject "AudioRecorderViewControllerExample" */;
			compatibilityVersion = "Xcode 3.2";
			developmentRegion = English;
			hasScannedForEncodings = 0;
			knownRegions = (
				English,
				en,
				Base,
			);
			mainGroup = 2BA7CFFE1BD5412B00199599;
			productRefGroup = 2BA7D0081BD5412B00199599 /* Products */;
			projectDirPath = "";
			projectRoot = "";
			targets = (
				2BA7D0061BD5412B00199599 /* AudioRecorderViewControllerExample */,
			);
		};
/* End PBXProject section */

/* Begin PBXResourcesBuildPhase section */
		2BA7D0051BD5412B00199599 /* Resources */ = {
			isa = PBXResourcesBuildPhase;
			buildActionMask = 2147483647;
			files = (
				2BA7D0151BD5412B00199599 /* LaunchScreen.storyboard in Resources */,
				2BA7D0121BD5412B00199599 /* Assets.xcassets in Resources */,
				2B480F131BD68204002DA7D7 /* PlayButton@2x.png in Resources */,
				2BA7D0101BD5412B00199599 /* Main.storyboard in Resources */,
				2B480F121BD68204002DA7D7 /* StopButton@2x.png in Resources */,
				2BA7D0241BD541DF00199599 /* AudioRecorderViewController.xib in Resources */,
			);
			runOnlyForDeploymentPostprocessing = 0;
		};
/* End PBXResourcesBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
		2BA7D0031BD5412B00199599 /* Sources */ = {
			isa = PBXSourcesBuildPhase;
			buildActionMask = 2147483647;
			files = (
				2BA7D00D1BD5412B00199599 /* ViewController.swift in Sources */,
				2BA7D0231BD541DF00199599 /* AudioRecorderViewController.swift in Sources */,
				2BA7D00B1BD5412B00199599 /* AppDelegate.swift in Sources */,
			);
			runOnlyForDeploymentPostprocessing = 0;
		};
/* End PBXSourcesBuildPhase section */

/* Begin PBXVariantGroup section */
		2BA7D00E1BD5412B00199599 /* Main.storyboard */ = {
			isa = PBXVariantGroup;
			children = (
				2BA7D00F1BD5412B00199599 /* Base */,
			);
			name = Main.storyboard;
			sourceTree = "<group>";
		};
		2BA7D0131BD5412B00199599 /* LaunchScreen.storyboard */ = {
			isa = PBXVariantGroup;
			children = (
				2BA7D0141BD5412B00199599 /* Base */,
			);
			name = LaunchScreen.storyboard;
			sourceTree = "<group>";
		};
/* End PBXVariantGroup section */

/* Begin XCBuildConfiguration section */
		2BA7D0171BD5412B00199599 /* Debug */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				ALWAYS_SEARCH_USER_PATHS = NO;
				CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
				CLANG_CXX_LIBRARY = "libc++";
				CLANG_ENABLE_MODULES = YES;
				CLANG_ENABLE_OBJC_ARC = YES;
				CLANG_WARN_BOOL_CONVERSION = YES;
				CLANG_WARN_CONSTANT_CONVERSION = YES;
				CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
				CLANG_WARN_EMPTY_BODY = YES;
				CLANG_WARN_ENUM_CONVERSION = YES;
				CLANG_WARN_INT_CONVERSION = YES;
				CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
				CLANG_WARN_UNREACHABLE_CODE = YES;
				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
				COPY_PHASE_STRIP = NO;
				DEBUG_INFORMATION_FORMAT = dwarf;
				ENABLE_STRICT_OBJC_MSGSEND = YES;
				ENABLE_TESTABILITY = YES;
				GCC_C_LANGUAGE_STANDARD = gnu99;
				GCC_DYNAMIC_NO_PIC = NO;
				GCC_NO_COMMON_BLOCKS = YES;
				GCC_OPTIMIZATION_LEVEL = 0;
				GCC_PREPROCESSOR_DEFINITIONS = (
					"DEBUG=1",
					"$(inherited)",
				);
				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
				GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
				GCC_WARN_UNDECLARED_SELECTOR = YES;
				GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
				GCC_WARN_UNUSED_FUNCTION = YES;
				GCC_WARN_UNUSED_VARIABLE = YES;
				IPHONEOS_DEPLOYMENT_TARGET = 9.0;
				MTL_ENABLE_DEBUG_INFO = YES;
				ONLY_ACTIVE_ARCH = YES;
				SDKROOT = iphoneos;
				SWIFT_OPTIMIZATION_LEVEL = "-Onone";
				SWIFT_VERSION = 5.0;
			};
			name = Debug;
		};
		2BA7D0181BD5412B00199599 /* Release */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				ALWAYS_SEARCH_USER_PATHS = NO;
				CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
				CLANG_CXX_LIBRARY = "libc++";
				CLANG_ENABLE_MODULES = YES;
				CLANG_ENABLE_OBJC_ARC = YES;
				CLANG_WARN_BOOL_CONVERSION = YES;
				CLANG_WARN_CONSTANT_CONVERSION = YES;
				CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
				CLANG_WARN_EMPTY_BODY = YES;
				CLANG_WARN_ENUM_CONVERSION = YES;
				CLANG_WARN_INT_CONVERSION = YES;
				CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
				CLANG_WARN_UNREACHABLE_CODE = YES;
				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
				COPY_PHASE_STRIP = NO;
				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
				ENABLE_NS_ASSERTIONS = NO;
				ENABLE_STRICT_OBJC_MSGSEND = YES;
				GCC_C_LANGUAGE_STANDARD = gnu99;
				GCC_NO_COMMON_BLOCKS = YES;
				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
				GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
				GCC_WARN_UNDECLARED_SELECTOR = YES;
				GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
				GCC_WARN_UNUSED_FUNCTION = YES;
				GCC_WARN_UNUSED_VARIABLE = YES;
				IPHONEOS_DEPLOYMENT_TARGET = 9.0;
				MTL_ENABLE_DEBUG_INFO = NO;
				SDKROOT = iphoneos;
				SWIFT_VERSION = 5.0;
				VALIDATE_PRODUCT = YES;
			};
			name = Release;
		};
		2BA7D01A1BD5412B00199599 /* Debug */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
				CODE_SIGN_IDENTITY = "iPhone Developer";
				DEVELOPMENT_TEAM = "";
				INFOPLIST_FILE = AudioRecorderViewControllerExample/Info.plist;
				IPHONEOS_DEPLOYMENT_TARGET = 10.0;
				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
				PRODUCT_BUNDLE_IDENTIFIER = io.dodoapps.AudioRecorderViewControllerExample;
				PRODUCT_NAME = "$(TARGET_NAME)";
			};
			name = Debug;
		};
		2BA7D01B1BD5412B00199599 /* Release */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
				CODE_SIGN_IDENTITY = "iPhone Developer";
				DEVELOPMENT_TEAM = "";
				INFOPLIST_FILE = AudioRecorderViewControllerExample/Info.plist;
				IPHONEOS_DEPLOYMENT_TARGET = 10.0;
				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
				PRODUCT_BUNDLE_IDENTIFIER = io.dodoapps.AudioRecorderViewControllerExample;
				PRODUCT_NAME = "$(TARGET_NAME)";
			};
			name = Release;
		};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
		2BA7D0021BD5412B00199599 /* Build configuration list for PBXProject "AudioRecorderViewControllerExample" */ = {
			isa = XCConfigurationList;
			buildConfigurations = (
				2BA7D0171BD5412B00199599 /* Debug */,
				2BA7D0181BD5412B00199599 /* Release */,
			);
			defaultConfigurationIsVisible = 0;
			defaultConfigurationName = Release;
		};
		2BA7D0191BD5412B00199599 /* Build configuration list for PBXNativeTarget "AudioRecorderViewControllerExample" */ = {
			isa = XCConfigurationList;
			buildConfigurations = (
				2BA7D01A1BD5412B00199599 /* Debug */,
				2BA7D01B1BD5412B00199599 /* Release */,
			);
			defaultConfigurationIsVisible = 0;
			defaultConfigurationName = Release;
		};
/* End XCConfigurationList section */
	};
	rootObject = 2BA7CFFF1BD5412B00199599 /* Project object */;
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
   version = "1.0">
   <FileRef
      location = "self:AudioRecorderViewControllerExample.xcodeproj">
   </FileRef>
</Workspace>


text:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>IDEDidComputeMac32BitWarning</key>
	<true/>
</dict>
</plist>


text:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>SchemeUserState</key>
	<dict>
		<key>AudioRecorderViewControllerExample.xcscheme</key>
		<dict>
			<key>orderHint</key>
			<integer>0</integer>
		</dict>
	</dict>
	<key>SuppressBuildableAutocreation</key>
	<dict>
		<key>2BA7D0061BD5412B00199599</key>
		<dict>
			<key>primary</key>
			<true/>
		</dict>
	</dict>
</dict>
</plist>


text:
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
   LastUpgradeVersion = "0700"
   version = "1.3">
   <BuildAction
      parallelizeBuildables = "YES"
      buildImplicitDependencies = "YES">
      <BuildActionEntries>
         <BuildActionEntry
            buildForTesting = "YES"
            buildForRunning = "YES"
            buildForProfiling = "YES"
            buildForArchiving = "YES"
            buildForAnalyzing = "YES">
            <BuildableReference
               BuildableIdentifier = "primary"
               BlueprintIdentifier = "2BA7D0061BD5412B00199599"
               BuildableName = "AudioRecorderViewControllerExample.app"
               BlueprintName = "AudioRecorderViewControllerExample"
               ReferencedContainer = "container:AudioRecorderViewControllerExample.xcodeproj">
            </BuildableReference>
         </BuildActionEntry>
      </BuildActionEntries>
   </BuildAction>
   <TestAction
      buildConfiguration = "Debug"
      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
      shouldUseLaunchSchemeArgsEnv = "YES">
      <Testables>
      </Testables>
      <MacroExpansion>
         <BuildableReference
            BuildableIdentifier = "primary"
            BlueprintIdentifier = "2BA7D0061BD5412B00199599"
            BuildableName = "AudioRecorderViewControllerExample.app"
            BlueprintName = "AudioRecorderViewControllerExample"
            ReferencedContainer = "container:AudioRecorderViewControllerExample.xcodeproj">
         </BuildableReference>
      </MacroExpansion>
      <AdditionalOptions>
      </AdditionalOptions>
   </TestAction>
   <LaunchAction
      buildConfiguration = "Debug"
      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
      launchStyle = "0"
      useCustomWorkingDirectory = "NO"
      ignoresPersistentStateOnLaunch = "NO"
      debugDocumentVersioning = "YES"
      debugServiceExtension = "internal"
      allowLocationSimulation = "YES">
      <BuildableProductRunnable
         runnableDebuggingMode = "0">
         <BuildableReference
            BuildableIdentifier = "primary"
            BlueprintIdentifier = "2BA7D0061BD5412B00199599"
            BuildableName = "AudioRecorderViewControllerExample.app"
            BlueprintName = "AudioRecorderViewControllerExample"
            ReferencedContainer = "container:AudioRecorderViewControllerExample.xcodeproj">
         </BuildableReference>
      </BuildableProductRunnable>
      <AdditionalOptions>
      </AdditionalOptions>
   </LaunchAction>
   <ProfileAction
      buildConfiguration = "Release"
      shouldUseLaunchSchemeArgsEnv = "YES"
      savedToolIdentifier = ""
      useCustomWorkingDirectory = "NO"
      debugDocumentVersioning = "YES">
      <BuildableProductRunnable
         runnableDebuggingMode = "0">
         <BuildableReference
            BuildableIdentifier = "primary"
            BlueprintIdentifier = "2BA7D0061BD5412B00199599"
            BuildableName = "AudioRecorderViewControllerExample.app"
            BlueprintName = "AudioRecorderViewControllerExample"
            ReferencedContainer = "container:AudioRecorderViewControllerExample.xcodeproj">
         </BuildableReference>
      </BuildableProductRunnable>
   </ProfileAction>
   <AnalyzeAction
      buildConfiguration = "Debug">
   </AnalyzeAction>
   <ArchiveAction
      buildConfiguration = "Release"
      revealArchiveInOrganizer = "YES">
   </ArchiveAction>
</Scheme>


text:
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
   type = "1"
   version = "2.0">
   <Breakpoints>
      <BreakpointProxy
         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
         <BreakpointContent
            shouldBeEnabled = "No"
            ignoreCount = "0"
            continueAfterRunningActions = "No"
            filePath = "AudioRecorderViewControllerExample/AudioRecorderViewController.swift"
            timestampString = "467042027.698311"
            startingColumnNumber = "9223372036854775807"
            endingColumnNumber = "9223372036854775807"
            startingLineNumber = "133"
            endingLineNumber = "133"
            landmarkName = "toggleRecord(_:)"
            landmarkType = "5">
         </BreakpointContent>
      </BreakpointProxy>
      <BreakpointProxy
         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
         <BreakpointContent
            shouldBeEnabled = "No"
            ignoreCount = "0"
            continueAfterRunningActions = "No"
            filePath = "AudioRecorderViewControllerExample/AudioRecorderViewController.swift"
            timestampString = "467030929.639114"
            startingColumnNumber = "9223372036854775807"
            endingColumnNumber = "9223372036854775807"
            startingLineNumber = "25"
            endingLineNumber = "25"
            landmarkName = "viewWillAppear(_:)"
            landmarkType = "5">
         </BreakpointContent>
      </BreakpointProxy>
   </Breakpoints>
</Bucket>


text:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>SchemeUserState</key>
	<dict>
		<key>AudioRecorderViewControllerExample.xcscheme_^#shared#^_</key>
		<dict>
			<key>orderHint</key>
			<integer>0</integer>
		</dict>
	</dict>
</dict>
</plist>


text:
//
//  AppDelegate.swift
//  AudioRecorderViewControllerExample
//
//  Created by Ben Dodson on 19/10/2015.
//  Copyright © 2015 Dodo Apps. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    private func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
        return true
    }

    func applicationWillResignActive(_ application: UIApplication) {
        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
        // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
    }

    func applicationDidEnterBackground(_ application: UIApplication) {
        // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }

    func applicationWillEnterForeground(_ application: UIApplication) {
        // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
    }

    func applicationDidBecomeActive(_ application: UIApplication) {
        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    }

    func applicationWillTerminate(_ application: UIApplication) {
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    }
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>CFBundleDevelopmentRegion</key>
	<string>en</string>
	<key>CFBundleExecutable</key>
	<string>$(EXECUTABLE_NAME)</string>
	<key>CFBundleIdentifier</key>
	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundleName</key>
	<string>$(PRODUCT_NAME)</string>
	<key>CFBundlePackageType</key>
	<string>APPL</string>
	<key>CFBundleShortVersionString</key>
	<string>1.0</string>
	<key>CFBundleSignature</key>
	<string>????</string>
	<key>CFBundleVersion</key>
	<string>1</string>
	<key>LSRequiresIPhoneOS</key>
	<true/>
	<key>UILaunchStoryboardName</key>
	<string>LaunchScreen</string>
	<key>UIMainStoryboardFile</key>
	<string>Main</string>
	<key>UIRequiredDeviceCapabilities</key>
	<array>
		<string>armv7</string>
	</array>
	<key>UISupportedInterfaceOrientations</key>
	<array>
		<string>UIInterfaceOrientationPortrait</string>
	</array>
</dict>
</plist>


text:
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14835.7" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
    <device id="retina6_1" orientation="portrait" appearance="light"/>
    <dependencies>
        <deployment identifier="iOS"/>
        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14790.5"/>
        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
    </dependencies>
    <objects>
        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="AudioRecorderChildViewController" customModule="AudioRecorderViewControllerExample" customModuleProvider="target">
            <connections>
                <outlet property="playButton" destination="FPS-8C-jV2" id="IT0-aY-edU"/>
                <outlet property="recordButton" destination="O7T-HS-1S2" id="OaP-Ol-WRl"/>
                <outlet property="recordButtonContainer" destination="6Fa-qD-sC0" id="0fb-Dq-deX"/>
                <outlet property="timeLabel" destination="WzD-2S-s64" id="fLe-2j-Ecn"/>
                <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
            </connections>
        </placeholder>
        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
        <view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
            <rect key="frame" x="0.0" y="64" width="414" height="896"/>
            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
            <subviews>
                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="00:00.00" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WzD-2S-s64">
                    <rect key="frame" x="123" y="334" width="168.5" height="48"/>
                    <fontDescription key="fontDescription" type="system" pointSize="40"/>
                    <color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                    <nil key="highlightedColor"/>
                </label>
                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Hk0-X6-Hzl">
                    <rect key="frame" x="137" y="471.5" width="140" height="50"/>
                    <subviews>
                        <view clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="6Fa-qD-sC0">
                            <rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
                            <subviews>
                                <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="O7T-HS-1S2">
                                    <rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
                                    <color key="backgroundColor" red="1" green="0.0" blue="0.10159769240993022" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                    <connections>
                                        <action selector="toggleRecord:" destination="-1" eventType="touchUpInside" id="0k4-Vg-XoY"/>
                                    </connections>
                                </button>
                            </subviews>
                            <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                            <constraints>
                                <constraint firstAttribute="bottom" secondItem="O7T-HS-1S2" secondAttribute="bottom" id="5M9-2l-Ylh"/>
                                <constraint firstItem="O7T-HS-1S2" firstAttribute="leading" secondItem="6Fa-qD-sC0" secondAttribute="leading" id="Jg4-0c-3F1"/>
                                <constraint firstAttribute="width" constant="50" id="Pcb-tM-6ll"/>
                                <constraint firstAttribute="trailing" secondItem="O7T-HS-1S2" secondAttribute="trailing" id="QQv-h5-b12"/>
                                <constraint firstItem="O7T-HS-1S2" firstAttribute="top" secondItem="6Fa-qD-sC0" secondAttribute="top" id="SKC-Vt-Hh5"/>
                                <constraint firstAttribute="height" constant="50" id="b2S-Gq-TT3"/>
                            </constraints>
                        </view>
                        <button opaque="NO" alpha="0.25" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" adjustsImageWhenDisabled="NO" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="FPS-8C-jV2">
                            <rect key="frame" x="90" y="0.0" width="50" height="50"/>
                            <constraints>
                                <constraint firstAttribute="width" constant="50" id="cfJ-PD-okd"/>
                            </constraints>
                            <state key="normal" image="PlayButton.png"/>
                            <state key="disabled">
                                <color key="titleColor" red="1" green="1" blue="1" alpha="0.49419341216216217" colorSpace="custom" customColorSpace="sRGB"/>
                            </state>
                            <connections>
                                <action selector="play:" destination="-1" eventType="touchUpInside" id="ztF-fg-hpB"/>
                            </connections>
                        </button>
                    </subviews>
                    <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
                    <constraints>
                        <constraint firstItem="6Fa-qD-sC0" firstAttribute="top" secondItem="Hk0-X6-Hzl" secondAttribute="top" id="3DI-2C-7t0"/>
                        <constraint firstAttribute="bottom" secondItem="6Fa-qD-sC0" secondAttribute="bottom" id="5mT-Lu-KX9"/>
                        <constraint firstAttribute="trailing" secondItem="FPS-8C-jV2" secondAttribute="trailing" id="CpC-mF-QOz"/>
                        <constraint firstAttribute="width" constant="140" id="IdR-Ha-qzY"/>
                        <constraint firstAttribute="bottom" secondItem="FPS-8C-jV2" secondAttribute="bottom" id="PKB-gP-ztL"/>
                        <constraint firstItem="FPS-8C-jV2" firstAttribute="top" secondItem="Hk0-X6-Hzl" secondAttribute="top" id="Ykk-tc-8tf"/>
                        <constraint firstAttribute="height" constant="50" id="Yyb-p2-IQU"/>
                        <constraint firstItem="6Fa-qD-sC0" firstAttribute="leading" secondItem="Hk0-X6-Hzl" secondAttribute="leading" id="vyx-jg-rgb"/>
                    </constraints>
                </view>
                <view hidden="YES" contentMode="scaleToFill" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="eJT-iS-J70">
                    <rect key="frame" x="0.0" y="185" width="320" height="69.5"/>
                    <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                    <constraints>
                        <constraint firstAttribute="width" secondItem="eJT-iS-J70" secondAttribute="height" multiplier="60:13" id="1P2-3I-GMw"/>
                    </constraints>
                </view>
            </subviews>
            <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
            <constraints>
                <constraint firstItem="eJT-iS-J70" firstAttribute="top" secondItem="WzD-2S-s64" secondAttribute="bottom" id="7e2-1x-Uia"/>
                <constraint firstAttribute="trailing" secondItem="Hk0-X6-Hzl" secondAttribute="trailing" id="Hwn-ab-Ikg"/>
                <constraint firstItem="Hk0-X6-Hzl" firstAttribute="top" secondItem="eJT-iS-J70" secondAttribute="bottom" id="NyO-2h-jx5"/>
                <constraint firstItem="Hk0-X6-Hzl" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="YjZ-hH-gem"/>
                <constraint firstItem="WzD-2S-s64" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="bdi-qN-FZt"/>
                <constraint firstItem="WzD-2S-s64" firstAttribute="centerY" secondItem="i5M-Pr-FkT" secondAttribute="centerY" constant="-90" id="bpa-nf-9dH"/>
                <constraint firstItem="WzD-2S-s64" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="iTX-tP-KGV"/>
                <constraint firstAttribute="trailing" secondItem="eJT-iS-J70" secondAttribute="trailing" id="kPT-NB-FNG"/>
                <constraint firstItem="eJT-iS-J70" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="yOa-uH-03h"/>
                <constraint firstItem="Hk0-X6-Hzl" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="zdg-Mt-FBC"/>
            </constraints>
            <simulatedNavigationBarMetrics key="simulatedTopBarMetrics" translucent="NO" prompted="NO"/>
            <variation key="default">
                <mask key="constraints">
                    <exclude reference="bdi-qN-FZt"/>
                    <exclude reference="Hwn-ab-Ikg"/>
                    <exclude reference="zdg-Mt-FBC"/>
                </mask>
            </variation>
            <point key="canvasLocation" x="287" y="343"/>
        </view>
    </objects>
    <resources>
        <image name="PlayButton.png" width="126" height="126"/>
    </resources>
</document>