Thanks to both of you for replying -- it was probably unhelpful of me not
to post the whole code, which I'm attaching here. The whole thing does
produce a note, but the pitch is off (octaves are very flat).
However, asking you to pick my altered version of someone else's code isn't
very reasonable.

Romain -- I'll look at the example you suggested, I imagine that's a better
starting-point anyway.

Cheers,

Rich

On Tue, Oct 13, 2020 at 3:10 PM Romain Michon <rmnmic...@gmail.com> wrote:

> Hi Rich,
>
> This indeed won't make any sound. The waveguide object of the physical
> modeling library in Faust is just 2 delay lines in parallel : it's just a
> simple waveguide without terminations. For a simple string example, have a
> look at the openString function:
> https://github.com/grame-cncm/faustlibraries/blob/master/physmodels.lib#L471
>
> Cheers,
>
> Romain
>
> On Sat, Oct 10, 2020 at 4:05 AM Julius Smith <julius.sm...@gmail.com>
> wrote:
>
>> Hi Rich,
>>
>> I am not familiar with this code, but thanks for the pointers.
>>
>> You have the right idea.  ma.SR/freq needs to equal the round-trip delay
>> up and down the waveguide, adding up all delay line lengths, all filter
>> delays, and the feedback delay from the Faust compiler (there's always at
>> least one sample of that in any closed loop).
>>
>> Cheers,
>> Julius
>>
>> On Fri, Oct 9, 2020 at 6:55 AM Rich Cochrane <rich.cochr...@bigi.org.uk>
>> wrote:
>>
>>> Hello,
>>>
>>> I'm trying to learn Faust's physical modeling features "by
>>> experimentation" so am blundering around a bit.
>>>
>>> I found the last example on this page comprehensible: "Waveguide-Strings
>>> in Faust":
>>> https://hvc.berlin/Sound_Synthesis/Physical_Modeling/physical-modeling-faust-examples/
>>>
>>> I wanted to be able to play it with a keyboard. I thought this might
>>> work:
>>>
>>> segment(pos) = waveguide(nMax,n)
>>>   with{
>>>   nMax = ma.SR/freq;
>>>   n = pos * nMax;
>>>   };
>>>
>>> Where freq is the usual frequency value triggered by a MIDI keyboard.
>>> But the result is a long way out of tune.
>>>
>>> I tried "nMax = freq : pm.f2l : pm.l2s;" instead but this appears to
>>> have the same net effect -- at least, it's also out of tune.
>>>
>>> What's the proper way to do this? Or is this base code not the right
>>> starting point for this?
>>>
>>> Cheers,
>>>
>>> Rich
>>>
>>>
>>> _______________________________________________
>>> Faudiostream-users mailing list
>>> Faudiostream-users@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/faudiostream-users
>>>
>>
>>
>> --
>> "Anybody who knows all about nothing knows everything" -- Leonard Susskind
>> _______________________________________________
>> Faudiostream-users mailing list
>> Faudiostream-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/faudiostream-users
>>
>
>
> --
>
> Romain Michon
> +33 (0)7 67 39 72 40http://grame.fr/~michon
>
>
// Heavily modified version of waveguide_string.dsp by Henrik von Coler 
(2020-06-09)
// Don't copy; this code is not correct.
import("all.lib");

// Parameters
gain = hslider("gain", 0.99, 0, 1, 0.01);
freq = hslider("freq", 440, 50, 1000, 0.01);
gate = button("gate") : en.adsr(0.01, 0.01, 0.9, 0.1);
pos = hslider("position",0.6,0,1,0.01);
fc = hslider("filter cutoff",5000,10,10000,1);

//////////////////////////////////////////////////////////
// This calculation is out of tune!
//////////////////////////////////////////////////////////
segment(maxLength) = waveguide(nMax,n)
with{
  nMax = freq : pm.f2l : pm.l2s;
  n = freq : pm.f2l : pm.l2s * pos/2;
};

// Terminations
rt = rTermination(basicBlock,*(-1) : si.smooth(1.0-2*(fc/ma.SR)));
lt = lTermination(*(-1)* 0.99,basicBlock);

// The physical model
idString(pos,excite) = endChain(wg)
with{
  wg = chain(lt : segment(6) : in(excite) : out : segment(6) : rt); // 
waveguide chain
};

process = idString(0.15, gate) <: _,_;
_______________________________________________
Faudiostream-users mailing list
Faudiostream-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/faudiostream-users

Reply via email to