What you could do is generate the open string notes EADGBE from ChucK, one at a time, and tune the guitar to that by listening to the beat frequencies resulting from interference with the reference tones, trust your ears, it'll work, and it's much more useful than a tuner.
When you can't figure out the beat frequencies you can use ChucK again, generate a note of 440 Hz and one of 441 Hz (for instance) at the same time and listen how they interfere with each other, it'll be much clearer then.
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 270
Posted: Sat May 24, 2008 6:32 am Post subject:
Blue Hell wrote:
Inventor wrote:
I just couldn't get a tuner just yet.
What you could do is generate the open string notes EADGBE from ChucK, one at a time, and tune the guitar to that by listening to the beat frequencies resulting from interference with the reference tones, trust your ears, it'll work, and it's much more useful than a tuner.
This didn't work, I think my ears are made of concrete, haha! But I did whip up a nice little guitar tuner in ChucK, the only thing is, you have to specify what string you are tuning. So it isn't super magical, it needs some info.
What I did was run the signal into a high Q band-pass filter at the target frequency, then observe the time between zero crossings. Naturally there is a lot more to it like a noise threshold and a keyboard interface, but that's it in a nutshell. Took about an hour to write it and tune the guitar to within +/- 1 % of desired frequency. I'll post the code in the ChucK forum if anyone wants it. _________________ "Let's make noise for peace." - Kijjaz
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 270
Posted: Sat May 24, 2008 8:27 am Post subject:
It looks like I have solved the ticking problem. It was a grounding issue. I was using a power strip with the ground tab clipped off of it. I should throw that one in the trash since I have the appropriate ground isolation plugs for my scope and such. In fact, I think I will. Sorry for any confusion. _________________ "Let's make noise for peace." - Kijjaz
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 270
Posted: Sat May 24, 2008 12:17 pm Post subject:
To see what is going on, I plotted the transfer function of the tube amp model. Unfortunately it has a nasty corner at the maximum output (minimum input). I think this is because of the oversimplification that I made where I said that the input current was zero. It isn't. Still, the plan was to cut corners wherever possible and then add them in later, so here is one that needs to be added back in, i guess...
Quite frankly, looking at the plot, I think a sigmoid function might make a good tube model. It wouldn't be based on circuit analysis, but it would give really excellent tubular bendiness at the rails. I just happen to be a real fan of the sigmoid function, call me weird...
Tube_Amp_Xfer_fctn.jpg
Description:
The transfer function of the tube amp model - yikes!
Filesize:
87.06 KB
Viewed:
578 Time(s)
This image has been reduced to fit the page. Click on it to enlarge.
_________________ "Let's make noise for peace." - Kijjaz
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 270
Posted: Sat May 24, 2008 4:16 pm Post subject:
Try this one on for size. I used a sharp sigmoid function with 40 line segments defining the transfer function. I looked at the waveforms in Audacity and they are very gently clipped. This one is such a good tube model, its better than a tube (dare I say)! Have a listen!
Tube_Amp_out13.mp3
Description:
Now that's tubular!
Filesize:
469.79 KB
Viewed:
1982 Time(s)
_________________ "Let's make noise for peace." - Kijjaz
That's better! This one is much kinder to the ears
I've toyed with sigmoid curves in the past, and I agree that they're very useful for soft (or not so soft...) clipping, but even they need band limiting. I'd still advice you to do the sine sweep test and listen for aliasing.
As you have discovered for yourself, "real" modelling is not always the answer - smoke and mirrors often do the trick just as well, if not better
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 270
Posted: Sat May 24, 2008 6:07 pm Post subject:
DrJustice wrote:
That's better! This one is much kinder to the ears
I've toyed with sigmoid curves in the past, and I agree that they're very useful for soft (or not so soft...) clipping, but even they need band limiting. I'd still advice you to do the sine sweep test and listen for aliasing.
As you have discovered for yourself, "real" modelling is not always the answer - smoke and mirrors often do the trick just as well, if not better
DJ
--
Thanks, Dr. J, I really like this model also. I think I will write it up on a web page.
For the sweep, I know that a guitar's maximum frequency is about 1.5 kHz, so including a few harmonics shouldn't the upper limit of the sweep be about 5 kHz instead of 20 kHz? Also for the band limiting, how about a 2 kHz low pass filter after the tube model's transfer function?
You know, if we are going to use a sigmoid function as a tube model, we will need a name for it. How about the "Zany electro-music.com Sigmoid Tube", or "ZeST" for short?
You are right about the smoke and mirrors, the more I see analog and digital circuit abuse, rules broken, and totally un-kosher circuits that are used in electronic music, the more I enjoy the whole bizarre catastrophe of amateur hobbyists breaking engineering rules for fun and great sounds, haha. So why shouldn't I join in the chaos and make a tube amp model that's not even based on tube amp circuit analysis? Rules are meant to be broken, or so they say! _________________ "Let's make noise for peace." - Kijjaz
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 270
Posted: Sat May 24, 2008 6:37 pm Post subject:
Dr. J, I ran the sweep test, although the high frequencies hurt my ears so I just did it up to 440 Hz. I found by observing the waveforms that band-limiting with a low pass filter on the output actually made the signal worse, causing it to be tooth-shaped instead of rounded. In the attached output file all the frequencies have the same characteristic shaping by the sigmoid transfer function. Can you hear any artifacts? i can't. Sounds like a winner to me.
Tube_Amp_out14.mp3
Description:
0 Hz to 440 Hz sweep of sinusoid applied to sigmoid tube amp model
Filesize:
469.79 KB
Viewed:
2068 Time(s)
_________________ "Let's make noise for peace." - Kijjaz
The reason for sweeping right up to 20kHz is just to test the algorithm. I don't know if you're familiar with aliasing, but if a signal has acquired aliased components, it is too late to lowpass filter it (unless you're lucky and all the aliases happen to be well outside the passband. Even if a normal steady guitar tone doesn't go all the way to 20kHz, playing the guitar will produce higher frequency content caused by fret noises, fingers against string winding noises and so on. I have never checked, but I would not be surprised if the attack portion has a fairly rich frequency content.
It's of course not the first use of a sigmoid function for soft clipping, but still an original ZeST effect can certainly use it as a basis. Why not to try and play with it, bending the curve some, filtering before and/or after, maybe even a touch of dynamic processing - break some rules, go for what sound good to you. If anything, my advice would be to try oversampling as well; I'd guess Chuck has some support for that(?)
Nope. It sounds nice and clean in that range. Waveform looks good too.
Edit: to refresh my own memory I just tried the god old x - x^3/6 with x scaled by 1.4 and it (and variants) is very clean . This one used to be called the "bandlimited sigmoid" and I now remember why (it's not really bandlimited, of course, but close enough for our purposes).
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 270
Posted: Sun May 25, 2008 9:15 am Post subject:
Thanks for your ideas, Dr. J, I did what you suggested. I ran the full 20 kHz sweep and sure enough there was plenty of aliasing. So I did the other thing you suggested, which was to play around with it to reduce the aliasing. After hours and hours of experimentation and a long sequence of failed ideas, I was able to create a pretty good solution. It works like this:
I watch for positive-going zero crossings and estimate the frequency of the input signal by averaging them with an exponential running average thingie. Then I vary the shape constant of the sigmoid according to a mathematical expression based on the estimated frequency divided by the maximum frequency. After lots of trial-and-error I was able to vary the shape of the sigmoid so that it is sharper for lower frequencies and smoother for higher frequencies, and also varies nonlinearly in such a way as to reduce the aliasing. That way the lower frequencies get that bendy tubular clipping effect and the upper frequencies see a nearly linear transfer function so they remain sinusoidal.
There are a lot of details that I won't bore you with, but suffice to say the result seems good to me. Sadly, in the process I learned that the frequency response of my hearing is rather poor. I could barely hear sounds above 10 or 12 kHz. Then again, I was sending the audio into my new Fender guitar amp which has a big midrange speaker so maybe that was part of it. So if there is still a lot of aliasing in the upper frequencies it's because I couldn't hear it very well.
Attached below are the final output of the 20 kHz audio sweep and the ChucK source code so you can glance over the algorithm. ChucK is quite readable even if you don't know the language. As always I welcome your comments and constructive criticism.
Tube_Amp_out16.mp3
Description:
The output of the 20 kHz sweep. Ahh, such gentle tubular bendiness!
Filesize:
313.88 KB
Viewed:
1905 Time(s)
Tube_Amp16.ck
Description:
The source code for the ChucK ZeST model - quite zesty!
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum