loots of bugfixes

This commit is contained in:
Djkato 2023-07-20 00:11:47 +02:00
parent 920ee5152a
commit 8ae616d1c7
14 changed files with 46 additions and 85 deletions

6
package-lock.json generated
View file

@ -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": {

View file

@ -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": {

View file

@ -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",

View file

@ -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",

View file

@ -69,7 +69,7 @@ interface SongConstructor {
key?: string
fft_data?: number[]
id?: ID,
metadata?: Map<string, any>
metadata?: any[]
}
class Song {
name: string
@ -83,7 +83,7 @@ class Song {
bpm?: number
key?: string
fft_data?: number[]
metadata: Map<string, any>
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<string, any>
this.metadata = data.metadata || []
}
}
@ -112,7 +112,7 @@ interface ArtistConstructor {
collections?: Ref[]
links?: [Platforms, URL][]
id?: ID
metadata?: Map<string, any>
metadata?: any[]
}
class Artist {
name = ""
@ -120,7 +120,7 @@ class Artist {
songs: Ref[]
collections: Ref[]
links?: [Platforms, URL][]
metadata: Map<string, any>
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<string, any>
this.metadata = data.metadata || []
}
}
interface CollectionConstructor {
@ -142,7 +142,7 @@ interface CollectionConstructor {
duration?: number
publish_date?: Date
id?: ID
metadata?: Map<string, any>
metadata?: any[]
name?: string
type?: CollectionType
@ -155,7 +155,7 @@ class Collection {
cover?: URL
duration?: number
publish_date?: Date
metadata: Map<string, any>
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<string, any>
this.metadata = data.metadata ? data.metadata : []
}
}
class DB {

View file

@ -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
}
}

View file

@ -1,7 +1,7 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "ESNext",
"module": "esnext",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,

View file

@ -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"
]
}

View file

@ -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",

View file

@ -1,5 +1,5 @@
{
"name": "preprocessor",
"name": "@euterpe.js/preprocessor",
"private": true,
"version": "0.0.0",
"type": "module",

View file

@ -1,5 +1,5 @@
{
"name": "preprocessor",
"name": "@euterpe.js/preprocessor",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "packages/preprocessor/src",

View file

@ -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<void>((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<AnalyzeReturn> {

View file

@ -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",

View file

@ -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} `