-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
838 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "chatgpt-web-midjourney-proxy", | ||
"version": "2.21.1", | ||
"version": "2.21.2", | ||
"private": false, | ||
"description": "ChatGPT Web Midjourney Proxy", | ||
"author": "Dooy <[email protected]>", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
const dataMap = new WeakMap(); | ||
|
||
/** | ||
* Normalizes a Float32Array to Array(m): We use this to draw amplitudes on a graph | ||
* If we're rendering the same audio data, then we'll often be using | ||
* the same (data, m, downsamplePeaks) triplets so we give option to memoize | ||
*/ | ||
const normalizeArray = ( | ||
data: Float32Array, | ||
m: number, | ||
downsamplePeaks: boolean = false, | ||
memoize: boolean = false | ||
) => { | ||
let cache, mKey, dKey; | ||
if (memoize) { | ||
mKey = m.toString(); | ||
dKey = downsamplePeaks.toString(); | ||
cache = dataMap.has(data) ? dataMap.get(data) : {}; | ||
dataMap.set(data, cache); | ||
cache[mKey] = cache[mKey] || {}; | ||
if (cache[mKey][dKey]) { | ||
return cache[mKey][dKey]; | ||
} | ||
} | ||
const n = data.length; | ||
const result = new Array(m); | ||
if (m <= n) { | ||
// Downsampling | ||
result.fill(0); | ||
const count = new Array(m).fill(0); | ||
for (let i = 0; i < n; i++) { | ||
const index = Math.floor(i * (m / n)); | ||
if (downsamplePeaks) { | ||
// take highest result in the set | ||
result[index] = Math.max(result[index], Math.abs(data[i])); | ||
} else { | ||
result[index] += Math.abs(data[i]); | ||
} | ||
count[index]++; | ||
} | ||
if (!downsamplePeaks) { | ||
for (let i = 0; i < result.length; i++) { | ||
result[i] = result[i] / count[i]; | ||
} | ||
} | ||
} else { | ||
for (let i = 0; i < m; i++) { | ||
const index = (i * (n - 1)) / (m - 1); | ||
const low = Math.floor(index); | ||
const high = Math.ceil(index); | ||
const t = index - low; | ||
if (high >= n) { | ||
result[i] = data[n - 1]; | ||
} else { | ||
result[i] = data[low] * (1 - t) + data[high] * t; | ||
} | ||
} | ||
} | ||
if (memoize) { | ||
cache[mKey as string][dKey as string] = result; | ||
} | ||
return result; | ||
}; | ||
|
||
export const WavRenderer = { | ||
/** | ||
* Renders a point-in-time snapshot of an audio sample, usually frequency values | ||
* @param canvas | ||
* @param ctx | ||
* @param data | ||
* @param color | ||
* @param pointCount number of bars to render | ||
* @param barWidth width of bars in px | ||
* @param barSpacing spacing between bars in px | ||
* @param center vertically center the bars | ||
*/ | ||
drawBars: ( | ||
canvas: HTMLCanvasElement, | ||
ctx: CanvasRenderingContext2D, | ||
data: Float32Array, | ||
color: string, | ||
pointCount: number = 0, | ||
barWidth: number = 0, | ||
barSpacing: number = 0, | ||
center: boolean = false | ||
) => { | ||
pointCount = Math.floor( | ||
Math.min( | ||
pointCount, | ||
(canvas.width - barSpacing) / (Math.max(barWidth, 1) + barSpacing) | ||
) | ||
); | ||
if (!pointCount) { | ||
pointCount = Math.floor( | ||
(canvas.width - barSpacing) / (Math.max(barWidth, 1) + barSpacing) | ||
); | ||
} | ||
if (!barWidth) { | ||
barWidth = (canvas.width - barSpacing) / pointCount - barSpacing; | ||
} | ||
const points = normalizeArray(data, pointCount, true); | ||
for (let i = 0; i < pointCount; i++) { | ||
const amplitude = Math.abs(points[i]); | ||
const height = Math.max(1, amplitude * canvas.height); | ||
const x = barSpacing + i * (barWidth + barSpacing); | ||
const y = center ? (canvas.height - height) / 2 : canvas.height - height; | ||
ctx.fillStyle = color; | ||
ctx.fillRect(x, y, barWidth, height); | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
<script setup lang="ts"> | ||
import aiGpts from "./aiGpts.vue" | ||
import aiGallery from "./aiGallery.vue" | ||
import realtimeLayout from "@/views/wav/realtimeLayout.vue" | ||
</script> | ||
<template> | ||
<aiGpts/> | ||
<aiGallery/> | ||
<!-- <aiOther/> --> | ||
<realtimeLayout/> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<template> | ||
<div class="container"> | ||
<div class="in-and-out"><div><div></div><div></div><div></div><div></div><div></div></div><div><div></div><div></div><div></div><div></div><div></div></div></div> | ||
</div> | ||
</template> | ||
<style scoped> | ||
@import './css/in-and-out.css'; | ||
.container { | ||
-ms-flex-align: center; | ||
align-items: center; | ||
-ms-flex-pack: center; | ||
justify-content: center; | ||
height: 175px; | ||
overflow: hidden; | ||
width: 100%; | ||
position: relative; | ||
display: flex; | ||
min-width: 200px; | ||
--primary: #fafafa; | ||
--secondary: #f9690e; | ||
} | ||
</style> |
Oops, something went wrong.