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 
 Forum index » DIY Hardware and Software » ChucK programming language
Boolean Algebra Sequencing
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [23 Posts]
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: 6221
Location: near Austin, Tx, USA
Audio files: 267

PostPosted: Thu Oct 18, 2007 12:50 am    Post subject: Boolean Algebra Sequencing
Subject description: Using digital logic to create sequences of notes.
Reply with quote  Mark this post and the followings unread

The excitement continues... After having some luck with my base n music synthesis, I had a good background beat but I wanted to add something more prominent, like another instrument. I ended up creating a Boolean algebra function off of the base n count sequence and driving a percussive note with the output of the logic function. For example, consider the following logic table exclusive or function:

a b i
0 0 0
0 1 1
1 0 1
1 1 0

Where a and b are the two-digit binary count sequence and i is the impulse driver for an impulse response note generator. As time progresses you get nothing-note-note-nothing, a sequence! Except in the attached ChucK program there is a five bit count with a more complex logic function.

Depending on how you choose your logic function, you can create repeating phrases of notes that follow each other, or well, technically any logical sequence of notes. So you see, this is not just an example but a broader technique that can be used to create musical sequencing without ever writing a note.

Well, it is so obvious that I am sure this has been done before and I am just reinventing the wheel again - does anyone have any references to prior work along these lines? Still, I remain pleased with the discovery because it is a way that I can do sequencing without having any musical knowledge (of which I have almost none).

Next I will just listen to it and perhaps play around with varying the frequency and amplitude of the notes according to this Boolean method. Also since the counts are base n, there is no need to restrict myself to Boolean algebra, any math function of the base n count will do. Hmmm...


base_n5.ck
 Description:
Boolean sequencing done by making music from a base n count, then driving impulse response filters from logic functions. You can sequence entire songs without endless streams of notes in arrays this way. This is just a demo of a broader technique.

Download
 Filename:  base_n5.ck
 Filesize:  2.09 KB
 Downloaded:  441 Time(s)

Back to top
View user's profile Send private message Send e-mail
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 267

PostPosted: Thu Oct 18, 2007 3:31 am    Post subject: Reply with quote  Mark this post and the followings unread

Well, I did play around with the song in the previous post and added enough features that I now consider this to be my first music composition. It has three instruments, all Boolean Sequenced to a five-digit count of base n, where n starts at 2 and increases for as long as you leave it running.

The main sound is created by five SinOsc's, one for each digit, with LSB at 200 Hz and MSB at 1kHz. Then there is a bass instrument modeled by an impulse-driven band-pass filter with two notes. Finally, a piano-like instrument that I created with five such impulse-driven filters in a harmonic sequence.

The SinOsc's simply count out the numeric sequence, while the bass and keyboard are driven by algebraic expressions that take the numeric sequence as input.

Unlike randomly sequenced sounds that I have created recently (following examples of others posting here), these sequences "make sense" to your head in some way. The Boolean encoding creates phrases that repeat themselves in chains, sort of like a real musician would do while playing an instrument. Also the keyboard frequency is derived from the counting digits in a way that is mathematically pleasing to the ear.

If you don't have ChucK running, you can hear the song on my new music website which is here:

http://www.freedomodds.com/music/

I hope you enjoy the song.


Boolean_Trio.ck
 Description:
A "trio" of instruments created with Boolean Synthesis. There's an organ-like background sound, a bass instrument, and a sort of a keyboard. Runs forever, just increases the value of the numeric base, n. My first music composition.

Download
 Filename:  Boolean_Trio.ck
 Filesize:  3 KB
 Downloaded:  356 Time(s)

Back to top
View user's profile Send private message Send e-mail
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Thu Oct 18, 2007 7:20 am    Post subject: Reply with quote  Mark this post and the followings unread

Sounds lovely!

I have a tip for you; you can have arrays of Ugens, like this;

Code:
// control variables
2 => int n; // numeric base of the sequence
100 => float frequency;

//instantiation is automatic
SinOsc s[5];

for(0 => int n; n < 5; n++)
 {
 // the patches
 s[n] => dac;
 
 // set up the oscillator frequencies
 (5 - n) * frequency => s[n].freq();
 }


Etc, etc, etc. In setups like your own here that can save you a lot of typing and later modifications become much easier.

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 267

