-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- sf2 compliant chorus (respects the generators) - maintaining legacy system - the synth will now use the legacy system if the website is served over insecure context - update README accordingly - finally added the event system to the documentation
- Loading branch information
Showing
11 changed files
with
213 additions
and
141 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
This file was deleted.
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const DEFAULT_DELAY = 0.02; | ||
const DELAY_VARIATION = 0.015; | ||
|
||
const OSC_FREQ = 1.5; | ||
const OSC_GAIN = 0.001; | ||
export class FancyChorus | ||
{ | ||
/** | ||
* @param output {AudioNode} | ||
*/ | ||
constructor(output) { | ||
const context = output.context; | ||
|
||
this.input = new GainNode(context, | ||
{ | ||
gain: 1 | ||
}); | ||
|
||
const osc = new OscillatorNode(context, { | ||
type: 'sine', | ||
frequency: OSC_FREQ | ||
}); | ||
|
||
const oscGain = new GainNode(context, { | ||
gain: OSC_GAIN | ||
}); | ||
osc.connect(oscGain); | ||
osc.start(); | ||
const delayOne = new DelayNode(context, { | ||
delayTime: DEFAULT_DELAY | ||
}); | ||
const delayTwo = new DelayNode(context, { | ||
delayTime: DEFAULT_DELAY + DELAY_VARIATION | ||
}); | ||
oscGain.connect(delayOne.delayTime); | ||
this.input.connect(delayOne); | ||
this.input.connect(delayTwo); | ||
delayTwo.connect(output); | ||
delayOne.connect(output); | ||
} | ||
} |
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,25 +1,15 @@ | ||
# This is the old synthesis system. | ||
It's not maintained anymore, but it's here for the HTTP websites which can't use AudioWorklets. | ||
To use this system, edit `synthetizer.js`: | ||
It's not updated anymore, but it's here for the HTTP websites which can't use AudioWorklets. | ||
To use this system, change the `synthesisMode` to `"legacy"`: | ||
|
||
```js | ||
import { MidiChannel } from './native_system/midi_channel.js'; | ||
synth.synthesisMode = "legacy"; | ||
``` | ||
and change the class from `WorkletChannel` to `MidiChannel` | ||
it should automatically create the legacy channels. | ||
If you want to automatically use this mode, then | ||
```js | ||
/** | ||
* create 16 channels | ||
* @type {WorkletChannel[]|MidiChannel[]} | ||
*/ | ||
this.midiChannels = [...Array(DEFAULT_CHANNEL_COUNT).keys()].map(j => new MidiChannel(this.volumeController, this.defaultPreset, j + 1, false)); | ||
|
||
// ... | ||
export const DEFAULT_SYNTHESIS_MODE = "legacy"; | ||
``` | ||
|
||
/** | ||
* Adds a new channel to the synthesizer | ||
*/ | ||
addNewChannel() | ||
{ | ||
this.midiChannels.push(new MidiChannel(this.volumeController, this.defaultPreset, this.midiChannels.length + 1, false)); | ||
this.eventHandler.callEvent("newchannel", this.midiChannels[this.midiChannels.length - 1]); | ||
} | ||
``` | ||
Note: | ||
the synth will try to detect if the worklets are available. if not, then it should switch to legacy |
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
Oops, something went wrong.