-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
1,076 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System; | ||
using nkast.Wasm.Dom; | ||
|
||
namespace nkast.Wasm.Audio | ||
{ | ||
public class AudioBuffer : JSObject | ||
{ | ||
BaseAudioContext _context; | ||
|
||
internal AudioBuffer(int uid, BaseAudioContext context) : base(uid) | ||
{ | ||
_context = context; | ||
} | ||
|
||
public int SampleRate | ||
{ | ||
get { return InvokeRet<int>("nkAudioBuffer.GetSampleRate"); } | ||
} | ||
|
||
public int Length | ||
{ | ||
get { return InvokeRet<int>("nkAudioBuffer.GetLength"); } | ||
} | ||
|
||
public int NumberOfChannels | ||
{ | ||
get { return InvokeRet<int>("nkAudioBuffer.GetNumberOfChannels"); } | ||
} | ||
|
||
public void CopyToChannel(float[] source, int channelNumber) | ||
{ | ||
Invoke("nkAudioBuffer.CopyToChannel", channelNumber, source); | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
if (IsDisposed) | ||
return; | ||
|
||
if (disposing) | ||
{ | ||
|
||
} | ||
|
||
_context = null; | ||
|
||
base.Dispose(disposing); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using nkast.Wasm.Dom; | ||
|
||
namespace nkast.Wasm.Audio | ||
{ | ||
public class AudioBufferSourceNode : AudioScheduledSourceNode | ||
{ | ||
|
||
internal AudioBufferSourceNode(int uid, BaseAudioContext context) : base(uid, context) | ||
{ | ||
} | ||
|
||
public AudioBuffer Buffer | ||
{ | ||
get { throw new NotImplementedException(); } | ||
set { Invoke("nkAudioBufferSourceNode.SetBuffer", value.Uid); } | ||
} | ||
|
||
public bool Loop | ||
{ | ||
get { return InvokeRet<bool>("nkAudioBufferSourceNode.GetLoop"); } | ||
set { Invoke("nkAudioBufferSourceNode.SetLoop", value ? 1 : 0); } | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
if (IsDisposed) | ||
return; | ||
|
||
if (disposing) | ||
{ | ||
|
||
} | ||
|
||
base.Dispose(disposing); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Microsoft.JSInterop.WebAssembly; | ||
using nkast.Wasm.Dom; | ||
|
||
namespace nkast.Wasm.Audio | ||
{ | ||
public class AudioContext : BaseAudioContext | ||
{ | ||
public AudioContext() : base(Register()) | ||
{ | ||
} | ||
|
||
|
||
private static int Register() | ||
{ | ||
WebAssemblyJSRuntime runtime = new WasmJSRuntime(); | ||
int uid = runtime.InvokeUnmarshalled<int>("nkAudioContext.Create"); | ||
return uid; | ||
} | ||
|
||
public void Close() | ||
{ | ||
Invoke("nkAudioContext.Close"); | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
if (IsDisposed) | ||
return; | ||
|
||
if (disposing) | ||
{ | ||
|
||
} | ||
|
||
Close(); | ||
|
||
base.Dispose(disposing); | ||
} | ||
|
||
internal sealed class WasmJSRuntime : WebAssemblyJSRuntime | ||
{ | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using nkast.Wasm.Dom; | ||
|
||
namespace nkast.Wasm.Audio | ||
{ | ||
public class AudioDestinationNode : AudioNode | ||
{ | ||
internal AudioDestinationNode(int uid, BaseAudioContext context) : base(uid, context) | ||
{ | ||
} | ||
|
||
public int MaxChannelCount | ||
{ | ||
get { return InvokeRet<int>("nkAudioDestinationNode.GetMaxChannelCount"); } | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
if (IsDisposed) | ||
return; | ||
|
||
if (disposing) | ||
{ | ||
|
||
} | ||
|
||
base.Dispose(disposing); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
using System; | ||
using nkast.Wasm.Dom; | ||
|
||
namespace nkast.Wasm.Audio | ||
{ | ||
public class AudioListener : JSObject | ||
{ | ||
BaseAudioContext _context; | ||
|
||
internal AudioListener(int uid, BaseAudioContext context) : base(uid) | ||
{ | ||
_context = context; | ||
} | ||
|
||
public float PositionX | ||
{ | ||
get { throw new NotImplementedException(); } | ||
set { Invoke("nkAudioListener.SetPositionX", value); } | ||
} | ||
|
||
public float PositionY | ||
{ | ||
get { throw new NotImplementedException(); } | ||
set { Invoke("nkAudioListener.SetPositionY", value); } | ||
} | ||
|
||
public float PositionZ | ||
{ | ||
get { throw new NotImplementedException(); } | ||
set { Invoke("nkAudioListener.SetPositionZ", value); } | ||
} | ||
|
||
public float ForwardX | ||
{ | ||
get { throw new NotImplementedException(); } | ||
set { Invoke("nkAudioListener.SetForwardX", value); } | ||
} | ||
|
||
public float ForwardY | ||
{ | ||
get { throw new NotImplementedException(); } | ||
set { Invoke("nkAudioListener.SetForwardY", value); } | ||
} | ||
|
||
public float ForwardZ | ||
{ | ||
get { throw new NotImplementedException(); } | ||
set { Invoke("nkAudioListener.SetForwardZ", value); } | ||
} | ||
|
||
public float UpX | ||
{ | ||
get { throw new NotImplementedException(); } | ||
set { Invoke("nkAudioListener.SetUpX", value); } | ||
} | ||
|
||
public float UpY | ||
{ | ||
get { throw new NotImplementedException(); } | ||
set { Invoke("nkAudioListener.SetUpY", value); } | ||
} | ||
|
||
public float UpZ | ||
{ | ||
get { throw new NotImplementedException(); } | ||
set { Invoke("nkAudioListener.SetUpZ", value); } | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
if (IsDisposed) | ||
return; | ||
|
||
if (disposing) | ||
{ | ||
|
||
} | ||
|
||
_context = null; | ||
|
||
base.Dispose(disposing); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using nkast.Wasm.Dom; | ||
|
||
namespace nkast.Wasm.Audio | ||
{ | ||
public class AudioNode : JSObject | ||
{ | ||
BaseAudioContext _context; | ||
|
||
protected BaseAudioContext Context { get { return _context; } } | ||
|
||
internal AudioNode(int uid, BaseAudioContext context) : base(uid) | ||
{ | ||
_context = context; | ||
} | ||
|
||
public void Connect(AudioNode destination) | ||
{ | ||
Invoke("nkAudioNode.Connect", destination.Uid); | ||
} | ||
|
||
public void Disconnect(AudioNode destination) | ||
{ | ||
Invoke("nkAudioNode.Disconnect", destination.Uid); | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
if (IsDisposed) | ||
return; | ||
|
||
if (disposing) | ||
{ | ||
|
||
} | ||
|
||
_context = null; | ||
|
||
base.Dispose(disposing); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using System; | ||
using nkast.Wasm.Dom; | ||
|
||
namespace nkast.Wasm.Audio | ||
{ | ||
public class AudioParam : JSObject | ||
{ | ||
BaseAudioContext _context; | ||
|
||
internal AudioParam(int uid, BaseAudioContext context) : base(uid) | ||
{ | ||
_context = context; | ||
} | ||
|
||
public float Value | ||
{ | ||
get { throw new NotImplementedException(); } | ||
set { Invoke("nkAudioParam.SetValue", value); } | ||
} | ||
|
||
public void SetValueAtTime(float value, float startTime) | ||
{ | ||
Invoke("nkAudioParam.SetValueAtTime", value, startTime); | ||
} | ||
|
||
public void LinearRampToValueAtTime(float value, float endTime) | ||
{ | ||
Invoke("nkAudioParam.LinearRampToValueAtTime", value, endTime); | ||
} | ||
|
||
public void ExponentialRampToValueAtTime(float value, float endTime) | ||
{ | ||
Invoke("nkAudioParam.ExponentialRampToValueAtTime", value, endTime); | ||
} | ||
|
||
public void SetTargetAtTime(float target, float startTime, float timeConstant) | ||
{ | ||
Invoke("nkAudioParam.SetTargetAtTime", target, startTime, timeConstant); | ||
} | ||
|
||
public void SetValueCurveAtTime(float[] values, float startTime, float duration) | ||
{ | ||
Invoke("nkAudioParam.SetValueCurveAtTime", startTime, duration, values); | ||
} | ||
|
||
public void CancelScheduledValues(float startTime) | ||
{ | ||
Invoke("nkAudioParam.CancelScheduledValues", startTime); | ||
} | ||
|
||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
if (IsDisposed) | ||
return; | ||
|
||
if (disposing) | ||
{ | ||
|
||
} | ||
|
||
_context = null; | ||
|
||
base.Dispose(disposing); | ||
} | ||
} | ||
} |
Oops, something went wrong.