4track 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/README.md +80 -0
- package/dist/assets/btn_fwd.svg +30 -0
- package/dist/assets/btn_normal.png +0 -0
- package/dist/assets/btn_pause.svg +30 -0
- package/dist/assets/btn_play.svg +25 -0
- package/dist/assets/btn_pressed.png +0 -0
- package/dist/assets/btn_rec.svg +25 -0
- package/dist/assets/btn_rew.svg +30 -0
- package/dist/assets/btn_stop.svg +25 -0
- package/dist/assets/casette_hiss.mp3 +0 -0
- package/dist/assets/casette_hiss_compressed.mp3 +0 -0
- package/dist/assets/cassette.jpg +0 -0
- package/dist/assets/counter_bg.png +0 -0
- package/dist/assets/fx/counter.wav +0 -0
- package/dist/assets/fx/ffwd.wav +0 -0
- package/dist/assets/fx/pause.wav +0 -0
- package/dist/assets/fx/play.wav +0 -0
- package/dist/assets/fx/record.wav +0 -0
- package/dist/assets/fx/stop.wav +0 -0
- package/dist/assets/fx/track.wav +0 -0
- package/dist/assets/logo.svg +51 -0
- package/dist/assets/noise_50.jpg +0 -0
- package/dist/assets/openstudio.svg +38 -0
- package/dist/assets/recorder-worklet.d.ts +8 -0
- package/dist/assets/recorder-worklet.js +30 -0
- package/dist/assets/rotator.png +0 -0
- package/dist/assets/slider-indicator.svg +139 -0
- package/dist/assets/slider.png +0 -0
- package/dist/assets/slideselect-indicator.svg +64 -0
- package/dist/assets/slideselect-thumb.png +0 -0
- package/dist/assets/svg-icons.d.ts +6 -0
- package/dist/assets/svg-icons.js +8 -0
- package/dist/assets.d.ts +34 -0
- package/dist/audio/constants.d.ts +4 -0
- package/dist/audio/constants.js +27 -0
- package/dist/audio/engine.svelte.d.ts +90 -0
- package/dist/audio/engine.svelte.js +604 -0
- package/dist/audio/input-fx.d.ts +8 -0
- package/dist/audio/input-fx.js +44 -0
- package/dist/audio/metering.d.ts +3 -0
- package/dist/audio/metering.js +20 -0
- package/dist/audio/pcm.d.ts +2 -0
- package/dist/audio/pcm.js +43 -0
- package/dist/audio/project-io.d.ts +6 -0
- package/dist/audio/project-io.js +85 -0
- package/dist/audio/recording.d.ts +2 -0
- package/dist/audio/recording.js +80 -0
- package/dist/audio/track.svelte.d.ts +13 -0
- package/dist/audio/track.svelte.js +17 -0
- package/dist/components/Cassette.svelte +179 -0
- package/dist/components/Cassette.svelte.d.ts +9 -0
- package/dist/components/FourTrack.svelte +443 -0
- package/dist/components/FourTrack.svelte.d.ts +16 -0
- package/dist/components/Mixer.svelte +105 -0
- package/dist/components/Mixer.svelte.d.ts +7 -0
- package/dist/components/TransportButtons.svelte +299 -0
- package/dist/components/TransportButtons.svelte.d.ts +10 -0
- package/dist/components/els/DigitRoller.svelte +82 -0
- package/dist/components/els/DigitRoller.svelte.d.ts +5 -0
- package/dist/components/els/Knob.svelte +267 -0
- package/dist/components/els/Knob.svelte.d.ts +12 -0
- package/dist/components/els/Light.svelte +104 -0
- package/dist/components/els/Light.svelte.d.ts +8 -0
- package/dist/components/els/Lights.svelte +101 -0
- package/dist/components/els/Lights.svelte.d.ts +11 -0
- package/dist/components/els/SlideSelect.svelte +159 -0
- package/dist/components/els/SlideSelect.svelte.d.ts +15 -0
- package/dist/components/els/Slider.svelte +139 -0
- package/dist/components/els/Slider.svelte.d.ts +21 -0
- package/dist/components/els/Timestamp.svelte +92 -0
- package/dist/components/els/Timestamp.svelte.d.ts +5 -0
- package/dist/fx/soundfx.d.ts +14 -0
- package/dist/fx/soundfx.js +65 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/types.d.ts +40 -0
- package/dist/types.js +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import stopUrl from '../assets/fx/stop.wav?url';
|
|
2
|
+
import ffwdUrl from '../assets/fx/ffwd.wav?url';
|
|
3
|
+
import pauseUrl from '../assets/fx/pause.wav?url';
|
|
4
|
+
import playUrl from '../assets/fx/play.wav?url';
|
|
5
|
+
import trackUrl from '../assets/fx/track.wav?url';
|
|
6
|
+
import counterUrl from '../assets/fx/counter.wav?url';
|
|
7
|
+
import recordUrl from '../assets/fx/record.wav?url';
|
|
8
|
+
const browser = typeof window !== 'undefined';
|
|
9
|
+
const soundPaths = {
|
|
10
|
+
stop: stopUrl,
|
|
11
|
+
ffwd: ffwdUrl,
|
|
12
|
+
pause: pauseUrl,
|
|
13
|
+
play: playUrl,
|
|
14
|
+
track: trackUrl,
|
|
15
|
+
counter: counterUrl,
|
|
16
|
+
record: recordUrl,
|
|
17
|
+
};
|
|
18
|
+
let ctx;
|
|
19
|
+
const buffers = new Map();
|
|
20
|
+
const loops = new Map();
|
|
21
|
+
async function getBuffer(key) {
|
|
22
|
+
if (!ctx)
|
|
23
|
+
ctx = new AudioContext();
|
|
24
|
+
if (buffers.has(key))
|
|
25
|
+
return buffers.get(key);
|
|
26
|
+
const response = await fetch(soundPaths[key]);
|
|
27
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
28
|
+
const audioBuffer = await ctx.decodeAudioData(arrayBuffer);
|
|
29
|
+
buffers.set(key, audioBuffer);
|
|
30
|
+
return audioBuffer;
|
|
31
|
+
}
|
|
32
|
+
export async function playFx(key, volume = 0.025) {
|
|
33
|
+
if (!browser)
|
|
34
|
+
return;
|
|
35
|
+
const buffer = await getBuffer(key);
|
|
36
|
+
const source = ctx.createBufferSource();
|
|
37
|
+
const gain = ctx.createGain();
|
|
38
|
+
source.buffer = buffer;
|
|
39
|
+
gain.gain.value = volume;
|
|
40
|
+
source.connect(gain).connect(ctx.destination);
|
|
41
|
+
source.start();
|
|
42
|
+
}
|
|
43
|
+
export async function playLoop(key, volume = 0.025) {
|
|
44
|
+
if (!browser)
|
|
45
|
+
return;
|
|
46
|
+
stopLoop(key);
|
|
47
|
+
const buffer = await getBuffer(key);
|
|
48
|
+
const source = ctx.createBufferSource();
|
|
49
|
+
const gain = ctx.createGain();
|
|
50
|
+
source.buffer = buffer;
|
|
51
|
+
source.loop = true;
|
|
52
|
+
gain.gain.value = volume;
|
|
53
|
+
source.connect(gain).connect(ctx.destination);
|
|
54
|
+
source.start();
|
|
55
|
+
loops.set(key, source);
|
|
56
|
+
}
|
|
57
|
+
export function stopLoop(key) {
|
|
58
|
+
if (!browser)
|
|
59
|
+
return;
|
|
60
|
+
const source = loops.get(key);
|
|
61
|
+
if (source) {
|
|
62
|
+
source.stop();
|
|
63
|
+
loops.delete(key);
|
|
64
|
+
}
|
|
65
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { AudioEngine } from './audio/engine.svelte.js';
|
|
2
|
+
export { Track } from './audio/track.svelte.js';
|
|
3
|
+
export { default as FourTrack } from './components/FourTrack.svelte';
|
|
4
|
+
export type { AudioEngineConfig, HiddenTrackConfig, TrimFxConfig, ProjectMetadata, TrackMeta, PlayState, LoadStatus } from './types.js';
|
package/dist/index.js
ADDED
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface HiddenTrackConfig {
|
|
2
|
+
url: string;
|
|
3
|
+
volume: number;
|
|
4
|
+
pan?: number;
|
|
5
|
+
}
|
|
6
|
+
export interface AudioEngineConfig {
|
|
7
|
+
sampleRate: number;
|
|
8
|
+
bitDepth: number;
|
|
9
|
+
maxSeconds: number;
|
|
10
|
+
trackCount: number;
|
|
11
|
+
inputFx: TrimFxConfig[];
|
|
12
|
+
workletUrl: string;
|
|
13
|
+
hiddenTracks?: HiddenTrackConfig[];
|
|
14
|
+
}
|
|
15
|
+
export interface TrimFxConfig {
|
|
16
|
+
type: 'trim';
|
|
17
|
+
enabled: boolean;
|
|
18
|
+
default: number;
|
|
19
|
+
gainMin: number;
|
|
20
|
+
gainRange: number;
|
|
21
|
+
curveBase: number;
|
|
22
|
+
curveRange: number;
|
|
23
|
+
}
|
|
24
|
+
export interface TrackMeta {
|
|
25
|
+
samples: number;
|
|
26
|
+
volume: number;
|
|
27
|
+
pan: number;
|
|
28
|
+
trimStart: number;
|
|
29
|
+
hidden?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface ProjectMetadata {
|
|
32
|
+
filetypeVersion?: number;
|
|
33
|
+
sampleRate: number;
|
|
34
|
+
bitDepth: number;
|
|
35
|
+
masterVolume: number;
|
|
36
|
+
tracks: TrackMeta[];
|
|
37
|
+
}
|
|
38
|
+
export type PlayState = 'stopped' | 'playing' | 'paused' | 'recording';
|
|
39
|
+
export type MicStatus = 'unsupported' | 'prompt' | 'denied' | 'no-device' | 'inactive' | 'active' | 'error';
|
|
40
|
+
export type LoadStatus = 'idle' | 'loading' | 'ready' | 'error';
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "4track",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A 4-track cassette recorder component for Svelte 5",
|
|
5
|
+
"license": "GPL-3.0-only",
|
|
6
|
+
"author": "Andre Boekhorst",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/andreboekhorst/4track.cc.git"
|
|
10
|
+
},
|
|
11
|
+
"keywords": ["svelte", "audio", "recorder", "cassette", "4-track"],
|
|
12
|
+
"type": "module",
|
|
13
|
+
"svelte": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"svelte": "./dist/index.js",
|
|
19
|
+
"default": "./dist/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"dev": "vite dev",
|
|
27
|
+
"build": "vite build",
|
|
28
|
+
"preview": "vite preview",
|
|
29
|
+
"package": "svelte-package -o dist",
|
|
30
|
+
"check": "svelte-check --tsconfig ./tsconfig.json",
|
|
31
|
+
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
|
|
32
|
+
"prepublishOnly": "npm run package"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"svelte": "^5.0.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@sveltejs/package": "^2.5.7",
|
|
39
|
+
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
|
40
|
+
"prettier": "^3.8.1",
|
|
41
|
+
"prettier-plugin-svelte": "^3.5.0",
|
|
42
|
+
"sass": "^1.97.3",
|
|
43
|
+
"svelte": "^5.49.2",
|
|
44
|
+
"svelte-check": "^4.3.6",
|
|
45
|
+
"typescript": "^5.9.3",
|
|
46
|
+
"vite": "^7.3.1"
|
|
47
|
+
}
|
|
48
|
+
}
|