Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Wasm.Audio/Audio/AudioBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public int Length
get { return InvokeRetInt("nkAudioBuffer.GetLength"); }
}

public double Duration
{
get { return InvokeRetDouble("nkAudioBuffer.GetDuration"); }
}

public int NumberOfChannels
{
get { return InvokeRetInt("nkAudioBuffer.GetNumberOfChannels"); }
Expand Down
5 changes: 5 additions & 0 deletions Wasm.Audio/Audio/AudioBufferSourceNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public AudioParam PlaybackRate
}
}

public void Start(double when = 0d, double offset = 0d, double duration = 0d)
{
Invoke("nkAudioBufferSourceNode.Start", when, offset, duration);
}

protected override void Dispose(bool disposing)
{
if (disposing)
Expand Down
9 changes: 9 additions & 0 deletions Wasm.Audio/Audio/BaseAudioContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ public int SampleRate
}
}

public double CurrentTime
{
get
{
double currentTime = InvokeRetDouble("nkAudioBaseContext.GetCurrentTime");
return currentTime;
}
}

public AudioDestinationNode Destination
{
get
Expand Down
25 changes: 24 additions & 1 deletion Wasm.Audio/wwwroot/js/Audio.8.0.11.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
Create: function()
{
var ac = new AudioContext();
var ac = new AudioContext();
return nkJSObject.RegisterObject(ac);
},
Create1: function(sampleRate)
Expand Down Expand Up @@ -63,6 +63,12 @@ window.nkAudioBaseContext =
var sr = ac.sampleRate;
return sr;
},
GetCurrentTime: function(uid, d)
{
var ac = nkJSObject.GetObject(uid);
var ct = ac.currentTime;
return ct;
},
GetDestination: function(uid, d)
{
var ac = nkJSObject.GetObject(uid);
Expand Down Expand Up @@ -183,6 +189,12 @@ window.nkAudioBuffer =
var ln = ab.length;
return ln;
},
GetDuration: function(uid, d)
{
var ab = nkJSObject.GetObject(uid);
var du = ab.duration;
return du;
},
GetNumberOfChannels: function(uid, d)
{
var ab = nkJSObject.GetObject(uid);
Expand Down Expand Up @@ -288,6 +300,17 @@ window.nkAudioBufferSourceNode =
var bs = nkJSObject.GetObject(uid);
var pr = bs.playbackRate;
return nkJSObject.RegisterObject(pr);
},
Start: function(uid, d)
{
var bs = nkJSObject.GetObject(uid);
var wh = Module.HEAPF64[(d+ 0) >> 3];
var os = Module.HEAPF64[(d+ 8) >> 3];
var du = Module.HEAPF64[(d+ 16) >> 3];
if (du > 0)
bs.start(wh, os, du);
else
bs.start(wh, os);
}
};

Expand Down