-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathimpulse_generator.jsfx
85 lines (65 loc) · 2.73 KB
/
impulse_generator.jsfx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
desc: Impulse Generator
version: 1.8.2
author: chokehold
tags: utility impulse response IR sampling
link: https://github.com/chkhld/jsfx/
screenshot: https://github.com/chkhld/jsfx/blob/main/assets/screenshots/impulse_generator.png
about:
# Impulse Generator
This will generate a 1-sample impulse when the trigger
slider is pulled over to the right.
May not sound terribly exciting, but creates the perfect
source to send through devices you want to capture as IR.
You would use this to capture a reverb or delay tail, the
frequency profile of a guitar cabinet or EQ, etc.
Load the generator as the first plugin on an empty track
then insert the plugins or devices to capture behind it.
Switch the record mode of the track to Output, start the
recording and push the Trigger slider to the right. Stop
the recording, trim the recorded item down to a sensible
length, make sure it has no crossfades at start and end.
IMPORTANT: you need to zoom right in and ensure that the
first sample in the item is the first sample that is not
on the center zero line. If you don't do this, the IR is
going to be delayed, and you'll have to remove the delay
in ReaVerb later by trimming the start/end times.
Export the resulting item into a WAV file, and load that
WAV into ReaVerb, done.
// ----------------------------------------------------------------------------
slider1:dBLevel=0<-48,0,0.0001>Level [dB]
slider2:btnTrig=0<0,1,1>Trigger
// By not having any in_pin and out_pin assignments, this plugin will
// automatically adapt to the number of channels of the track.
@init
// Converts dB values to float gain factors.
function dBToGain (decibels) (pow(10, decibels * 0.05));
@slider
// Turns the slider's dB value into a float gain factor.
// Essentially the impulse sample sent on to the device.
impulse = dBToGain(dBLevel);
// If the trigger slider was just dragged to the right,
// set the flag that signals the impulse should play.
(btnTrig == 1 && prvTrig == 0) ? (triggered = 1) : (triggered = 0);
// Update this status flag to track slider changes
prvTrig = btnTrig;
@sample
// If the trigger slider was moved to the right
(triggered == 1) ?
(
// Start at channel 0
channel = 0;
// Cycle through the available channels
while (channel < num_ch)
(
// Play the impulse sample at the set level
spl(channel) = impulse;
// Increment counter to next channel
channel += 1;
);
// For this kind of purpose the impulse should only last
// for a duration of 1 sample. Having played the impulse
// sample already, the trigger slider and state flag can
// be reset immediately.
btnTrig = 0;
triggered = 0;
);