From 8ae616d1c7c08b3752c96105c987b0b47bc9ff65 Mon Sep 17 00:00:00 2001 From: Djkato Date: Thu, 20 Jul 2023 00:11:47 +0200 Subject: [PATCH] loots of bugfixes --- package-lock.json | 6 +-- package.json | 3 +- packages/euterpe/package.json | 2 +- packages/music-library/package.json | 2 +- packages/music-library/src/index.ts | 18 +++---- packages/music-library/src/refrence db.json | 53 --------------------- packages/music-library/tsconfig.json | 2 +- packages/music-library/tsconfig.lib.json | 17 +++++-- packages/player/package.json | 2 +- packages/preprocessor/package.json | 2 +- packages/preprocessor/project.json | 2 +- packages/preprocessor/src/main.ts | 8 +++- packages/visualizer/package.json | 2 +- packages/visualizer/src/index.ts | 12 ++--- 14 files changed, 46 insertions(+), 85 deletions(-) delete mode 100644 packages/music-library/src/refrence db.json diff --git a/package-lock.json b/package-lock.json index 9e817af..1618b80 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6251,9 +6251,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.464", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.464.tgz", - "integrity": "sha512-guZ84yoou4+ILNdj0XEbmGs6DEWj6zpVOWYpY09GU66yEb0DSYvP/biBPzHn0GuW/3RC/pnaYNUWlQE1fJYtgA==", + "version": "1.4.465", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.465.tgz", + "integrity": "sha512-XQcuHvEJRMU97UJ75e170mgcITZoz0lIyiaVjk6R+NMTJ8KBIvUHYd1779swgOppUlzxR+JsLpq59PumaXS1jQ==", "dev": true }, "node_modules/emoji-regex": { diff --git a/package.json b/package.json index 59cedeb..0c1b73d 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "publish-player": "nx build player && cd dist/packages/player && npm publish --access=public", "publish-visualizer": "nx build visualizer && cd dist/packages/visualizer && npm publish --access=public", "publish-library": "nx build music-library && cd dist/packages/music-library && npm publish --access=public", - "publish-euterpe": "nx build euterpe && cd dist/packages/euterpe && npm publish --access=public" + "publish-euterpe": "nx build euterpe && cd dist/packages/euterpe && npm publish --access=public", + "publish-all": "npm run publish-player && npm run publish-library && npm run publish-visualizer && npm run publish-euterpe" }, "private": false, "devDependencies": { diff --git a/packages/euterpe/package.json b/packages/euterpe/package.json index 7b4d783..9e993d2 100644 --- a/packages/euterpe/package.json +++ b/packages/euterpe/package.json @@ -1,6 +1,6 @@ { "name": "@euterpe.js/euterpe", - "version": "1.0.1", + "version": "1.0.4", "type": "module", "description": "Fully featured solution for playing music on the web. Support for local library, audio visuals and more!", "main": "./src/index.js", diff --git a/packages/music-library/package.json b/packages/music-library/package.json index 774fc34..ced8af6 100644 --- a/packages/music-library/package.json +++ b/packages/music-library/package.json @@ -1,6 +1,6 @@ { "name": "@euterpe.js/music-library", - "version": "1.0.4", + "version": "1.0.7", "type": "module", "description": "A simple music library, acting as a Local DB as JS Object. Contains everything a person would need to store their music data for website playback.", "main": "./src/index.js", diff --git a/packages/music-library/src/index.ts b/packages/music-library/src/index.ts index c810566..6c2c89e 100644 --- a/packages/music-library/src/index.ts +++ b/packages/music-library/src/index.ts @@ -69,7 +69,7 @@ interface SongConstructor { key?: string fft_data?: number[] id?: ID, - metadata?: Map + metadata?: any[] } class Song { name: string @@ -83,7 +83,7 @@ class Song { bpm?: number key?: string fft_data?: number[] - metadata: Map + metadata: any[] /** * The ID is always there, don't worry :) */ @@ -101,7 +101,7 @@ class Song { this.key = data.key this.fft_data = data.fft_data this.id = data.id - this.metadata = data.metadata || new Map + this.metadata = data.metadata || [] } } @@ -112,7 +112,7 @@ interface ArtistConstructor { collections?: Ref[] links?: [Platforms, URL][] id?: ID - metadata?: Map + metadata?: any[] } class Artist { name = "" @@ -120,7 +120,7 @@ class Artist { songs: Ref[] collections: Ref[] links?: [Platforms, URL][] - metadata: Map + metadata: any[] /** * The ID is always there, don't worry :) */ @@ -132,7 +132,7 @@ class Artist { this.collections = data.collections || [] this.links = data.links this.id = data.id - this.metadata = data.metadata || new Map + this.metadata = data.metadata || [] } } interface CollectionConstructor { @@ -142,7 +142,7 @@ interface CollectionConstructor { duration?: number publish_date?: Date id?: ID - metadata?: Map + metadata?: any[] name?: string type?: CollectionType @@ -155,7 +155,7 @@ class Collection { cover?: URL duration?: number publish_date?: Date - metadata: Map + metadata: any[] /** * The ID is always there, don't worry :) */ @@ -168,7 +168,7 @@ class Collection { this.publish_date = data.publish_date this.id = data.id this.name = data.name - this.metadata = data.metadata ? data.metadata : new Map + this.metadata = data.metadata ? data.metadata : [] } } class DB { diff --git a/packages/music-library/src/refrence db.json b/packages/music-library/src/refrence db.json deleted file mode 100644 index 9bd839b..0000000 --- a/packages/music-library/src/refrence db.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "artist": { - "id": 0, - "name": "", - "pfp?": "url('')", - "songs?": [ - "ref(songs,0)", - "ref(songs,2)" - ], - "collections?": [ - "ref(collections,0)" - ], - "links?": [ - "(youtube, url(''))", - "(key, url(''))" - ] - }, - "song": { - "id": 0, - "publish-date?": "00-00-0000", - "name": "", - "artists": [ - "ref(artists, 0)", - "ref(artists, 1)" - ], - "remix_artists": [ - "ref(artists,3)" - ], - "in_collection?": "ref(collections,0)", - "url": "url('')", - "cover?": "either url or use collections cover", - "duration": 123, - "bpm?": 120, - "key": "A Minor", - "fft_data?": [ - 0, - 1 - ] - }, - "collection": { - "id": 0, - "publish-date?": "00-00-0000", - "artists": [ - "ref(artists, 0)" - ], - "songs": [ - "ref(songs, 1)", - "ref(songs, 2)" - ], - "cover": "url('')", - "duration": 123 - } -} \ No newline at end of file diff --git a/packages/music-library/tsconfig.json b/packages/music-library/tsconfig.json index 7758f7b..e617450 100644 --- a/packages/music-library/tsconfig.json +++ b/packages/music-library/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "module": "ESNext", + "module": "esnext", "forceConsistentCasingInFileNames": true, "strict": true, "noImplicitOverride": true, diff --git a/packages/music-library/tsconfig.lib.json b/packages/music-library/tsconfig.lib.json index 33eca2c..6789e19 100644 --- a/packages/music-library/tsconfig.lib.json +++ b/packages/music-library/tsconfig.lib.json @@ -3,8 +3,17 @@ "compilerOptions": { "outDir": "../../dist/out-tsc", "declaration": true, - "types": ["node"] + "types": [ + "node" + ] }, - "include": ["src/**/*.ts"], - "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] -} + "include": [ + "src/**/*.ts", + "README.md" + ], + "exclude": [ + "jest.config.ts", + "src/**/*.spec.ts", + "src/**/*.test.ts" + ] +} \ No newline at end of file diff --git a/packages/player/package.json b/packages/player/package.json index 6cb0026..3a2a0a6 100644 --- a/packages/player/package.json +++ b/packages/player/package.json @@ -1,6 +1,6 @@ { "name": "@euterpe.js/player", - "version": "1.0.22", + "version": "1.0.23", "type": "module", "description": "A simple, safe AudioContext web music player", "main": "./src/index.js", diff --git a/packages/preprocessor/package.json b/packages/preprocessor/package.json index 617df89..d4ef236 100644 --- a/packages/preprocessor/package.json +++ b/packages/preprocessor/package.json @@ -1,5 +1,5 @@ { - "name": "preprocessor", + "name": "@euterpe.js/preprocessor", "private": true, "version": "0.0.0", "type": "module", diff --git a/packages/preprocessor/project.json b/packages/preprocessor/project.json index 9b17227..89e1059 100644 --- a/packages/preprocessor/project.json +++ b/packages/preprocessor/project.json @@ -1,5 +1,5 @@ { - "name": "preprocessor", + "name": "@euterpe.js/preprocessor", "$schema": "../../node_modules/nx/schemas/project-schema.json", "projectType": "application", "sourceRoot": "packages/preprocessor/src", diff --git a/packages/preprocessor/src/main.ts b/packages/preprocessor/src/main.ts index 2720535..0e3496d 100644 --- a/packages/preprocessor/src/main.ts +++ b/packages/preprocessor/src/main.ts @@ -11,6 +11,7 @@ export async function start() { console.log("Creating svgs...") const waveform_canvas = document.querySelector("#waveform-canvas") as SVGSVGElement for (const song of result.db.songs) { + console.log("creating waveform for -> " + song.name) const waveform_visual_builder = new AudioVisualBuilder(result.analyzer_node, waveform_canvas) .set_fft_data_tresholds({ point_count_i: 100, fft_multiplier_i: 1, fft_offset_i: -80 }) .set_fft_time_smoothing(0.8) @@ -18,9 +19,12 @@ export async function start() { const waveform_visual = waveform_visual_builder.build(ShapeType.Waveform, true, { fft_data: new Float32Array(new Float64Array(song.fft_data!)), orientation: WaveformOrientation.Horizontal, shape_type: WaveformShape.LineLike }) waveform_visual.draw_once() await new Promise((done) => setTimeout(() => done(), 300)) - song.metadata.set("waveform-svg", waveform_canvas.innerHTML) + // @ts-ignore + song.metadata[0] = waveform_canvas.innerHTML + song.fft_data = [] } - console.log(result.db) + console.dir(result.db, { depth: null }) + console.log(JSON.stringify(result.db)) }) } async function analyze(): Promise { diff --git a/packages/visualizer/package.json b/packages/visualizer/package.json index 3fc90ae..b82218a 100644 --- a/packages/visualizer/package.json +++ b/packages/visualizer/package.json @@ -1,6 +1,6 @@ { "name": "@euterpe.js/visualizer", - "version": "1.0.3", + "version": "1.0.6", "type": "module", "description": "Music visualizer based on SVG and AudioContext", "main": "./src/index.js", diff --git a/packages/visualizer/src/index.ts b/packages/visualizer/src/index.ts index bad15e9..5392e06 100644 --- a/packages/visualizer/src/index.ts +++ b/packages/visualizer/src/index.ts @@ -177,7 +177,7 @@ export class AudioVisual { const cp2x = x2 - (x3 - x1) / 6 * k const cp2y = y2 - (y3 - y1) / 6 * k - path += "C" + [cp1x, cp1y, cp2x, cp2y, x2, y2] + path += "C" + [cp1x.toFixed(2), cp1y.toFixed(2), cp2x.toFixed(2), cp2y.toFixed(2), x2.toFixed(2), y2.toFixed(2)] } return path } @@ -287,7 +287,7 @@ export class AudioVisual { switch (this.#shape.shape_type) { case ShapeType.Line: { for (let i = 0; i < arr.length; i++) { - path += `L ${arr[i].x},${arr[i].y} ` + path += `L ${arr[i].x.toFixed(2)},${arr[i].y.toFixed(2)} ` } if (this.#shape.shape_type == ShapeType.Line) { path += `L ${this.#canvas_width} ${this.#canvas_height} ` @@ -297,16 +297,16 @@ export class AudioVisual { } case ShapeType.Circle: { for (let i = 0; i < arr.length; i++) { - path += `L ${arr[i].x},${arr[i].y} ` + path += `L ${arr[i].x.toFixed(2)},${arr[i].y.toFixed(2)} ` } break } case ShapeType.Waveform: { for (let i = 0; i < arr.length; i += 2) { - path += `L ${arr[i].x},${arr[i].y} ` + path += `L ${arr[i].x.toFixed(2)},${arr[i].y.toFixed(2)} ` } for (let i = arr.length - 1; i >= 0; i -= 2) { - path += `L ${arr[i].x},${arr[i].y} ` + path += `L ${arr[i].x.toFixed(2)},${arr[i].y.toFixed(2)} ` } } } @@ -318,7 +318,7 @@ export class AudioVisual { const anchors = this.#create_perpendicular_anchors(arr) for (let i = 1; i < arr.length; i++) { - path += `C ${anchors[i - 1].rightAnchor.x} ${anchors[i - 1].rightAnchor.y} ${anchors[i].leftAnchor.x} ${anchors[i].leftAnchor.y} ${arr[i].x} ${arr[i].y} ` + path += `C ${anchors[i - 1].rightAnchor.x.toFixed(2)} ${anchors[i - 1].rightAnchor.y.toFixed(2)} ${anchors[i].leftAnchor.x.toFixed(2)} ${anchors[i].leftAnchor.y.toFixed(2)} ${arr[i].x.toFixed(2)} ${arr[i].y.toFixed(2)} ` } if (this.#shape.shape_type == ShapeType.Line) { //path += `L ${this.canvasWidth} ${this.canvasHeight / 2} `