Author |
Message |
Inventor
Stream Operator
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 267
|
Posted: Tue Mar 10, 2009 3:40 am Post subject:
Improving the kijjaz Guitar Subject description: Your suggestions please |
|
|
Hey, it's me again. I've been using kijjaz's guitar and drum models in my programs and they work just fine, but I feel that the guitar model has reached a sort of plateau. It's based on the mandolin, with a number of mandolin instruments summed together and sent into a SinOsc limiter. Here is the guitar model that I'm using right now, recoded completely from kijjaz's original example:
Code: |
// guitar based on kijjaz's model
class guitar {
// define guitar strings
num_guitar_strings => int num_strings;
Mandolin mandy[num_strings];
//
// distortion
Gain gd_in => Gain divide => Gain gd_out;
gd_in => FullRect fwr => Gain add => divide;
Step step => add;
4 => divide.op; // make it a divider
0.025 => step.next;
//
// hook up guitar and pedals
// summ strings into pedal
for (int i; i <num_strings> gd_in;
}
gd_out => Gain output;
fun void strum (float freq, float pluck) {
for (int i; i <num_strings> mandy[i].freq;
pluck => mandy[i].pluck;
}
}
fun void set_guitar (int numStrings, float strength, float stringDamping, float bodySize, float stringDetune) {
numStrings => num_strings;
for (int i; i <num_strings> mandy[i].gain;
stringDamping => mandy[i].stringDamping;
bodySize => mandy[i].bodySize;
stringDetune => mandy[i].stringDetune;
}
}
}
|
Note that I have modified the distortion to be x/(n+|x|) type, as discussed in the earlier distortion thread.
What I would like to do is model the guitar more realistically including 6 strings, or 4 strings for a bass guitar model. This would include playing notes and chords. I have the option of using the Mandolin, StifKarp, or Sitar instruments in ChucK, but I'd rather do it with string synthesis.
Would anyone care to enlighten me as to a string synthesis technique that might be reasonably efficient in ChucK? Kijjaz, Kassen, you both are familiar with this sort of thing, what do you suggest? Anyone else? Thanks. _________________ "Let's make noise for peace." - Kijjaz |
|
Back to top
|
|
|
Inventor
Stream Operator
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 267
|
Posted: Tue Mar 10, 2009 4:10 am Post subject:
|
|
|
Oh, OK, I did a search and found the wiki pages on Karplus-Strong string synthsis and group delay, here:
http://en.wikipedia.org/wiki/Karplus-Strong_string_synthesis
and here:
http://en.wikipedia.org/wiki/Group_delay
You send a burst of noise into a feedback loop consisting of a delay line and a filter. The burst of noise should be one period long and the delay line plus the group delay of the fiilter should add up to one period.
So what the guitar model, called a Digitar for Digital Guitar by Karplus and Strong needs is six of these strings. Then we can have the software set the frequency of each string to make a chord, or just do one string for a note.
Other guitar effects such as bending could be simulated by varying the delay over the duration of the note.
Also note that the filter must attenuate the feedback signal, so I suppose that the sustain of the note is determined by the amount of attenuation.
Looks like this will be a bit of an effort but worth the time. Digitar! _________________ "Let's make noise for peace." - Kijjaz |
|
Back to top
|
|
|
Inventor
Stream Operator
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 267
|
|
Back to top
|
|
|
Inventor
Stream Operator
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 267
|
|
Back to top
|
|
|
kijjaz
Joined: Sep 20, 2004 Posts: 765 Location: bangkok, thailand
Audio files: 4
|
|
Back to top
|
|
|
kijjaz
Joined: Sep 20, 2004 Posts: 765 Location: bangkok, thailand
Audio files: 4
|
|
Back to top
|
|
|
Inventor
Stream Operator
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 267
|
|
Back to top
|
|
|
kijjaz
Joined: Sep 20, 2004 Posts: 765 Location: bangkok, thailand
Audio files: 4
|
Posted: Tue Mar 10, 2009 8:28 am Post subject:
|
|
|
That is an amazing distortion sound for this guitar!! -_-
I'm trying to get a simpler sound from a simpler model:
the original StifKarp = Karplus-Strong algorithm with simple low-pass filter.
But i'll try to add more things to make it sounds more natural
especially the detuning effect in the string.
Description: |
kijjaz - Simple Guitar Design 0.1.0 |
|
Download |
Filename: |
kijjaz - Simple Guitar Design 0.1.0.ck |
Filesize: |
919 Bytes |
Downloaded: |
529 Time(s) |
Description: |
Simple Guitar Design 0.1.0 |
|
Download |
Filename: |
kijjaz - Simple Guitar Design 0.1.0.ck |
Filesize: |
919 Bytes |
Downloaded: |
522 Time(s) |
|
|
Back to top
|
|
|
kijjaz
Joined: Sep 20, 2004 Posts: 765 Location: bangkok, thailand
Audio files: 4
|
|
Back to top
|
|
|
kijjaz
Joined: Sep 20, 2004 Posts: 765 Location: bangkok, thailand
Audio files: 4
|
|
Back to top
|
|
|
kijjaz
Joined: Sep 20, 2004 Posts: 765 Location: bangkok, thailand
Audio files: 4
|
|
Back to top
|
|
|
Inventor
Stream Operator
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 267
|
|
Back to top
|
|
|
kijjaz
Joined: Sep 20, 2004 Posts: 765 Location: bangkok, thailand
Audio files: 4
|
|
Back to top
|
|
|
Inventor
Stream Operator
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 267
|
Posted: Tue Mar 10, 2009 10:45 am Post subject:
|
|
|
Well, in the Wikipedia entry for Karplus-Strong they mention that the frequency is equal to the delay *plus* the group delay of the filter. That's why I included the Wikipedia entry for group delay in the second post as well.
So to fix the tuning problem, I think we need to figure out the group delay of the filter and incorporate that into the delay line setting.
Also if I read correctly, the noise burst duration should be equal to 1/frequency, which it is not in the current model. That makes sense because we want to fill the full delay with noise, not just some of it. _________________ "Let's make noise for peace." - Kijjaz |
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Tue Mar 10, 2009 1:20 pm Post subject:
|
|
|
Inventor wrote: | Well, in the Wikipedia entry for Karplus-Strong they mention that the frequency is equal to the delay *plus* the group delay of the filter. That's why I included the Wikipedia entry for group delay in the second post as well. |
Don't forget about the sample of extra delay inherent in a feedback loop. Originally the filter used simply averaged between the current and the last (z-1) sample, later evolutions of KS of course use more elaborate filters.
Quote: | So to fix the tuning problem, I think we need to figure out the group delay of the filter and incorporate that into the delay line setting. |
Shouldn't the important factor be the phase effect of the filter at the frequency intended? A 4 pole filter (or 2 2pole ones, to make things easy with LPF which I think is a 2 pole filter) should be phase-neutral at the set gain.
Quote: | Also if I read correctly, the noise burst duration should be equal to 1/frequency, which it is not in the current model. That makes sense because we want to fill the full delay with noise, not just some of it. |
As I see things the burst of noise relates to the way the string is plucked/struck/bowed/whatever. Texturing the noise and enveloping it will all have interesting expressive effects. I used to experiment with resonators fed by drum-machine hits quite extensively. Different high-hats and cymbals would sound a bit like bowing while toms would be more akin to a blow to the body of a electric bass-guitar (a interesting playing technique at high gain!), those were certainly way longer than second/f.
Also remember, BTW, that you can halve the frequency by inverting the feedback gain and that it can be useful to remove DC offset (either inside of the loop or after the instrument). _________________ Kassen |
|
Back to top
|
|
|
Inventor
Stream Operator
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 267
|
Posted: Tue Mar 10, 2009 4:49 pm Post subject:
|
|
|
Thanks for all the info, Kassen. It's a little over my head, but I'll do my best to apply it! _________________ "Let's make noise for peace." - Kijjaz |
|
Back to top
|
|
|
Inventor
Stream Operator
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 267
|
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Tue Mar 10, 2009 8:32 pm Post subject:
|
|
|
Inventor wrote: | Thanks for all the info, Kassen. It's a little over my head, but I'll do my best to apply it! |
Shout if you get stuck, I didn't intend to write "impressive clever" stuff, I wanted to share some notes on working practically with KS. If something there looks incomprehensible I'll try to re-phrase it. _________________ Kassen |
|
Back to top
|
|
|
Inventor
Stream Operator
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 267
|
Posted: Tue Mar 10, 2009 9:49 pm Post subject:
|
|
|
Kassen wrote: | Inventor wrote: | Thanks for all the info, Kassen. It's a little over my head, but I'll do my best to apply it! |
Shout if you get stuck, I didn't intend to write "impressive clever" stuff, I wanted to share some notes on working practically with KS. If something there looks incomprehensible I'll try to re-phrase it. |
Well, one question: why would a four-pole filter be phase neutral at the set gain? As I understand it a simple LPF model with default Q of 1 has zero phase at DC, increasing phase as frequency increases, and 90 degrees of phase at high frequencies for each pole.
In this case we're setting the cutoff to three times the string frequency, so that puts us in the region where the phase is well under 45 degrees.
Also a four pole filter, even if it had phase of 360 degrees at the string frequency, would have a one cycle delay time. I think this is what is meant by the group delay of the filter, which is why the Wikipedia page on Karplus-Strong said that the feedback loop should have delay equal to the delay line delay plus the filter group delay.
So, in summary, I think we need to figure out the group delay of a 2-pole low-pass filter at 1/3 cutoff frequency and subtract that from the period of the string frequency to set the delay line.
Does that make any sense? _________________ "Let's make noise for peace." - Kijjaz |
|
Back to top
|
|
|
telstarmagikistferrari
Joined: Jun 16, 2008 Posts: 280 Location: Indianapolis, Indiana
Audio files: 43
|
Posted: Tue Mar 10, 2009 10:38 pm Post subject:
|
|
|
This program is super interesting, especially the interface.
I've read several reviews for software (always NI Kontakt engine) for emulating strumming, etc. I love that similar things are being done in the ChucK community, however small.
Using a regular keyboard in place of a multi-thousand-dollar monome appeals to no end, all aesthetic differences aside. Really cool stuff, Inventor/(kijjaz/Kassen)! |
|
Back to top
|
|
|
Inventor
Stream Operator
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 267
|
Posted: Wed Mar 11, 2009 5:30 am Post subject:
|
|
|
Thank you telstar!
Here is the most recent source code and an audio demonstration. I added some features, including barre chords, reverb, microphone input, and recording.
Description: |
The latest Digitar source code |
|
Download |
Filename: |
Digitar15.ck |
Filesize: |
15.01 KB |
Downloaded: |
398 Time(s) |
Description: |
|
Download |
Filename: |
Digitar.mp3 |
Filesize: |
3.39 MB |
Downloaded: |
1099 Time(s) |
_________________ "Let's make noise for peace." - Kijjaz |
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Wed Mar 11, 2009 10:21 am Post subject:
|
|
|
Inventor wrote: |
Well, one question: why would a four-pole filter be phase neutral at the set gain? As I understand it a simple LPF model with default Q of 1 has zero phase at DC, increasing phase as frequency increases, and 90 degrees of phase at high frequencies for each pole. |
I think it should have a 90° phase offset at the cutoff frequency per pole. Hence 4 pole filters will resonate; if you add feedback it lines up exactly at the cutoff frequency creating a resonant peak there. _________________ Kassen |
|
Back to top
|
|
|
Inventor
Stream Operator
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 267
|
Posted: Wed Mar 11, 2009 11:18 am Post subject:
|
|
|
Kassen wrote: | Inventor wrote: |
Well, one question: why would a four-pole filter be phase neutral at the set gain? As I understand it a simple LPF model with default Q of 1 has zero phase at DC, increasing phase as frequency increases, and 90 degrees of phase at high frequencies for each pole. |
I think it should have a 90° phase offset at the cutoff frequency per pole. Hence 4 pole filters will resonate; if you add feedback it lines up exactly at the cutoff frequency creating a resonant peak there. |
Well I'm not sure be I doubt that a 4-pole low-pass filter with feedback will resonate because the gain at the cutoff frequency is -3dB, so the loop gain is below unity. Isn't there a resonant peak below the cutoff frequency for Q higher than 1, as in a Wah pedal? Not sure. But how would that affect the delay calculations for Karplus-Strong anyway? _________________ "Let's make noise for peace." - Kijjaz |
|
Back to top
|
|
|
blue hell
Site Admin
Joined: Apr 03, 2004 Posts: 24079 Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320
|
Posted: Wed Mar 11, 2009 11:41 am Post subject:
|
|
|
Inventor wrote: | But how would that affect the delay calculations for Karplus-Strong anyway? |
I'm not 100% sure ... but let me try anyway ...
When you'd have a phase shift of lets say 180 deg at for a filter that is in your loop at the resonance frequency that 180 deg shift would amount to half a period of that particular frequency, and thus it corresponds with 1/2f seconds of delay in the signal and that would be the delay to compensate for. Now you probably wont re-tune your filter for different lengths of the delay line (different ouput frequencies), so you'll also have to figure out the filter delay for all other frequencies (based on the actual phase shift at those frequencies).
Now when you are having a filter with constant group delay you'd see that that all those times would evaluate to the same value, and you'd have to subtract that fixed value from the calculated delay time for the delay line (based upon the wanted frequency). So that would be sort of easy to calculate (based upon a known phase shift at a known frequency for the filter chosen).
Now what filters would exhibit constant group delay is another question ... Bessel filters are said to approximate it ... but I really know nothing here.
There would be another possible approach ... namely making a tuning table that you manually fix for some frequencies and then perform a linear interpolation on for the in-between frequency values.
Anyway, anyone, please correct me when I'm wrong. _________________ Jan
also .. could someone please turn down the thermostat a bit.
|
|
Back to top
|
|
|
JovianPyx
Joined: Nov 20, 2007 Posts: 1988 Location: West Red Spot, Jupiter
Audio files: 224
|
Posted: Thu Mar 12, 2009 11:08 am Post subject:
|
|
|
Hello ChucK people,
This guitar thread caught my attention because I have an interest in Karplus-Strong models.
First, let me warn that I am _not_ a ChucK programmer, in fact, I am lower than a noob. I've looked at the source, but I'm very lost.
My question, however, is really about K-S.
I've implemented K-S in a few different digital synthesizers using an FPGA. One is an 8 voice polysynth ( PolyDaWG/8 ) and the other is a 56 string "harp" I call Xarp-56. I also experimented with the Perry Cooke slide flute model a bit.
My question is regarding the string model and the reflection filter. My implementation uses a simple single pole IIR filter. I see there is a bit of discussion here regarding more than one pole for the reflection filter.
I thought about using a 2 or more pole filter, such as a state variable filter in lowpass mode and assumed that this would cause harmonics at the filter's resonance (Fc) to die out more slowly than the fundamental assuming Fc is above the fundamental of the string's natural vibrational frequency and a Q of greater than unity and some general attentuation to keep the gain < unity at all frequencies. Is this a correct assumption? Seems it would be interesting to be able to select the harmonic to enhance this way.
I'm curious as to what instrument types this technique models.
What I'm not seeing in the ChucK source for this project is the structure of the reflection filter - is this part of a library?
With FPGA design, I have to create such filters without the benefit of a library other than a "library" of modules I've created myself or obtained from others. I've gotten code for things like UART and DAC drivers from friends. The bulk of the code in my designs was code I wrote.
Anyone who might be interested in my FPGA MIDI synth designs can look at the links in my sig... _________________ FPGA, dsPIC and Fatman Synth Stuff
Time flies like a banana. Fruit flies when you're having fun. BTW, Do these genes make my ass look fat? corruptio optimi pessima
Last edited by JovianPyx on Thu Mar 12, 2009 11:36 am; edited 2 times in total |
|
Back to top
|
|
|
|