PostPosted: Thu Oct 18, 2007 7:26 am    Post subject: Reply with quote  Mark this post and the followings unread

Way cool, thanks for the tip Kassen! I will start doing things that way now. So much to learn...
Back to top
View user's profile Send private message Send e-mail
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 267

PostPosted: Sat Oct 20, 2007 10:18 pm    Post subject: Reply with quote  Mark this post and the followings unread

I decided to try an 8-bit counter and it worked out pretty well. This time there are three instruments: a high-pitched plucked instrument, a lower-pitched plucked instrument, and a sort of haunting harp-like instrument that sounds like something is wailing or winding up. You'll know what I mean if you give this one a listen.

Adding more bits helped to create a more complex sequence in the instruments, though I'm not sure if I've taken best advantage of that.


Boolean_8bit.ck
 Description:
Another Boolean sequence, this time with an 8-bit counter, two twangy plucked instruments and a haunting harp-like instrument. Not better, not worse, just different.

Download
 Filename:  Boolean_8bit.ck
 Filesize:  4.15 KB
 Downloaded:  385 Time(s)

Back to top
View user's profile Send private message Send e-mail
kijjaz



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Sun Oct 21, 2007 7:16 pm    Post subject: Reply with quote  Mark this post and the followings unread

Cool! I love the ideas.
It creates very greate sounding patterns here, this is a very good example and piece of music.
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 267

PostPosted: Wed Oct 24, 2007 7:26 pm    Post subject: Reply with quote  Mark this post and the followings unread

kijjaz wrote:
Cool! I love the ideas.
It creates very greate sounding patterns here, this is a very good example and piece of music.


Thanks, kijjaz. I am just beginning to learn some basic rules for creating these Boolean sequences. One of them is: use simple expressions of the lower-order bits and complex expressions of the upper order bits. If you use a complex expression involving the lower order bits then it won't pluck very often and you'll get a lot of silence. If you use a simple expression involving the upper order bits then it will pluck constantly for a major portion of your song.

For example j3&&j2&&j1&&j0 will only pluck once every 16 notes, and j15&&j14 will pluck constantly for 1/4 of your song. So to just create something quick, easy, and simple to give you a potentially interesting sequence, you want long upper bit logic and short lower bit logic.

However, rules are made to be broken and you might even want to pick out individual count numbers with long expressions and lots of them, that gives you less algorithmic magic and more direct control of the sequence. I'll post some more general observations as I learn them. Enjoy.
Back to top
View user's profile Send private message Send e-mail
kijjaz



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Wed Oct 24, 2007 10:32 pm    Post subject: Reply with quote  Mark this post and the followings unread

Sometimes I also make some grooves out from this kind of idea,
but based on simple binary (0 or 1) 1-dimension Cellular Automata.

one expression i love to play with in cellular automata is 'exclusive or' or ^ in chuck

Code:
int a[20]; int a_new[20];
for(int i; i < 20; i++) maybe * maybe => a[i]; // 25% probability that a[i] would be 1
while(true) {
   for(int i; i < 20; i++) a[(i + 19) % 20] ^ a[(i + 21) % 20] => a_new[i]; // do a cellular automata operation
   for(int i; i < 20; i++) a_new[i] => a[i]; // update a's with new values
   // more code: do something with a's
   // etc..
}


I usually find some fun result from this kind of system.
applying some random adjustments to it is kinda fun also..
for example..
if (maybe) 0 => a[0];

this would indeed make the system more unpredictable but similar pattern still appear.[/code]
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 267

PostPosted: Thu Oct 25, 2007 12:51 am    Post subject: Reply with quote  Mark this post and the followings unread

kijjaz wrote:
Sometimes I also make some grooves out from this kind of idea,
but based on simple binary (0 or 1) 1-dimension Cellular Automata.

one expression i love to play with in cellular automata is 'exclusive or' or ^ in chuck



Cellular automata, is that what the 2d automation called "life" is made of? I didn't know you could do that in one dimension. It would lend itself well to a video animation sequence, I could just draw a sphere or not at each pixel.

