Repository navigation
refactor: add Seconds and Gain Type aliases, replace enum with const,… #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
04e70d7
adf35df
af0b533
ded0ca7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,13 @@ | ||
| import type { Fade } from "./Fade"; | ||
| import type { ID } from "./UtilTypes"; | ||
| import type { ID, Seconds } from "./UtilTypes"; | ||
|
|
||
| export interface AudioEvent { | ||
| id: ID; | ||
| clipId: ID; | ||
| trackId: ID; | ||
| buffer: AudioBuffer; | ||
| startAbsTime: number; | ||
| offsetIntoBuffer: number; | ||
| duration: number; | ||
| startAbsTime: Seconds; | ||
| offsetIntoBuffer: Seconds; | ||
| duration: Seconds; | ||
| fades: Fade[]; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| import type { Fade } from "./Fade"; | ||
| import type { ID } from "./UtilTypes"; | ||
| import type { ID, Seconds } from "./UtilTypes"; | ||
|
|
||
| export interface Clip { | ||
| id: ID; | ||
| bufferID: ID; | ||
| startTime: number; | ||
| duration: number; | ||
| offset: number; // offset from start of project | ||
| startTime: Seconds; | ||
| duration: Seconds; | ||
| offset: Seconds; // offset from start of project | ||
| fades: Fade[]; | ||
| title: string; | ||
| } |
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have no idea what typescript fuckery is going on here
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So how we have ID determining string instead of just using string, here seconds and gain adds context instead of using plain number types to avoid mismatches. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,16 @@ | ||
| export type FadeType = 'LINEAR' | 'EXPONENTIAL'; | ||
| import type {Seconds, Gain} from "./UtilTypes" | ||
|
|
||
| export const FadeType = { | ||
| LINEAR: 0, | ||
| EXPONENTIAL: 1, | ||
| } as const; | ||
|
|
||
| export type FadeType = (typeof FadeType)[keyof typeof FadeType]; | ||
|
|
||
| export interface Fade { | ||
| type: FadeType; | ||
| startOffset: number; | ||
| endOffset: number; | ||
| startGain: number; | ||
| endGain: number; | ||
| startOffset: Seconds; | ||
| endOffset: Seconds; | ||
| startGain: Gain; | ||
| endGain: Gain; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
| import type { ID } from "./UtilTypes"; | ||
| import type { ID, Seconds, Gain } from "./UtilTypes"; | ||
| import type { Clip } from "./Clip" | ||
|
|
||
| export interface Track { | ||
| id: ID; | ||
| clips: Clip[]; | ||
| gain: number; | ||
| gain: Gain; | ||
| muted: boolean; | ||
| getEventsBetween(windowStart: number, windowEnd: number): number[]; | ||
| getEventsBetween(windowStart: Seconds, windowEnd: Seconds): Seconds[]; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,3 @@ | ||
| export type ID = string; | ||
| export type ID = string; | ||
| export type Seconds = number; | ||
| export type Gain = number; |
Uh oh!
There was an error while loading. Please reload this page.