Hi Nycholas,

Here is a simple attack-release envelop generator.

//----------------------- `ar(a,r,t)` -------------------
// Simple attack-release envelop generator
//
// Where:
// * `a` = attack time in samples (a>0)
// * `r` = release time in samples (r>0)
// * `t` = trig signal, restart the envelop when not 0
//
// Example:
//
//      process = button("play") : ar(100,10000) *
library("music.lib").osc(440);
//
ar(a,r,t) = rec~(_,_):!,_
  with {
  // n is the time position in the envelop
  // v is the value of the envelop
  rec(n,v) = (n+1)*(t==0),
  max(0, v*(t==0) + (n<a)/a - (n>=a)/r);
  };


Cheers

Yann



2016-06-16 8:55 GMT+02:00 Albert Graef <aggr...@gmail.com>:

> Yes, I see (or rather hear) what you mean. The adsr from the library
> doesn't properly deal with zero sustains. Sorry, I don't have a ready-made
> solution for this. Any dsp buff here who knows how to do an envelop which
> enters the release phase immediately after attack (i.e., like ASR, but
> without the S)? This shouldn't be too hard to do, but I can't wrap my head
> around it at this time in the morning. ;-)
>
> On Thu, Jun 16, 2016 at 2:36 AM, Nycholas Maia <nyckm...@gmail.com> wrote:
>
>> Hi Albert,
>>
>> Thank you for your quick response.
>> Now the ADSR envelop start to work, but I can't get the staccato sound *(very
>> fast/short sound)...like a percussive musical instrument.*
>> If I press and sustain a MIDI keyboard DOWN, the FL play a continuos
>> sound. And I don't want it now.
>> Could you help me?
>>
>> Here is my simple code just to test the ADSR envelop and percussive
>> sound:
>> ===================
>> import("music.lib");
>> import("instrument.lib");
>>
>> freq = nentry("freq", 440, 20, 20000, 1);
>> gain = nentry("gain", 1, 0, 10, 0.01);
>> gate = button("gate");
>>
>> sine = osc(freq) * gain;
>>
>> Attack = hslider("Attack (ms)", 100, 0, 200, 1);
>> Decay = hslider("Decay (ms)", 100, 0, 200, 1);
>> Sustain = hslider("Sustain (percent)", 10, 0, 100, 1);
>> Release = hslider("Release (ms)", 100, 0, 200, 1);
>>
>> // Convert to milliseconds:
>> ADSR_env = adsr(Attack/1000, Decay/1000, 90, Release/1000, gate);
>>
>> process = (sine * ADSR_env) <: _, _;
>> ==================
>>
>> Thank you for your patience.
>>
>> Kind regards!
>> Nyck
>>
>> On Wed, Jun 15, 2016 at 3:52 PM, Albert Graef <aggr...@gmail.com> wrote:
>>
>>> Hi Nycholas,
>>>
>>> AFAICT from a quick glance, you've got two problems in your code:
>>>
>>> - gate must be a 0/1 signal if you want to use it to trigger asr/adsr.
>>> That doesn't work if you pipe it through the smoothing filter.
>>>
>>> - you only multiply the signal by the envelop, not by envelop *and* gate
>>>
>>> On Wed, Jun 15, 2016 at 5:00 AM, Nycholas Maia <nyckm...@gmail.com>
>>> wrote:
>>>
>>>> gate = button("gate") : smooth(0.999); // 0/1
>>>>
>>>
>>> Remove ' : smooth(0.999)' here.
>>>
>>> process = (sine * ASR_env) * gate <: _, _;
>>>> //process = (sine * ADSR_env) * gate <: _, _;
>>>>
>>>
>>> Remove ' * gate' here.
>>>
>>> --
>>> Dr. Albert Gr"af
>>> Computer Music Research Group, JGU Mainz, Germany
>>> Email:  aggr...@gmail.com
>>> WWW:    https://plus.google.com/+AlbertGraef
>>>
>>
>>
>
>
> --
> Dr. Albert Gr"af
> Computer Music Research Group, JGU Mainz, Germany
> Email:  aggr...@gmail.com
> WWW:    https://plus.google.com/+AlbertGraef
>
>
> ------------------------------------------------------------------------------
> What NetFlow Analyzer can do for you? Monitors network bandwidth and
> traffic
> patterns at an interface-level. Reveals which users, apps, and protocols
> are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity
> planning
> reports.
> http://pubads.g.doubleclick.net/gampad/clk?id=1444514421&iu=/41014381
> _______________________________________________
> Faudiostream-users mailing list
> Faudiostream-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/faudiostream-users
>
>
------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports. http://pubads.g.doubleclick.net/gampad/clk?id=1444514421&iu=/41014381
_______________________________________________
Faudiostream-users mailing list
Faudiostream-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/faudiostream-users

Reply via email to