it works
This commit is contained in:
parent
ac2e450e38
commit
7da7554493
4 changed files with 30 additions and 6 deletions
|
|
@ -89,6 +89,22 @@ export function getCompressor(ac, threshold, ratio, knee, attack, release) {
|
||||||
return new DynamicsCompressorNode(ac, options);
|
return new DynamicsCompressorNode(ac, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const adsrmin = 0.001;
|
||||||
|
export const getADSRDefaults = (
|
||||||
|
a,
|
||||||
|
d,
|
||||||
|
s,
|
||||||
|
r,
|
||||||
|
def = { attack: adsrmin, decay: adsrmin, sustain: 1, release: adsrmin },
|
||||||
|
) => {
|
||||||
|
console.log(a, d, s, r);
|
||||||
|
if (a == null && d == null && s == null && r == null) {
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
const sustain = s ?? ((a != null && d == null) || (a == null && d == null)) ? def.sustain : adsrmin;
|
||||||
|
return { attack: a ?? adsrmin, decay: d ?? adsrmin, sustain, release: r ?? adsrmin };
|
||||||
|
};
|
||||||
|
|
||||||
export function createFilter(
|
export function createFilter(
|
||||||
context,
|
context,
|
||||||
type,
|
type,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { noteToMidi, valueToMidi, nanFallback } from './util.mjs';
|
import { noteToMidi, valueToMidi, nanFallback } from './util.mjs';
|
||||||
import { getAudioContext, registerSound } from './index.mjs';
|
import { getAudioContext, registerSound } from './index.mjs';
|
||||||
import { getEnvelope } from './helpers.mjs';
|
import { getADSRDefaults, getEnvelope } from './helpers.mjs';
|
||||||
import { logger } from './logger.mjs';
|
import { logger } from './logger.mjs';
|
||||||
|
|
||||||
const bufferCache = {}; // string: Promise<ArrayBuffer>
|
const bufferCache = {}; // string: Promise<ArrayBuffer>
|
||||||
|
|
@ -251,7 +251,8 @@ export async function onTriggerSample(t, value, onended, bank, resolveUrl) {
|
||||||
loop = s.startsWith('wt_') ? 1 : value.loop;
|
loop = s.startsWith('wt_') ? 1 : value.loop;
|
||||||
const ac = getAudioContext();
|
const ac = getAudioContext();
|
||||||
// destructure adsr here, because the default should be different for synths and samples
|
// destructure adsr here, because the default should be different for synths and samples
|
||||||
const { attack = 0.001, decay = 0.001, sustain = 1, release = 0.001 } = value;
|
|
||||||
|
const { attack, decay, sustain, release } = getADSRDefaults(value.attack, value.decay, value.sustain, value.release);
|
||||||
//const soundfont = getSoundfontKey(s);
|
//const soundfont = getSoundfontKey(s);
|
||||||
const time = t + nudge;
|
const time = t + nudge;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { midiToFreq, noteToMidi } from './util.mjs';
|
import { midiToFreq, noteToMidi } from './util.mjs';
|
||||||
import { registerSound, getAudioContext } from './superdough.mjs';
|
import { registerSound, getAudioContext } from './superdough.mjs';
|
||||||
import { gainNode, getEnvelope, getExpEnvelope } from './helpers.mjs';
|
import { gainNode, getADSRDefaults, getEnvelope, getExpEnvelope } from './helpers.mjs';
|
||||||
import { getNoiseMix, getNoiseOscillator } from './noise.mjs';
|
import { getNoiseMix, getNoiseOscillator } from './noise.mjs';
|
||||||
|
|
||||||
const mod = (freq, range = 1, type = 'sine') => {
|
const mod = (freq, range = 1, type = 'sine') => {
|
||||||
|
|
@ -30,7 +30,14 @@ export function registerSynthSounds() {
|
||||||
s,
|
s,
|
||||||
(t, value, onended) => {
|
(t, value, onended) => {
|
||||||
// destructure adsr here, because the default should be different for synths and samples
|
// destructure adsr here, because the default should be different for synths and samples
|
||||||
let { attack = 0.001, decay = 0.05, sustain = 0.6, release = 0.01 } = value;
|
const { attack, decay, sustain, release } = getADSRDefaults(
|
||||||
|
value.attack,
|
||||||
|
value.decay,
|
||||||
|
value.sustain,
|
||||||
|
value.release,
|
||||||
|
{ attack: 0.001, decay: 0.05, sustain: 0.6, release: 0.01 },
|
||||||
|
);
|
||||||
|
console.log({ attack, decay, sustain, release });
|
||||||
|
|
||||||
let sound;
|
let sound;
|
||||||
if (waveforms.includes(s)) {
|
if (waveforms.includes(s)) {
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,8 @@ pub fn init(
|
||||||
/* ...........................................................
|
/* ...........................................................
|
||||||
Open OSC Ports
|
Open OSC Ports
|
||||||
............................................................*/
|
............................................................*/
|
||||||
let sock = UdpSocket::bind("127.0.0.1:57122").unwrap();
|
let sock = UdpSocket::bind("169.254.248.82:57122").unwrap();
|
||||||
let to_addr = String::from("127.0.0.1:57120");
|
let to_addr = String::from("169.254.180.239:57120");
|
||||||
sock.set_nonblocking(true).unwrap();
|
sock.set_nonblocking(true).unwrap();
|
||||||
sock.connect(to_addr).expect("could not connect to OSC address");
|
sock.connect(to_addr).expect("could not connect to OSC address");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue