Skip to content
This repository has been archived by the owner on Apr 3, 2022. It is now read-only.

Commit

Permalink
feat(filters): added distortion and rotation (#11)
Browse files Browse the repository at this point in the history
fix(filters): renamed bands to equalizer, which is the correct property
  • Loading branch information
kyranet authored Feb 10, 2021
1 parent 851f209 commit 5396625
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/core/Player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ export class Player<T extends BaseNode = BaseNode> extends EventEmitter {

/**
* @deprecated Please use `setFilters({ bands })` instead.
* @param bands The equalizer bads to be set.
* @param equalizer The equalizer bads to be set.
*/
public setEqualizer(bands: readonly EqualizerBand[]) {
return this.setFilters({ bands });
public setEqualizer(equalizer: readonly EqualizerBand[]) {
return this.setFilters({ equalizer });
}

public seek(position: number) {
Expand Down
82 changes: 76 additions & 6 deletions src/types/OutgoingPayloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,29 +155,41 @@ export interface OutgoingFilterPayload extends BaseOutgoingPayload {
volume?: number;

/**
* The equalizer bands.
* The equalizer bands, there are 15 bands (0-14) that can be changed.
*/
bands?: readonly EqualizerBand[];
equalizer?: readonly EqualizerBand[];

/**
* The karaoke options.
* The karaoke options, uses equalization to eliminate a part of a band, usually targeting vocals.
*/
karaoke?: KaraokeOptions;

/**
* The timescale options.
* The timescale options, used to change the speed, pitch, and rate.
*/
timescale?: TimescaleOptions;

/**
* The tremolo options.
* The tremolo options, uses amplification to create a shuddering effect, where the volume quickly oscillates,
* {@link https://en.wikipedia.org/wiki/File:Fuse_Electronics_Tremolo_MK-III_Quick_Demo.ogv example}.
*/
tremolo?: FrequencyDepthOptions;

/**
* The vibrato options.
* The vibrato options. Similar to tremolo, while tremolo oscillates the volume, vibrato oscillates the pitch.
*/
vibrato?: FrequencyDepthOptions;

/**
* The distortion options.
*/
distortion?: DistortionOptions;

/**
* The rotation options. This rotates the sound around the stereo channels/user headphones, also known as
* {@link https://en.wikipedia.org/wiki/Panning_(audio) Audio Panning}.
*/
rotation?: RotationOptions;
}

export interface KaraokeOptions {
Expand Down Expand Up @@ -239,3 +251,61 @@ export interface FrequencyDepthOptions {
*/
depth?: number;
}

export interface DistortionOptions {
/**
* The sine's offset.
* @default 0.0
*/
sinOffset?: number;

/**
* The sine's scale.
* @default 1.0
*/
sinScale?: number;

/**
* The cosine's offset.
* @default 0.0
*/
cosOffset?: number;

/**
* The cosine's scale.
* @default 1.0
*/
cosScale?: number;

/**
* The tangent offset.
* @default 0.0
*/
tanOffset?: number;

/**
* The tangent scale.
* @default 1.0
*/
tanScale?: number;

/**
* The overall offset for all waves.
* @default 0.0
*/
offset?: number;

/**
* The overall scale for all waves.
* @default 1.0
*/
scale?: number;
}

export interface RotationOptions {
/**
* The frequency in Hz to rotate.
* @default 2.0
*/
rotationHz?: number;
}

0 comments on commit 5396625

Please sign in to comment.