Re: [LAD] LV2::Synth from one note to another

From: Phil CM <philcm@email-addr-hidden>
Date: Wed Oct 08 2014 - 21:23:45 EEST

On 08/10/14 13:36, Raine M. Ekman wrote:
>> Phil CM <philcm@email-addr-hidden> wrote:
>>> Now the only think that is left is a portamento function, to go from
>>> one note to another (/exactly/ like so-404
>>> <http://d00m.org/%7Esomeone/so404/> does).
>
> Quoting Philipp Überbacher <murks@email-addr-hidden>:
>> I have never done this but I suggest to look at the calf monosynth
>> code. AFAIR it has a couple of different ways to handle
>> successive/overlapping notes.
>>
>> Another synth that comes to mind and has portamento is phasex.
>
> Well, if it has to be exactly the same, I'd suggest digging in the
> so-404 code and not in those other synths. Looks like it adjusts
> frequency at samplerate/100, calculating:
> freq = ((portamento/127.0)*0.9)*freq +
> (1.0-((portamento/127.0)*0.9))*tfreq;
>
> I guess tfreq is the target frequency of the note being portamented
> towards.
>
OK, so I found how to control the envelope with a new control, and how
to output values in console while jalv runs, like this :

printf("Key: %d, Period: %d, Vel: %d, Envelope: %f\n", key, m_period,
velocity, m_envelope);

And it prints this :

Key: 77, Period: 276, Vel: 81, Envelope: 0.632812
Key: 79, Period: 246, Vel: 75, Envelope: 0.585938
Key: 64, Period: 584, Vel: 43, Envelope: 0.335938
Key: 76, Period: 292, Vel: 54, Envelope: 0.421875
Key: 65, Period: 551, Vel: 54, Envelope: 0.421875
Key: 64, Period: 584, Vel: 64, Envelope: 0.500000
Key: 77, Period: 276, Vel: 55, Envelope: 0.429688
Key: 76, Period: 292, Vel: 44, Envelope: 0.343750
Key: 76, Period: 292, Vel: 63, Envelope: 0.492188
Key: 67, Period: 491, Vel: 78, Envelope: 0.609375

So apparently the period /is/ the note. (I looked in the lib for the
formula).
Now how do I introduce those freq and portamento variables, are they
variables (or parameters or functions or keywords) that exists for me to
use it, or do I have to declare them and if so, how do I connect them to
render()? Maybe I don't even need them, most of the logic seems to be
already here:
See, look how it goes :

   void render(uint32_t from, uint32_t to) {
     if (m_key == LV2::INVALID_KEY)
       return;
     for (uint32_t i = from; i < to; ++i) {
       m_envelope = *p(p_enve);
       float pwm = *p(p_pwm) + (1 - *p(p_pwm)) * m_envelope;
       float s = -0.25 + 0.5 * (m_counter > m_period * (1 + pwm) / 2);
       // float s = -0.25 + 0.5 * (m_counter > m_period / 2);
       m_counter = (m_counter + 1) % m_period;
       p(p_left)[i] += s;
       p(p_right)[i] += s;
       if (m_envelope > 0)
     m_envelope -= 0.5 / m_rate;
     }
   }

And /from/ and /to/ are already there. This for loop determines the
duration of the note, right? I have to use some of that time to go from
/from/ to /to/ in a fraction of that time.

How do I do that?

--
Phil

_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Thu Oct 9 00:15:02 2014

This archive was generated by hypermail 2.1.8 : Thu Oct 09 2014 - 00:15:02 EEST