Skip to content

Commit

Permalink
Added support for ChannelMergerNode and ChannelSplitterNode.
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferStrube committed Oct 14, 2023
1 parent 1ea3566 commit c9edb3e
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
(157, 200),
(202, 252),
(254, 254),
(285, 315),
(285, 333),
(388, 396),
(446, 456),
(461, 468)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using Microsoft.JSInterop;
using KristofferStrube.Blazor.WebAudio.Extensions;
using KristofferStrube.Blazor.WebAudio.Options;
using KristofferStrube.Blazor.WebIDL.Exceptions;
using Microsoft.JSInterop;

namespace KristofferStrube.Blazor.WebAudio;

Expand Down Expand Up @@ -26,5 +29,23 @@ public class ChannelMergerNode : AudioNode
return Task.FromResult(new ChannelMergerNode(jSRuntime, jSReference));
}

/// <summary>
/// Creates an <see cref="ChannelMergerNode"/> using the standard constructor.
/// </summary>
/// <remarks>
/// It throws an <see cref="IndexSizeErrorException"/> if <see cref="ChannelMergerOptions.NumberOfInputs"/> is less than <c>1</c> or larger than the supported number of channels.
/// </remarks>
/// <param name="jSRuntime">An <see cref="IJSRuntime"/> instance.</param>
/// <param name="context">The <see cref="BaseAudioContext"/> this new <see cref="ChannelMergerNode"/> will be associated with.</param>
/// <param name="options">Optional initial parameter value for this <see cref="ChannelMergerNode"/>.</param>
/// <exception cref="IndexSizeErrorException"></exception>
/// <returns>A new instance of an <see cref="ChannelMergerNode"/>.</returns>
public static async Task<ChannelMergerNode> CreateAsync(IJSRuntime jSRuntime, BaseAudioContext context, ChannelMergerOptions? options = null)
{
IJSObjectReference helper = await jSRuntime.GetHelperAsync();
IJSObjectReference jSInstance = await helper.InvokeAsync<IJSObjectReference>("constructChannelMergerNode", context, options);
return new ChannelMergerNode(jSRuntime, jSInstance);
}

private ChannelMergerNode(IJSRuntime jSRuntime, IJSObjectReference jSReference) : base(jSRuntime, jSReference) { }
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using Microsoft.JSInterop;
using KristofferStrube.Blazor.WebAudio.Extensions;
using KristofferStrube.Blazor.WebAudio.Options;
using KristofferStrube.Blazor.WebIDL.Exceptions;
using Microsoft.JSInterop;

namespace KristofferStrube.Blazor.WebAudio;

Expand All @@ -25,5 +28,23 @@ public class ChannelSplitterNode : AudioNode
return Task.FromResult(new ChannelSplitterNode(jSRuntime, jSReference));
}

/// <summary>
/// Creates an <see cref="ChannelSplitterNode"/> using the standard constructor.
/// </summary>
/// <remarks>
/// It throws an <see cref="IndexSizeErrorException"/> if <see cref="ChannelSplitterOptions.NumberOfInputs"/> is less than <c>1</c> or larger than the supported number of channels.
/// </remarks>
/// <param name="jSRuntime">An <see cref="IJSRuntime"/> instance.</param>
/// <param name="context">The <see cref="BaseAudioContext"/> this new <see cref="ChannelSplitterNode"/> will be associated with.</param>
/// <param name="options">Optional initial parameter value for this <see cref="ChannelSplitterNode"/>.</param>
/// <exception cref="IndexSizeErrorException"></exception>
/// <returns>A new instance of an <see cref="ChannelSplitterNode"/>.</returns>
public static async Task<ChannelSplitterNode> CreateAsync(IJSRuntime jSRuntime, BaseAudioContext context, ChannelSplitterOptions? options = null)
{
IJSObjectReference helper = await jSRuntime.GetHelperAsync();
IJSObjectReference jSInstance = await helper.InvokeAsync<IJSObjectReference>("constructChannelSplitterNode", context, options);
return new ChannelSplitterNode(jSRuntime, jSInstance);
}

private ChannelSplitterNode(IJSRuntime jSRuntime, IJSObjectReference jSReference) : base(jSRuntime, jSReference) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
namespace KristofferStrube.Blazor.WebAudio;

/// <summary>
/// This specifies the options that can be used in constructing all <see cref="AudioNode"/>s. All members are optional. However, the specific values used for each node depends on the actual node.
/// This specifies the options that can be used in constructing all <see cref="AudioNode"/>s.
/// All members are optional. However, the specific values used for each node depends on the actual node.
/// </summary>
/// <remarks><see href="https://www.w3.org/TR/webaudio/#AudioNodeOptions">See the API definition here</see>.</remarks>
public class AudioNodeOptions
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using KristofferStrube.Blazor.WebIDL.Exceptions;

namespace KristofferStrube.Blazor.WebAudio.Options;


/// <summary>
/// This specifies the options to use in constructing a <see cref="ChannelMergerNode"/>.
/// </summary>
/// <remarks><see href="https://www.w3.org/TR/webaudio/#ChannelMergerOptions">See the API definition here</see>.</remarks>
public class ChannelMergerOptions : AudioNodeOptions
{
/// <summary>
/// The number inputs for the <see cref="ChannelMergerNode"/>.
/// </summary>
/// <remarks>
/// It throws an <see cref="IndexSizeErrorException"/> if it is less than <c>1</c> or larger than the supported number of channels when used for constructing a <see cref="ChannelMergerNode"/>.
/// </remarks>
public ulong NumberOfInputs { get; set; } = 6;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using KristofferStrube.Blazor.WebIDL.Exceptions;

namespace KristofferStrube.Blazor.WebAudio.Options;

/// <summary>
/// This specifies the options to use in constructing a <see cref="ChannelSplitterNode"/>.
/// </summary>
/// <remarks><see href="https://www.w3.org/TR/webaudio/#ChannelSplitterOptions">See the API definition here</see>.</remarks>
public class ChannelSplitterOptions : AudioNodeOptions
{
/// <summary>
/// The number inputs for the <see cref="ChannelSplitterNode"/>.
/// </summary>
/// <remarks>
/// It throws an <see cref="IndexSizeErrorException"/> if it is less than <c>1</c> or larger than the supported number of channels when used for constructing a <see cref="ChannelSplitterNode"/>.
/// </remarks>
public ulong NumberOfInputs { get; set; } = 6;
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ export function constructBiquadFilterNode(context, options) {
return new BiquadFilterNode(context, options);
}

export function constructChannelMergerNode(context, options) {
return new ChannelMergerNode(context, options);
}

export function constructChannelSplitterNode(context, options) {
return new ChannelSplitterNode(context, options);
}

export function constructAudioBuffer(options) {
return new AudioBuffer(options);
}
Expand Down

0 comments on commit c9edb3e

Please sign in to comment.