electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » Developers' Corner
Tube Amp Models
Post new topic   Reply to topic Moderators: DrJustice
Page 4 of 4 [87 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Goto page: Previous 1, 2, 3, 4
Author Message
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 5978
Location: San Antonio, Tx, USA
Audio files: 258

PostPosted: Sat May 24, 2008 4:47 am    Post subject: Reply with quote  Mark this post and the followings unread

Blue Hell wrote:
I did like the rough distortion, sounds usable to me.


Cool, thanks Jan, that means I'm getting somewhere after all this effort!

_________________
"Let's make noise for peace." - Kijjaz
Back to top
View user's profile Send private message Send e-mail
Blue Hell
Site Admin


Joined: Apr 03, 2004
Posts: 20706
Location: The Netherlands, Enschede
Audio files: 157
G2 patch files: 318

PostPosted: Sat May 24, 2008 5:03 am    Post subject: Reply with quote  Mark this post and the followings unread

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.

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.

_________________
Jan
Back to top
View user's profile Send private message Visit poster's website
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 5978
Location: San Antonio, Tx, USA
Audio files: 258

PostPosted: Sat May 24, 2008 6:32 am    Post subject: Reply with quote  Mark this post and the followings unread

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
Back to top
View user's profile Send private message Send e-mail
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 5978
Location: San Antonio, Tx, USA
Audio files: 258

PostPosted: Sat May 24, 2008 8:27 am    Post subject: Reply with quote  Mark this post and the followings unread

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
Back to top
View user's profile Send private message Send e-mail
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 5978
Location: San Antonio, Tx, USA
Audio files: 258

PostPosted: Sat May 24, 2008 12:17 pm    Post subject: Reply with quote  Mark this post and the followings unread

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:  86 Time(s)
This image has been reduced to fit the page. Click on it to enlarge.

Tube_Amp_Xfer_fctn.jpg



_________________
"Let's make noise for peace." - Kijjaz
Back to top
View user's profile Send private message Send e-mail
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 5978
Location: San Antonio, Tx, USA
Audio files: 258

PostPosted: Sat May 24, 2008 4:16 pm    Post subject: Reply with quote  Mark this post and the followings unread

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!

Download
 Filename:  Tube_Amp_out13.mp3
 Filesize:  469.79 KB
 Downloaded:  314 Time(s)


_________________
"Let's make noise for peace." - Kijjaz
Back to top
View user's profile Send private message Send e-mail
DrJustice



Joined: Sep 13, 2004
Posts: 2052
Location: Morokulien
Audio files: 3

PostPosted: Sat May 24, 2008 5:09 pm    Post subject: Reply with quote  Mark this post and the followings unread

That's better! This one is much kinder to the ears Very Happy

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 Laughing

DJ
--
Back to top
View user's profile Send private message Visit poster's website
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 5978
Location: San Antonio, Tx, USA
Audio files: 258

PostPosted: Sat May 24, 2008 6:07 pm    Post subject: Reply with quote  Mark this post and the followings unread

DrJustice wrote:
That's better! This one is much kinder to the ears Very Happy

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 Laughing

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
Back to top
View user's profile Send private message Send e-mail
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 5978
Location: San Antonio, Tx, USA
Audio files: 258

PostPosted: Sat May 24, 2008 6:37 pm    Post subject: Reply with quote  Mark this post and the followings unread

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

Download
 Filename:  Tube_Amp_out14.mp3
 Filesize:  469.79 KB
 Downloaded:  341 Time(s)


_________________
"Let's make noise for peace." - Kijjaz
Back to top
View user's profile Send private message Send e-mail
DrJustice



Joined: Sep 13, 2004
Posts: 2052
Location: Morokulien
Audio files: 3

PostPosted: Sat May 24, 2008 6:55 pm    Post subject: Reply with quote  Mark this post and the followings unread

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(?)

DJ
--
Back to top
View user's profile Send private message Visit poster's website
DrJustice



Joined: Sep 13, 2004
Posts: 2052
Location: Morokulien
Audio files: 3

PostPosted: Sat May 24, 2008 7:00 pm    Post subject: Reply with quote  Mark this post and the followings unread

Inventor wrote:
Can you hear any artifacts?

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).

DJ
--
Back to top
View user's profile Send private message Visit poster's website
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 5978
Location: San Antonio, Tx, USA
Audio files: 258

PostPosted: Sun May 25, 2008 9:15 am    Post subject: Reply with quote  Mark this post and the followings unread

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!

Download
 Filename:  Tube_Amp_out16.mp3
 Filesize:  313.88 KB
 Downloaded:  330 Time(s)


Tube_Amp16.ck
 Description:
The source code for the ChucK ZeST model - quite zesty!

Download
 Filename:  Tube_Amp16.ck
 Filesize:  3.31 KB
 Downloaded:  96 Time(s)


_________________
"Let's make noise for peace." - Kijjaz
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic Moderators: DrJustice
Page 4 of 4 [87 Posts]
View unread posts
View new posts in the last week
Goto page: Previous 1, 2, 3, 4
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » Developers' Corner
Jump to:  

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
e-m mkii

Please support our site. If you click through and buy from
our affiliate partners, we earn a small commission.


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use