Also I didn't know ChucK had an exclusive or operator, ^. I had been wanting to try exclusive or in the beat and frequency sections, but did not want to write a function and make a nasty complicated nesting of function calls to get it. I will try it on the guitar riff next. Thanks for the idea, you have a wealth of knowledge and creativity kijjaz.
Back to top
View user's profile Send private message Send e-mail
kijjaz



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Thu Oct 25, 2007 4:58 am    Post subject: Reply with quote  Mark this post and the followings unread

Thanks Inventor,

I'll start working on your original binary data operation way with some of my idea incoporated.

Oh another thing about exclusive or,
for binary int data, we can also use + and % to do that.

int a; int b;
// code...
<<< (a+b) % 2 >>>; // this is the exclusive or of a and b again..

but surely ^ looks better heheh.

i also wanna work more on bitwise operations.
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 267

PostPosted: Thu Oct 25, 2007 6:48 am    Post subject: Reply with quote  Mark this post and the followings unread

I added a cellular automata guitar as well as a few more guitars to the guitar lab, so I thought it was time to post it again. The cellular automata guitar sounds kind of random, well it is random. My favorite is "east meets west", so I made a similar bass guitar and they sound good together.


guitar_lab3.ck
 Description:
Latest guitar lab, has 3 or 4 each of lead and bass guitars, plus left and right fades. Use the selector switches at the top to pick one bass and one lead guitar.

Download
 Filename:  guitar_lab3.ck
 Filesize:  7.44 KB
 Downloaded:  306 Time(s)

Back to top
View user's profile Send private message Send e-mail
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 267

PostPosted: Sun Oct 28, 2007 4:47 am    Post subject: Reply with quote  Mark this post and the followings unread

So far on the Boolean sequencing frontier I have found three Boolean note sequences and two algebraic frequency expressions that work well, especially with kijjaz's electric guitar. The three Boolean note sequences are as follows:

1. OR of adjacent ANDed terms: j0&j1 | j2&j3 | j4&j5 | j6&j7 | ...
2. OR of progressive ANDed terms: j0&j1 | j2&j3&j4 | j5&j6&j7&j8 | ...
3. XOR of overlapping ANDed terms: j0&j1 ^ j1&j2 ^ j2&j3 ^ j3&j4 ^ ....

The two algebraic frequency expressions are as follows:

1. Addition of bits: 4 + j0 + j1 + j2 + j3 + j4 + j5 + ...
2. Subtraction of bits: 12 - j0 - j1 - j2 - j3 - j4 - j5 - ...

And for a final twist, you can add weights to the bits of the two algebraic frequency expressions, though I have not found that weighted bits actually sounded all that good.

I have made 3 guitars that stand out from the others in their quality: sequence 1 with expression 1, sequence 2 with expression 1, and sequence 3 with expression 2. The first has a powerful sound, the second has an "East Meets West" sound, and the third has hesitant pauses followed by rapid notes. I don't know the musical terms to describe these, but they sound good to me. There are other variations worth trying such as overlapping sequences 1 and 2, or using adjacent or progressive bits with sequence 3. Also I'm curious how an alternating sign algebraic expression would sound, perhaps I'll try it. Anyway, I'll keep you posted on my progress with Boolean sequencing in this or a similar thread. Enjoy!
Back to top
View user's profile Send private message Send e-mail
chuckles



Joined: Apr 02, 2007
Posts: 72
Location: San Diego, California

PostPosted: Mon Oct 29, 2007 9:51 am    Post subject: Please keep updating your researches Reply with quote  Mark this post and the followings unread

I finally got a chance to look at and hear some of these ideas, super well done and kudos!
A note about low powered machines: The cpu I ran the boolean_trio on (2.2G Celeron) did get some crackles (even though it only showed 60% CPU). boolean_8bit on the other hand worked just fine with a max average cpu of about 17%.
In any case, I could hear the note sequencers that were being generated and they are good. It just goes to show you don't need complicated algorithms to create musically interesting output...
Back to top
View user's profile Send private message
chuckles



Joined: Apr 02, 2007
Posts: 72
Location: San Diego, California

PostPosted: Mon Oct 29, 2007 9:56 am    Post subject: 1D cellular automata reference Reply with quote  Mark this post and the followings unread

Inventor wrote:
Cellular automata, is that what the 2d automation called "life" is made of? I didn't know you could do that in one dimension.


