@nexart/codemode-sdk 1.0.1 → 1.1.1
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/CHANGELOG.md +109 -0
- package/CODE_MODE_PROTOCOL.md +312 -0
- package/README.md +308 -56
- package/dist/core-index.d.ts +21 -0
- package/dist/core-index.d.ts.map +1 -0
- package/dist/core-index.js +26 -0
- package/dist/execute.d.ts +46 -0
- package/dist/execute.d.ts.map +1 -0
- package/dist/execute.js +268 -0
- package/dist/index.d.ts +36 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +43 -17
- package/dist/loop-engine.d.ts +4 -1
- package/dist/loop-engine.d.ts.map +1 -1
- package/dist/loop-engine.js +17 -12
- package/dist/noise-bridge.d.ts +44 -0
- package/dist/noise-bridge.d.ts.map +1 -0
- package/dist/noise-bridge.js +68 -0
- package/dist/noise-engine.d.ts +74 -0
- package/dist/noise-engine.d.ts.map +1 -0
- package/dist/noise-engine.js +132 -0
- package/dist/noise-sketches/fractalNoise.d.ts +11 -0
- package/dist/noise-sketches/fractalNoise.d.ts.map +1 -0
- package/dist/noise-sketches/fractalNoise.js +121 -0
- package/dist/noise-sketches/index.d.ts +21 -0
- package/dist/noise-sketches/index.d.ts.map +1 -0
- package/dist/noise-sketches/index.js +28 -0
- package/dist/p5-runtime.d.ts +56 -4
- package/dist/p5-runtime.d.ts.map +1 -1
- package/dist/p5-runtime.js +348 -22
- package/dist/sound-bridge.d.ts +89 -0
- package/dist/sound-bridge.d.ts.map +1 -0
- package/dist/sound-bridge.js +128 -0
- package/dist/soundart-engine.d.ts +87 -0
- package/dist/soundart-engine.d.ts.map +1 -0
- package/dist/soundart-engine.js +173 -0
- package/dist/soundart-sketches/chladniBloom.d.ts +3 -0
- package/dist/soundart-sketches/chladniBloom.d.ts.map +1 -0
- package/dist/soundart-sketches/chladniBloom.js +53 -0
- package/dist/soundart-sketches/dualVortex.d.ts +3 -0
- package/dist/soundart-sketches/dualVortex.d.ts.map +1 -0
- package/dist/soundart-sketches/dualVortex.js +67 -0
- package/dist/soundart-sketches/geometryIllusion.d.ts +3 -0
- package/dist/soundart-sketches/geometryIllusion.d.ts.map +1 -0
- package/dist/soundart-sketches/geometryIllusion.js +89 -0
- package/dist/soundart-sketches/index.d.ts +39 -0
- package/dist/soundart-sketches/index.d.ts.map +1 -0
- package/dist/soundart-sketches/index.js +72 -0
- package/dist/soundart-sketches/isoflow.d.ts +3 -0
- package/dist/soundart-sketches/isoflow.d.ts.map +1 -0
- package/dist/soundart-sketches/isoflow.js +60 -0
- package/dist/soundart-sketches/loomWeave.d.ts +3 -0
- package/dist/soundart-sketches/loomWeave.d.ts.map +1 -0
- package/dist/soundart-sketches/loomWeave.js +59 -0
- package/dist/soundart-sketches/noiseTerraces.d.ts +3 -0
- package/dist/soundart-sketches/noiseTerraces.d.ts.map +1 -0
- package/dist/soundart-sketches/noiseTerraces.js +53 -0
- package/dist/soundart-sketches/orb.d.ts +3 -0
- package/dist/soundart-sketches/orb.d.ts.map +1 -0
- package/dist/soundart-sketches/orb.js +50 -0
- package/dist/soundart-sketches/pixelGlyphs.d.ts +3 -0
- package/dist/soundart-sketches/pixelGlyphs.d.ts.map +1 -0
- package/dist/soundart-sketches/pixelGlyphs.js +72 -0
- package/dist/soundart-sketches/prismFlowFields.d.ts +3 -0
- package/dist/soundart-sketches/prismFlowFields.d.ts.map +1 -0
- package/dist/soundart-sketches/prismFlowFields.js +51 -0
- package/dist/soundart-sketches/radialBurst.d.ts +3 -0
- package/dist/soundart-sketches/radialBurst.d.ts.map +1 -0
- package/dist/soundart-sketches/radialBurst.js +60 -0
- package/dist/soundart-sketches/resonantSoundBodies.d.ts +3 -0
- package/dist/soundart-sketches/resonantSoundBodies.d.ts.map +1 -0
- package/dist/soundart-sketches/resonantSoundBodies.js +89 -0
- package/dist/soundart-sketches/rings.d.ts +11 -0
- package/dist/soundart-sketches/rings.d.ts.map +1 -0
- package/dist/soundart-sketches/rings.js +89 -0
- package/dist/soundart-sketches/squares.d.ts +3 -0
- package/dist/soundart-sketches/squares.d.ts.map +1 -0
- package/dist/soundart-sketches/squares.js +52 -0
- package/dist/soundart-sketches/waveStripes.d.ts +3 -0
- package/dist/soundart-sketches/waveStripes.d.ts.map +1 -0
- package/dist/soundart-sketches/waveStripes.js +44 -0
- package/dist/static-engine.d.ts +4 -1
- package/dist/static-engine.d.ts.map +1 -1
- package/dist/static-engine.js +13 -8
- package/dist/types.d.ts +75 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +19 -1
- package/package.json +23 -17
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SoundArt → Code Mode Engine
|
|
3
|
+
*
|
|
4
|
+
* This is the orchestrator that runs SoundArt styles through the Code Mode engine.
|
|
5
|
+
* It replaces the old Canvas2D-based SoundArt renderer with a Code Mode pipeline.
|
|
6
|
+
*
|
|
7
|
+
* Architecture:
|
|
8
|
+
* 1. Sound analysis produces SoundFeatures (unchanged)
|
|
9
|
+
* 2. SoundFeatures → SoundSnapshot conversion
|
|
10
|
+
* 3. SoundSnapshot injected as S.* globals into Code Mode
|
|
11
|
+
* 4. SoundArt sketch executed via Code Mode runtime
|
|
12
|
+
* 5. Result: PNG or MP4 output
|
|
13
|
+
*/
|
|
14
|
+
import type { SoundSnapshot, SoundFeatures } from '../../shared/soundSnapshot';
|
|
15
|
+
import { type SoundArtSketchName } from './soundart-sketches';
|
|
16
|
+
export interface TweakParams {
|
|
17
|
+
volumeRangeFactor?: number;
|
|
18
|
+
centroidBrightnessFactor?: number;
|
|
19
|
+
aggressionPaletteFactor?: number;
|
|
20
|
+
rhythmPatternFactor?: number;
|
|
21
|
+
harmonySmoothnessFactor?: number;
|
|
22
|
+
attackSharpnessFactor?: number;
|
|
23
|
+
dynamicRangeVariationFactor?: number;
|
|
24
|
+
bassThicknessFactor?: number;
|
|
25
|
+
trebleSharpnessFactor?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface SoundArtEngineConfig {
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
seed?: number;
|
|
31
|
+
backgroundMode?: 'rgb' | 'black' | 'white';
|
|
32
|
+
tweakParams?: TweakParams;
|
|
33
|
+
}
|
|
34
|
+
export interface SoundArtRenderOptions {
|
|
35
|
+
style: SoundArtSketchName;
|
|
36
|
+
sound: SoundFeatures;
|
|
37
|
+
canvas: HTMLCanvasElement;
|
|
38
|
+
config: SoundArtEngineConfig;
|
|
39
|
+
onProgress?: (progress: number) => void;
|
|
40
|
+
}
|
|
41
|
+
export interface SoundArtRenderResult {
|
|
42
|
+
style: SoundArtSketchName;
|
|
43
|
+
mode: 'soundart';
|
|
44
|
+
snapshot: SoundSnapshot;
|
|
45
|
+
metadata: SoundArtMetadata;
|
|
46
|
+
}
|
|
47
|
+
export interface SoundArtMetadata {
|
|
48
|
+
mode: 'SoundArt';
|
|
49
|
+
style: SoundArtSketchName;
|
|
50
|
+
timestamp: string;
|
|
51
|
+
soundFeatures: {
|
|
52
|
+
duration: number;
|
|
53
|
+
amplitude: number;
|
|
54
|
+
frequency: number;
|
|
55
|
+
bass: number;
|
|
56
|
+
treble: number;
|
|
57
|
+
aggression: number;
|
|
58
|
+
};
|
|
59
|
+
effects: {
|
|
60
|
+
timeFilter: boolean;
|
|
61
|
+
backgroundMode: string;
|
|
62
|
+
};
|
|
63
|
+
generationParams: {
|
|
64
|
+
seed: number;
|
|
65
|
+
canvasSize: {
|
|
66
|
+
width: number;
|
|
67
|
+
height: number;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Render a SoundArt style using Code Mode
|
|
73
|
+
*
|
|
74
|
+
* This is the main entry point for the new SoundArt → Code Mode pipeline.
|
|
75
|
+
*/
|
|
76
|
+
export declare function renderSoundArtViaCodeMode(options: SoundArtRenderOptions): Promise<SoundArtRenderResult>;
|
|
77
|
+
/**
|
|
78
|
+
* Check if a SoundArt style can be rendered via Code Mode
|
|
79
|
+
*/
|
|
80
|
+
export declare function canRenderViaCodeMode(style: SoundArtSketchName): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Get the list of SoundArt styles available via Code Mode
|
|
83
|
+
*/
|
|
84
|
+
export declare function getCodeModeAvailableStyles(): SoundArtSketchName[];
|
|
85
|
+
export type { SoundSnapshot, SoundFeatures } from '../../shared/soundSnapshot';
|
|
86
|
+
export type { SoundArtSketchName } from './soundart-sketches';
|
|
87
|
+
//# sourceMappingURL=soundart-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"soundart-engine.d.ts","sourceRoot":"","sources":["../soundart-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAI/E,OAAO,EAAqB,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEjF,MAAM,WAAW,WAAW;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,OAAO,CAAC;IAC3C,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,kBAAkB,CAAC;IAC1B,KAAK,EAAE,aAAa,CAAC;IACrB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,MAAM,EAAE,oBAAoB,CAAC;IAC7B,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,kBAAkB,CAAC;IAC1B,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,aAAa,CAAC;IACxB,QAAQ,EAAE,gBAAgB,CAAC;CAC5B;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,kBAAkB,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,OAAO,EAAE;QACP,UAAU,EAAE,OAAO,CAAC;QACpB,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,gBAAgB,EAAE;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC;KAC/C,CAAC;CACH;AAqCD;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,oBAAoB,CAAC,CAoG/B;AA4BD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAEvE;AAED;;GAEG;AACH,wBAAgB,0BAA0B,IAAI,kBAAkB,EAAE,CAGjE;AAGD,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC/E,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SoundArt → Code Mode Engine
|
|
3
|
+
*
|
|
4
|
+
* This is the orchestrator that runs SoundArt styles through the Code Mode engine.
|
|
5
|
+
* It replaces the old Canvas2D-based SoundArt renderer with a Code Mode pipeline.
|
|
6
|
+
*
|
|
7
|
+
* Architecture:
|
|
8
|
+
* 1. Sound analysis produces SoundFeatures (unchanged)
|
|
9
|
+
* 2. SoundFeatures → SoundSnapshot conversion
|
|
10
|
+
* 3. SoundSnapshot injected as S.* globals into Code Mode
|
|
11
|
+
* 4. SoundArt sketch executed via Code Mode runtime
|
|
12
|
+
* 5. Result: PNG or MP4 output
|
|
13
|
+
*/
|
|
14
|
+
import { createSoundSnapshot } from '../../shared/soundSnapshot';
|
|
15
|
+
import { createP5Runtime } from './p5-runtime';
|
|
16
|
+
import { injectSoundGlobals, generateSoundPalette, inferGenreProfile } from './sound-bridge';
|
|
17
|
+
import { getSoundArtSketch } from './soundart-sketches';
|
|
18
|
+
/**
|
|
19
|
+
* Apply tweak multipliers to a SoundSnapshot
|
|
20
|
+
*/
|
|
21
|
+
function applyTweaksToSnapshot(snapshot, tweaks) {
|
|
22
|
+
if (!tweaks)
|
|
23
|
+
return snapshot;
|
|
24
|
+
const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
|
|
25
|
+
const tweaked = {
|
|
26
|
+
...snapshot,
|
|
27
|
+
volume: snapshot.volume * (tweaks.volumeRangeFactor ?? 1),
|
|
28
|
+
brightness: snapshot.brightness * (tweaks.centroidBrightnessFactor ?? 1),
|
|
29
|
+
aggression: snapshot.aggression * (tweaks.aggressionPaletteFactor ?? 1),
|
|
30
|
+
rhythmicity: snapshot.rhythmicity * (tweaks.rhythmPatternFactor ?? 1),
|
|
31
|
+
harmonicity: snapshot.harmonicity * (tweaks.harmonySmoothnessFactor ?? 1),
|
|
32
|
+
attack: snapshot.attack * (tweaks.attackSharpnessFactor ?? 1),
|
|
33
|
+
dynamicRange: snapshot.dynamicRange * (tweaks.dynamicRangeVariationFactor ?? 1),
|
|
34
|
+
bass: snapshot.bass * (tweaks.bassThicknessFactor ?? 1),
|
|
35
|
+
treble: snapshot.treble * (tweaks.trebleSharpnessFactor ?? 1),
|
|
36
|
+
};
|
|
37
|
+
// Clamp all numeric values to reasonable range
|
|
38
|
+
tweaked.volume = clamp(tweaked.volume, 0, 250);
|
|
39
|
+
tweaked.brightness = clamp(tweaked.brightness, 0, 250);
|
|
40
|
+
tweaked.aggression = clamp(tweaked.aggression, 0, 250);
|
|
41
|
+
tweaked.rhythmicity = clamp(tweaked.rhythmicity, 0, 250);
|
|
42
|
+
tweaked.harmonicity = clamp(tweaked.harmonicity, 0, 250);
|
|
43
|
+
tweaked.attack = clamp(tweaked.attack, 0, 250);
|
|
44
|
+
tweaked.dynamicRange = clamp(tweaked.dynamicRange, 0, 250);
|
|
45
|
+
tweaked.bass = clamp(tweaked.bass, 0, 250);
|
|
46
|
+
tweaked.treble = clamp(tweaked.treble, 0, 250);
|
|
47
|
+
return tweaked;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Render a SoundArt style using Code Mode
|
|
51
|
+
*
|
|
52
|
+
* This is the main entry point for the new SoundArt → Code Mode pipeline.
|
|
53
|
+
*/
|
|
54
|
+
export async function renderSoundArtViaCodeMode(options) {
|
|
55
|
+
const { style, sound, canvas, config, onProgress } = options;
|
|
56
|
+
onProgress?.(0.1);
|
|
57
|
+
// 1. Get the sketch code
|
|
58
|
+
const sketchCode = getSoundArtSketch(style);
|
|
59
|
+
if (!sketchCode) {
|
|
60
|
+
throw new Error(`SoundArt style "${style}" has not been converted to Code Mode yet`);
|
|
61
|
+
}
|
|
62
|
+
onProgress?.(0.2);
|
|
63
|
+
// 2. Create SoundSnapshot from SoundFeatures
|
|
64
|
+
const baseSnapshot = createSoundSnapshot(sound, sound.frames);
|
|
65
|
+
// 3. Apply tweak multipliers to the snapshot
|
|
66
|
+
const snapshot = applyTweaksToSnapshot(baseSnapshot, config.tweakParams);
|
|
67
|
+
onProgress?.(0.3);
|
|
68
|
+
// 3. Create the p5 runtime with seeded randomness
|
|
69
|
+
// Derive deterministic seed from sound features if not provided
|
|
70
|
+
const deriveSeedFromSound = (sound) => {
|
|
71
|
+
// Create a stable hash from sound parameters
|
|
72
|
+
const hashInput = (sound.rms * 1000) +
|
|
73
|
+
(sound.centroid * 100) +
|
|
74
|
+
(sound.durationSec * 10000) +
|
|
75
|
+
((sound.bands?.bass ?? 0) * 500) +
|
|
76
|
+
((sound.bands?.treble ?? 0) * 700);
|
|
77
|
+
// Simple hash to integer
|
|
78
|
+
return Math.abs(Math.floor(hashInput * 2147483647) % 2147483647) || 123456;
|
|
79
|
+
};
|
|
80
|
+
const runtimeConfig = {
|
|
81
|
+
seed: config.seed ?? deriveSeedFromSound(sound),
|
|
82
|
+
};
|
|
83
|
+
canvas.width = config.width;
|
|
84
|
+
canvas.height = config.height;
|
|
85
|
+
const baseRuntime = createP5Runtime(canvas, config.width, config.height, runtimeConfig);
|
|
86
|
+
// 4. Inject sound globals (S.*)
|
|
87
|
+
const runtime = injectSoundGlobals(baseRuntime, snapshot);
|
|
88
|
+
onProgress?.(0.4);
|
|
89
|
+
// 5. Add helper globals
|
|
90
|
+
const globals = {
|
|
91
|
+
...runtime,
|
|
92
|
+
width: config.width,
|
|
93
|
+
height: config.height,
|
|
94
|
+
backgroundMode: config.backgroundMode ?? 'rgb',
|
|
95
|
+
palette: generateSoundPalette(snapshot),
|
|
96
|
+
genre: inferGenreProfile(snapshot),
|
|
97
|
+
};
|
|
98
|
+
onProgress?.(0.5);
|
|
99
|
+
// 6. Execute the sketch
|
|
100
|
+
try {
|
|
101
|
+
executeSketch(sketchCode, globals);
|
|
102
|
+
onProgress?.(0.9);
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
console.error(`[SoundArtEngine] Error executing style "${style}":`, error);
|
|
106
|
+
throw new Error(`Style "${style}" execution failed: ${error}`);
|
|
107
|
+
}
|
|
108
|
+
onProgress?.(1.0);
|
|
109
|
+
// 7. Build metadata
|
|
110
|
+
const metadata = {
|
|
111
|
+
mode: 'SoundArt',
|
|
112
|
+
style,
|
|
113
|
+
timestamp: new Date().toISOString(),
|
|
114
|
+
soundFeatures: {
|
|
115
|
+
duration: sound.durationSec,
|
|
116
|
+
amplitude: sound.rms,
|
|
117
|
+
frequency: sound.centroid,
|
|
118
|
+
bass: sound.bands?.bass ?? 0,
|
|
119
|
+
treble: sound.bands?.treble ?? 0,
|
|
120
|
+
aggression: snapshot.aggression,
|
|
121
|
+
},
|
|
122
|
+
effects: {
|
|
123
|
+
timeFilter: false,
|
|
124
|
+
backgroundMode: config.backgroundMode ?? 'rgb',
|
|
125
|
+
},
|
|
126
|
+
generationParams: {
|
|
127
|
+
seed: runtimeConfig.seed,
|
|
128
|
+
canvasSize: { width: config.width, height: config.height },
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
return {
|
|
132
|
+
style,
|
|
133
|
+
mode: 'soundart',
|
|
134
|
+
snapshot,
|
|
135
|
+
metadata,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Execute a sketch string in the context of the runtime globals
|
|
140
|
+
*/
|
|
141
|
+
function executeSketch(code, globals) {
|
|
142
|
+
// Build the function context with all globals
|
|
143
|
+
const globalNames = Object.keys(globals);
|
|
144
|
+
const globalValues = Object.values(globals);
|
|
145
|
+
// Wrap the sketch code to call setup() and optionally draw()
|
|
146
|
+
const wrappedCode = `
|
|
147
|
+
${code}
|
|
148
|
+
|
|
149
|
+
// Execute setup
|
|
150
|
+
if (typeof setup === 'function') {
|
|
151
|
+
setup();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// For static mode, we don't call draw()
|
|
155
|
+
// Loop mode would call draw() in a frame loop
|
|
156
|
+
`;
|
|
157
|
+
// Create and execute the function
|
|
158
|
+
const sketchFunction = new Function(...globalNames, wrappedCode);
|
|
159
|
+
sketchFunction(...globalValues);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Check if a SoundArt style can be rendered via Code Mode
|
|
163
|
+
*/
|
|
164
|
+
export function canRenderViaCodeMode(style) {
|
|
165
|
+
return getSoundArtSketch(style) !== undefined;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Get the list of SoundArt styles available via Code Mode
|
|
169
|
+
*/
|
|
170
|
+
export function getCodeModeAvailableStyles() {
|
|
171
|
+
const { getAvailableSoundArtSketches } = require('./soundart-sketches');
|
|
172
|
+
return getAvailableSoundArtSketches();
|
|
173
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const CHLADNI_BLOOM_SKETCH = "\nfunction setup() {\n const bgMode = typeof backgroundMode !== 'undefined' ? backgroundMode : 'rgb';\n if (bgMode === 'white') background(245, 245, 245);\n else if (bgMode === 'black') background(10, 10, 10);\n else {\n const r = Math.floor((S.brightness / 100) * 255);\n const g = Math.floor((S.rhythmicity / 100) * 255);\n const b = Math.floor((S.harmonicity / 100) * 255);\n background(r, g, b);\n }\n\n translate(width / 2, height / 2);\n \n const layers = Math.floor(map(S.volume + S.rhythmicity, 0, 200, 20, 90));\n const minStrokeW = map(S.volume, 0, 100, 1.0, 3.0);\n const maxStrokeW = map(S.treble, 0, 100, 2.0, 5.0);\n\n noFill();\n\n for (let i = 0; i < layers; i++) {\n const freq1 = Math.floor(map(S.aggression + random() * 50, 0, 150, 3, 20));\n const freq2 = Math.floor(map(S.treble + random() * 50, 0, 150, 2, 8));\n const amp = map(S.dynamicRange + random() * 30, 0, 130, 60, 400);\n const rotation = map(S.harmonicity + random() * 50, 0, 150, 0, PI * 4);\n const radiusOffset = map(S.bass, 0, 100, 40, 80);\n const strokeW = map(S.treble + S.volume * 0.5, 0, 100, minStrokeW, maxStrokeW);\n \n const hBase = (330 + random() * 100) % 360;\n const finalH = (hBase + (random() * 40 - 60) + map(S.hue, 0, 100, -10, 10) + 360) % 360;\n const finalC = constrain(85 + map(S.brightness, 0, 100, -20, 20), 0, 100);\n const finalL = constrain(90 + map(S.brightness, 0, 100, -15, 15), 0, 100);\n const finalA = constrain(0.5 + map(S.attack, 0, 100, 0, 0.5), 0.3, 1);\n\n push();\n rotate(rotation);\n strokeWeight(strokeW);\n stroke('hsla(' + finalH + ',' + finalC + '%,' + finalL + '%,' + finalA + ')');\n \n const angleStep = map(S.treble, 0, 100, 0.07, 0.03);\n beginShape();\n for (let aa = 0; aa < PI * 2; aa += angleStep) {\n const rad = radiusOffset * i + amp * sin(freq1 * aa) * cos(freq2 * aa * map(S.rhythmicity, 0, 100, 0.3, 2));\n const x = rad * cos(aa);\n const y = rad * sin(aa);\n vertex(x, y);\n }\n endShape(CLOSE);\n pop();\n }\n}\n";
|
|
2
|
+
export default CHLADNI_BLOOM_SKETCH;
|
|
3
|
+
//# sourceMappingURL=chladniBloom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chladniBloom.d.ts","sourceRoot":"","sources":["../../soundart-sketches/chladniBloom.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,+hEAmDhC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export const CHLADNI_BLOOM_SKETCH = `
|
|
2
|
+
function setup() {
|
|
3
|
+
const bgMode = typeof backgroundMode !== 'undefined' ? backgroundMode : 'rgb';
|
|
4
|
+
if (bgMode === 'white') background(245, 245, 245);
|
|
5
|
+
else if (bgMode === 'black') background(10, 10, 10);
|
|
6
|
+
else {
|
|
7
|
+
const r = Math.floor((S.brightness / 100) * 255);
|
|
8
|
+
const g = Math.floor((S.rhythmicity / 100) * 255);
|
|
9
|
+
const b = Math.floor((S.harmonicity / 100) * 255);
|
|
10
|
+
background(r, g, b);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
translate(width / 2, height / 2);
|
|
14
|
+
|
|
15
|
+
const layers = Math.floor(map(S.volume + S.rhythmicity, 0, 200, 20, 90));
|
|
16
|
+
const minStrokeW = map(S.volume, 0, 100, 1.0, 3.0);
|
|
17
|
+
const maxStrokeW = map(S.treble, 0, 100, 2.0, 5.0);
|
|
18
|
+
|
|
19
|
+
noFill();
|
|
20
|
+
|
|
21
|
+
for (let i = 0; i < layers; i++) {
|
|
22
|
+
const freq1 = Math.floor(map(S.aggression + random() * 50, 0, 150, 3, 20));
|
|
23
|
+
const freq2 = Math.floor(map(S.treble + random() * 50, 0, 150, 2, 8));
|
|
24
|
+
const amp = map(S.dynamicRange + random() * 30, 0, 130, 60, 400);
|
|
25
|
+
const rotation = map(S.harmonicity + random() * 50, 0, 150, 0, PI * 4);
|
|
26
|
+
const radiusOffset = map(S.bass, 0, 100, 40, 80);
|
|
27
|
+
const strokeW = map(S.treble + S.volume * 0.5, 0, 100, minStrokeW, maxStrokeW);
|
|
28
|
+
|
|
29
|
+
const hBase = (330 + random() * 100) % 360;
|
|
30
|
+
const finalH = (hBase + (random() * 40 - 60) + map(S.hue, 0, 100, -10, 10) + 360) % 360;
|
|
31
|
+
const finalC = constrain(85 + map(S.brightness, 0, 100, -20, 20), 0, 100);
|
|
32
|
+
const finalL = constrain(90 + map(S.brightness, 0, 100, -15, 15), 0, 100);
|
|
33
|
+
const finalA = constrain(0.5 + map(S.attack, 0, 100, 0, 0.5), 0.3, 1);
|
|
34
|
+
|
|
35
|
+
push();
|
|
36
|
+
rotate(rotation);
|
|
37
|
+
strokeWeight(strokeW);
|
|
38
|
+
stroke('hsla(' + finalH + ',' + finalC + '%,' + finalL + '%,' + finalA + ')');
|
|
39
|
+
|
|
40
|
+
const angleStep = map(S.treble, 0, 100, 0.07, 0.03);
|
|
41
|
+
beginShape();
|
|
42
|
+
for (let aa = 0; aa < PI * 2; aa += angleStep) {
|
|
43
|
+
const rad = radiusOffset * i + amp * sin(freq1 * aa) * cos(freq2 * aa * map(S.rhythmicity, 0, 100, 0.3, 2));
|
|
44
|
+
const x = rad * cos(aa);
|
|
45
|
+
const y = rad * sin(aa);
|
|
46
|
+
vertex(x, y);
|
|
47
|
+
}
|
|
48
|
+
endShape(CLOSE);
|
|
49
|
+
pop();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
53
|
+
export default CHLADNI_BLOOM_SKETCH;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const DUAL_VORTEX_SKETCH = "\nfunction setup() {\n const bgMode = typeof backgroundMode !== 'undefined' ? backgroundMode : 'rgb';\n if (bgMode === 'white') background(245, 245, 245);\n else if (bgMode === 'black') background(10, 10, 10);\n else {\n const r = Math.floor((S.brightness / 100) * 255);\n const g = Math.floor((S.rhythmicity / 100) * 255);\n const b = Math.floor((S.harmonicity / 100) * 255);\n background(r, g, b);\n }\n\n const presence = 1.0 - S.silence / 100;\n const sizeFactor = (S.length * 0.7 + S.volume * 0.6);\n const layers = Math.floor(map(S.length, 0, 100, 60, 180));\n const baseR = map(sizeFactor, 0, 100, Math.min(width, height) * 0.15, Math.min(width, height) * 0.55);\n const steps = Math.floor(map(S.attack, 0, 100, 180, 480));\n const twist = map(S.harmonicity, 0, 100, 0.5, 3.5);\n const bulge = map(S.aggression, 0, 100, 0.05, 0.55);\n const waveF = map(S.rhythmicity, 0, 100, 0.8, 5.0);\n const CY = height * 0.5 + map(S.bass, 0, 100, -height * 0.1, height * 0.1);\n const wBase = map(S.volume, 0, 100, 1.5, 6.0);\n const alphaLo = map(S.dynamicRange, 0, 100, 80, 180) * presence;\n const alphaHi = map(S.dynamicRange, 0, 100, 180, 255) * presence;\n\n const mainHue = (S.brightness * 3.6) % 360;\n \n noFill();\n\n for (let pass = 0; pass < 2; pass++) {\n const isSecond = pass === 0;\n const alphaScale = isSecond ? 0.7 : 1.0;\n const weightScale = isSecond ? 0.85 : 1.1;\n \n for (let i = 0; i < layers; i++) {\n const t = i / (layers - 1);\n const h = (mainHue + i * 22.5) % 360;\n const sat = map(S.treble, 0, 100, 60, 90);\n const bri = map(S.bass, 0, 100, 70, 95);\n \n const r0 = baseR * (0.6 + (isSecond ? 0.8 : 0.7) * sin(PI * 2 * t + 0.42));\n const rot = t * (twist + 0.6) + sin(i * 0.05) * map(S.attack, 0, 100, 0.02, 0.12);\n \n const hueShift = (i / layers) * 120;\n const finalH = (h + hueShift) % 360;\n const a = lerp(alphaHi, alphaLo, pow(t, 0.9)) * alphaScale / 255;\n \n push();\n translate(width * 0.5, CY);\n rotate(rot);\n \n strokeWeight(max(0.6, wBase * weightScale));\n stroke('hsla(' + finalH + ',' + sat + '%,' + bri + '%,' + constrain(a, 0, 1) + ')');\n \n beginShape();\n for (let k = 0; k <= steps; k++) {\n const ang = map(k, 0, steps, 0, PI * 2);\n const baseRR = r0 * (1.0 + bulge * sin(ang * waveF + t * PI * 3));\n vertex(baseRR * cos(ang), baseRR * sin(ang));\n }\n endShape(CLOSE);\n pop();\n }\n }\n}\n";
|
|
2
|
+
export default DUAL_VORTEX_SKETCH;
|
|
3
|
+
//# sourceMappingURL=dualVortex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dualVortex.d.ts","sourceRoot":"","sources":["../../soundart-sketches/dualVortex.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,m/EAiE9B,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export const DUAL_VORTEX_SKETCH = `
|
|
2
|
+
function setup() {
|
|
3
|
+
const bgMode = typeof backgroundMode !== 'undefined' ? backgroundMode : 'rgb';
|
|
4
|
+
if (bgMode === 'white') background(245, 245, 245);
|
|
5
|
+
else if (bgMode === 'black') background(10, 10, 10);
|
|
6
|
+
else {
|
|
7
|
+
const r = Math.floor((S.brightness / 100) * 255);
|
|
8
|
+
const g = Math.floor((S.rhythmicity / 100) * 255);
|
|
9
|
+
const b = Math.floor((S.harmonicity / 100) * 255);
|
|
10
|
+
background(r, g, b);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const presence = 1.0 - S.silence / 100;
|
|
14
|
+
const sizeFactor = (S.length * 0.7 + S.volume * 0.6);
|
|
15
|
+
const layers = Math.floor(map(S.length, 0, 100, 60, 180));
|
|
16
|
+
const baseR = map(sizeFactor, 0, 100, Math.min(width, height) * 0.15, Math.min(width, height) * 0.55);
|
|
17
|
+
const steps = Math.floor(map(S.attack, 0, 100, 180, 480));
|
|
18
|
+
const twist = map(S.harmonicity, 0, 100, 0.5, 3.5);
|
|
19
|
+
const bulge = map(S.aggression, 0, 100, 0.05, 0.55);
|
|
20
|
+
const waveF = map(S.rhythmicity, 0, 100, 0.8, 5.0);
|
|
21
|
+
const CY = height * 0.5 + map(S.bass, 0, 100, -height * 0.1, height * 0.1);
|
|
22
|
+
const wBase = map(S.volume, 0, 100, 1.5, 6.0);
|
|
23
|
+
const alphaLo = map(S.dynamicRange, 0, 100, 80, 180) * presence;
|
|
24
|
+
const alphaHi = map(S.dynamicRange, 0, 100, 180, 255) * presence;
|
|
25
|
+
|
|
26
|
+
const mainHue = (S.brightness * 3.6) % 360;
|
|
27
|
+
|
|
28
|
+
noFill();
|
|
29
|
+
|
|
30
|
+
for (let pass = 0; pass < 2; pass++) {
|
|
31
|
+
const isSecond = pass === 0;
|
|
32
|
+
const alphaScale = isSecond ? 0.7 : 1.0;
|
|
33
|
+
const weightScale = isSecond ? 0.85 : 1.1;
|
|
34
|
+
|
|
35
|
+
for (let i = 0; i < layers; i++) {
|
|
36
|
+
const t = i / (layers - 1);
|
|
37
|
+
const h = (mainHue + i * 22.5) % 360;
|
|
38
|
+
const sat = map(S.treble, 0, 100, 60, 90);
|
|
39
|
+
const bri = map(S.bass, 0, 100, 70, 95);
|
|
40
|
+
|
|
41
|
+
const r0 = baseR * (0.6 + (isSecond ? 0.8 : 0.7) * sin(PI * 2 * t + 0.42));
|
|
42
|
+
const rot = t * (twist + 0.6) + sin(i * 0.05) * map(S.attack, 0, 100, 0.02, 0.12);
|
|
43
|
+
|
|
44
|
+
const hueShift = (i / layers) * 120;
|
|
45
|
+
const finalH = (h + hueShift) % 360;
|
|
46
|
+
const a = lerp(alphaHi, alphaLo, pow(t, 0.9)) * alphaScale / 255;
|
|
47
|
+
|
|
48
|
+
push();
|
|
49
|
+
translate(width * 0.5, CY);
|
|
50
|
+
rotate(rot);
|
|
51
|
+
|
|
52
|
+
strokeWeight(max(0.6, wBase * weightScale));
|
|
53
|
+
stroke('hsla(' + finalH + ',' + sat + '%,' + bri + '%,' + constrain(a, 0, 1) + ')');
|
|
54
|
+
|
|
55
|
+
beginShape();
|
|
56
|
+
for (let k = 0; k <= steps; k++) {
|
|
57
|
+
const ang = map(k, 0, steps, 0, PI * 2);
|
|
58
|
+
const baseRR = r0 * (1.0 + bulge * sin(ang * waveF + t * PI * 3));
|
|
59
|
+
vertex(baseRR * cos(ang), baseRR * sin(ang));
|
|
60
|
+
}
|
|
61
|
+
endShape(CLOSE);
|
|
62
|
+
pop();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
`;
|
|
67
|
+
export default DUAL_VORTEX_SKETCH;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const GEOMETRY_ILLUSION_SKETCH = "\nfunction setup() {\n const bgMode = typeof backgroundMode !== 'undefined' ? backgroundMode : 'rgb';\n if (bgMode === 'white') background(245, 245, 245);\n else if (bgMode === 'black') background(10, 10, 10);\n else {\n const r = Math.floor((S.brightness / 100) * 255);\n const g = Math.floor((S.rhythmicity / 100) * 255);\n const b = Math.floor((S.harmonicity / 100) * 255);\n background(r, g, b);\n }\n\n const hueBase = map(S.hue, 0, 100, 0, 360);\n const hueVar = map(S.treble, 0, 100, 20, 240);\n const sizeScale = map(S.volume, 0, 100, 0.05, 1.8);\n const rotAmt = map(S.aggression, 0, 100, 0, PI / 3);\n const layers = Math.floor(map(S.length, 0, 100, 120, 900));\n const alphaLevel = map(S.amplitude, 0, 100, 0.25, 1.3);\n const lineCount = Math.floor(map(S.rhythmicity, 0, 100, 40, 600));\n const strokeW = map(S.attack, 0, 100, 0.5, 6.5);\n const distort = map(S.harmonicity, 0, 100, 0, 70);\n const bias = map(S.mid, 0, 100, 0, 1);\n const bright = map(S.brightness, 0, 100, 0.4, 2.2);\n const sat = map(S.chroma, 0, 100, 0.4, 5.4);\n const cont = map(S.dynamicRange, 0, 100, 0.5, 3.4);\n const layerDepth = map(S.harmonicity, 0, 100, 0.2, 2.2);\n\n const baseScale = map(S.volume, 0, 100, 0.5, 1.1);\n const densityScale = map(S.length, 0, 100, 0.9, 0.7);\n const scaleFactor = constrain(baseScale * densityScale, 0.6, 1.0);\n\n translate(width / 2, height / 2);\n scale(scaleFactor, scaleFactor);\n\n const combined = S.rhythmicity * 0.6 + S.harmonicity * 0.4;\n const spacingFactor = map(combined, 0, 100, 2.5, 0.3);\n const spacingAmp = map(S.volume, 0, 100, 0.3, 1.2);\n\n for (let i = 0; i < layers; i++) {\n push();\n rotate((random() - 0.5) * rotAmt * 2);\n \n const w = random() * width * sizeScale;\n const h = random() * height * sizeScale;\n \n translate(\n (random() - 0.5) * width * spacingFactor * spacingAmp,\n (random() - 0.5) * height * spacingFactor * spacingAmp\n );\n\n const hue = (hueBase + random() * hueVar - hueVar / 2 + 360) % 360;\n const fillSat = constrain(60 * sat, 0, 100);\n const fillLight = constrain(60 * bright * cont, 0, 100);\n const strokeLight = constrain(30 * cont, 0, 100);\n\n fill(hslColor(hue, fillSat, fillLight, alphaLevel * layerDepth));\n stroke(hslColor(hue, fillSat * 0.6, strokeLight, alphaLevel));\n strokeWeight(strokeW);\n\n const rectW = w * (bias > 0.5 ? lerp(0.5, 1.0, random()) : lerp(0.1, 0.5, random()));\n const rectH = h * (bias < 0.5 ? lerp(0.5, 1.0, random()) : lerp(0.1, 0.5, random()));\n\n rect(\n -rectW / 2 + (random() - 0.5) * distort,\n -rectH / 2 + (random() - 0.5) * distort,\n rectW,\n rectH\n );\n pop();\n }\n\n noFill();\n stroke(hslColor(hueBase, 25, 75, 0.25));\n strokeWeight(1);\n for (let i = 0; i < lineCount; i++) {\n const x1 = random() * width - width / 2;\n const y1 = random() * height - height / 2;\n const x2 = x1 + lerp(-100, 100, random());\n const y2 = y1 + lerp(-100, 100, random());\n line(x1, y1, x2, y2);\n }\n}\n\nfunction hslColor(h, s, l, a) {\n if (a !== undefined) return 'hsla(' + h + ',' + s + '%,' + l + '%,' + a + ')';\n return 'hsl(' + h + ',' + s + '%,' + l + '%)';\n}\n";
|
|
2
|
+
export default GEOMETRY_ILLUSION_SKETCH;
|
|
3
|
+
//# sourceMappingURL=geometryIllusion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometryIllusion.d.ts","sourceRoot":"","sources":["../../soundart-sketches/geometryIllusion.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,krGAuFpC,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export const GEOMETRY_ILLUSION_SKETCH = `
|
|
2
|
+
function setup() {
|
|
3
|
+
const bgMode = typeof backgroundMode !== 'undefined' ? backgroundMode : 'rgb';
|
|
4
|
+
if (bgMode === 'white') background(245, 245, 245);
|
|
5
|
+
else if (bgMode === 'black') background(10, 10, 10);
|
|
6
|
+
else {
|
|
7
|
+
const r = Math.floor((S.brightness / 100) * 255);
|
|
8
|
+
const g = Math.floor((S.rhythmicity / 100) * 255);
|
|
9
|
+
const b = Math.floor((S.harmonicity / 100) * 255);
|
|
10
|
+
background(r, g, b);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const hueBase = map(S.hue, 0, 100, 0, 360);
|
|
14
|
+
const hueVar = map(S.treble, 0, 100, 20, 240);
|
|
15
|
+
const sizeScale = map(S.volume, 0, 100, 0.05, 1.8);
|
|
16
|
+
const rotAmt = map(S.aggression, 0, 100, 0, PI / 3);
|
|
17
|
+
const layers = Math.floor(map(S.length, 0, 100, 120, 900));
|
|
18
|
+
const alphaLevel = map(S.amplitude, 0, 100, 0.25, 1.3);
|
|
19
|
+
const lineCount = Math.floor(map(S.rhythmicity, 0, 100, 40, 600));
|
|
20
|
+
const strokeW = map(S.attack, 0, 100, 0.5, 6.5);
|
|
21
|
+
const distort = map(S.harmonicity, 0, 100, 0, 70);
|
|
22
|
+
const bias = map(S.mid, 0, 100, 0, 1);
|
|
23
|
+
const bright = map(S.brightness, 0, 100, 0.4, 2.2);
|
|
24
|
+
const sat = map(S.chroma, 0, 100, 0.4, 5.4);
|
|
25
|
+
const cont = map(S.dynamicRange, 0, 100, 0.5, 3.4);
|
|
26
|
+
const layerDepth = map(S.harmonicity, 0, 100, 0.2, 2.2);
|
|
27
|
+
|
|
28
|
+
const baseScale = map(S.volume, 0, 100, 0.5, 1.1);
|
|
29
|
+
const densityScale = map(S.length, 0, 100, 0.9, 0.7);
|
|
30
|
+
const scaleFactor = constrain(baseScale * densityScale, 0.6, 1.0);
|
|
31
|
+
|
|
32
|
+
translate(width / 2, height / 2);
|
|
33
|
+
scale(scaleFactor, scaleFactor);
|
|
34
|
+
|
|
35
|
+
const combined = S.rhythmicity * 0.6 + S.harmonicity * 0.4;
|
|
36
|
+
const spacingFactor = map(combined, 0, 100, 2.5, 0.3);
|
|
37
|
+
const spacingAmp = map(S.volume, 0, 100, 0.3, 1.2);
|
|
38
|
+
|
|
39
|
+
for (let i = 0; i < layers; i++) {
|
|
40
|
+
push();
|
|
41
|
+
rotate((random() - 0.5) * rotAmt * 2);
|
|
42
|
+
|
|
43
|
+
const w = random() * width * sizeScale;
|
|
44
|
+
const h = random() * height * sizeScale;
|
|
45
|
+
|
|
46
|
+
translate(
|
|
47
|
+
(random() - 0.5) * width * spacingFactor * spacingAmp,
|
|
48
|
+
(random() - 0.5) * height * spacingFactor * spacingAmp
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const hue = (hueBase + random() * hueVar - hueVar / 2 + 360) % 360;
|
|
52
|
+
const fillSat = constrain(60 * sat, 0, 100);
|
|
53
|
+
const fillLight = constrain(60 * bright * cont, 0, 100);
|
|
54
|
+
const strokeLight = constrain(30 * cont, 0, 100);
|
|
55
|
+
|
|
56
|
+
fill(hslColor(hue, fillSat, fillLight, alphaLevel * layerDepth));
|
|
57
|
+
stroke(hslColor(hue, fillSat * 0.6, strokeLight, alphaLevel));
|
|
58
|
+
strokeWeight(strokeW);
|
|
59
|
+
|
|
60
|
+
const rectW = w * (bias > 0.5 ? lerp(0.5, 1.0, random()) : lerp(0.1, 0.5, random()));
|
|
61
|
+
const rectH = h * (bias < 0.5 ? lerp(0.5, 1.0, random()) : lerp(0.1, 0.5, random()));
|
|
62
|
+
|
|
63
|
+
rect(
|
|
64
|
+
-rectW / 2 + (random() - 0.5) * distort,
|
|
65
|
+
-rectH / 2 + (random() - 0.5) * distort,
|
|
66
|
+
rectW,
|
|
67
|
+
rectH
|
|
68
|
+
);
|
|
69
|
+
pop();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
noFill();
|
|
73
|
+
stroke(hslColor(hueBase, 25, 75, 0.25));
|
|
74
|
+
strokeWeight(1);
|
|
75
|
+
for (let i = 0; i < lineCount; i++) {
|
|
76
|
+
const x1 = random() * width - width / 2;
|
|
77
|
+
const y1 = random() * height - height / 2;
|
|
78
|
+
const x2 = x1 + lerp(-100, 100, random());
|
|
79
|
+
const y2 = y1 + lerp(-100, 100, random());
|
|
80
|
+
line(x1, y1, x2, y2);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function hslColor(h, s, l, a) {
|
|
85
|
+
if (a !== undefined) return 'hsla(' + h + ',' + s + '%,' + l + '%,' + a + ')';
|
|
86
|
+
return 'hsl(' + h + ',' + s + '%,' + l + '%)';
|
|
87
|
+
}
|
|
88
|
+
`;
|
|
89
|
+
export default GEOMETRY_ILLUSION_SKETCH;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SoundArt Sketches Index
|
|
3
|
+
*
|
|
4
|
+
* All SoundArt styles converted to Code Mode sketches.
|
|
5
|
+
* Each sketch uses S.* globals for sound-derived parameters.
|
|
6
|
+
*/
|
|
7
|
+
export type SoundArtSketchName = 'rings' | 'pixelGlyphs' | 'radialBurst' | 'orb' | 'waveStripes' | 'squares' | 'loomWeave' | 'noiseTerraces' | 'prismFlowFields' | 'chladniBloom' | 'dualVortex' | 'isoflow' | 'geometryIllusion' | 'resonantSoundBodies';
|
|
8
|
+
/**
|
|
9
|
+
* Map of all available SoundArt sketches
|
|
10
|
+
* Each sketch is a string containing Code Mode compatible code
|
|
11
|
+
*/
|
|
12
|
+
export declare const SOUNDART_SKETCHES: Record<SoundArtSketchName, string>;
|
|
13
|
+
/**
|
|
14
|
+
* Get a SoundArt sketch by name
|
|
15
|
+
*/
|
|
16
|
+
export declare function getSoundArtSketch(name: SoundArtSketchName): string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Get list of available (converted) SoundArt sketches
|
|
19
|
+
*/
|
|
20
|
+
export declare function getAvailableSoundArtSketches(): SoundArtSketchName[];
|
|
21
|
+
/**
|
|
22
|
+
* Check if a SoundArt sketch has been converted to Code Mode
|
|
23
|
+
*/
|
|
24
|
+
export declare function isSoundArtSketchAvailable(name: SoundArtSketchName): boolean;
|
|
25
|
+
export { RINGS_SKETCH } from './rings';
|
|
26
|
+
export { PIXEL_GLYPHS_SKETCH } from './pixelGlyphs';
|
|
27
|
+
export { RADIAL_BURST_SKETCH } from './radialBurst';
|
|
28
|
+
export { ORB_SKETCH } from './orb';
|
|
29
|
+
export { WAVE_STRIPES_SKETCH } from './waveStripes';
|
|
30
|
+
export { SQUARES_SKETCH } from './squares';
|
|
31
|
+
export { LOOM_WEAVE_SKETCH } from './loomWeave';
|
|
32
|
+
export { NOISE_TERRACES_SKETCH } from './noiseTerraces';
|
|
33
|
+
export { PRISM_FLOW_FIELDS_SKETCH } from './prismFlowFields';
|
|
34
|
+
export { CHLADNI_BLOOM_SKETCH } from './chladniBloom';
|
|
35
|
+
export { DUAL_VORTEX_SKETCH } from './dualVortex';
|
|
36
|
+
export { ISOFLOW_SKETCH } from './isoflow';
|
|
37
|
+
export { GEOMETRY_ILLUSION_SKETCH } from './geometryIllusion';
|
|
38
|
+
export { RESONANT_SOUND_BODIES_SKETCH } from './resonantSoundBodies';
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../soundart-sketches/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAiBH,MAAM,MAAM,kBAAkB,GAC1B,OAAO,GACP,aAAa,GACb,aAAa,GACb,KAAK,GACL,aAAa,GACb,SAAS,GACT,WAAW,GACX,eAAe,GACf,iBAAiB,GACjB,cAAc,GACd,YAAY,GACZ,SAAS,GACT,kBAAkB,GAClB,qBAAqB,CAAC;AAE1B;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAehE,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM,GAAG,SAAS,CAE9E;AAED;;GAEG;AACH,wBAAgB,4BAA4B,IAAI,kBAAkB,EAAE,CAEnE;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAE3E;AAED,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SoundArt Sketches Index
|
|
3
|
+
*
|
|
4
|
+
* All SoundArt styles converted to Code Mode sketches.
|
|
5
|
+
* Each sketch uses S.* globals for sound-derived parameters.
|
|
6
|
+
*/
|
|
7
|
+
import { RINGS_SKETCH } from './rings';
|
|
8
|
+
import { PIXEL_GLYPHS_SKETCH } from './pixelGlyphs';
|
|
9
|
+
import { RADIAL_BURST_SKETCH } from './radialBurst';
|
|
10
|
+
import { ORB_SKETCH } from './orb';
|
|
11
|
+
import { WAVE_STRIPES_SKETCH } from './waveStripes';
|
|
12
|
+
import { SQUARES_SKETCH } from './squares';
|
|
13
|
+
import { LOOM_WEAVE_SKETCH } from './loomWeave';
|
|
14
|
+
import { NOISE_TERRACES_SKETCH } from './noiseTerraces';
|
|
15
|
+
import { PRISM_FLOW_FIELDS_SKETCH } from './prismFlowFields';
|
|
16
|
+
import { CHLADNI_BLOOM_SKETCH } from './chladniBloom';
|
|
17
|
+
import { DUAL_VORTEX_SKETCH } from './dualVortex';
|
|
18
|
+
import { ISOFLOW_SKETCH } from './isoflow';
|
|
19
|
+
import { GEOMETRY_ILLUSION_SKETCH } from './geometryIllusion';
|
|
20
|
+
import { RESONANT_SOUND_BODIES_SKETCH } from './resonantSoundBodies';
|
|
21
|
+
/**
|
|
22
|
+
* Map of all available SoundArt sketches
|
|
23
|
+
* Each sketch is a string containing Code Mode compatible code
|
|
24
|
+
*/
|
|
25
|
+
export const SOUNDART_SKETCHES = {
|
|
26
|
+
rings: RINGS_SKETCH,
|
|
27
|
+
pixelGlyphs: PIXEL_GLYPHS_SKETCH,
|
|
28
|
+
radialBurst: RADIAL_BURST_SKETCH,
|
|
29
|
+
orb: ORB_SKETCH,
|
|
30
|
+
waveStripes: WAVE_STRIPES_SKETCH,
|
|
31
|
+
squares: SQUARES_SKETCH,
|
|
32
|
+
loomWeave: LOOM_WEAVE_SKETCH,
|
|
33
|
+
noiseTerraces: NOISE_TERRACES_SKETCH,
|
|
34
|
+
prismFlowFields: PRISM_FLOW_FIELDS_SKETCH,
|
|
35
|
+
chladniBloom: CHLADNI_BLOOM_SKETCH,
|
|
36
|
+
dualVortex: DUAL_VORTEX_SKETCH,
|
|
37
|
+
isoflow: ISOFLOW_SKETCH,
|
|
38
|
+
geometryIllusion: GEOMETRY_ILLUSION_SKETCH,
|
|
39
|
+
resonantSoundBodies: RESONANT_SOUND_BODIES_SKETCH,
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Get a SoundArt sketch by name
|
|
43
|
+
*/
|
|
44
|
+
export function getSoundArtSketch(name) {
|
|
45
|
+
return SOUNDART_SKETCHES[name];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get list of available (converted) SoundArt sketches
|
|
49
|
+
*/
|
|
50
|
+
export function getAvailableSoundArtSketches() {
|
|
51
|
+
return Object.keys(SOUNDART_SKETCHES);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Check if a SoundArt sketch has been converted to Code Mode
|
|
55
|
+
*/
|
|
56
|
+
export function isSoundArtSketchAvailable(name) {
|
|
57
|
+
return name in SOUNDART_SKETCHES;
|
|
58
|
+
}
|
|
59
|
+
export { RINGS_SKETCH } from './rings';
|
|
60
|
+
export { PIXEL_GLYPHS_SKETCH } from './pixelGlyphs';
|
|
61
|
+
export { RADIAL_BURST_SKETCH } from './radialBurst';
|
|
62
|
+
export { ORB_SKETCH } from './orb';
|
|
63
|
+
export { WAVE_STRIPES_SKETCH } from './waveStripes';
|
|
64
|
+
export { SQUARES_SKETCH } from './squares';
|
|
65
|
+
export { LOOM_WEAVE_SKETCH } from './loomWeave';
|
|
66
|
+
export { NOISE_TERRACES_SKETCH } from './noiseTerraces';
|
|
67
|
+
export { PRISM_FLOW_FIELDS_SKETCH } from './prismFlowFields';
|
|
68
|
+
export { CHLADNI_BLOOM_SKETCH } from './chladniBloom';
|
|
69
|
+
export { DUAL_VORTEX_SKETCH } from './dualVortex';
|
|
70
|
+
export { ISOFLOW_SKETCH } from './isoflow';
|
|
71
|
+
export { GEOMETRY_ILLUSION_SKETCH } from './geometryIllusion';
|
|
72
|
+
export { RESONANT_SOUND_BODIES_SKETCH } from './resonantSoundBodies';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const ISOFLOW_SKETCH = "\nfunction setup() {\n const bgMode = typeof backgroundMode !== 'undefined' ? backgroundMode : 'rgb';\n if (bgMode === 'white') background(245, 245, 245);\n else if (bgMode === 'black') background(10, 10, 10);\n else {\n const r = Math.floor((S.brightness / 100) * 255);\n const g = Math.floor((S.rhythmicity / 100) * 255);\n const b = Math.floor((S.harmonicity / 100) * 255);\n background(r, g, b);\n }\n\n const cx = width / 2;\n const cy = height / 2;\n const maxRadius = min(width, height) * 0.6;\n const layers = 3;\n const burstsPerLayer = Math.floor(map(S.rhythmicity, 0, 100, 20, 40));\n\n noFill();\n\n for (let l = 0; l < layers; l++) {\n const hue = map(l === 0 ? S.bass : (l === 1 ? S.brightness : S.treble), 0, 100, 0, 360);\n const alpha = map(l === 0 ? S.volume : (l === 1 ? S.aggression : S.dynamicRange), 0, 100, 0.7, 1);\n const sat = 85 + random() * 15;\n \n stroke('hsla(' + hue + ',' + sat + '%,95%,' + alpha + ')');\n strokeWeight(map(S.volume + l * 10, 0, 130, 1.2, 4.8));\n \n const radiusScale = map(S.dynamicRange + l * 20, 0, 150, 0.8, 1.4);\n const noiseAmp = map(S.aggression, 0, 100, 0.5, 3.0);\n const swirl = map(S.treble + l * 20, 0, 150, 0.3, 1.5);\n const rotSkew = map(S.harmonicity, 0, 100, -0.5, 0.5);\n const deformSkew = map(S.attack, 0, 100, -PI * 0.4, PI * 0.4);\n const centerJitter = map(S.bass, 0, 100, -60, 60);\n\n for (let b = 0; b < burstsPerLayer; b++) {\n const baseAngle = map(b + l * burstsPerLayer, 0, layers * burstsPerLayer, 0, PI * 2);\n const burstCount = Math.floor(map(S.volume + S.rhythmicity, 0, 200, 30, 90));\n \n for (let j = 0; j < burstCount; j++) {\n const angle = baseAngle + map(j, 0, burstCount, -0.02, 0.02);\n const ox = cx + cos(angle) * centerJitter;\n const oy = cy + sin(angle) * centerJitter;\n \n beginShape();\n for (let r0 = 0; r0 < maxRadius * radiusScale; r0 += 3) {\n const normR = r0 / maxRadius;\n const n = noise(cos(angle + rotSkew) * normR * noiseAmp, sin(angle + swirl) * normR * noiseAmp);\n const deform = map(n, 0, 1, -PI * swirl, PI * swirl) + deformSkew;\n const px = ox + cos(angle + deform) * r0;\n const py = oy + sin(angle + deform) * r0;\n vertex(px, py);\n }\n endShape();\n }\n }\n }\n}\n";
|
|
2
|
+
export default ISOFLOW_SKETCH;
|
|
3
|
+
//# sourceMappingURL=isoflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isoflow.d.ts","sourceRoot":"","sources":["../../soundart-sketches/isoflow.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,g2EA0D1B,CAAC;AAEF,eAAe,cAAc,CAAC"}
|