This repository has been archived by the owner on Jun 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
813 additions
and
582 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
import { ComponentUpdateEvent } from '../heck/components/Component'; | ||
|
||
export type Observer<T> = ( arg: T ) => void; | ||
import { Observer } from '../utils/Observer'; | ||
|
||
export const resizeObservers: Observer<[ width: number, height: number ]>[] = []; | ||
export const editorVisibleObservers: Observer<boolean>[] = []; | ||
export const musicRendererStatusObservers: Observer<'none' | 'compiling' | 'applying'>[] = []; | ||
export const preparationProgressObservers: Observer<number>[] = []; | ||
export const audioAnalyzerObservers: Observer<void>[] = []; | ||
export const componentUpdateObservers: Observer<ComponentUpdateEvent>[] = []; | ||
export const shaderEventApplyObservers: Observer<void>[] = []; | ||
export const shaderEventAlterObservers: Observer<void>[] = []; |
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,3 @@ | ||
import { GLSLMusicEditor } from '../music/GLSLMusicEditor'; | ||
|
||
export const glslMusicEditor = new GLSLMusicEditor(); |
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,61 @@ | ||
import { audio } from '../globals/audio'; | ||
|
||
export class AudioBufferPlayer { | ||
public gainNode: GainNode; | ||
public buffer?: AudioBuffer; | ||
|
||
private __currentSource?: AudioBufferSourceNode | null; | ||
private __beginTime: number; | ||
private __pausedTime: number; | ||
|
||
public get isPlaying(): boolean { | ||
return this.__currentSource != null; | ||
} | ||
|
||
public get time(): number { | ||
if ( this.__currentSource != null ) { | ||
return audio.currentTime - this.__beginTime; | ||
} else { | ||
return this.__pausedTime; | ||
} | ||
} | ||
|
||
public set time( time: number ) { | ||
const { isPlaying } = this; | ||
|
||
this.pause(); | ||
this.__pausedTime = time; | ||
|
||
if ( isPlaying ) { | ||
this.play(); | ||
} | ||
} | ||
|
||
public constructor() { | ||
this.gainNode = audio.createGain(); | ||
|
||
this.__beginTime = 0.0; | ||
this.__pausedTime = 0.0; | ||
} | ||
|
||
public play(): void { | ||
this.pause(); | ||
|
||
this.__currentSource = audio.createBufferSource(); | ||
this.__currentSource.connect( this.gainNode ); | ||
this.__currentSource.buffer = this.buffer!; | ||
this.__currentSource.start( 0.0, this.__pausedTime ); | ||
|
||
this.__beginTime = audio.currentTime - this.__pausedTime; | ||
} | ||
|
||
public pause(): void { | ||
if ( this.__currentSource != null ) { | ||
this.__currentSource.stop(); | ||
this.__currentSource.disconnect(); | ||
this.__currentSource = null; | ||
|
||
this.__pausedTime = audio.currentTime - this.__beginTime; | ||
} | ||
} | ||
} |
Oops, something went wrong.