Well, I'm sure you've already found this reference or another, but
http://en.wikipedia.org/wiki/Cellular_automata#Simplest

of course, the whole article is worth studying as well...

.r.

(hmm...don't know why that URL didn't come out right...I do have disable html and bbcode off...)
Back to top
View user's profile Send private message
blue hell
Site Admin


Joined: Apr 03, 2004
Posts: 24085
Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320

PostPosted: Mon Oct 29, 2007 10:34 am    Post subject: Re: 1D cellular automata reference Reply with quote  Mark this post and the followings unread

chuckles wrote :

"(hmm...don't know why that URL didn't come out right...I do have disable html and bbcode off...)"



URLs are bit tricky, sometimes the forum doesn't understand 'm. I edited out the URL tags you put in and now it's OK ... I hope .. but Wikipedia seems down ...

It could be that the full form :

[url=http_etc]link text[/url]

would have worked here, but that doesn't always work either. The URL you used has a # in it, maybe that's the problem ... URLs with question marks are troublesome quite often.

What nearly always works is

<A href="the url" target="new_window">link text</A>

For short links it's easiest to just type the URL like http://www.example.com and the forum software will make it into a link. For long URLs this can be annoying though as the page layout can get very wide.

Sometimes it needs a bit of experimentation what works out best.

_________________
Jan
also .. could someone please turn down the thermostat a bit.
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Back to top
View user's profile Send private message Visit poster's website
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Mon Oct 29, 2007 11:59 am    Post subject: Re: Please keep updating your researches Reply with quote  Mark this post and the followings unread

chuckles wrote:

A note about low powered machines: The cpu I ran the boolean_trio on (2.2G Celeron) did get some crackles (even though it only showed 60% CPU). boolean_8bit on the other hand worked just fine with a max average cpu of about 17%.


I'd try increasing the size of the buffer, see "chuck --help" for the exact syntax, it's likely stray processes on the same computer interrupting and being rude about it, with a larger buffer you have more "headroom" for such things. Sadly that will mean more latency, if you need crackle-free performance with low latency I fear the only way to get it will be to tune your OS, meaning killing anything that might be "rude" in that way (can be fun, can be cause for a re-install, proceed with caution).

About 1d cellular automata; they are less well known then Conway's life but quite interesting. You do get to use a second dimension to indicate the thing's history and if you do you get patterns that look a lot like some patterns that occur in nature. Stephen Wolfram wrote more about this then most people would call "sensible".... And of course it's quite sad that mr Conway's "real" work on number theory is virtually unknown compared to his funny little game. Oh, well, that's how it goes.

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kijjaz



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Tue Oct 30, 2007 7:27 am    Post subject: Reply with quote  Mark this post and the followings unread

This one is one of the pattern we see out of a binary 1D cellular automata
Using a size=16 array, this

Code:
// 2D Sierpinski from a 1D cellular automata generation: Example
// by kijjaz (kijjaz@yahoo.com)
// feel free to use and modify and share.

// prepare int tables for 1-Dimension cellular automata
int table[16];
int table_new[16];

// set initial status (modify this to see different start patterns)
1 => table[0] => table[4] => table[5];

while(true)
{
   // display table content
   <<< table[0], table[1], table[2], table[3], table[4], table[5], table[6], table[7],
   table[8], table[9], table[10], table[11], table[12], table[13], table[14], table[15] >>>;

   for(int i; i < 16; i++) 0 => table_new[i]; // reset "new" table

   // apply a cellular automata rule
   // if the cell is dead (value == 0), any alive cell (value == 1) adjacent to the cell can make it becomes alive
   // but if the cell is alive, living without any other neighbors will make it die from loneliness and living with 2 neighbors will make it die from starvation
   for(int i; i < 16; i++)
   if (table[i] == 0) table[(i - 1 + 16) % 16] | table[(i + 1 + 16) % 16] => table_new[i];
   else table[(i - 1 + 16) % 16] ^ table[(i + 1 + 16) % 16] => table_new[i];
   // NOTE: using (i + n + 16) % 16 will wrap the table around

   for(int i; i < 16; i++) table_new[i] => table[i]; // update table
   .5::second => now;
}


