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 » ChucK programming language
Whitney Music Box
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [5 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
jbum



Joined: Oct 24, 2006
Posts: 26
Location: Los Angeles

PostPosted: Tue Oct 31, 2006 2:57 pm    Post subject: Whitney Music Box
Subject description: Some sample ChucK source code for producing this piece.
Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Visit poster's website
jbum



Joined: Oct 24, 2006
Posts: 26
Location: Los Angeles

PostPosted: Wed Nov 01, 2006 4:22 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Visit poster's website
majutsu



Joined: Jun 18, 2006
Posts: 151
Location: New York
Audio files: 1

PostPosted: Wed Nov 01, 2006 4:27 pm    Post subject: Reply with quote  Mark this post and the followings unread

thanks for sharing
interesting

_________________
All phenomena are atoms in association and dissociation.
Back to top
View user's profile Send private message
jbum



Joined: Oct 24, 2006
Posts: 26
Location: Los Angeles

PostPosted: Fri Nov 03, 2006 9:41 pm    Post subject: Reply with quote  Mark this post and the followings unread

I posted a couple new Whitney Box variations in which I used ChucK to generate the sound.

http://www.coverpop.com/whitney/forums.html?var=v19
http://www.coverpop.com/whitney/forums.html?var=v20

For the stereo variation, I recorded the dac.left and dac.right channels separately. I haven't figured out a way to record in stereo directly to WvOut.

_________________
<a href="http://www.krazydad.com/">krazydad.com</a>
Back to top
View user's profile Send private message Visit poster's website
cebec



Joined: Apr 19, 2004
Posts: 1089
Location: Virginia
Audio files: 3
G2 patch files: 31

PostPosted: Sun Nov 05, 2006 1:48 pm    Post subject: Reply with quote  Mark this post and the followings unread

cool stuff!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [5 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