|
| 1 | +// Unity C# reference source |
| 2 | +// Copyright (c) Unity Technologies. For terms of use, see |
| 3 | +// https://unity3d.com/legal/licenses/Unity_Reference_Only_License |
| 4 | + |
| 5 | +using System; |
| 6 | +using UnityEngine; |
| 7 | +using UnityEngine.Bindings; |
| 8 | + |
| 9 | +namespace UnityEditor |
| 10 | +{ |
| 11 | + [NativeType(Header = "Editor/Mono/Audio/WaveformStreamer.bindings.h")] |
| 12 | + internal sealed partial class WaveformStreamer |
| 13 | + { |
| 14 | + internal IntPtr m_Data; |
| 15 | + |
| 16 | + public bool done |
| 17 | + { |
| 18 | + get { return Internal_WaveformStreamerQueryFinishedStatus(m_Data); } |
| 19 | + } |
| 20 | + public void Stop() |
| 21 | + { |
| 22 | + Internal_WaveformStreamerStop(m_Data); |
| 23 | + } |
| 24 | + |
| 25 | + public WaveformStreamer(AudioClip clip, double start, double duration, |
| 26 | + int numOutputSamples, Func<WaveformStreamer, float[], int, bool> onNewWaveformData) |
| 27 | + { |
| 28 | + m_Data = Internal_WaveformStreamerCreate(this, clip, start, duration, numOutputSamples, onNewWaveformData); |
| 29 | + } |
| 30 | + |
| 31 | + private WaveformStreamer(AudioClip clip, double start, double duration, |
| 32 | + int numOutputSamples, Func<object, float[], int, bool> onNewWaveformData) |
| 33 | + { |
| 34 | + m_Data = Internal_WaveformStreamerCreateUntyped(this, clip, start, duration, numOutputSamples, onNewWaveformData); |
| 35 | + } |
| 36 | + |
| 37 | + ~WaveformStreamer() |
| 38 | + { |
| 39 | + if (m_Data != IntPtr.Zero) |
| 40 | + Internal_WaveformStreamerDestroy(m_Data); |
| 41 | + } |
| 42 | + |
| 43 | + internal static object CreateUntypedWaveformStreamer(AudioClip clip, double start, double duration, |
| 44 | + int numOutputSamples, Func<object, float[], int, bool> onNewWaveformData) |
| 45 | + { |
| 46 | + return new WaveformStreamer(clip, start, duration, numOutputSamples, onNewWaveformData); |
| 47 | + } |
| 48 | + |
| 49 | + [NativeThrows] |
| 50 | + internal static extern IntPtr Internal_WaveformStreamerCreate(WaveformStreamer instance, [NotNull] AudioClip clip, double start, double duration, |
| 51 | + int numOutputSamples, [NotNull] Func<WaveformStreamer, float[], int, bool> onNewWaveformData); |
| 52 | + |
| 53 | + internal static extern bool Internal_WaveformStreamerQueryFinishedStatus(IntPtr streamer); |
| 54 | + |
| 55 | + internal static extern void Internal_WaveformStreamerStop(IntPtr streamer); |
| 56 | + |
| 57 | + [NativeThrows] |
| 58 | + internal static extern IntPtr Internal_WaveformStreamerCreateUntyped(object instance, [NotNull] AudioClip clip, double start, double duration, |
| 59 | + int numOutputSamples, [NotNull] Func<object, float[], int, bool> onNewWaveformData); |
| 60 | + |
| 61 | + [NativeMethod(IsThreadSafe = true)] |
| 62 | + internal static extern void Internal_WaveformStreamerDestroy(IntPtr streamer); |
| 63 | + } |
| 64 | +} |
0 commit comments