#!/usr/bin/perl -w #Rain.pl - Computer Music Composition by Jacob T. Joaquin #Copyright (C) 2001 Jacob T. Joaquin # #This program is free software; you can redistribute it and/or #modify it under the terms of the GNU General Public License #as published by the Free Software Foundation; either version 2 #of the License, or (at your option) any later version. # #This program is distributed in the hope that it will be useful, #but WITHOUT ANY WARRANTY; without even the implied warranty of #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #GNU General Public License for more details. # #You should have received a copy of the GNU General Public License #along with this program; if not, write to the Free Software #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. use strict; use Rain; use ComputerMusic; use Chaos; # Declare path and files my $path = "./"; # path of generated .orc file my $fileOrc = "Rain.orc"; # generated filename my $fileSco = "Rain.sco"; # generated filename my $gpl = ";Rain.sco - Csound Score to Rain, a composition by Jacob T. Joaquin ;Copyright (C) 2001 Jacob T. Joaquin ; ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either version 2 ;of the License, or (at your option) any later version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ;email: imjake\@nyc.rr.com "; open(SCO, "> $path$fileSco") or die "Couldn't open $fileOrc for writing: $!\n"; print SCO $gpl; print SCO "f1 0 8192 10 1\n\n"; #---------------- Globals my $centerPitch = 420; my $voice1Reverb = 0.125; my $voice2Reverb = 0.05; my $ampScale = 3; my $voice1Amp = 0.1 * $ampScale; my $voice2Amp = 0.1 * $ampScale; #---------------- timeMap my %t; $t{start} = 0.5 ; # start time $t{intro_A} = $t{start} + 20.0 ; # Fade the Rate Fast to Slow $t{intro_B} = $t{intro_A} + 60.0 ; # Steady slow rate $t{intro_C} = $t{intro_B} + 120.0 ; # increase duration of harmonics $t{sec_A_0} = $t{intro_C} + 4.0 ; # increase duration of harmonics $t{sec_A_1} = $t{sec_A_0} + 45.0 ; # increase duration of harmonics $t{sec_A_2} = $t{sec_A_1} + 15.0 ; # increase v2 rate, reduce v2 amp $t{sec_A_3} = $t{sec_A_2} + 120.0 ; # just voice 1 $t{sec_B_0} = $t{sec_A_3} + 3.0 ; # just voice 1 $t{sec_B_1} = $t{sec_B_0} + 15.0 ; # just voice 1 $t{sec_B_2} = $t{sec_B_1} + 2.0 ; # just voice 1 $t{sec_B_3} = $t{sec_B_2} + 30.0 ; # just voice 1 $t{sec_C_0} = $t{sec_B_3} + 2.0 ; # just voice 1 $t{sec_C_1} = $t{sec_C_0} + 45.0 ; # just voice 1 my $revTime = $t{sec_C_1} + 8; print SCO "i106 0 $revTime 1 0.25 3.0 1.1 0.8\n\n"; print SCO "i106 0 $revTime 2 0.25 3.1 1.0 0.2\n\n"; print "start\t" . timeStamp( $t{start} ) . "\n"; print "intro_A\t" . timeStamp( $t{intro_A} ) . "\n"; print "intro_B\t" . timeStamp( $t{intro_B} ) . "\n"; print "intro_C\t" . timeStamp( $t{intro_C} ) . "\n"; print "sec_A_0\t" . timeStamp( $t{sec_A_0} ) . "\n"; print "sec_A_1\t" . timeStamp( $t{sec_A_1} ) . "\n"; print "sec_A_2\t" . timeStamp( $t{sec_A_2} ) . "\n"; print "sec_A_3\t" . timeStamp( $t{sec_A_3} ) . "\n"; print "sec_B_0\t" . timeStamp( $t{sec_B_0} ) . "\n"; print "sec_B_1\t" . timeStamp( $t{sec_B_1} ) . "\n"; print "sec_B_2\t" . timeStamp( $t{sec_B_2} ) . "\n"; print "sec_B_3\t" . timeStamp( $t{sec_B_3} ) . "\n"; print "sec_C_0\t" . timeStamp( $t{sec_C_0} ) . "\n"; print "sec_C_1\t" . timeStamp( $t{sec_C_1} ) . "\n"; sub timeStamp { my $return .= int($_[0] / 60) . ":"; if (($_[0] % 60) < 10) { $return .= "0" } $return .= sprintf "%d", $_[0] % 60; return $return; } #------------ distantDrip #-------- Setup my $voice1 = Rain->new(); my $voice1Chaos = Chaos->new(0.5, 0.5); $voice1->duration(0.192); $voice1->lag(0.015); $voice1->attack(0.005); $voice1->amp(0.2); $voice1->pitch($centerPitch*1.5); $voice1->slope(1); my $voice1nHarm = 3; my $reverbCode = "$voice1->reverbMix((1 - (($voice1->nHarmonics()-1)/($voice1nHarm))) * $voice1Reverb)"; my $s1 = 0.6; my $s2 = 0.4; #---- TESTING GROUND while(0){ my $counter = $t{start}; while($counter < $t{intro_A}){ $voice1nHarm = ComputerMusic::interpolateExp($counter, $t{start}, $t{intro_A}, 8, 4, 8); $voice1->pan(rand()); $voice1->nHarmonics(int($voice1nHarm)); $voice1->slope(rand()); eval $reverbCode; $voice1->amp($voice1Amp * $voice1->slope()); print SCO $voice1->score($counter); $counter += $voice1Chaos->normalized() * 0.75; } $voice1nHarm = 4; } #---- Section: intro_A my $counter = $t{start}; while($counter < $t{intro_A}){ $voice1nHarm = ComputerMusic::interpolateExp($counter, $t{start}, $t{intro_A}, 8, 4, 8); $voice1->pan(rand()); $voice1->nHarmonics(int($voice1nHarm)); $voice1->slope(rand($s1)+$s2); eval $reverbCode; $voice1->amp($voice1Amp * $voice1->slope()); print SCO $voice1->score($counter); $counter += $voice1Chaos->normalized() * ComputerMusic::interpolateExp($counter, $t{start}, $t{intro_A}, 4, 2, 16); } $voice1nHarm = 4; #---- Section: intro_B while($counter < $t{intro_B}){ $voice1nHarm = ComputerMusic::interpolateExp($counter, $t{intro_A}, $t{intro_B}, 4, 8, -3); $voice1->pan(rand()); $voice1->nHarmonics(int($voice1nHarm)); $voice1->slope(rand($s1)+$s2); eval $reverbCode; $voice1->amp($voice1Amp * $voice1->slope()); print SCO $voice1->score($counter); $counter += $voice1Chaos->normalized() * 2; } $voice1nHarm = 8; #---- Section: intro_C my $voice1dur; my $ampTemp; my $step = 1.0594630943593; while($counter < $t{intro_C}){ $voice1->pitch($centerPitch*1.5); # $voice1->bend(1); if ($counter > 120) { unless( int(rand(8)) ){ $voice1->pitch($centerPitch*1.5/$step/$step); # $voice1->bend(rand(0.2)+0.9); print "*"; } } $voice1nHarm = ComputerMusic::interpolateExp($counter, $t{intro_B}, $t{intro_C}, 8, 4, 8); $voice1dur = ComputerMusic::interpolateExp($counter, $t{intro_B}, $t{intro_C}, 0.192, 0.45, -3); $ampTemp = 1; unless(int(rand(8))) {$voice1dur *= rand(2) + 1; $ampTemp = 0.75 }; $voice1->duration($voice1dur); $voice1->pan(rand()); $voice1->nHarmonics(int($voice1nHarm)); $voice1->slope(rand($s1)+$s2); eval $reverbCode; $voice1->amp($voice1Amp * $voice1->slope() * $ampTemp); print SCO $voice1->score($counter); $counter += $voice1Chaos->normalized() * ComputerMusic::interpolateExp($counter, $t{intro_B}, $t{intro_C}, 2, 1.8, -8); } $voice1nHarm = 4; $voice1->pitch($centerPitch*1.5); $voice1->bend(1); #---- Section: Sec_A_0 my $voice2 = Rain->new(); my $voice2Chaos = Chaos->new(0.5, 0.5); $voice2->duration(0.392); $voice2->lag(.025); $voice2->attack(0.005); $voice2->nHarmonics(16); $voice2->amp(0.2); $voice2->pitch($centerPitch); my $voice2nHarm = 4; #-- Voice 2 my $counter2 = $t{intro_C}; while($counter2 < $t{sec_A_0}){ $voice2nHarm = ComputerMusic::interpolateExp($counter2, $t{intro_C}, $t{sec_A_0}, 4, 24, 8); $voice2->pan(rand()); $voice2->nHarmonics(rand($voice2nHarm) + 1); $voice2->amp(sqrt($voice2->nHarmonics() / $voice2nHarm) * $voice2Amp); print SCO $voice2->score($counter2); $counter2 += $voice1Chaos->normalized() * ComputerMusic::interpolateExp($counter2, $t{intro_C}, $t{sec_A_0}, 0.125, 1.333, -4); } $voice2nHarm = 24; #---- Section: Sec_A_1 #-- Voice 1 while($counter < $t{sec_A_1}){ $voice1nHarm = ComputerMusic::interpolateExp($counter, $t{intro_C}, $t{sec_A_1}, 16, 8, 8); $voice1dur = ComputerMusic::interpolateExp($counter, $t{intro_C}, $t{sec_A_01}, 0.45, 0.3, -3); $voice1->duration($voice1dur); $voice1->pan(rand()); $voice1->nHarmonics(int($voice1nHarm)); $voice1->slope(rand($s1)+$s2); eval $reverbCode; $voice1->amp($voice1Amp * $voice1->slope()); print SCO $voice1->score($counter); $counter += $voice1Chaos->normalized() * ComputerMusic::interpolateExp($counter, $t{intro_C}, $t{sec_A_1}, 1.8, 2.2, -8); } $voice1nHarm = 4; #-- Voice 2 my $voice2dur; while($counter2 < $t{sec_A_1}){ $voice2dur = 0.192; unless(int(rand(12))) {$voice2dur *= rand(4) + 1 }; $voice2->duration($voice2dur); $voice2->pan(rand()); $voice2->nHarmonics(rand($voice2nHarm) + 1); $voice2->amp(sqrt($voice2->nHarmonics() / $voice2nHarm) * $voice2Amp); print SCO $voice2->score($counter2); $counter2 += $voice1Chaos->normalized() * ComputerMusic::interpolateExp($counter2, $t{sec_A_0}, $t{sec_A_1}, 1.333, 0.5, -2); } #---- Section: Sec_A_2 #-- Voice 1 while($counter < $t{sec_A_2}){ $voice1nHarm = ComputerMusic::interpolateExp($counter, $t{sec_A_1}, $t{sec_A_2}, 16, 8, 8); $voice1dur = ComputerMusic::interpolateExp($counter, $t{sec_A_1}, $t{sec_A_2}, 0.3, 0.192, -3); $voice1->duration($voice1dur); $voice1->pan(rand()); $voice1->nHarmonics(int($voice1nHarm)); $voice1->slope(rand($s1)+$s2); eval $reverbCode; $voice1->amp($voice1Amp * $voice1->slope()); print SCO $voice1->score($counter); $counter += $voice1Chaos->normalized() * ComputerMusic::interpolateExp($counter, $t{sec_A_1}, $t{sec_A_2}, 1.8, 1.0, -8); } #-- Voice 2 my $voice2Pan = 0; $voice2dur = 0.192; $voice2->duration($voice2dur); my $voice2AmpTemp; while($counter2 < $t{sec_A_2}){ $voice2nHarm = ComputerMusic::interpolateExp($counter2, $t{sec_A_1}, $t{sec_A_2}, 24, 4, 8); $voice2Pan = ComputerMusic::interpolateExp($counter2, $t{sec_A_1}, $t{sec_A_2}, 0.0, 1.0, 1); $voice2->pan($voice2Pan); $voice2->nHarmonics(rand($voice2nHarm) + 1); $voice2AmpTemp = ComputerMusic::interpolateExp($counter2, $t{sec_A_1}, $t{sec_A_2}, 0.125, 0.05, 8); $voice2->amp(sqrt($voice2->nHarmonics() / $voice2nHarm) * $voice2AmpTemp); print SCO $voice2->score($counter2); $counter2 += $voice1Chaos->normalized() * ComputerMusic::interpolateExp($counter2, $t{sec_A_1}, $t{sec_A_2}, 0.5, 0.0625, 2); } undef $counter2; #---- Section: Sec_A_3 #-- Voice 1 $voice1->duration(0.192); while($counter < $t{sec_A_3}){ $voice1->pitch($centerPitch*1.5); # $voice1->bend(1); if ($counter > 285) { unless( int(rand(4)) ){ if (int(rand(2))) { $voice1->pitch($centerPitch*1.5/$step/$step) } else { $voice1->pitch($centerPitch*1.5/$step/$step/$step) } # $voice1->bend(rand(0.05)+0.975); print "."; } } $voice1nHarm = ComputerMusic::interpolateExp($counter, $t{sec_A_2}, $t{sec_A_3}, 8, 4, 2); $voice1->pan(rand()); $voice1->nHarmonics(int($voice1nHarm)); $voice1->slope(rand($s1)+$s2); eval $reverbCode; $voice1->amp($voice1Amp * $voice1->slope()); print SCO $voice1->score($counter); $counter += $voice1Chaos->normalized() * ComputerMusic::interpolateExp($counter, $t{sec_A_2}, $t{sec_A_3}, 1.0, 3, -8); } $voice1nHarm = 4; $voice1->pitch($centerPitch*1.5); #$voice1->bend(1); #---- Section: Sec_B_0 #-- Voice 1 $voice1->duration(0.192); while($counter < $t{sec_B_0}){ $voice1->pan(rand()); $voice1->nHarmonics(int($voice1nHarm)); $voice1->slope(rand($s1)+$s2); eval $reverbCode; $voice1->amp($voice1Amp * $voice1->slope()); print SCO $voice1->score($counter); $counter += $voice1Chaos->normalized() * ComputerMusic::interpolateExp($counter, $t{sec_A_3}, $t{sec_B_0}, 3, 1.5, -8); } #-- Voice 2 $voice2dur = 0.192; $voice2->duration($voice2dur); $voice2nHarm = 24; $counter2 = $t{sec_A_3}; $voice2Amp *= 0.75; while($counter2 < $t{sec_B_0}){ $voice2->pan(rand()); $voice2->nHarmonics(rand($voice2nHarm) + 1); $voice2->amp(sqrt($voice2->nHarmonics() / $voice2nHarm) * $voice2Amp); print SCO $voice2->score($counter2); $counter2 += $voice1Chaos->normalized() * ComputerMusic::interpolateExp($counter2, $t{sec_A_3}, $t{sec_B_0}, 1.5, 0.25, -8); } undef $counter2; #---- Section: Sec_B_1 #-- Voice 1 $voice1->duration(0.192); while($counter < $t{sec_B_1}){ $voice1->pan(rand()); $voice1->nHarmonics(rand($voice1nHarm) + 1); eval $reverbCode; $voice1->amp(sqrt($voice1->nHarmonics() / $voice1nHarm) * $voice1Amp); print SCO $voice1->score($counter); $counter += $voice1Chaos->normalized() * ComputerMusic::interpolateExp($counter, $t{sec_B_0}, $t{sec_B_1}, 1, 0.8, -8); } #---- Section: Sec_B_2 #-- Voice 1 $voice1->duration(0.192); while($counter < $t{sec_B_2}){ $voice1->pan(rand()); $voice1->nHarmonics(rand($voice1nHarm) + 1); eval $reverbCode; $voice1->amp(sqrt($voice1->nHarmonics() / $voice1nHarm) * $voice1Amp); print SCO $voice1->score($counter); $counter += $voice1Chaos->normalized() * ComputerMusic::interpolateExp($counter, $t{sec_B_1}, $t{sec_B_2}, 0.8, 0.5, -8); } #-- Voice 2 $counter2 = $t{sec_B_1}; $voice2Amp *= 1.1; while($counter2 < $t{sec_B_2}){ $voice2->pan(rand()); $voice2->nHarmonics(rand($voice2nHarm) + 1); $voice2->amp(sqrt($voice2->nHarmonics() / $voice2nHarm) * $voice2Amp); print SCO $voice2->score($counter2); $counter2 += $voice1Chaos->normalized() * ComputerMusic::interpolateExp($counter2, $t{sec_B_1}, $t{sec_B_2}, 1.5, 0.25, -16); } undef $counter2; #---- Section: Sec_B_3 #-- Voice 1 $voice1->duration(0.192); while($counter < $t{sec_B_3}){ $voice1->pan(rand()); $voice1->nHarmonics(rand($voice1nHarm) + 1); eval $reverbCode; $voice1->amp(sqrt($voice1->nHarmonics() / $voice1nHarm) * $voice1Amp); print SCO $voice1->score($counter); $counter += $voice1Chaos->normalized() * ComputerMusic::interpolateExp($counter, $t{sec_B_2}, $t{sec_B_3}, 0.5, 1.25, -8); } #---- Section: Sec_C_0 #-- Voice 1 while($counter < $t{sec_C_0}){ $voice1->pan(rand()); $voice1->nHarmonics(int($voice1nHarm)); $voice1->slope(rand($s1)+$s2); eval $reverbCode; $voice1->amp($voice1Amp * $voice1->slope()); print SCO $voice1->score($counter); $counter += $voice1Chaos->normalized() * ComputerMusic::interpolateExp($counter, $t{sec_B_3}, $t{sec_C_0}, 1.25, 1, -8); } #-- Voice 2 $counter2 = $t{sec_B_3}; $voice2Amp *= 0.8; my $voice2Pitch; while($counter2 < $t{sec_C_0}){ $voice2Pitch = ComputerMusic::interpolateExp($counter2, $t{sec_B_3}, $t{sec_C_0}, $centerPitch * 0.5, $centerPitch, 1); $voice2->pitch($voice2Pitch); $voice2->pan(rand()); $voice2->nHarmonics(rand($voice2nHarm) + 1); $voice2->amp(sqrt($voice2->nHarmonics() / $voice2nHarm) * $voice2Amp); print SCO $voice2->score($counter2); $counter2 += $voice1Chaos->normalized() * ComputerMusic::interpolateExp($counter2, $t{sec_B_3}, $t{sec_C_0}, 0.0625, 0.3125, -2); } $voice2->pitch($centerPitch); #---- Section: Sec_C_0 #-- Voice 1 while($counter < $t{sec_C_0}){ $voice1->pan(rand()); $voice1->nHarmonics(int($voice1nHarm)); $voice1->slope(rand($s1)+$s2); eval $reverbCode; $voice1->amp($voice1Amp * $voice1->slope()); print SCO $voice1->score($counter); $counter += $voice1Chaos->normalized() * ComputerMusic::interpolateExp($counter, $t{sec_B_3}, $t{sec_C_0}, 1, 3, -8); } #-- Voice 2 #$voice2Amp *= 0.8; while($counter2 < $t{sec_C_1}){ $voice2->pan(rand()); $voice2nHarm = ComputerMusic::interpolateExp($counter2, $t{sec_C_0}, $t{sec_C_1}, 24, 4, 8); $voice2->nHarmonics(rand($voice2nHarm) + 1); $voice2->slope( ComputerMusic::interpolateExp($counter2, $t{sec_C_0}, $t{sec_C_1}, 1, 0.8, -4) ); $voice2AmpTemp = ComputerMusic::interpolateExp($counter2, $t{sec_C_0}, $t{sec_C_1}, $voice2Amp, 0, -4); $voice2->amp(sqrt($voice2->nHarmonics() / $voice2nHarm) * $voice2AmpTemp); print SCO $voice2->score($counter2); $counter2 += $voice1Chaos->normalized() * 0.3125; } $voice2->pitch($centerPitch); close SCO;