We can notice easily from the result that it keeps going on.
This is quite fun for generating grooves.
Adding up these bits give a lovely result also
(Also good for melody and chords)

I consider this a nice pattern to play with and modify.
we can turn this into a more crazy system.
the idea is quite similar to the poppular rules in Conway's Game of Life.

Code:
1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0
0 1 0 1 1 1 1 0 0 0 0 0 0 0 0 1
1 0 1 1 0 0 1 1 0 0 0 0 0 0 1 0
0 1 1 1 1 1 1 1 1 0 0 0 0 1 0 1
1 1 0 0 0 0 0 0 1 1 0 0 1 0 1 0
1 1 1 0 0 0 0 1 1 1 1 1 0 1 0 1
0 0 1 1 0 0 1 1 0 0 0 1 1 0 1 1
1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1
0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0
0 0 0 0 0 0 0 1 1 0 1 1 0 0 0 0
0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0
0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 0
0 0 0 0 1 1 1 1 0 0 0 1 1 1 1 0
0 0 0 1 1 0 0 1 1 0 1 1 0 0 1 1
1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0
1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1
1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1
0 0 0 0 1 1 0 0 0 0 0 0 0 1 1 0
0 0 0 1 1 1 1 0 0 0 0 0 1 1 1 1
1 0 1 1 0 0 1 1 0 0 0 1 1 0 0 1
1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1
0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0
0 0 0 0 0 0 0 1 1 0 1 1 0 0 0 0
0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0
0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 0
0 0 0 0 1 1 1 1 0 0 0 1 1 1 1 0
0 0 0 1 1 0 0 1 1 0 1 1 0 0 1 1
1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0
1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1
... etc ...


Inventor: Oh!! and these patterns create really cool graphics hahah
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Tue Oct 30, 2007 9:12 am    Post subject: Reply with quote  Mark this post and the followings unread

Kijjaz, those exact patterns are the ones that you can find on real sea-shells.

Steven Levy wrote a book on "artificial life" in the early-mid 90's that has quite a bit of info on the discovery of these but there is also plenty out there on the web... with pretty pictures! :¬)

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 267

PostPosted: Tue Oct 30, 2007 10:10 am    Post subject: Reply with quote  Mark this post and the followings unread

kijjaz wrote:
Inventor: Oh!! and these patterns create really cool graphics hahah


Hmmm... If we have a CA instrument then we can make a scrolling seashell out of the CA bits that are currently being played. Nice idea, kijjaz!

I am currently working on a "Zeus on the Mountain" video, featuring the lightning that I generated from an FFT, but it isn't working out well. Perhaps I will do something with CA instead...
Back to top
View user's profile Send private message Send e-mail
blue hell
Site Admin


Joined: Apr 03, 2004
Posts: 24085
Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320

PostPosted: Tue Oct 30, 2007 1:59 pm    Post subject: Reply with quote  Mark this post and the followings unread

I had to do a translation to see what the pattern looks like, thought I might post it just as well :

Code:

X       X X                   
  X   X X X X                 X
X   X X     X X             X 
  X X X X X X X X         X   X
X X             X X     X   X 
X X X         X X X X X   X   X
    X X     X X       X X   X X
X X X X X X X X X   X X X X X X
                X X X         
              X X   X X       
            X X X X X X X     
          X X           X X   
        X X X X       X X X X 
      X X     X X   X X     X X
X   X X X X X X X X X X X X X X
X X X                         
X   X X                       X
X X X X X                   X X
        X X               X X 
      X X X X           X X X X
X   X X     X X       X X     X
X X X X X X X X X   X X X X X X
                X X X         
              X X   X X       
            X X X X X X X     
          X X           X X   
        X X X X       X X X X 
      X X     X X   X X     X X
X   X X X X X X X X X X X X X X
X X X                         
X   X X                       X


This might be nice indeed for texture mapping on shell shapes.

_________________
Jan
also .. could someone please turn down the thermostat a bit.
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Back to top
View user's profile Send private message Visit poster's website
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 267

PostPosted: Fri Nov 02, 2007 2:17 am    Post subject: Reply with quote  Mark this post and the followings unread

Here is kind of a spooky sound for a late Halloween, It is made from Noise => BPF => JCRev => dac. It's amazing what you can do with just plain old noise!


