Csound Csound-dev Csound-tekno Search About

Manule Granule Perl Program Orc & Sco

Date1998-05-10 04:30
FromHans Mikelson
SubjectManule Granule Perl Program Orc & Sco
Hi there,

Here is a Perl program for creating scores.  It's set up for a granular type
score right now.

Have fun,
Hans Mikelson

#Perl code
# Generate Score
$scofile="auto.sco";
open (SCO, ">$scofile");
print SCO "f1 0 1024 10 1 .3 .1 0 .2 .02 0 .1 .04\n";

#     Grains  Sta  Fqc  FqcRng
grain(200,    0,   900, .25);
grain(100,    5,   300, .50);
grain(150,    7,   600, .25);
close (SCO);

sub grain
 {
  my $ngrains = $_[0];
  my $strt    = $_[1];
  my $freq    = $_[2];
  my $frange  = $_[3];
  for ( $i=0; $i<$ngrains; $i++)
   {
    $rnd1 = rand(1);
    $sta  = $rnd1*5+$strt;
    $dur  = rand(2)+.01;
    $amp  = 2000;
    $fqc  = rand($frange*$freq)+$freq;
    $pan  = rand(1);
    print SCO "i1 $sta $dur $amp $fqc $pan\n";
   }
 }

; ORCHESTRA
sr = 44100
kr = 4410
ksmps = 10
nchnls=2

     instr  1

kamp linseg 0, p3/2, p4, p3/2, 0           ; Fade in and out
aout oscil  kamp, p5, 1                    ; Simple oscillator
     outs   aout*sqrt(p6), aout*sqrt(1-p6) ; Output with panning

     endin