electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links
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 
go to the radio page Live at electro-music.com radio 1 Please visit the chat
  host / artist show at your time
today> Modulator ESP Adventures In Sound
 Forum index » DIY Hardware and Software » ChucK programming language
My ChucKs
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [6 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
audiodef



Joined: Sep 05, 2011
Posts: 726
Location: LFO1
Audio files: 53

PostPosted: Wed Mar 14, 2018 1:09 pm    Post subject: My ChucKs Reply with quote  Mark this post and the followings unread

Very recently, and finally, got into learning ChucK. I thought I would share my ChucKs here, just for fun.

Right now I'm messing around with the basics, but it's fun how much noise you can make with just that.

This sounds like a pulsing saw being launched from a cloud of noise.

sawlaunch.ck:
Code:

SawOsc n => TwoPole o => dac;

100.0 => float s;
0.0 => float v;

while(true){
   Std.fabs(Math.tan(v)) * s/200 => o.b0;
   Std.fabs(Math.tan(v)) / s => o.freq;
   Std.fabs(Math.cos(v)) * v => n.sfreq;
   3::ms => now;
   0.9 +=> v;
   o =< dac;
   1::ms => now;
   o => dac;
}


This variant sounds vaguely like a motor starting roughly, then smoothing out.

motorlaunch.ck:
Code:

SawOsc n => TwoPole o => dac;
20.0 => n.freq;

1::minute/240/8 => dur T; // 240 bpm 32d notes
T - (now % T) => now; // Sync to beat

100.0 => float s;
0.0 => float v;

while(true){
   Std.fabs(Math.tan(v)) * s/200 => o.b0;
        Std.fabs(Math.tan(v)) / s => o.freq;
        Std.fabs(Math.cos(v)) * v => n.sfreq;
        T/3 => now;
        0.9 +=> v;
        o =< dac;
        1::ms => now;
        o => dac;
}


Note: I had to disable HTML in this post to get the code to display correctly, due to the < and > in ChucK being mistaken for HTML. EDIT: As originally noted by Kassen. Smile

_________________
There's an invisible radio gnome playing a gong from a flying teapot - don't miss out!

Last edited by audiodef on Thu Mar 15, 2018 2:23 pm; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website
audiodef



Joined: Sep 05, 2011
Posts: 726
Location: LFO1
Audio files: 53

PostPosted: Wed Mar 14, 2018 1:17 pm    Post subject: Reply with quote  Mark this post and the followings unread

Depending on how you tweak moe, larry and curly, this could be an arpeggiated Impulse or a modulated buzz - or something funky in between.

moepad.ck:
Code:

// moe
Impulse moe_impulse => BiQuad moe_filter => dac;
.99 => moe_filter.prad; // Goes off the rails and farts itself out at 1.0
1 => moe_filter.eqzs;
5123.0 => float moe_sweep; // Sweeps up to this freq
0.05 => float moe_inc;

// larry
Impulse larry_impulse => BiQuad larry_filter => dac;
.99 => larry_filter.prad;
1 => larry_filter.eqzs;
500.0 => float larry_sweep;
0.06 => float larry_inc;
// Create mathematical relationship between larrylater and larrytimepass
2.3 => float larrylater;
larrylater/1.1 => float larrytimepass;

// curly
Impulse curly_impulse => BiQuad curly_filter => dac;
.99 => curly_filter.prad;
1 => curly_filter.eqzs;
4000.0 => float curly_sweep;
1.03 => float curly_inc;
2.0 => float curlylater;
curlylater/.02 => float curlytimepass;

// all
0.0 => float v;

while(true){
   // Softer at values less than 1.0
   1.0 => moe_impulse.next;
   Std.fabs(Math.sin(v)) * moe_sweep => moe_filter.pfreq;
   // Smaller = more gentle sweep, larger = faster but more quantized sweep
   moe_inc +=> v;
   now + larrylater::ms => time later;
   while(now < later){
      1.0 => larry_impulse.next;
      Std.fabs(Math.sin(v)) * larry_sweep => larry_filter.pfreq;
      larry_inc +=> v;
      larrytimepass::ms => now;
      now + curlylater::ms => time evenlater;
      while(now < evenlater){
         1.0 => curly_impulse.next;
         Std.fabs(Math.sin(v)) * curly_sweep => curly_filter.pfreq;
         curly_inc -=> v;
         curlytimepass::ms => now;
      }
   }
   10::ms => now;
}

_________________
There's an invisible radio gnome playing a gong from a flying teapot - don't miss out!
Back to top
View user's profile Send private message Visit poster's website
audiodef



Joined: Sep 05, 2011
Posts: 726
Location: LFO1
Audio files: 53

PostPosted: Wed Mar 14, 2018 3:54 pm    Post subject: Reply with quote  Mark this post and the followings unread

A simple robot voice:

robot.ck:
Code:

SawOsc saw => BiQuad q => dac;

1::minute/120/4 => dur T; // 120 bpm sixteenth notes
T - (now % T) => now; // Sync to beat

for (5=>int i; true; i++) { // Infinite loop
        Std.rand2f(77, 83) => saw.freq; // Centered around 80 - adjust to taste
        Std.rand2f(0.0, 0.99) => saw.width;
        Std.rand2f(0.0, 0.99) => q.b0 => q.prad => q.zrad => q.a0; // ROBOFILTER
        T => now;
}


It's easy to adjust this to play a simple random arpeggio with specific notes and an octave multiplier:

arp.ck
Code:

SawOsc saw => BiQuad q => dac;

1::minute/120/4 => dur T; // 120 bpm sixteenth notes
T - (now % T) => now; // Sync to beat

[33,36,40,43,45] @=> int note[]; // MIDI notes, Am 2 oct below middle-C
5 => int oct; // Octave multiplier

for (5=>int i; true; i++) { // Infinite loop
        (Std.mtof(note[Std.rand2(0, 4)]))*oct => saw.freq;
        Std.rand2f(0.0, 0.99) => saw.width;
        Std.rand2f(0.0, 0.99) => q.b0 => q.prad => q.zrad => q.a0; // ROBOFILTER
        T => now;
}

_________________
There's an invisible radio gnome playing a gong from a flying teapot - don't miss out!
Back to top
View user's profile Send private message Visit poster's website
audiodef



Joined: Sep 05, 2011
Posts: 726
Location: LFO1
Audio files: 53

PostPosted: Thu Mar 15, 2018 12:20 pm    Post subject: Reply with quote  Mark this post and the followings unread

Here's a little detuned square osc arp ChucK. As is, it plays a growly, punchy, snappy bass.

squarp.ck:
Code:

SqrOsc sq => LPF lpf => ADSR e => dac;
SqrOsc sq2 => lpf;

1::minute/240/4 => dur T; // 240 bpm sixteenth notes
T - (now % T) => now; // Sync to beat

[9,12,21] @=> int note[];
1 => int oct; // Octave multiplier
7 => int keyshift; // Shift from A-1-C0-A0, in half-notes
1.002 => float detune;

while(true){
   // Set rando everything
        oct*(Std.mtof(note[Math.random2(0,note.cap()-1)])+keyshift) => float freq;
        freq => sq.freq;
        detune * freq => sq2.freq; // 2d osc detuned
        Math.random2f(0.0, 1.0) => sq.gain;
        Math.random2f(0.0, 1.0) => sq2.gain; // Indiv gain for oscs
        e.set(Math.random2(0,50)::ms, Math.random2(0,80)::ms, Math.random2f(0.01, 0.30), T*4);
        Math.random2f(250,2000) => lpf.freq; // Adjust filter range to taste
        Math.random2f(0.1,3.0) => lpf.Q; // Adjust to taste. Higher than 2 is quite snappy

        // Play
        e.keyOn();
        T => now;
        e.keyOff();
        T*2 => now;
}

_________________
There's an invisible radio gnome playing a gong from a flying teapot - don't miss out!
Back to top
View user's profile Send private message Visit poster's website
audiodef



Joined: Sep 05, 2011
Posts: 726
Location: LFO1
Audio files: 53

PostPosted: Thu Mar 15, 2018 5:18 pm    Post subject: Reply with quote  Mark this post and the followings unread

I was playing with getting two lines to play together. This is a bit of silliness.

choralfun.ck:
Code:

SinOsc s => Chorus c => ADSR e => dac;
SinOsc s2 => Chorus c2 => e;

1::minute/60/4 => dur T; // 60 bpm sixteenth notes
T - (now % T) => now; // Sync to beat

0.2 => c.modDepth => c2.modDepth;
0.2 => c.mix => c2.mix;

T / 2::ms => float tfreq; // Sync mod freq with beat (kind of)

// Larger attack makes more of a hit instead of less. Not sure why.
e.set(5::ms, 10::ms, 0.5, 200::ms);

1.5 => float detune; // Affects chorus beats
1.0 => float cdetune;

function void sinbass(float tempomult, int freqmult, float g){
   while(true){
      Math.random2f(80.0 * freqmult, 160.0 * freqmult) => float oscfreq;
      oscfreq => s.freq;
      detune * oscfreq => s2.freq;
      Math.random2f(tfreq/2, tfreq) => float cfreq;
      cfreq => c.modFreq;
      cdetune * cfreq => c2.modFreq;
      g => s.gain => s2.gain;
      e.keyOn();
      T*tempomult*2 => now;
      e.keyOff();
      T*tempomult => now;
   }
}

spork ~ sinbass(2.0,1,1);
T*32 => now;
spork ~ sinbass(0.5,3,0.2);
while(true) 1::ms => now;

_________________
There's an invisible radio gnome playing a gong from a flying teapot - don't miss out!
Back to top
View user's profile Send private message Visit poster's website
audiodef



Joined: Sep 05, 2011
Posts: 726
Location: LFO1
Audio files: 53

PostPosted: Fri Mar 16, 2018 8:44 am    Post subject: Reply with quote  Mark this post and the followings unread

Here is a simple SinOsc pulsator that depends on modulating "now."

sinpulsator.ck:
Code:

SinOsc op2 => SinOsc op1 => dac;

//880 => op1.freq; // At this level of modulation, op1.freq makes no audible difference.

0.0 => float phase;
3000.0 => float sweepfreq; // 8000 = techno/trance pulse, lower values soften this effect. Muddy at 1000.
400.0 => float gainsweep; // Lower values soften the overall volume and take some of the edge off.
1.1 => float dursweep; // This value produces a nice pulse depending on   above values.

while(true){
   Std.fabs(Math.sin(phase)) * sweepfreq => op2.freq;
        Std.fabs(Math.sin(phase * 1.2)) * gainsweep => op2.gain;
        0.1 +=> phase;
        Std.fabs(Math.sin(phase)) * dursweep::ms => now;
        //2::ms => now; // Duration makes a very large difference here. Comment out above line if using this.
}

_________________
There's an invisible radio gnome playing a gong from a flying teapot - don't miss out!
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [6 Posts]
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 » ChucK programming language
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


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