Author |
Message |
jbum

Joined: Oct 24, 2006 Posts: 26 Location: Los Angeles
|
Posted: Tue Oct 31, 2006 2:57 pm Post subject:
Whitney Music Box Subject description: Some sample ChucK source code for producing this piece. |
 |
|
Hi Folks,
Thought you might like some sample ChucK code for playing with the Whitney Music Box algorithm. Here it is.
http://www.coverpop.com/whitney/whitney.ck.html
For a visualization of what is going on, check this link:
http://www.coverpop.com/whitney/
Code: |
// Whitney Music Box
//
// Jim Bumgardner jbum@jbum.com
48 => int nbrDots;
55 => float baseFreq;
180 => float durationOfPiece;
2.0/nbrDots => float dotGain;
fun void whitneyDot(float baseFreq, float secs, int nDots)
{
StifKarp voc => dac;
dotGain => voc.gain;
for (0 => int i; i < nDots; ++i)
{
baseFreq => voc.freq;
1 => voc.noteOn;
secs::second => now;
1 => voc.noteOff;
}
}
// Sample Chromatic Pitch Function
fun float pitchFuncC(float baseFreq, int noteIdx)
{
return baseFreq*Math.pow(2,noteIdx/12.0);
}
// Sample Reversed Harmonics Pitch Function
fun float pitchFuncH(float baseFreq, int noteIdx)
{
return baseFreq*(nbrDots-noteIdx);
}
for (0 => int i; i < nbrDots; ++i)
{
spork ~ whitneyDot(pitchFuncC(baseFreq,i), durationOfPiece/(i+1), i+1);
}
durationOfPiece::second => now;
|
_________________ <a href="http://www.krazydad.com/">krazydad.com</a> |
|
Back to top
|
|
 |
jbum

Joined: Oct 24, 2006 Posts: 26 Location: Los Angeles
|
Posted: Wed Nov 01, 2006 4:22 pm Post subject:
|
 |
|
Here's an alternate version which uses a SinOsc with a pluck-like envelope, and which uses more dots and harmonic pitches.
Note: I'm wishing there was a built-in ugen in ChucK for producing non-linear envelopes ala the CSound linen function - it would greatly simplify or eliminate the playNote() function in this code.
This version is nearly fast enough for real-time on my computer (unlike the last version).
Code: |
// Whitney Music Box - sine waves with pluckish envelope
//
// Jim Bumgardner jbum@jbum.com
120 => int nbrDots;
20 => float baseFreq;
180 => float durationOfPiece;
2.0/nbrDots => float dotGain;
fun void playNote(float freq, float amp)
{
SinOsc voc => dac;
freq => voc.freq;
1 => int attack;
1/65536.0 => float myGain;
myGain => voc.gain;
while (attack || myGain > .001)
{
10::ms => now;
if (attack) {
myGain*1.25 => myGain => voc.gain;
if (myGain >= amp) {
0 => attack;
}
}
else {
myGain*.99 => myGain => voc.gain;
}
}
}
fun void whitneyDot(float baseFreq, float secs, int nDots)
{
for (0 => int i; i < nDots; ++i)
{
spork ~ playNote(baseFreq, dotGain);
secs::second => now;
}
}
// Sample Chromatic Pitch Function
fun float pitchFuncC(float baseFreq, int noteIdx)
{
return baseFreq*Math.pow(2,noteIdx/12.0);
}
// Sample Reversed Harmonics Pitch Function
fun float pitchFuncH(float baseFreq, int noteIdx)
{
return baseFreq*(nbrDots-noteIdx);
}
for (0 => int i; i < nbrDots; ++i)
{
spork ~ whitneyDot(pitchFuncH(baseFreq,i), durationOfPiece/(i+1), i+1);
}
durationOfPiece::second => now;
|
_________________ <a href="http://www.krazydad.com/">krazydad.com</a> |
|
Back to top
|
|
 |
majutsu

Joined: Jun 18, 2006 Posts: 151 Location: New York
Audio files: 1
|
Posted: Wed Nov 01, 2006 4:27 pm Post subject:
|
 |
|
thanks for sharing
interesting _________________ All phenomena are atoms in association and dissociation. |
|
Back to top
|
|
 |
jbum

Joined: Oct 24, 2006 Posts: 26 Location: Los Angeles
|
|
Back to top
|
|
 |
cebec

Joined: Apr 19, 2004 Posts: 1089 Location: Virginia
Audio files: 3
G2 patch files: 31
|
Posted: Sun Nov 05, 2006 1:48 pm Post subject:
|
 |
|
cool stuff! |
|
Back to top
|
|
 |
|