64 lines
1.6 KiB
C#
64 lines
1.6 KiB
C#
/* Copyright (C) 2014 DaikonForge */
|
|
|
|
namespace DaikonForge.VoIP
|
|
{
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// Event handler for when new audio data becomes available
|
|
/// </summary>
|
|
public delegate void AudioBufferReadyHandler( BigArray<float> newData, int frequency );
|
|
public delegate void AudioIntHandler(int length);
|
|
public delegate void AudioStateHandler();
|
|
/// <summary>
|
|
/// Base class for audio input devices
|
|
/// </summary>
|
|
public abstract class AudioInputDeviceBase : MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
/// Called when new audio data becomes available
|
|
/// </summary>
|
|
public event AudioBufferReadyHandler OnAudioBufferReady;
|
|
|
|
public event AudioIntHandler OnRecordingEnd;
|
|
|
|
public event AudioStateHandler OnRecordingStart;
|
|
|
|
public event AudioStateHandler OnNoRecordingPerimission;
|
|
|
|
/// <summary>
|
|
/// Start recording audio data
|
|
/// </summary>
|
|
public abstract void StartRecording();
|
|
|
|
/// <summary>
|
|
/// Stop recording audio data
|
|
/// </summary>
|
|
public abstract void StopRecording();
|
|
|
|
protected void bufferReady( BigArray<float> newData, int frequency )
|
|
{
|
|
if( OnAudioBufferReady != null )
|
|
OnAudioBufferReady( newData, frequency );
|
|
}
|
|
|
|
protected void RecordingFinish(int length)
|
|
{
|
|
if (OnRecordingEnd != null)
|
|
OnRecordingEnd(length);
|
|
}
|
|
|
|
protected void RecordingStart()
|
|
{
|
|
OnRecordingStart?.Invoke();
|
|
}
|
|
|
|
protected void NoRecordingPerimissions()
|
|
{
|
|
if (OnNoRecordingPerimission != null)
|
|
OnNoRecordingPerimission();
|
|
}
|
|
|
|
|
|
}
|
|
} |