-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
12 changed files
with
225 additions
and
81 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
"name": "amethyst", | ||
"author": "Geoxor <[email protected]>", | ||
"productName": "Amethyst", | ||
"version": "1.7.6", | ||
"version": "1.7.7", | ||
"main": "./release/dist/main/main.js", | ||
"licenses": [ | ||
{ | ||
|
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,25 @@ | ||
<template > | ||
<CustomNode :node="node" title="Single Band Filter" :icon="FilterIcon"> | ||
<p class="font-aseprite"><strong class="text-white font-aseprite font-thin text-opacity-50">Gain</strong> {{ gain }} | ||
dB</p> | ||
|
||
<Slider @mousedown.stop v-model="gain" min="-18" max="18" @change="props.node.node.gain.value = gain" /> | ||
|
||
<p class="font-aseprite"><strong class="text-white font-aseprite font-thin text-opacity-50">Frequency</strong> {{ | ||
frequency | ||
}} | ||
Hz</p> | ||
<Slider @mousedown.stop v-model="frequency" max="2000" @change="props.node.node.frequency.value = frequency" /> | ||
</CustomNode> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { AmethystEqualizerNode } from '../../logic/audio'; | ||
import { ref } from 'vue'; | ||
import FilterIcon from '../../icons/nodes/FilterIcon.vue'; | ||
import Slider from '../input/Slider.vue'; | ||
import CustomNode from './CustomNode.vue'; | ||
const props = defineProps<{ node: AmethystEqualizerNode }>(); | ||
const gain = ref(props.node.node.gain.value); | ||
const frequency = ref(props.node.node.frequency.value); | ||
</script> |
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,11 @@ | ||
<template > | ||
<CustomNode :node="node" title="Input" description="From Amethyst" :icon="StepIntoIcon" /> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { AmethystAudioNode } from 'renderer/logic/audio'; | ||
import StepIntoIcon from '../../icons/nodes/StepIntoIcon.vue'; | ||
import CustomNode from './CustomNode.vue'; | ||
defineProps<{ node: AmethystAudioNode<any> }>(); | ||
</script> |
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,11 @@ | ||
<template > | ||
<CustomNode meterless :node="node" title="Output" description="To Speakers" :icon="StepOutIcon"></CustomNode> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { AmethystAudioNode } from 'renderer/logic/audio'; | ||
import StepOutIcon from '../../icons/nodes/StepOutIcon.vue'; | ||
import CustomNode from './CustomNode.vue'; | ||
defineProps<{ node: AmethystAudioNode<any> }>(); | ||
</script> |
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,15 @@ | ||
<template> | ||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 172 172" | ||
width="16" height="16"> | ||
<g fill="none" fill-rule="nonzero" stroke="none" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" | ||
stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" font-family="none" font-weight="none" | ||
font-size="none" text-anchor="none" style="mix-blend-mode: normal"> | ||
<path d="M0,172v-172h172v172z" fill="none"></path> | ||
<g fill="currentColor"> | ||
<path | ||
d="M50.16667,21.5c-3.956,0 -7.16667,3.21067 -7.16667,7.16667c0,3.956 3.21067,7.16667 7.16667,7.16667c3.956,0 7.16667,-3.21067 7.16667,-7.16667c0,-3.956 -3.21067,-7.16667 -7.16667,-7.16667zM121.83333,21.5c-3.956,0 -7.16667,3.21067 -7.16667,7.16667c0,3.956 3.21067,7.16667 7.16667,7.16667c3.956,0 7.16667,-3.21067 7.16667,-7.16667c0,-3.956 -3.21067,-7.16667 -7.16667,-7.16667zM150.36003,28.59668c-1.86189,0.05548 -3.62905,0.83363 -4.92708,2.1696l-23.59961,23.59961l-16.43294,-16.43294c-2.7988,-2.79764 -7.33531,-2.79764 -10.13411,0l-23.59961,23.59961l-16.43294,-16.43294c-2.7988,-2.79764 -7.33532,-2.79764 -10.13411,0l-21.5,21.5c-1.87219,1.79753 -2.62635,4.46674 -1.97162,6.97822c0.65473,2.51148 2.61604,4.47279 5.12752,5.12752c2.51148,0.65473 5.18069,-0.09943 6.97822,-1.97163l16.43294,-16.43294l16.43294,16.43294c2.7988,2.79764 7.33532,2.79764 10.13411,0l23.59961,-23.59961l16.43294,16.43294c2.7988,2.79764 7.33531,2.79764 10.13411,0l28.66667,-28.66667c2.11962,-2.06035 2.75694,-5.21064 1.60486,-7.93287c-1.15207,-2.72224 -3.85719,-4.45797 -6.81189,-4.37084zM50.16667,78.83333c-3.956,0 -7.16667,3.21067 -7.16667,7.16667c0,3.956 3.21067,7.16667 7.16667,7.16667c3.956,0 7.16667,-3.21067 7.16667,-7.16667c0,-3.956 -3.21067,-7.16667 -7.16667,-7.16667zM121.83333,78.83333c-3.956,0 -7.16667,3.21067 -7.16667,7.16667c0,3.956 3.21067,7.16667 7.16667,7.16667c3.956,0 7.16667,-3.21067 7.16667,-7.16667c0,-3.956 -3.21067,-7.16667 -7.16667,-7.16667zM50.16667,107.5c-3.956,0 -7.16667,3.21067 -7.16667,7.16667c0,3.956 3.21067,7.16667 7.16667,7.16667c3.956,0 7.16667,-3.21067 7.16667,-7.16667c0,-3.956 -3.21067,-7.16667 -7.16667,-7.16667zM121.83333,107.5c-3.956,0 -7.16667,3.21067 -7.16667,7.16667c0,3.956 3.21067,7.16667 7.16667,7.16667c3.956,0 7.16667,-3.21067 7.16667,-7.16667c0,-3.956 -3.21067,-7.16667 -7.16667,-7.16667zM28.66667,136.16667c-2.58456,-0.03655 -4.98858,1.32136 -6.29153,3.55376c-1.30295,2.2324 -1.30295,4.99342 0,7.22582c1.30295,2.2324 3.70697,3.59031 6.29153,3.55376h114.66667c2.58456,0.03655 4.98858,-1.32136 6.29153,-3.55376c1.30295,-2.2324 1.30295,-4.99342 0,-7.22582c-1.30295,-2.2324 -3.70697,-3.59031 -6.29153,-3.55376z"> | ||
</path> | ||
</g> | ||
</g> | ||
</svg> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,128 @@ | ||
export class AmethystEffect { | ||
constructor(public context: AudioContext) { | ||
import { Position } from "@vue-flow/core"; | ||
import { loadFolder } from "main/handles"; | ||
import { DefineComponent, Ref, ref } from "vue"; | ||
import InputNode from "../components/nodes/InputNode.vue" | ||
import OutputNode from "../components/nodes/OutputNode.vue" | ||
import FilterNode from "../components/nodes/FilterNode.vue" | ||
|
||
export interface IAmethystNodeProperties { | ||
id: string, | ||
type: `custom-${string}`, | ||
position: { x: number, y: number }, | ||
sourcePosition: Position, | ||
}; | ||
|
||
export interface IAmethystNodeConnection { | ||
id: `${string}-${string}`, | ||
source: string, | ||
target: string, | ||
animated: true, | ||
}; | ||
|
||
export class AmethystAudioNodeManager { | ||
public nodes: AmethystAudioNode<AudioNode>[] = ref([]).value; | ||
|
||
public constructor(public input: AudioNode, public context: AudioContext) { | ||
const output = this.context.destination; | ||
|
||
this.nodes.push(new AmethystAudioNode(input, "input", InputNode, { x: -50, y: 0 }, false)) | ||
this.nodes.push(new AmethystEqualizerNode(this.context, "filter", { x: 100, y: 0 })) | ||
this.nodes.push(new AmethystAudioNode(output, "output", OutputNode, { x: 350, y: 0 }, false)) | ||
|
||
this.connectNodes(); | ||
} | ||
|
||
private connectNodes() { | ||
const enabledNodes = this.nodes.filter(n => !n.isDisabled); | ||
|
||
for (let i = enabledNodes.length - 1; i >= 0; i--) { | ||
const previousNode = enabledNodes[i - 1]; | ||
const node = enabledNodes[i]; | ||
|
||
previousNode && previousNode.connectTo(node); | ||
} | ||
} | ||
|
||
private reconnectNodes() { | ||
this.nodes.forEach(node => node.disconnect()); | ||
this.connectNodes(); | ||
} | ||
|
||
public removeNode(id: string) { | ||
const target = this.nodes[this.nodes.findIndex(node => node.properties.id === id)]; | ||
if (!target.isRemovable) return; | ||
target.disconnect(); | ||
delete this.nodes[this.nodes.findIndex(node => node.properties.id === id)]; | ||
this.nodes = this.nodes.filter(n => !!n); | ||
this.connectNodes(); | ||
} | ||
|
||
public addNode<T extends AudioNode>(node: AmethystAudioNode<T>) { | ||
this.nodes.splice(this.nodes.length - 2, 0, node); | ||
this.connectNodes(); | ||
} | ||
|
||
public disableNode<T extends AudioNode>(node: AmethystAudioNode<T>) { | ||
node.isDisabled = true; | ||
this.reconnectNodes(); | ||
} | ||
|
||
public enableNode<T extends AudioNode>(node: AmethystAudioNode<T>) { | ||
node.isDisabled = false; | ||
this.reconnectNodes(); | ||
} | ||
|
||
public getNodeProperties() { | ||
return this.nodes.map(node => node.properties); | ||
} | ||
|
||
public getNodeComponents() { | ||
return this.nodes.map(node => node.component); | ||
} | ||
|
||
public getNodeConnections() { | ||
return this.nodes.map(node => node.connection).filter(n => !!n) as IAmethystNodeConnection[]; | ||
} | ||
} | ||
|
||
export class Filter extends AmethystEffect { | ||
public node: BiquadFilterNode; | ||
export class AmethystAudioNode<T extends AudioNode> { | ||
public properties: IAmethystNodeProperties; | ||
public connection: IAmethystNodeConnection | undefined; | ||
public isDisabled: boolean = false; | ||
private connectedTo: AmethystAudioNode<T> | undefined; | ||
|
||
public constructor(public node: T, name: string, public component: DefineComponent<{}, {}, any>, position: IAmethystNodeProperties["position"], public isRemovable: boolean = true) { | ||
this.properties = { | ||
id: name, | ||
type: `custom-${name}`, | ||
position, | ||
sourcePosition: Position.Right, | ||
} | ||
} | ||
|
||
constructor(public context: AudioContext) { | ||
super(context); | ||
this.node = this.context.createBiquadFilter(); | ||
public getSlotName() { | ||
return `node-${this.properties.type}`; | ||
} | ||
|
||
} | ||
public connectTo(target: AmethystAudioNode<T>) { | ||
this.connectedTo = target; | ||
this.connection = { id: `edge-${this.properties.id}-${target.properties.id}`, source: this.properties.id, target: target.properties.id, animated: true } | ||
this.node.connect(target.node); | ||
} | ||
|
||
public disconnect() { | ||
this.node.disconnect(); | ||
delete this.connection; | ||
} | ||
} | ||
|
||
export class AmethystEqualizerNode extends AmethystAudioNode<BiquadFilterNode> { | ||
public constructor(context: AudioContext, name: string, position: IAmethystNodeProperties["position"]) { | ||
const filter = context.createBiquadFilter(); | ||
filter.type = "lowshelf"; | ||
filter.frequency.value = 100; | ||
filter.gain.value = 0; | ||
|
||
super(filter, name, FilterNode, position); | ||
} | ||
} |
Oops, something went wrong.