Code:
// noise_lab1.ck
// copyright 2007 Les Hall
// This code is protected by the GNU General Public License
// Evaluates test expressions for creating noise songs

// parameters
1 => int noise; // select which noise
                // 0:  no noise
                // 1:  noise
1.00 => float noise_gainR;   // right gain of noise
1.00 => float noise_gainL;   // left gain of noise
2 => int n;  // counting base
100 => float base_freq;  // all freqencies are multiplied by this
8 => float notes_per_second;  // the timing

Noise A;
A => BPF f => JCRev r1 => Gain g_noise_right => dac.right;
A => f => JCRev r2 => Gain g_noise_left => dac.left;
A.gain(100);
f.Q(1000);
r1.mix(0.2);
r2.mix(0.2);
g_noise_right.gain(noise_gainR);
g_noise_left.gain(noise_gainL);

// declare variables
float freq;  // the frequency multiplier of the next note of the instrument

// time loop
for (0 => int j15; j15 < n; j15++) { for (0 => int j14; j14 < n; j14++) {
for (0 => int j13; j13 < n; j13++) { for (0 => int j12; j12 < n; j12++) {
for (0 => int j11; j11 < n; j11++) { for (0 => int j10; j10 < n; j10++) {
for (0 => int j9; j9 < n; j9++) { for (0 => int j8; j8 < n; j8++) {
for (0 => int j7; j7 < n; j7++) { for (0 => int j6; j6 < n; j6++) {
for (0 => int j5; j5 < n; j5++) { for (0 => int j4; j4 < n; j4++) {
for (0 => int j3; j3 < n; j3++) { for (0 => int j2; j2 < n; j2++) {
for (0 => int j1; j1 < n; j1++) { for (0 => int j0; j0 < n; j0++) {

// noise
if (noise == 1) {
    if (j11&j10 ^ j9&j8 ^ j7&j6 ^ j5&j4 ^ j3&j2 ^ j1&j0) {
        f.freq((7+j11-j10+j9-j8+j7-j6+j5-j4+j3-j2+j1-j0) / 2.0 * base_freq);
    }
}

// advance time
1::second / notes_per_second => now;

} } } } } } } } } } } } } } } }
Back to top
View user's profile Send private message Send e-mail
apalomba



Joined: Nov 01, 2007
Posts: 4
Location: Austin, TX

PostPosted: Tue May 06, 2008 9:24 am    Post subject: Reply with quote  Mark this post and the followings unread

Hey Inventor, I just recently discovered this thread. I find it very
interesting. I am quite impressed at the results one can get with this
technique of sequencing.

I have some questions about the Chuck source code. In Boolean_Trio,
the line...

for (0 => int j1; j1 <n> s1.gain; ...

Does this act as some kind of shift register? Why are you setting the
gain here?

Can you explain the the "logic threshold" means?
// calculate the logic threshold
(n-1) / 2.0 => float t;



Thanks,
Anthony
Back to top
View user's profile Send private message
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 267

PostPosted: Tue May 06, 2008 8:24 pm    Post subject: Reply with quote  Mark this post and the followings unread

apalomba wrote:
I have some questions about the Chuck source code. In Boolean_Trio,
the line...

for (0 => int j1; j1 <n> s1.gain; ...

Does this act as some kind of shift register? Why are you setting the
gain here?

Can you explain the the "logic threshold" means?
// calculate the logic threshold
(n-1) / 2.0 => float t;

Thanks,
Anthony


Actually that <n> occurs when we accidentally post code without turning off the HTML. The forum software then interprets code as html and hoses it up. I attached a copy of Boolean_Trio for you to use if you like.

The logic threshold is sort of broken. It works in binary, and it was intended for using base counts greater than two. The idea was to fashion rules for Boolean Algebra when the inputs can be base 3, base 4, etc. I don't really use it anymore, though it remains in the software as an artifact. I'd just ignore it and use base 2 cause that's all you need really, the higher bases get really repetetive.

Thanks for looking at my work, I'm glad you are enjoying it!


Boolean_Trio2.ck
 Description:
The latest Boolean Trio.

Download
 Filename:  Boolean_Trio2.ck
 Filesize:  3.36 KB
 Downloaded:  243 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: Kassen
Page 1 of 1 [23 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