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 
Live streaming at radio.electro-music.com

  host / artist show at your time
<on air> EdisonRex Edison's Electronic Review
Please visit the chat
 Forum index » DIY Hardware and Software » Les Hall's Projects including eChucK
Prototyping EChucK in ChucK
Post new topic   Reply to topic Moderators: Inventor
Page 1 of 1 [1 Post]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
Inventor
Stream Operator


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

PostPosted: Thu Mar 26, 2009 7:55 am    Post subject: Prototyping EChucK in ChucK
Subject description: Examples of how to do it, explained.
Reply with quote  Mark this post and the followings unread

Hello again,

As an intro to programming in ChucK for EChucK purposes, I thought I would write up a description of the "Matt Belamy of Muse" Fuzz program that I wrote. It takes a guitar input connected to the line-in jack of the computer and does a Fuzz effect on it. Here is the code:

Code:

// Fuzz Test Code
// Copyright 2009 Les Hall
// This software is protected by the GNU General Public License


// the patch
//
// automatic gain control
adc => Gain div1;
adc => FullRect fwr1 => LPF f1 => Gain add1 => div1;
Step step1 => add1;
4 => div1.op;
20 => f1.freq;
0.2 => step1.next;
1.0 => adc.gain;
//
// distortion
div1 => Gain div2 => dac;
div1 => FullRect fwr2 => Gain add2 => div2;
Step step2 => add2;
4 => div2.op;
0.02 => step2.next;  // set level of distortion (less is more)


// time loop
while (true) {
    second => now;
}


There are three sections to the code, the AGC (automatic gain control), the distortion (or Fuzz), and the time loop. I will describe these in detail.

In the AGC section the first three lines are the patch. This is where we hook up the UGens that perform the AGC. They are a divider and a signal level calculator. Then the last four lines of this section are the patch parameters. Those lines configure the UGens so they do what we wanat them to do. How it all works is as follows:

The input signal goes into the div1 divider which divides it by a slowly changing signal level value produced in the second line by a rectifier followed by a low-pass filter which gives the envelope of the signal. Then a step1 value is added to that signal level so the AGC doesn't go nuts when there is no signal. The div1.op line tells div1 to be a divider, the f1.freq line sets the f1 cutoff frequency, the step1.next line sets the maximum level of AGC, and the adc.gain line sets the input gain.

The net result is the input signal being divided by a 20 Hz envelope of itself, which is a crude form of AGC.

In the distortion section the first three lines implement the equation:

Code:

dac = div1 / (step2 +|div1|)


which does a soft distortion, or fuzz of the signal. Once again the div2 line sets the divider to be a divider, and then the step2 line sets the level of severity of the fuzz effect.

Then finally we need to tell ChucK to loop forever in time, which is done with an infinite loop that advances time inside of it.

You can test this code with or without a guitar. With a guitar you just jack into the line-in Jack using a 1/4" to 1/8" adapter and play your guitar into it. Without a guitar you use your computer's microphone and talk, sing, whistle or hum into the microphone. You will hear your voice with the fuzz effect applied.

This program is a software prototype of a dsPIC implementation of the algorithm because all of the UGen operations are implementable in the dsPIC chip. This is powerful because it permits us to software prototype and share files over the web and so forth before going through the much more difficult process of actually programming a chip and testing it.

The program file is in the sticky thread called "EChucK Files", which is the open source repository. Enjoy!

_________________
"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: Inventor
Page 1 of 1 [1 Post]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » Les Hall's Projects including eChucK
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