exponential ADSR envelope using LP filter
I've been experimenting with making an exponential envelope using filters rather than lines. Instead of trying to re-process the linear data that [line~] objects make, I'm giving a hard 1 or 0 signal to a LP filter with very low cutoff to take create the curve.
Maybe this is an old trick, but it's new to me and I've been very pleased with the results. It gives nice, varied envelope curves, and it's satisfyingly simple and CPU friendly.
Do you know of any good Envelope Patches?
So I've made this module to allow for stochastic variation of dynamic envelopes. It allows you to choose between three envelope types or determine the probability of each occuring. With the "ran"(dom) setting, the envelope lengths can be determined autonomously, or you can input a bang (third inlet) to coordinate the envelopes with other modules.
Depending on the length of the envelope, I can sometimes hear the low "resolution" of the "moderate" and particularly the "sharp" envelope, as they are only a four-point approximation of a curve. I can add more points of course, though, ideally, I should probably add a mechanism that takes the length of the envelope into consideration when determining the amount of points and the proportions of the envelope. Of course, if there are already excellent abstractions out there of which I'm unaware, I'd be happy if you could share them with me, so that I can avoid (further) re-inventing the wheel.
N.B: Open demo.pd to test the module.
P.S. It's possible that I've re-invented the wheel in multiple ways in this module, e.g. in the probability determination found in [dynamics]>[pd envelope_type]>[pd envelope_type_pool_and probability]. Any advice regarding pre-existing objects is appreciated.
EDIT: re-uploaded without [gate] and in .zip format.
envelope.zip
graph clipping
@whale-av: It seems more likely that the graph and garray code was written first, without realizing that clipping was needed.
Consider:
- It's not just the dependent variable (i.e., y position) which can fall outside the bounds of the graph. If you try to change the x range for a 100-element array to be between 50 and 60, for example, the array will extend well past the graph's horizontal boundaries, too. So the dialog makes it seem like you can set the graph to view only a portion of an array when in fact that's not true.
- Even for y-values, it's not just that they can be shown above or below the graph. For extreme values they can fall well beyond the canvas viewport, causing the vertical scrollbar to shrink so small that it becomes difficult to navigate the canvas anymore.
- Even if you clipped the garray to fall within the left and right bounds of the graph, data structure arrays on a GOP will continue to be a problem because the user can set the x value for each element independently. But when they extend beyond the GOP you run into other problems, like failing to react to mouse events, or not getting redrawn properly.
It's difficult to address a lot of this because garrays are entangled in the data structure code for [plot]. So a fix in one area is likely to have unforeseen side-effects for the other.
Beatmaker Abstract
http://www.2shared.com/photo/mA24_LPF/820_am_July_26th_13_window_con.html
I conceptualized this the other day. The main reason I wanted to make this is because I'm a little tired of complicated ableton live. I wanted to just be able to right click parameters and tell them to follow midi tracks.
The big feature in this abstract is a "Midi CC Module Window" That contains an unlimited (or potentially very large)number of Midi CC Envelope Modules. In each Midi CC Envelope Module are Midi CC Envelope Clips. These clips hold a waveform that is plotted on a tempo divided graph. The waveform is played in a loop and synced to the tempo according to how long the loop is. Only one clip can be playing per module. If a parameter is right clicked, you can choose "Follow Midi CC Envelope Module 1" and the parameter will then be following the envelope that is looping in "Midi CC Envelope Module 1".
Midi note clips function in the same way. Every instrument will be able to select one Midi Notes Module. If you right clicked "Instrument Module 2" in the "Instrument Module Window" and selected "Midi input from Midi Notes Module 1", then the notes coming out of "Midi Notes Module 1" would be playing through the single virtual instrument you placed in "Instrument Module 2".
If you want the sound to come out of your speakers, then navigate to the "Bus" window. Select "Instrument Module 2" with a drop-down check off menu by right-clicking "Inputs". While still in the "Bus" window look at the "Output" window and check the box that says "Audio Output". Now the sound is coming through your speakers. Check off more Instrument Modules or Audio Track Modules to get more sound coming through the same bus.
Turn the "Aux" on to put all audio through effects.
Work in "Bounce" by selecting inputs like "Input Module 3" by right clicking and checking off Input Modules. Then press record and stop. Copy and paste your clip to an Audio Track Module, the "Sampler" or a Side Chain Audio Track Module.
Work in "Master Bounce" to produce audio clips by recording whatever is coming through the system for everyone to hear.
Chop and screw your audio in the sampler with highlight and right click processing effects. Glue your sample together and put it in an Audio Track Module or a Side Chain Audio Track Module.
Use the "Threshold Setter" to perform long linear modulation. Right click any parameter and select "Adjust to Threshold". The parameter will then adjust its minimum and maximum values over the length of time described in the "Threshold Setter".
The "Execution Engine" is used to make sure all changes happen in sync with the music.
IE>If you selected a subdivision of 2, and a length of 2, then it would take four quarter beats(starting from the next quarter beat) for the change to take place. So if you're somewhere in the a (1e+a) then you will have to wait for 2, 3, 4, 5, to pass and your change would happen on 6.
IE>If you selected a subdivision of 1 and a length of 3, you would have to wait 12 beats starting on the next quater beat.
IE>If you selected a subdivision of 8 and a length of 3, you would have to wait one and a half quarter beats starting on the next 8th note.
http://www.pdpatchrepo.info/hurleur/820_am,_July_26th_13_window_conception.png
MIDI activated envelopes
Sorry to repost about this, but there is something I'm not getting.
In Csound and SuperCollider (as in any VST instrument, etc.), there are standard, built-in mechanisms for MIDI-activated envelopes -- meaning playing synths from a keyboard.
In Csound, it's the 'r' family of line and envelope opcodes. In SuperCollider, it's the 'gate' parameter of the EnvGen UGen.
What these do is:
- start the envelope when you press a keyboard key,
- keep the sustain level as long as you hold the key,
- engage the release segment of the envelope when you release the key (ie Note Off MIDI message).
When I posted about this ealier, someone kindly pointed me to the [c_adsr] object in RjLib. But RjLib is part of neither Pd vanilla nor Pd extended.
Leading me to ask:
-
Is playing synths from a keyboard something that Pd people just do not do? Those who need this use Csound or SC?
-
Or do all Pd users immediately install the RjLib after installing Pd, and use RjLib all the time?
-
Or does Pd have another mechanism for MIDI-driven envelopes that I'm unaware of and that everybody uses?
Thanks very much.
I'd be very curious to know if other Pd users have asked themselves the same question.
Export patch as rtas?
@Maelstorm said:
If you're on OSX, jack can be used as an insert plug-in so you can avoid the separate tracks, but you still get the latency.
which you can, depending on your host, eliminate by setting the track delay for the track with the plugin. So if the buffer is 512 sample/11.82 ms then set the delay to that and it should be spot on.
I've had the whole Jack graph latency explained to me numerous times by Stephane Letz and it still doesn't go in.....Heres what he told me...
> > Its the Pd > JAck > Ableton latency. (Ableton has otoh 3 different
> > ways of manually setting latency compensation - I'm just not very
> > clear on where to start with regards to input from JAck)
> >>>>
>
> This is NO latency introduced in a Pd > JAck > Ableton kind of
> chain; the JACK server activate each client in turn (that is Pd *then*
> Ableton in this case) in the *same* given audio cycle.
>
> Remember : the JACK server is able to "sort" (in some way) the graph
> of all connected clients to activate each client audio callback at the
> right place during the audio cycle. For example:
>
> 1) in a sequential kind of graph like IN ==> A ==> B ==> C ==> OUT,
> JACK server will activate A (which would typically consume new audio
> buffers available in machine audio IN drivers) then activate B (which
> would typically consume "output" just produced by A) , then activate
> C , then produce the machine OUT audio buffers.
>
> 2) in a graph will parallel sub-graph like : IN ==> A ==> B ==> C
> ==> OUT and IN ==> D ==> B ==> C ==> OUT (that is both A and D are
> connected to input and send to, then JACK server is able to
> activate A and D at the same time (since the both only depends of IN)
> and a multi-core machine will typically run A and D at the same time
> on 2 different cores. Then when A *and* D are finished, B can be
> activated... and so on.
>
> The input/output latency of a usual CoreAudio application running
> is: driver input latency + driver input latency offset + 2
> application buffer-size + driver output latency + driver output
> latency offset.
>
this next part is the important bit i think...
> For a graph of JACK clients: driver input latency + driver input
> latency offset + 2 JACK Server buffer-size + ( one extra buffer-
> size ) + driver output latency + driver output latency offset.
>
> (Note : there is an additional one extra buffer-size latency on OSX,
> since the JACK server is running in the so called "asynchronous" mode
> [there is also a "synchronous" mode without this one extra buffer-size
> available, but it is less reliable on OSX and we choose to use the
> "asynchronous" mode by default.])
>
> Stephane
>
Transdetect~ and transcomp~: transient shaping and detection
transcomp~ uses transdetect~ to shape the initial attack and release of a signal.
Requires IEM's FIR~, fexpr~ and dbtorms~ which are provided in PD-Extended.
To work properly the transdetect folder should be added to PD's path.
Start by opening help-transcomp~.pd
01 Implementation:
transdetect~ works by using two pairs of envelope followers. The first pair
subtracts an envelope follower with a slow attack from an accurate follower,
the result of which is a signal containing the initial attack. For the initial
release, the second pair subtracts an accurate envelope follower from one with
a slow release.
An envelope follower measures the mean square power of a signal over time
(see 3.audio.examples/H06.envelope.follower.pd for details on implementing an
envelope follower). To do this we must use a low pass filter at a very low
frequency. In order to achieve an accurate follower a linear phase FIR filter
was used (using IEM's FIR~ external). Unfortunately this introduces a phase
delay.
In order to facilitate the use of different envelope follower implementations,
transdetect~ requires a filter type as a creation argument implemented in
followernameTransDetectEF~.pd. 4 linear phase fir implementations are provided:
181, 251, 451 and 501 taps filters. The 501 taps filter provides the most
accurate filter but with a phase delay of 5.668 ms at 44.1kHz (raise the
sampling rate to lower the phase delay). They were all generating using
http://www.dsptutor.freeuk.com/FIRFilterDesign/FIRFiltDes102.html with a
cutoff frequency between 5 and 10 Hz.
A compromise between accuracy and phase delay might be achieved by using
minimum phase FIR filters. A 5th implementation using PD's native lop~ object
is also provided under the designation iir (FIR~ not required).
Along with different possible envelope follower implementation transdetect~
also requires an attack and hold type implemented in
attacknameTransDetectAttackShape~.pd and holdnameTransDetectHoldShape~.pd
respectively. These implementations dictate the kind of attack and release
curves used on the envelope followers (linear, slow[er|est] and fast[er|est]).
All implementations provided use fexpr~. A more efficient external could be
made to take fexpr~ place.
02 Use
In help-transcomp~.pd patch enable start and pay attention to the snap in the
hit. Disable the green toggle button to disable the compression make the snap
go away. Check out the tables on the left to see the results of the transient
compression.
transcomp~ is useful when used with recorded drums to maximize or minimize
its transient (to make it punchier or to make snare drums less clappy).
transcomp~ uses transdetect~. By itself transdetect~ can be used to synthesis
hits from a recording. For example, take a bass drum recording and use the
signals generated by transdetect~ to shape the frequency and envelope of a
synthesized kick drum.
Would love to have some feedback and some help in turning the linear phase filters into minimum phase filters.
Strange Behavior
what's your soundcard's sampling rate? tabwrite~ will only display the graph once all the data has been read into the graph.
your graph is 6000 samples long, and your metro is 200ms. so at 44100hz, 200ms = 8820 samples, so because the graph is full, it is displayed.
but if you have a lower sampling rate, say 22050hz, then 200ms will only graph 4410 samples. because this is less than the size of the graph, the tabwrite~ is retriggered before the graph is full, and thus will not display the output. a smaller graph should help, hopefully.
Graph decoration problem
hi, i'm new to puredata and i have a problem about graphs,
for example, i create a graph and i want to put some bangs, some toggles.. inside,
i edit the graph with right click->open, when i close it and look at the graph at parent patch all GUI objects are messed up - misplaced..
is there any way that i can decorate these graph objects properly?
for example,
i have a graph width 200- height 150
i want my toggles to be at a specific position (x,y) like (10,25) (30,25) (50 25)...
is that possible?
thanx