-
Notifications
You must be signed in to change notification settings - Fork 0
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
6 changed files
with
254 additions
and
7 deletions.
There are no files selected for viewing
Binary file not shown.
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,138 @@ | ||
{ | ||
"nodes": [ | ||
{ | ||
"id": "6c235b85e9207e2f", | ||
"name": "Oscillator", | ||
"data": { | ||
"baseFreq": 440, | ||
"waveform": "sine" | ||
} | ||
}, | ||
{ | ||
"id": "2b6c4d44d4f69ef6", | ||
"name": "Gain", | ||
"data": { | ||
"gain": 0.2 | ||
} | ||
}, | ||
{ | ||
"id": "a742397e3e6cf5ad", | ||
"name": "Universal Output", | ||
"data": { | ||
"gain": 1 | ||
} | ||
}, | ||
{ | ||
"id": "9a3ce700284ae274", | ||
"name": "Note Frequency", | ||
"data": { | ||
"octave": 3, | ||
"note": "7" | ||
} | ||
}, | ||
{ | ||
"id": "9158c035be4da8c9", | ||
"name": "Note Frequency", | ||
"data": { | ||
"octave": 3, | ||
"note": "3" | ||
} | ||
}, | ||
{ | ||
"id": "825965ae7cf0e811", | ||
"name": "Oscillator", | ||
"data": { | ||
"baseFreq": 440, | ||
"waveform": "sine" | ||
} | ||
}, | ||
{ | ||
"id": "051ec48cb7a4c245", | ||
"name": "Note Frequency", | ||
"data": { | ||
"octave": 4, | ||
"note": "2" | ||
} | ||
}, | ||
{ | ||
"id": "1b521693124a65ac", | ||
"name": "Oscillator", | ||
"data": { | ||
"baseFreq": 440, | ||
"waveform": "sine" | ||
} | ||
}, | ||
{ | ||
"id": "168f3351a007a05d", | ||
"name": "Note Frequency", | ||
"data": { | ||
"octave": 3, | ||
"note": "10" | ||
} | ||
}, | ||
{ | ||
"id": "72da2ef00bdfcc04", | ||
"name": "Oscillator", | ||
"data": { | ||
"baseFreq": 440, | ||
"waveform": "sine" | ||
} | ||
} | ||
], | ||
"connections": [ | ||
{ | ||
"source": "2b6c4d44d4f69ef6", | ||
"sourceOutput": "signal", | ||
"target": "a742397e3e6cf5ad", | ||
"targetInput": "signal" | ||
}, | ||
{ | ||
"source": "9a3ce700284ae274", | ||
"sourceOutput": "value", | ||
"target": "6c235b85e9207e2f", | ||
"targetInput": "baseFrequency" | ||
}, | ||
{ | ||
"source": "9158c035be4da8c9", | ||
"sourceOutput": "value", | ||
"target": "825965ae7cf0e811", | ||
"targetInput": "baseFrequency" | ||
}, | ||
{ | ||
"source": "825965ae7cf0e811", | ||
"sourceOutput": "signal", | ||
"target": "2b6c4d44d4f69ef6", | ||
"targetInput": "signal" | ||
}, | ||
{ | ||
"source": "1b521693124a65ac", | ||
"sourceOutput": "signal", | ||
"target": "2b6c4d44d4f69ef6", | ||
"targetInput": "signal" | ||
}, | ||
{ | ||
"source": "168f3351a007a05d", | ||
"sourceOutput": "value", | ||
"target": "72da2ef00bdfcc04", | ||
"targetInput": "baseFrequency" | ||
}, | ||
{ | ||
"source": "72da2ef00bdfcc04", | ||
"sourceOutput": "signal", | ||
"target": "2b6c4d44d4f69ef6", | ||
"targetInput": "signal" | ||
}, | ||
{ | ||
"source": "051ec48cb7a4c245", | ||
"sourceOutput": "value", | ||
"target": "1b521693124a65ac", | ||
"targetInput": "baseFrequency" | ||
}, | ||
{ | ||
"source": "6c235b85e9207e2f", | ||
"sourceOutput": "signal", | ||
"target": "2b6c4d44d4f69ef6", | ||
"targetInput": "signal" | ||
} | ||
] | ||
} |
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,57 @@ | ||
import { ClassicPreset as Classic } from "rete" | ||
import { socket, audioCtx, audioSources, audioSourceStates } from "../default" | ||
import { DropdownControl } from "../controls/DropdownControl"; | ||
|
||
export class NoteFrequencyNode extends Classic.Node<{}, { value: Classic.Socket }, { note: DropdownControl, octave: Classic.InputControl<"number", number> }> { | ||
width = 180 | ||
height = 160 | ||
constructor(change: () => void, initial?: { octave: number, note: string }) { | ||
super('Note Frequency'); | ||
|
||
this.addOutput('value', new Classic.Output(socket, 'Frequency')); | ||
|
||
const dropdownOptions = [ | ||
{ value: "0", label: "A" }, | ||
{ value: "1", label: "A#/B♭" }, | ||
{ value: "2", label: "B" }, | ||
{ value: "3", label: "C" }, | ||
{ value: "4", label: "C#/D♭" }, | ||
{ value: "5", label: "D" }, | ||
{ value: "6", label: "D#/E♭" }, | ||
{ value: "7", label: "E" }, | ||
{ value: "8", label: "F" }, | ||
{ value: "9", label: "F#/G♭" }, | ||
{ value: "10", label: "G" }, | ||
{ value: "11", label: "G#/A♭" }, | ||
] | ||
this.addControl("note", new DropdownControl(change, dropdownOptions, initial ? initial.note : "0")) | ||
|
||
this.addControl( | ||
'octave', | ||
new Classic.InputControl('number', { initial: initial ? initial.octave : 4, change }) | ||
); | ||
} | ||
|
||
data(): { value: AudioNode } { | ||
const constantNode = audioCtx.createConstantSource(); | ||
const noteVal = Number(this.controls.note.value) | ||
const octave = this.controls.octave.value || 0 | ||
const val = 440 * Math.pow(2.0, (octave - 4) + (1.0 / 12) * noteVal); | ||
|
||
constantNode.offset.setValueAtTime(val, audioCtx.currentTime); | ||
|
||
audioSources.push(constantNode); | ||
audioSourceStates.push(false); | ||
|
||
return { | ||
value: constantNode | ||
} | ||
} | ||
|
||
serialize() { | ||
return { | ||
octave: this.controls.octave.value, | ||
note: this.controls.note.value | ||
} | ||
} | ||
} |