-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(dsp): various minor additions, updates, renames, docs
- Loading branch information
1 parent
bf506a5
commit e5e1a22
Showing
14 changed files
with
138 additions
and
93 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
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
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
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
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
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,39 @@ | ||
import { AGen } from "./agen"; | ||
|
||
/** | ||
* https://en.wikipedia.org/wiki/Dirac_comb | ||
* | ||
* @param period - | ||
* @param start - | ||
*/ | ||
export const impulseTrain = (period: number, start?: number) => | ||
new ImpulseTrain(1, 0, period, start); | ||
|
||
export const impulseTrainT = <T>( | ||
on: T, | ||
off: T, | ||
period: number, | ||
start?: number | ||
) => new ImpulseTrain(on, off, period, start); | ||
|
||
export const impulseTrainB = (period: number, start?: number) => | ||
new ImpulseTrain(true, false, period, start); | ||
|
||
export class ImpulseTrain<T> extends AGen<T> { | ||
constructor( | ||
protected _on: T, | ||
protected _off: T, | ||
protected _period: number, | ||
protected _pos = 0 | ||
) { | ||
super(_off); | ||
this._pos--; | ||
} | ||
|
||
next() { | ||
return (this._val = | ||
++this._pos >= this._period | ||
? ((this._pos = 0), this._on) | ||
: this._off); | ||
} | ||
} |
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
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
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
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
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
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.