[Csnd] wguide1: how to estimate/approximate note sustain

Hey hey,
is there a simple formula, given the single delay line waveguide (wguide1) opcode, to estimate the decay of a note? Something either directly based on the supplied user parameters or values easily derived from them. The exciter might be an unknown. If we consider it to be a very short noise burst, could that help?

I find it quite difficult to adjust the cutoff and feedback values across certain note ranges to result in plausibly similar note lengths. The strings of an acoustic guitar will decay at somewhat different lengths, but not too drastically different. Is the samplerate of the orchestra a factor to be taken into account?

Any hints would be appreciated.

Best wishes,

Jeanette

Hi Jeanette. As you know I’ve been tinkering with the slightly unpredictable world of physical modeling (noise is random!).

In this case I found using the noise opcode beneficial due to the ability to constrain it with the built in lpf (kbeta). It helps even out amplitudes; without a lpf I find higher notes are much louder.

-odac -m2 ; -o wguide1_dur_48000.wav

sr = 48000
ksmps = 32
nchnls = 2
0dbfs = 1

gkCnt init 0
seed 0

instr trig
kNote[] fillarray 33, 40, 45, 52, 57, 64, 69
kLen = lenarray(kNote)
kTrig = metro(.2)
kFreq = mtof(kNote[gkCnt])
schedkwhen kTrig, 0, 0, 2, 0, 5, kFreq

if kTrig == 1 then
gkCnt += 1
endif

if gkCnt == kLen then
gkCnt = 0
endif

endin

instr 2
aEnv = expseg:a(1, .1, .0001)
aSig = noise(2 * aEnv, 0.99)
kFreq = p4
; kDur affects general duration of notes
; by exponentially raising cutoff relative
; to note frequency
; in this case, when the highest note (A440)
; is played, the cutoff is 22kHz
iDur = 50 ; affects general duration
kCut = p4 * iDur ; filter cutoff freq.
print p4 ; prints note freq.
print p4 * iDur ; prints cutoff freq.
; kRtio = duration of lower vs higher freq
; ex. value of .5 will increase dur. of high notes vs low
; value of .01 will decrease dur. of higher notes vs low
iRtio = .5
; prints feedback value
print .992 + (.006 - (.6/p4 * iRtio))
kFbk = 0.992 + (.006 - (.6/kFreq * iRtio))
aWg1 = wguide1(aSig, kFreq, kCut, kFbk)
aOut = dcblock2(aWg1)
outs aOut, aOut

endin

i"trig" 0 70 e

Here there are 2 primary factors at work in the code. As the note pitch rises, the cutoff freq increases exponentially & the feedback level increases as well.

For example, with a note at 55 Hz the wguide filter cutoff will be 2750 & the feedback .993

At A440 the cutoff is 22kHz and the feedback .997

I think it creates “plausibly similar” note lengths. To increase overall note lengths you can raise the initial kFbk level above .992

The iRtio value affects the duration ratio of high vs low notes (see comments).

I noticed that notes higher than 440, however, start dropping dramatically in duration. For ex., using an orc sr of 48000, A880 will raise the wguide cutoff to 44kHz but the note has essentially no sustain. However, if the sr is raised to 96000 it’s duration increases substantially (although the timbre of all the notes now sounds brighter to me, I don’t find it particularly appealing…) so clearly the sr of the orc would appear to be a factor.

This does pose another issue though as higher notes again start rising in amplitude. I’m not sure adjusting the noise kbeta would help, I haven’t yet tried it. Perhaps raising the kbeta in relation to the note/cutoff freq. might help.

I think therein lies a possible problem with finding a “simple” formula. There seems to be a relationship between the exciter freq. (and the duration of it), the wguide cutoff freq., the feedback level, the osc sr and the resulting amplitude of each note relating to the exc. freq & wguide cutoff.

Perhaps someone can offer a better mathematical solution (it’s definitely not a strength of mine) as these are only my personal anecdotal experiences. I wonder how practical any formula might be as changes to the exciter source would possibly prevent any method from being precise unless possibly applied in an opcode. And of course noise itself is a random exciter, although that seems beneficial for some models as it inherently creates constant variation.

I hope to see some other responses, I find this a really interesting method of synthesis and there are certainly those here with much more knowledge than myself in this area.

I uploaded two files here for convenience, one at sr 48000 & the other at 96000:
https://github.com/ST-Music/csound-examples/tree/main/physical_modeling/wguide1

Not sure this really answers your question but perhaps offers one perspective.

Best,
Scott

hi Scott,
thanks for this starting point. For now, I shall take it up and use it. It seems a basis arrived by some careful experimentation.

Best wishes,

Jeanette

You’re quite welcome. Yes, experimentation indeed, I haven’t the skills to code physical modeling in any logical way.

As the Sound on Sound article
https://www.soundonsound.com/techniques/physical-modelling-synthesis-explained

put it:
The process of ‘misusing’ sound synthesis techniques has worked very well for analogue synthesizers, and I see no reason why modelling‑based instruments should be any different. If it sounds like the timbre you want, the method used to produce the timbre may well be irrelevant to you.

If you find any clever solutions please let me know!

Best,
Scott

-Amp
-Filter
-Delay
… three basic blocks used to create Models. Some 11 or 12 math form expressions used in modeling.

In late 1975 to mid '76, a friend and I were trying to use what was called “numerical modeling” using
vector math in a digital audio data stream, as a way to maintain data validity and minimize errors. I say
“trying”, because we were doing 16-bit data with two tandem 8-bit CPU’s that could not handle the
calculation load and were too slow for processing audio.

1978, someone was trying to model pianos in a primitive way, that spawned other methods. Then
came John Chowning with Freeverb and FM synthesis and founder of CCRMA. And since then
Julius Smith has carried that on there,… along with his four books on modeling. Thank you
John and Julius.

1990 or '92, Los Angeles, AES convention, two guys from CCRMA with faster, better processors
demoed physical modeling. Everyone was wowed, including my future boss. Commercial modeling
came out around 1995 ish. Now I work at Line 6 since 2007 (now part of Yamaha Guitar Group).

Bit of historical background to go with that SOS article.

-PBS

An interesting area of synthesis, nice to read your comments. Although the mathematical aspects of his work are a little beyond my ability to use productively, I quite enjoy Julius Smith’s work (Jeanette originally introduced me to it).

Anyone curious can find the 4 books available to read online here:

https://www.dsprelated.com/freebooks.php

Also cool to hear you work at Line 6; I’ve been using their products since the PodXT followed in the footsteps of the original red bean.

Best,
Scott

⁣Get TypeApp for Android ​

I think I put Jeanette on to his books. Been acquainted with Julius since about 1986 ish,
read all his papers in AES Journal and I have his four books. Jeanette has been going down
some interesting roads, will be cool to hear the results.

There is also Julius’ web area at CCRMA,…
https://ccrma.stanford.edu

https://ccrma.stanford.edu/~jos/

Enjoy,
-Partev

An interesting area of synthesis, nice to read your comments. Although the mathematical aspects of his work are a little beyond my ability to use productively, I quite enjoy Julius Smith’s work (Jeanette originally introduced me to it).

Anyone curious can find the 4 books available to read online here:

https://www.dsprelated.com/freebooks.php

Also cool to hear you work at Line 6; I’ve been using their products since the PodXT followed in the footsteps of the original red bean.

Best,
Scott