mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-16 16:18:32 +00:00
it works
This commit is contained in:
parent
ac2e450e38
commit
7da7554493
@ -89,6 +89,22 @@ export function getCompressor(ac, threshold, ratio, knee, attack, release) {
|
||||
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(
|
||||
context,
|
||||
type,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { noteToMidi, valueToMidi, nanFallback } from './util.mjs';
|
||||
import { getAudioContext, registerSound } from './index.mjs';
|
||||
import { getEnvelope } from './helpers.mjs';
|
||||
import { getADSRDefaults, getEnvelope } from './helpers.mjs';
|
||||
import { logger } from './logger.mjs';
|
||||
|
||||
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;
|
||||
const ac = getAudioContext();
|
||||
// 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 time = t + nudge;
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { midiToFreq, noteToMidi } from './util.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';
|
||||
|
||||
const mod = (freq, range = 1, type = 'sine') => {
|
||||
@ -30,7 +30,14 @@ export function registerSynthSounds() {
|
||||
s,
|
||||
(t, value, onended) => {
|
||||
// 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;
|
||||
if (waveforms.includes(s)) {
|
||||
|
||||
@ -53,8 +53,8 @@ pub fn init(
|
||||
/* ...........................................................
|
||||
Open OSC Ports
|
||||
............................................................*/
|
||||
let sock = UdpSocket::bind("127.0.0.1:57122").unwrap();
|
||||
let to_addr = String::from("127.0.0.1:57120");
|
||||
let sock = UdpSocket::bind("169.254.248.82:57122").unwrap();
|
||||
let to_addr = String::from("169.254.180.239:57120");
|
||||
sock.set_nonblocking(true).unwrap();
|
||||
sock.connect(to_addr).expect("could not connect to OSC address");
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user