| 11 | * @internal |
| 12 | */ |
| 13 | export class TestOutput implements ISynthOutput { |
| 14 | public samples: Float32Array[] = []; |
| 15 | public sampleCount: number = 0; |
| 16 | private _storeSamples: boolean; |
| 17 | |
| 18 | public get sampleRate(): number { |
| 19 | return 44100; |
| 20 | } |
| 21 | |
| 22 | public constructor(storeSamples: boolean = true) { |
| 23 | this._storeSamples = storeSamples; |
| 24 | } |
| 25 | |
| 26 | public open(_bufferTimeInMilliseconds: number): void { |
| 27 | this.samples = []; |
| 28 | (this.ready as EventEmitter).trigger(); |
| 29 | } |
| 30 | |
| 31 | public play(): void { |
| 32 | // nothing to do |
| 33 | } |
| 34 | |
| 35 | public destroy(): void { |
| 36 | // nothing to do |
| 37 | } |
| 38 | |
| 39 | public next(): void { |
| 40 | (this.sampleRequest as EventEmitter).trigger(); |
| 41 | } |
| 42 | |
| 43 | public pause(): void { |
| 44 | // nothing to do |
| 45 | } |
| 46 | |
| 47 | public addSamples(f: Float32Array): void { |
| 48 | if (this._storeSamples) { |
| 49 | this.samples.push(f); |
| 50 | } |
| 51 | this.sampleCount += f.length; |
| 52 | (this.samplesPlayed as EventEmitterOfT<number>).trigger(f.length / SynthConstants.AudioChannels); |
| 53 | } |
| 54 | |
| 55 | public resetSamples(): void { |
| 56 | // nothing to do |
| 57 | } |
| 58 | |
| 59 | public activate(): void { |
| 60 | // nothing to do |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Fired when the output has been successfully opened and is ready to play samples. |
| 65 | */ |
| 66 | readonly ready: IEventEmitter = new EventEmitter(); |
| 67 | |
| 68 | /** |
| 69 | * Fired when a certain number of samples have been played. |
| 70 | */ |
nothing calls this directly
no outgoing calls
no test coverage detected