Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"lint:fix": "eslint . --fix",
"format": "prettier --write \"src/**/*.{ts,tsx,json,css}\"",
"format:check": "prettier --check \"src/**/*.{ts,tsx,json,css}\"",
"preview": "vite preview"
"preview": "vite preview",
"check": "npm run lint && npm run format:check && npm run build",
"fix": "npm run lint:fix && npm run format && npm run build"
},
"dependencies": {
"react": "^19.2.0",
Expand Down
4 changes: 2 additions & 2 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@
box-sizing: border-box;
}

.library-tabs{
.library-tabs {
display: flex;
width: 100%;
border-bottom: 1px solid var(--border-color);
}

.library-tab{
.library-tab {
flex: 1;
padding: var(--space-3) 0;
font-size: var(--fs-base);
Expand Down
6 changes: 3 additions & 3 deletions src/components/MusicLibrary.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useState } from 'react'
import { useState } from 'react';

type Tab = 'music' | 'sfx'
type Tab = 'music' | 'sfx';

export default function MusicLibrary() {
const [activeTab, setActiveTab] = useState<Tab>('music')
const [activeTab, setActiveTab] = useState<Tab>('music');

return (
<div className="music-library">
Expand Down
10 changes: 3 additions & 7 deletions src/components/NowPlaying.tsx
Comment thread
rafizamankhan marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@ export default function NowPlaying() {
<div className="np-content">
{/* Album Cover */}
<div className="np-album-cover-wrapper">
<img
src={mockSong.coverUrl}
alt={`${mockSong.album} cover`}
className="np-album-cover"
/>
<img src={mockSong.coverUrl} alt={`${mockSong.album} cover`} className="np-album-cover" />
</div>

{/* Main Section */}
Expand Down Expand Up @@ -91,14 +87,14 @@ export default function NowPlaying() {

{/* Controls */}
<div className="np-controls">
<button
<button
className={`np-btn np-play-btn ${isPlaying ? 'active' : ''}`}
onClick={handlePlay}
title="Play"
>
▶ Play
</button>
<button
<button
className={`np-btn np-pause-btn ${!isPlaying ? 'active' : ''}`}
onClick={handlePause}
title="Pause"
Expand Down
8 changes: 4 additions & 4 deletions types/AudioEvent.ts
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[];
}
8 changes: 4 additions & 4 deletions types/Clip.ts
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;
}
17 changes: 12 additions & 5 deletions types/Fade.ts

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea what typescript fuckery is going on here

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The 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;
}
6 changes: 3 additions & 3 deletions types/Track.ts
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[];
}
4 changes: 3 additions & 1 deletion types/UtilTypes.ts
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;