Train timetables were converted into music. This CD contains music of great variety; electronica, dance, contemporary classical music, experimental metal, chiptune, and even animal screams.
In the sleeve of this CD, I misspelled the URL of JR East website.
| wrong | http://www.jreasttimetable.jp/ |
| correct | http://www.jreast-timetable.jp/ |
One day, I noticed that it should be interesting if railroad timetables were converted into music. Therefore, I made a sample by way of experiment. I used the timetable of JR Shinjuku Station because it has 14 tracks and handles about 1.5 million passengers a day. I found it had musical developments. For example, when the music met rush hours, music got aggressive too. So I decided to make music of all 29 stations on the Yamanote Line.
I converted timetables into music as follows. I treated one minute of a timetable as a sixteenth note, and notes were played at departures of trains.
The pitch of the notes were calculated based on the following expression.
("line ID" × "hour" + "minute") mod "number of tones"
The "line ID" in this expression means which line I used. For example, the line ID of Saikyo Line at Shinjuku Station bound for Omiya is 1. I used timetables on the web site of East Japan Railway Company as of March 23, 2008.
Although some music are dedicated to specific musicians, do not take them seriously, just take them as respects. And most of them (except Ueno Station etc) do not relate to the places of the stations, too. I added intros or outros to some music for musical sake, but I changed neither those pitch nor those timing. They are combined with timetables.
The left woodwinds play in C major, the right woodwinds play in Ab minor. They play tenute once every three times, and perform staccatos strongly as the remainder.
Six taikos play as kumi-daiko. Uses the power of hits as tone series, not those pitches.
Performs a minimal phrase of 7/16 throughout the whole music. The sounds are not performed at the departures of trains. When a train pulls out, the note is selected from the phrase by calculating above expression.
Two moog-like bass synthesizers are played on a TR-808-like drum machine. In this music, Yaoya-san means TR-808.
Every stations on the Yamanote Line has its departure melody. It is the theme of "The Third Man" for Ebisu Station. This music repeats seven notes at the beginning of that theme. Each pair of the lines is played in its own octave.
Six lines on the Shibuya Station are linked to six strings of a guitar. And the pentatonic scale is performed.
Phrases of four demisemiquavers are performed on the in-C like pulse.
Like "Helicopter String Quartet", the quartet is placed opposite order. Phrases go up in the beginning, keep those pitch in the middle stage, and go down in the end.
Uses the chromatic scale as a tone series. Each of 13 lines performs the celesta sound. The faster train departures, the higher octave is used by its note. Auguste Mustel is the inventor of celesta.
Multiple percussions are used as a tone series. And notes are phased, changing the width of the gap according to the time of the timetable.
Repeats a same phrase throughout the whole music, like the Gotanda Station. But in this case, notes are not selected. The phrase change its tempo at the departures of trains.
A performance by a quarter tone piano with its sustain pedal pressed throughout music.
Gagaku - the Japanese classical music - traces its roots to China. This music uses ritsu scale as a tone series. Fast trains are converted to high tones or water sounds.
A Robert Fripp style minimal phrase gets whole tone higher and higher, according to the time of the timetable. The notes are shifted at the departures of trains.
The koto is a harp of Japan and Yatsuhashi Kengyo is the most famous musician of koto. Two lines are mixed into one koto sound. And if departure times are same, the glissando or bending is used.
The sounds are not performed according to the timetable, but are stored. And they are released every 30 minutes of the timetable. If the timings of notes are same, those octaves are shifted.
Instruments are played in the same order of Britten's "Young Person's Guide to the Orchestra". So all Instruments play together after the whip.
A string quartet using open strings only.
Young girls are dancing.
Music made by sampling sounds of Uguisu (Japanese Bushwarbler) and Uguisu-Jo (women announcers in Japanese).
The Ueno Zoo might be the most famous zoo in Japan. 48 animal voices are used as a tone series. All notes except intro and outro are results of the calculation.
Uses Meshuggah-style additive rhythm (four 13s and 12) with down tuned guitars.
This is so-called chiptune with its bass phrase referring some anime songs. And words that otaku girls seems to say are added. Uses Magical 8bit Plug; a VST instrument developed by YMCK.
Uses tone clusters as a tone series. The clusters move semitone up and down at the departures of trains.
Metronome sounds are played at the departures of trains. To avoid overlaps, all sounds are shifted by line ID × 256th note.
A Kechak-style music.
Uses overtones of E, from the first one (165Hz) to the 29th one (4,785Hz). The notes are selected according to the timetable, and performed in order.
Performs rests at the timing of departures.
Its instruments are same as "Quartet for the End of Time", and its tone serieses are same as "Modes of Limited Transposition".
Blank track. There is no philosophical meaning. :-)
Wakkanai Station is the northmost railway station in Japan. Because it has only eight train departures, BACH motif is repeated twice.
Do not worry. I did not convert timetables into music manually. I wrote Perl scripts for each music. Those scripts generated MMLs, and MMLs were converted into MIDI files by MML2MID. Then I imported MIDI files into my music sequencer software and modified them.
Data of timetable are stored in the array named @times. They looks like as follows:
my @times; $times[1]=<<_; 06 25 通快 川 06 34 06 39 通快 川 06 43 武 ....
Hours and minutes are separated by tab. Some lines have additional information about train types.
Please note that trival codes like setting departures, compressing rests, etc. are omitted. And these codes are only for explanation, they may not work.
use strict;
my %all_notes = (
flute_l => [qw(
o5c o5d o5e o5f o5g o5a o5b
o6c o6d o6e o6f o6g o6a o6b
)],
oboe_l => [qw(
o4c o4d o4e o4f o4g o4a o4b
o5c o5d o5e o5f o5g o5a o5b
)],
fagot_l => [qw(
o2c o2d o2e o2f o2g o2a o2b
o3c o3d o3e o3f o3g o3a o3b
)],
horn_l => [qw(
o2c o2d o2e o2f o2g o2a o2b
o3c o3d o3e o3f o3g o3a o3b
o4c o4d o4e o4f o4g o4a o4b
)],
clarinet_l => [qw(
o3c o3d o3e o3f o3g o3a o3b
o4c o4d o4e o4f o4g o4a o4b
o5c o5d o5e o5f o5g o5a o5b
)],
flute_r => [qw(
o4a- o4b- o5c- o5d- o5e- o5f- o5g-
o5a- o5b- o6c- o6d- o6e- o6f- o6g-
)],
oboe_r => [qw(
o4a- o4b- o5c- o5d- o5e- o5f- o5g-
)],
fagot_r => [qw(
o2a- o2b- o3c- o3d- o3e- o3f- o3g-
)],
horn_r => [qw(
o1a- o1b- o2c- o2d- o2e- o2f- o2g-
o2a- o2b- o3c- o3d- o3e- o3f- o3g-
o3a- o3b- o4c- o4d- o4e- o4f- o4g-
)],
clarinet_r => [qw(
o3a- o3b- o4c- o4d- o4e- o4f- o4g-
o4a- o4b- o5c- o5d- o5e- o5f- o5g-
)],
);
my @times;
# snipped
# times are set...
my $mml = '';
for my $i(0 .. $#times) {
# preparing...
my $current_times = $times[$i];
next unless defined $current_times;
my $prev_minutes = 0;
my $prev_oct = '';
my $velocity = 0;
$mml .= sprintf('%s C%d"%d" ', chr(65 + $i), $i, $i) . " \n";
$mml .= chr(65 + $i) . ' ';
# selecting note series
my @notes;
if ($i == 1 || $i == 2) {
@notes = @{$all_notes{'flute' . ($i % 2 ? '_l' : '_r')}} ;
}elsif($i == 3 || $i == 4){
@notes = @{$all_notes{'oboe' . ($i % 2 ? '_l' : '_r')}} ;
}elsif($i == 5 || $i == 6){
@notes = @{$all_notes{'clarinet' . ($i % 2 ? '_l' : '_r')}} ;
}elsif($i == 7 || $i == 8){
@notes = @{$all_notes{'horn' . ($i % 2 ? '_l' : '_r')}} ;
}elsif($i==9 || $i==10){
@notes = @{$all_notes{'fagot' . ($i % 2 ? '_l' : '_r')}} ;
}
foreach my $time(split(/\n/, $current_times)) {
# setting hour, minute and information
my($h, $m, $info) = split(/\s+/, $time);
# cleaning noises
$h =~ tr/0-9//cd;
$m =~ tr/0-9//cd;
# calculating time elapsed
# base time is 4:00
my $minutes = $h * 60 + $m - 4 * 60;
# putting rests
if ($prev_minutes == 0 && $minutes != 0) {
$mml .= 'r16';
}
if ($minutes - $prev_minutes > 1) {
$mml .= 'r16' x ($minutes - $prev_minutes - 1);
}
# selecting note
my $this_note = $notes[($i * $h + $m) % @notes];
# compressing octaves
if ($this_note =~ /^o(\d)/) {
if ($prev_oct == $1) {
$this_note =~ s/^o$1//;
} else {
$prev_oct = $1 ;
}
}
# piano or forte?
# tenuto or staccato?
if ($velocity == 0) {
$this_note = "k64${this_note}";
} elsif ($velocity == 1) {
$this_note = "k96${this_note}";
}
# adding note to mml
$mml .= $this_note . '16';
# misc...
$prev_minutes = $minutes;
$velocity = ($velocity + 1) % 3;
}
$mml .= "\n";
}
use strict;
my @times;
# snipped
# times are set...
my $mml = '';
for my $i(0 .. $#times) {
# preparing...
# snipped
# see the script of Shinagawa Station
foreach my $time(split(/\n/, $current_times)) {
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
# piano or forte?
my $is_loud = ($i * $h + $m ) % 4;
$mml .= $is_loud ? 'k100c16' : 'k44c16';
# misc...
$prev_minutes = $minutes;
}
$mml .= "\n";
}
use strict;
my %riffs = (
l => [qw(o4e o4f+ o4g o4f+ o4a o4g o4f+)],
r => [qw(o4a o4b o5c o4b o5d o5c o4b)],
);
my @times;
# snipped
# times are set...
# saving departures information
my @time_hashes;
for my $i(0 .. $#times) {
my $current_times = $times[$i];
next unless defined $current_times;
$time_hashes[$i] = {};
foreach my $time(split(/\n/, $current_times)) {
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
# the note at this time must be shifted
$time_hashes[$i]->{sprintf('%02d%02d', $h, $m)} = 1;
}
}
my $mml = '';
for my $i(0 .. $#times) {
my $j = 0;
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
# which riff should I use?
my @riff = @{$riffs{$i == 1 ? 'l' : 'r'}};
my $prev_oct = '';
# every minutes has tone
for my $h(4 .. 25) {
for my $m(0 .. 59) {
my $this_note;
if(exists $time_hashes[$i]->{sprintf('%02d%02d', $h, $m)}){
# note at departure is shifted
$this_note = $riff[($j + $i * $h + $m) % @riff];
} else {
$this_note = $riff[$j];
}
$j = ($j + 1) % @riff;
# compressing octaves
# see the script of Shinagawa Station
# misc...
$mml .= $this_note;
}
}
$mml .= "\n";
}
use strict;
my @notes=qw(c c+ d d+ e f f+ g g+ a a+ b);
my @times;
# snipped
# times are set...
my $mml = '';
for my $i(0 .. $#times) {
# preparing...
# snipped
# see the script of Shinagawa Station
foreach my $time(split(/\n/, $current_times)) {
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
# determing note
$mml .= $notes[($i * $h + $m)% @notes] . '16';
# misc...
$prev_minutes=$minutes;
}
$mml .= "\n ";
}
use strict;
my @riff = qw(g g+ a g+ a g+ a);
my @times;
# snipped
# times are set...
# selecting notes
my @time_hashes;
for my $i(0 .. $#times) {
my $current_times = $times[$i];
next unless defined $current_times;
$time_hashes[$i] = {};
foreach my $time(split(/\n/, $current_times)) {
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
# setting note
$time_hashes[$i]->{sprintf('%02d%02d', $h, $m)} = $riff[$j];
# next note will be used
$j = ($j + 1) % @riff;
}
}
my $mml = '';
for my $i(0 .. $#times) {
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
foreach my $time (split(/\n/, $current_times)){
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
# adding note of this time
$mml .= $time_hashes[$i]->{sprintf('%02d%02d', $h, $m)} . '16';
# misc...
$prev_minutes=$minutes;
}
$mml .= "\n";
}
use strict;
my %notes = (
A => [
[qw(o2f+ o2a)],
[qw(o2b o3c)],
[qw(o3e o3f+)],
[qw(o3a o3b)],
[qw(o4c+ o4e)],
[qw(o4f+ o4a)],
],
D => [
[qw(o2b o3d)],
[qw(o3e o3f+)],
[qw(o3a o3b)],
[qw(o4d o4e)],
[qw(o4f+ o4a)],
[qw(o4b o5d)],
],
E => [
[qw(o3c+ o3e)],
[qw(o3f+ o3g+)],
[qw(o3b o4c+)],
[qw(o4e o4f+)],
[qw(o4g+ o4b)],
[qw(o5c+ o5e)],
],
);
my @chords = qw(A A A A D D A A E E D D A A A A);
my @times;
# snipped
# times are set...
# determing chord
my %time_to_chords;
my $chord_position = 0;
for my $h(4 .. 25) {
for my $m(0 .. 59) {
my $time = sprintf('%02d%02d', $h, $m);
if ($chord_position < 4 * 4) {
$time_to_chords{$time} = 'A';
} elsif ($chord_position < 4 * 6) {
$time_to_chords{$time} = 'D';
} elsif ($chord_position < 4 * 8) {
$time_to_chords{$time} = 'A';
} elsif ($chord_position < 4 * 10) {
$time_to_chords{$time} = 'E';
} elsif ($chord_position < 4 * 12) {
$time_to_chords{$time} = 'D';
} else {
$time_to_chords{$time} = 'A';
}
$chord_position = ($chord_position + 1) % 64
}
}
my $mml = '';
for my $i(0 .. $#times) {
# preparing...
# snipped
# see the script of Shinagawa Station
foreach my $time(split(/\n/, $current_times)) {
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
# setting note
my $this_chord = $time_to_chords{sprintf('%02d%02d', $h, $m)};
my $note_index = ($i * $h + $m) % @{$notes{$this_chord}};
my $this_note = $notes{$this_chord}->[$i - 1]->[$note_index] . '16';
# compressing octaves
# see the script of Shinagawa Station
# setting velocities
if ($m % 4 == 0) {
$mml .= "k96${this_note}";
} elsif ($m % 4 == 2) {
$mml .= "k88${this_note}";
} else {
$mml .= "k72${this_note}";
}
# misc...
$prev_minutes = $minutes;
}
$mml .= "\n";
}
use strict;
my @notes = qw(c d r e f r g a r b);
my @times;
# snipped
# times are set...
# saving departures information
my @time_hashes;
# snipped
# see the script of Gotanda Station
my $mml = '';
for my $i(0 .. $#times) {
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
# preparing...
my $prev_hhmm = '';
my $prev_pattern = 'r16';
# because a pattern has four 16th notes, every minutes must be checked
for my $h(4 .. 25) {
for my $m(0 .. 59) {
my $this_note;
if (exists $time_hashes[$i]->{sprintf('%02d%02d', $h, $m)}) {
# using first two notes for this time
$mml .= join(
'',
map{
$notes[$_] . '32'
}split(//, sprintf('%02d', $h))
);
$prev_hhmm = sprintf('%02d%02d', $h, $m);
} elsif ($prev_hhmm) {
# using remainder
$prev_pattern = join(
'',
map{
$notes[$_] . '32'
}split(//, substr($prev_hhmm, 2, 2))
);
$mml .= $prev_pattern;
$prev_hhmm = '';
} else {
# resting
$mml .= 'r16';
}
}
}
$mml .= "\n"
}
use strict;
my %notes = (
violin_up => [qw(
o3g o3g+ o3a o3a+ o3b o4c o4c+ o4d o4d+ o4e o4f o4f+
o4g o4g+ o4a o4a+ o4b o5c o5c+ o5d o5d+ o5e o5f o5f+
o5g o5g+ o5a o5a+ o5b o6c o6c+ o6d o6d+ o6e
)],
viola_up => [qw(
o3c o3c+ o3d o3d+ o3e o3f o3f+ o3g o3g+ o3a o3a+ o3b
o4c o4c+ o4d o4d+ o4e o4f o4f+ o4g o4g+ o4a o4a+ o4b
o5c o5c+ o5d o5d+ o5e o5f o5f+ o5g o5g+ o5a
)],
cello_up => [qw(
o2c o2c+ o2d o2d+ o2e o2f o2f+ o2g o2g+ o2a o2a+ o2b
o3c o3c+ o3d o3d+ o3e o3f o3f+ o3g o3g+ o3a o3a+ o3b
o4c o4c+ o4d o4d+ o4e o4f o4f+ o4g o4g+ o4a
)],
violin_hovering => [qw(o5g o5g+ o5a o5a+ o5b)],
viola_hovering => [qw(o5c o5c+ o5d o5d+ o5e)],
cello_hovering => [qw(o4c o4c+ o4d o4d+ o4e)],
violin_down => [qw(
o6e o6d+ o6d o6c+ o6c o5b o5a+ o5a o5g+ o5g o5f+ o5f
o5e o5d+ o5d o5c+ o5c o4b o4a+ o4a o4g+ o4g o4f+ o4f
o4e o4d+ o4d o4c+ o4c o3b o3a+ o3a o3g+ o3g
)],
viola_down => [qw(
o5a o5g+ o5g o5f+ o5f o5e o5d+ o5d o5c+ o5c o4b o4a+
o4a o4g+ o4g o4f+ o4f o4e o4d+ o4d o4c+ o4c o3b o3a+
o3a o3g+ o3g o3f+ o3f o3e o3d+ o3d o3c+ o3c
)],
cello_down => [qw(
o4a o4g+ o4g o4f+ o4f o4e o4d+ o4d o4c+ o4c o3b o3a+
o3a o3g+ o3g o3f+ o3f o3e o3d+ o3d o3c+ o3c o2b o2a+
o2a o2g+ o2g o2f+ o2f o2e o2d+ o2d o2c+ o2c
)],
);
my @times;
# snipped
# times are set...
my $mml = '';
for my $i(0 .. $#times) {
# preparing...
# snipped
# see the script of Shinagawa Station
foreach my $time(split(/\n/, $current_times)) {
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
# selecting tone series
my @this_notes;
if ($i == 1) {
if ($hhmm le '1200') {
@this_notes = @{$notes{cello_up}};
} elsif ($hhmm le '1700') {
@this_notes = @{$notes{cello_hovering}};
} else {
@this_notes = @{$notes{cello_down}};
}
} elsif ($i == 2) {
if ($hhmm le '1200') {
@this_notes = @{$notes{viola_up}};
} elsif ($hhmm le '1700') {
@this_notes = @{$notes{viola_hovering}};
} else {
@this_notes = @{$notes{viola_down}};
}
} else {
if ($hhmm le '1200') {
@this_notes = @{$notes{violin_up}};
} elsif ($hhmm le '1700') {
@this_notes = @{$notes{violin_hovering}};
} else {
@this_notes = @{$notes{violin_down}};
}
}
my $this_note = $this_notes[($i * $h + $m) % @this_notes];
# compressing octaves
# see the script of Shinagawa Station
# misc...
$mml .= $this_note . '16';
$prev_minutes = $minutes;
}
$mml .= "\n";
}
use strict;
my @notes = qw(c c+ d d+ e f f+ g g+ a a+ b);
my @times;
# snipped
# times are set...
my $mml = '';
for my $i(0 .. $#times) {
# preparing...
# snipped
# see the script of Shinagawa Station
foreach my $time(split(/\n/, $current_times)) {
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
# determing octave
my $octave = 0;
if ($info =~ /中特/ || $info =~ /青特/ || $info =~ /通特/) {
$octave = 1;
} elsif ($info =~ /快ムえ/) {
$octave = 1;
} elsif ($info =~ /通快/ || $info =~ /特快/) {
$octave = 2;
} elsif ($info =~ /特?あ/ || $info =~ /特か/ || $info =~ /H千/) {
$octave = 3;
} elsif ($info =~ /中ラ/ || $info =~ /青ラ/ || $info =~ /ム信/) {
$octave = 3;
} elsif ($info =~ /特/) {
$octave = 3;
} elsif ($info =~ /H古/ || $info =~ /H小/ || $info =~ /NEX/) {
$octave = 3;
} elsif ($info =~ /快/) {
$octave = 1;
}
if ($octave != 0) {
$mml .= '>' x $octave;
}
$mml .= $notes[($i * $h + $m) % @notes] . '16';
if ($octave != 0) {
$mml .= '<' x $octave;
}
# misc...
$prev_minutes = $minutes;
}
$mml .= "\n";
}
use strict;
my @notes = qw(d d+ e);
my @times;
# snipped
# times are set...
my $mml = '';
for my $i(0 .. $#times) {
# preparing...
# snipped
# see the script of Shinagawa Station
foreach my $time(split(/\n/, $current_times)) {
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
# generating pattern
my $loops;
if ($h < 8) {
$loops = 0;
} elsif ($h < 12) {
$loops = 1;
} elsif ($h < 18) {
$loops = 2;
} elsif ($h < 22) {
$loops = 1;
} else {
$loops = 0;
}
if ($loops == 0) {
if ($i == 1) {
$mml .= 'p84';
} else {
$mml .= 'p104';
}
$mml .= 'k96' . $notes[($i * $h + $m) % @notes] . '16';
} elsif ($loops == 1) {
if ($i == 1) {
$mml .= 'p84';
} else {
$mml .= 'p104';
}
$mml .= 'k96' . $notes[($i * $h + $m) % @notes] . '32';
if ($i == 1) {
$mml .= 'p24';
} else {
$mml .= 'p44';
}
$mml .= 'k84' . $notes[($i * $h + $m + 1) % @notes] . '32';
} else {
if ($i == 1) {
$mml .= 'p54';
} else {
$mml .= 'p74';
}
$mml .= 'l%4k96' . $notes[($i * $h + $m) % @notes];
if ($i == 1) {
$mml .= 'p104';
} else {
$mml .= 'p124';
}
$mml .= 'l%4k84' . $notes[($i * $h + $m + 1) % @notes];
if ($i == 1) {
$mml .= 'p4';
} else {
$mml .= 'p24';
}
$mml .= 'l%4k62' . $notes[($i * $h + $m + 2) % @notes];
}
# misc...
$prev_minutes = $minutes;
}
$mml .= "\n";
}
use strict;
my @riff = qw(o3f+ g+ a+ o4c d e f+ g+ a+ o5c d e);
my @times;
# snipped
# times are set...
# saving departures information
my @time_hashes;
# snipped
# see the script of Gotanda Station
my $mml = '';
for my $i(0 .. $#times) {
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
# preparing...
my $j = 0;
# every minutes has tone
for my $h(4 .. 25) {
for my $m(0 .. 59) {
my $this_note;
if (exists $time_hashes[$i]->{sprintf('%02d%02d', $h, $m)}) {
# changing tempo
my $pattern = ($i * $h + $m) % 3;
if ($pattern == 0) {
# double speed
$mml .= $riff[$j] . '32';
$j = ($j + 1) % @riff;
$mml .= $riff[$j] . '32';
} elsif ($pattern == 1){
# three times speed
$mml .= 'l%4';
$mml .= $riff[$j];
for (1 .. 2) {
$j = ($j + 1) % @riff;
$mml .= $riff[$j];
}
} else {
# four times speed
$mml .= $riff[$j].'64';
for (1 .. 3) {
$j = ($j + 1) % @riff;
$mml .= $riff[$j] . '64';
}
}
} else {
# normal tempo
$mml .= $riff[$j] . '16';
}
# moving to next note
$j = ($j + 1) % @riff;
}
}
$mml .= "\n";
}
use strict;
# ^ means quarter-tone up
my @notes = qw(
o2c o3c o4c o5c o6c o4c o5c o6c o4c o5c o6c
o2c^ o3c^ o4c^ o5c^ o6c^ o4c^ o5c^ o6c^ o4c^ o5c^ o6c^
o2e o3e o4e o5e o6e o4e o5e o6e o4e o5e o6e
o2e^ o3e^ o4e^ o5e^ o6e^ o4e^ o5e^ o6e^ o4e^ o5e^ o6e^
o2g+ o3g+ o4g+ o5g+ o6g+ o4g+ o5g+ o6g+ o4g+ o5g+ o6g+
o2g+^ o3g+^ o4g+^ o5g+^ o6g+^ o4g+^ o5g+^ o6g+^ o4g+^ o5g+^ o6g+^
o2c+ o3c+ o4c+ o5c+ o6c+ o4c+ o5c+ o6c+ o4c+ o5c+ o6c+
o2c+^ o3c+^ o4c+^ o5c+^ o6c+^ o4c+^ o5c+^ o6c+^ o4c+^ o5c+^ o6c+^
o2f o3f o4f o5f o6f o4f o5f o6f o4f o5f o6f
o2f^ o3f^ o4f^ o5f^ o6f^ o4f^ o5f^ o6f^ o4f^ o5f^ o6f^
o2a o3a o4a o5a o6a o4a o5a o6a o4a o5a o6a
o2a^ o3a^ o4a^ o5a^ o6a^ o4a^ o5a^ o6a^ o4a^ o5a^ o6a^
o2d o3d o4d o5d o6d o4d o5d o6d o4d o5d o6d
o2d^ o3d^ o4d^ o5d^ o6d^ o4d^ o5d^ o6d^ o4d^ o5d^ o6d^
o2f+ o3f+ o4f+ o5f+ o6f+ o4f+ o5f+ o6f+ o4f+ o5f+ o6f+
o2f+^ o3f+^ o4f+^ o5f+^ o6f+^ o4f+^ o5f+^ o6f+^ o4f+^ o5f+^ o6f+^
o2a+ o3a+ o4a+ o5a+ o6a+ o4a+ o5a+ o6a+ o4a+ o5a+ o6a+
o2a+^ o3a+^ o4a+^ o5a+^ o6a+^ o4a+^ o5a+^ o6a+^ o4a+^ o5a+^ o6a+^
o2d+ o3d+ o4d+ o5d+ o6d+ o4d+ o5d+ o6d+ o4d+ o5d+ o6d+
o2d+^ o3d+^ o4d+^ o5d+^ o6d+^ o4d+^ o5d+^ o6d+^ o4d+^ o5d+^ o6d+^
o2g o3g o4g o5g o6g o4g o5g o6g o4g o5g o6g
o2g^ o3g^ o4g^ o5g^ o6g^ o4g^ o5g^ o6g^ o4g^ o5g^ o6g^
o2b o3b o4b o5b o6b o4b o5b o6b o4b o5b o6b
o2b^ o3b^ o4b^ o5b^ o6b^ o4b^ o5b^ o6b^ o4b^ o5b^ o6b^
);
my @times;
# snipped
# times are set...
my $mml = '';
for my $i(0 .. $#times) {
my $current_times = $times[$i];
next unless defined $current_times;
# normal notes and quarter notes must be in different MIDI channel
my $prev_oct_normal = '';
my $prev_oct_qup = '';
my $mml_normal .= sprintf('%s C%d"%d" ', chr(65 + $i), $i, $i) . " \n";
$mml_normal .= chr(65 + $i) . ' P ';
my $mml_qup .= sprintf('%s C%d"%d" ', chr(65 + $i), $i, $i) . " \n";
$mml_qup .= chr(65 + $i) . ' BS80 P ';
foreach my $time(split(/\n/, $current_times)) {
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
# determing base velocity
my $velocity_base = 40;
if ($hhmm ge '0700' && $hhmm lt '1000') {
$velocity_base = 80;
} elsif ($hhmm ge '1000' && $hhmm lt '1615') {
$velocity_base = 40;
} elsif ($hhmm ge '1615' && $hhmm lt '2156') {
$velocity_base = 80;
} else {
$velocity_base = 40;
}
# selecting note
my $this_note = $notes[($h + $i * $m) % @notes] . '16';
# compressing octaves
# see the script of Shinagawa Station
if ($this_note =~ s/\^//) {
$mml_normal .= 'r16';
$mml_qup .= 'P k' . ($velocity_base + ($i * $h + $m) % 20) . $this_note;
} else {
$mml_normal .= 'P k' . ($velocity_base + ($i * $h + $m) % 20) . $this_note;
$mml_qup .= 'r16';
}
# misc...
$prev_minutes=$minutes;
}
$mml .= $mml_normal . "\n" . $mml_qup . "\n"
}
use strict;
my @notes = qw(c d f g a);
my @times;
# snipped
# times are set...
my $mml = '';
for my $i(0 .. $#times) {
# preparing...
# snipped
# see the script of Shinagawa Station
foreach my $time(split(/\n/, $current_times)) {
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
# determing octave
my $octave = 0;
if ($info =~ /通快/ || $info =~ /特快/) {
$octave = 2;
} elsif ($info =~ /特/ || $info =~ /ム/ || $info =~ /NEX/) {
$octave = 3;
} elsif ($info =~/快/) {
$octave = 1;
}
if ($octave != 0) {
$mml .= '>' x $octave;
}
$mml .= $notes[($i * $h + $m) % @notes] . '16';
if ($octave != 0) {
$mml .= '<' x $octave;
}
# misc...
$prev_minutes = $minutes;
}
$mml .= "\n";
}
use strict;
my %riffs;
$riffs{4} = [qw(o3f o3c+ o2b o3c+)];
$riffs{5} = $riffs{4};
$riffs{6} = [qw(o3g o3d+ o3c+ o3d+)];
$riffs{7} = $riffs{6};
$riffs{8} = [qw(o3a o3f o3d+ o3f)];
$riffs{9} = $riffs{8};
$riffs{10} = [qw(o3b o3g o3f o3g)];
$riffs{11} = $riffs{10};
$riffs{12} = [qw(o4c+ o3a o3g o3a)];
$riffs{13} = $riffs{12};
$riffs{14} = [qw(o4d+ o3b o3a o3b)];
$riffs{15} = $riffs{14};
$riffs{16} = [qw(o4f o4c+ o3b o4c+)];
$riffs{17} = $riffs{16};
$riffs{18} = [qw(o4g o4d+ o4c+ o4d+)];
$riffs{19} = $riffs{18};
$riffs{20} = [qw(o4a o4f o4d+ o4f)];
$riffs{21} = $riffs{20};
$riffs{22} = [qw(o4b o4g o4f o4g)];
$riffs{23} = $riffs{22};
$riffs{24} = [qw(o5c+ o4a o4g o4a)];
$riffs{25} = $riffs{24};
$riffs{26} = [qw(o5d+ o4b o4a o4b)];
$riffs{27} = $riffs{26};
my @times;
# snipped
# times are set...
# saving departures information
my @time_hashes;
for my $i(0 .. $#times) {
my $current_times = $times[$i];
next unless defined $current_times;
foreach my $time (split(/\n/,$current_times)) {
# setting hour, minute and information
# cleaning noises
# see the script of Shinagawa Station
# counting departures
$time_hash{sprintf('%02d%02d', $h, $m)} ||= 0;
$time_hash{sprintf('%02d%02d', $h, $m)}++;
$time_hash{sprintf('%02d%02d', $h, $m)}++;
}
}
my $mml = 'A C1"1"' . " \n" . 'A C1 l16';
my $prev_oct = '';
my $i = 0;
# every minutes has tone
for my $h(4 .. 25) {
for my $m(0 .. 59) {
last if $h == 25 && $m == 30;
my $this_note;
if ($m == 0) {
# getting louder and louder
$mml .= 'k' . ($h * 4) . 'v' . ($h * 4);
}
my $this_hhmm = sprintf('%02d%02d', $h, $m);
if (exists $time_hash{$this_hhmm}) {
# using the note of next riff at departures of trains
$this_note = $riffs{$h + $time_hash{$this_hhmm}}->[$i];
} else {
# using original note
$this_note = $riffs{$h}->[$i];
}
# moving to next note of riff
$i = ($i + 1) % @{$riffs{4}};
# compressing octaves
# see the script of Shinagawa Station
# misc...
$mml .= $this_note;
}
}
use strict;
my @notes = qw(
o4g o3c o3d o3d+ o3g o3g+ o4c o4d o4d+ o4g o4g+ o5c o5d
o5c o4g+ o4g o4d+ o4d o4c o3g+ o3g o3d+ o3d o3c
);
# assigning note to MIDI channel
my %note2ch = (
'o4g' => 1,
'o3c' => 2,
'o3d' => 3,
'o3d+' => 4,
'o3g' => 5,
'o3g+' => 6,
'o4c' => 7,
'o4d' => 8,
'o4d+' => 9,
'o4g' => 10,
'o4g+' => 11,
'o5c' => 12,
'o5d' => 13,
);
my @times;
# snipped
# times are set...
# saving departures information
my %time_hash;
my %time_hash_bend;
for my $i(0 .. $#times) {
my $current_times = $times[$i];
next unless defined $current_times;
foreach my $time(split(/\n/, $current_times)) {
my($h, $m) = split(/\s+/, $time);
$h =~ tr/0-9//cd;
$m =~ tr/0-9//cd;
my $this_note = $notes[($i * $h + $m) % @notes];
my $this_hhmm = sprintf('%02d%02d', $h, $m);
if (exists $time_hash{$this_hhmm}) {
# use bending with overlaps
$time_hash_bend{$this_hhmm} = 1;
}
$time_hash{$this_hhmm} = $this_note;
}
}
# generating mml for every channels;
my @mmls;
for my $i(1 .. (scalar(keys(%note2ch)) + 1 + 1)) {
$mmls[$i] = sprintf('%s C%d"%d" ', chr(65 + $i), $i, $i) . " \n";
$mmls[$i].=chr(65 + $i).' ';
}
for my $h(4 .. 25) {
for my $m(0 .. 59){
my $this_hhmm = sprintf('%02d%02d', $h, $m);
if (exists $time_hash{$this_hhmm}) {
my $this_note = $time_hash{$this_hhmm};
if (exists $note2ch{$this_note}) {
for my $i(1 .. (scalar(keys(%note2ch)) + 1)) {
if ($i == $note2ch{$this_note}) {
$mmls[$i] .= $this_note . '16';
} else {
$mmls[$i] .= 'r16';
}
}
} else {
$mmls[1] .= $this_note . '16';
for my $i(2 .. (scalar(keys(%note2ch)) + 1)) {
$mmls[$i] .= 'r16';
}
}
} else {
for my $i(1 .. (scalar(keys(%note2ch)) + 1)) {
$mmls[$i] .= 'r16';
}
}
# mark for bending
if (exists $time_hash_bend{$this_hhmm}) {
$mmls[scalar(keys(%note2ch)) + 1 + 1] .= 'o6b16';
} else {
$mmls[scalar(keys(%note2ch)) + 1 + 1] .= 'r16';
}
}
}
# output
for my $i(1 .. (scalar(keys(%note2ch)) + 1 + 1)){
# snipped
# compressing rests
print $mmls[$j] . "\n";
}
use strict;
my @notes = qw(o4c o4c+ o4d o4d+ o4e o4f o4f+ o4g o4g+ o4a o4a+ o4b);
my @times;
# snipped
# times are set...
# storing tones
my @rounded_notes;
my $last_rounded_time;
my %rounded_times;
for my $i(0 .. $#times) {
my $current_times = $times[$i];
next unless defined $current_times;
my %pool;
foreach my $time(split(/\n/, $current_times)) {
# setting hour, minute and information
# cleaning noises
# see the script of Shinagawa Station
# rounding time
my $rounded_hhmm = &rounded_hhmm($h, $m);
unless (exists $pool{$rounded_hhmm}) {
$pool{$rounded_hhmm} = {};
$rounded_times{$rounded_hhmm} = $hhmm;
}
$last_rounded_time = $hhmm;
my $this_note = $notes[($i * $h + $m) % @notes];
while (exists $pool{$rounded_hhmm}->{$this_note}) {
if ($this_note =~ /^o(\d)(.+)/) {
if ($1 == 4) {
$this_note = 'o3' . $2;
} elsif ($1 == 3) {
$this_note = 'o5' . $2;
} elsif ($1 == 5) {
$this_note = 'o2' . $2;
} elsif ($1 == 2) {
$this_note = 'o6' . $2;
} else {
die;
}
}
}
$pool{$rounded_hhmm}->{$this_note} = 1;
}
@rounded_notes[$i] = \%pool;
}
for my $i(0 .. $#times) {
next unless defined $rounded_notes[$i];
foreach my $time(sort(keys(%{$rounded_notes[$i]}))) {
if ($time ne $rounded_times{$time}) {
$rounded_notes[$i]->{$rounded_times{$time}} = $rounded_notes[$i]->{$time};
delete $rounded_notes[$i]->{$time};
}
}
}
# generating mml
my $mml = '';
for my $i(0 .. $#times) {
next unless defined $rounded_notes[$i];
# preparing...
# snipped
# see the script of Shinagawa Station
my $count=0;
foreach my $time(sort(keys(%{$rounded_notes[$i]}))) {
my($h, $m);
if($time =~ /^(\d{2})(\d{2})$/) {
$h = $1;
$m = $2;
}
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
# flushing stored notes
$mml .= join('0', keys(%{$rounded_notes[$i]->{$time}})) . '16';
# misc...
$prev_minutes = $minutes;
}
$mml .= "\n";
}
sub rounded_hhmm {
my $hh = shift;
my $mm = shift;
if ($mm < 30) {
return "${hh}00";
} else {
return "${hh}30";
}
}
use strict;
my %notes = (
flute => [qw(o5c o5d o5e o5f o5g o5a o5b)],
piccolo => [qw(o6c o6d o6e o6f o6g o6a o6b)],
oboe => [qw(o4c o4d o4e o4f o4g o4a o4b)],
clarinet => [qw(o3c o3d o3e o3f o3g o3a o3b)],
fagot => [qw(o2c o2d o2e o2f o2g o2a o2b)],
violin => [qw(o5c o5d o5e o5f o5g o5a o5b)],
viola => [qw(o4c o4d o4e o4f o4g o4a o4b)],
cello => [qw(o3c o3d o3e o3f o3g o3a o3b)],
contrabass => [qw(o2c o2d o2e o2f o2g o2a o2b)],
harp => [qw(o3c o3d o3e o3f o3g o3a o3b o4c o4d o4e o4f o4g o4a o4b)],
horn => [qw(o3c o3d o3e o3f o3g o3a o3b)],
trumpet => [qw(o5c o5d o5e o5f o5g o5a o5b)],
trombone => [qw(o3c o3d o3e o3f o3g o3a o3b)],
tuba => [qw(o2c o2d o2e o2f o2g o2a o2b)],
timpani => [qw(o2c o2d o2e o2f o2g o2a o2b)],
bdrum_and_cymbal => [qw(o2c o3b)],
tmb_and_triangle => [qw(o3f+ o5g+ o5a)],
snare_and_wblock => [qw(o2e o5e- o5e)],
xylophon => [qw(o5c o5d o5e o5f o5g o5a o5b)],
cnet_and_tomtom => [qw(o2e- o3g)],
whip => [qw(o4c o4d o4e)],
percs => [qw(o2c o3b o3f+ o5g+ o5a)]
);
my @times;
# snipped
# times are set...
my $mml = '';
for my $i(0 .. $#times) {
# preparing...
# snipped
# see the script of Shinagawa Station
foreach my $time(split(/\n/, $current_times)) {
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
my $this_time = sprintf('%02d%02d', $h, $m);
my @this_notes;
if ($h <= 4) {
if ($i == 1 || $i == 2) {
@this_notes = @{$notes{flute}};
} else {
@this_notes = @{$notes{piccolo}};
}
} elsif ($h <= 5) {
@this_notes = @{$notes{oboe}};
} elsif ($h <= 6) {
@this_notes = @{$notes{clarinet}};
} elsif ($h <= 7) {
@this_notes = @{$notes{fagot}};
} elsif ($h <= 8) {
@this_notes = @{$notes{violin}};
} elsif ($h <= 9) {
@this_notes = @{$notes{viola}};
} elsif ($h <= 10) {
@this_notes = @{$notes{cello}};
} elsif ($h <= 11) {
@this_notes = @{$notes{contrabass}};
} elsif ($h <= 12) {
@this_notes = @{$notes{harp}};
} elsif ($h <= 13) {
@this_notes = @{$notes{horn}};
} elsif ($h <= 14) {
@this_notes = @{$notes{trumpet}};
} elsif ($h <= 15) {
if ($i == 1 || $i == 2) {
@this_notes = @{$notes{trombone}};
} else {
@this_notes = @{$notes{tuba}};
}
} elsif ($this_time lt '1620') {
@this_notes = @{$notes{timpani}};
} elsif ($this_time lt '1640') {
@this_notes = @{$notes{bdrum_and_cymbal}};
} elsif ($this_time lt '1700') {
@this_notes = @{$notes{tmb_and_triangle}};
} elsif ($this_time lt '1720') {
@this_notes = @{$notes{snare_and_wblock}};
} elsif ($this_time lt '1740') {
@this_notes = @{$notes{xylophon}};
} elsif ($this_time lt '1800') {
@this_notes = @{$notes{cnet_and_tomtom}};
} elsif ($this_time lt '1830') {
@this_notes = @{$notes{whip}};
} else {
@this_notes = @{$notes{flute}};
# using codes below when playing together
# harp
# @notes = @{$notes{harp}};
# percussions
# @notes = @{$notes{percs}};
}
my $this_note = $notes[($i * $h + $m) % @notes] . '16';
# compressing octaves
# misc...
$mml .= $this_note;
$prev_minutes = $minutes;
}
$mml .= "\n";
}
use strict;
my %notes = (
violin => [qw(o3g o4d o4a o5e)],
viola => [qw(o3c o3g o4d o4a)],
cello => [qw(o2c o2g o3d o3a)],
);
my @times;
# snipped
# times are set...
my $mml = '';
for my $i(0..$#times){
# preparing...
# snipped
# see the script of Shinagawa Station
foreach my $time(split(/\n/, $current_times)) {
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
# determing notes
my @this_notes;
if ($i == 3 || $i == 4) {
@this_notes = @{$notes{violin}};
} elsif ($i == 2 ){
@this_notes = @{$notes{viola}};
} else {
@this_notes = @{$notes{cello}};
}
my $this_note = $notes[($i * $h + $m) % @notes];
# compressing octaves
# see the script of Shinagawa Station
# misc...
$mml .= $this_note . '16';
$prev_minutes = $minutes;
}
$mml .= "\n";
}
use strict;
my %notes = (
on => 'g+0b0>e16<',
off => 'g0b-0>d-0e-16<',
);
my @times;
# snipped
# times are set...
# saving departures information
my @time_hashes;
# snipped
# see the script of Gotanda Station
my $mml = '';
for my $i(0 .. $#times) {
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
# determing octave
if ($i == 1 || $i == 2) {
$mml .= 'o5';
} elsif ($i == 3 || $i == 4) {
$mml .= 'o4';
} else {
$mml .= 'o3';
}
# every minutes has tone
for my $h(4 .. 25) {
for my $m(0 .. 59) {
my $this_note;
if (exists $time_hashes[$i]->{sprintf('%02d%02d', $h, $m)}) {
$this_note = 'k100' . $notes{on};
} else {
if ($m % 2 == 0) {
$this_note = 'k48' . $notes{off};
} else {
$this_note = 'r16';
}
}
$mml .= $this_note;
}
}
$mml .= "\n";
}
use strict;
my @notes = qw(c c+ d d+ e f f+ g g+ a a+);
my @times;
# snipped
# times are set...
my $mml = '';
for my $i(0 .. $#times) {
# preparing...
# snipped
# see the script of Shinagawa Station
foreach my $time(split(/\n/, $current_times)) {
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
$mml .= $notes[($i * $h + $m) % @notes] . '16';
$prev_minutes = $minutes;
}
$mml .= "\n";
}
use strict;
my @notes = qw(
o2c o2c+ o2d o2d+ o2e o2f o2f+ o2g o2g+ o2a o2a+ o2b
o3c o3c+ o3d o3d+ o3e o3f o3f+ o3g o3g+ o3a o3a+ o3b
o4c o4c+ o4d o4d+ o4e o4f o4f+ o4g o4g+ o4a o4a+ o4b
o5c o5c+ o5d o5d+ o5e o5f o5f+ o5g o5g+ o5a o5a+ o5b
);
my @times;
# snipped
# times are set...
my $mml = '';
for my $i(0 .. $#times) {
# preparing...
# snipped
# see the script of Shinagawa Station
foreach my $time(split(/\n/, $current_times)) {
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
$mml .= $notes[($i * $h + $m) % @notes] . '16';
# compressing octaves
# see the script of Shinagawa Station
$prev_minutes = $minutes;
}
$mml .= "\n";
}
use strict;
my @notes = qw(
o2d+16 o2e16 o2f16 o2f+16 o2g16 o2g+16
o2a16 o2a+16 o2b16 o3c16 o3c+16 o3d16
);
my @times;
# snipped
# times are set...
my $mml = '';
my %drum_notes;
my %bass_notes;
for my $i(0 .. $#times) {
# preparing...
# snipped
# see the script of Shinagawa Station
foreach my $time(split(/\n/, $current_times)) {
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
my $this_note = $notes[($i * $h + $m) % @notes];
$mml .= $this_note;
# saving time for drums
$drum_notes{$hhmm} = 'a32r32';
# determing note for bass
my $note_for_bass;
if ($this_note =~ /^o(\d)([a-g+]+)/) {
$note_for_bass = 'o' . ($1 - 1) . $2 . '16';
}
if (exists $bass_notes{$hhmm}) {
# lower is better
if (&cmp_note($bass_notes{$hhmm}, $note_for_bass) == 1) {
$bass_notes{$hhmm} = $note_for_bass;
}
} else {
$bass_notes{$hhmm} = $note_for_bass;
}
# misc...
$prev_minutes = $minutes;
}
$mml .= "\n";
}
# generating mml for drums and bass
for my $i(5 .. 6) {
$mml .= sprintf('%s C%d"%d" ', chr(65 + $i), $i, $i) . " \n";
$mml .= chr(65 + $i) . ' ';
# setting octave for drums
$mml .= 'o1' if $i == 6;
# flushing notes
for my $h(4 .. 25) {
for my $m(0 .. 59) {
my $hhmm = sprintf('%02d%02d', $h, $m);
if ($i == 5) {
# bass
if (exists $bass_notes{$hhmm}) {
$mml .= $bass_notes{$hhmm};
} else {
$mml .= 'r16';
}
} else {
# drums
if (exists $drum_notes{$hhmm}) {
$mml .= $drum_notes{$hhmm};
} else {
$mml .= 'r16';
}
}
}
}
$mml .= "\n";
}
sub cmp_note {
my $note_a = shift;
my $note_b = shift;
my $oct_a;
if ($note_a =~ /o(\d)/) {
$oct_a = $1;
}
my $oct_b;
if ($note_b =~ /o(\d)/) {
$oct_b = $1;
}
if ($oct_a == $oct_b) {
return $note_a cmp $note_b;
} else {
return $oct_a <=> $oct_b;
}
}
use strict;
my @notes = qw(
o4e o4f o4f+ o4g o4g+ o4a o4a+ o4b o5c o5c+ o5d o5d+
o5e o5f o5f+ o5g o5g+ o5a o5a+ o5b o6c o6c+ o6d o6d+ o6e
);
my @times;
# snipped
# times are set...
my $mml = '';
for my $i(0 .. $#times) {
# preparing...
# snipped
# see the script of Shinagawa Station
foreach my $time(split(/\n/, $current_times)) {
# setting hour, minute and information
# cleaning noises
# compressing octaves
# and so on...
# see the script of Shinagawa Station
my $this_note = $notes[($i * $h + $m) % @notes];
# compressing octaves
# see the script of Shinagawa Station
# generating 32th note, not 16th note
$mml .= $this_note . '32r32';
# misc...
$prev_minutes = $minutes;
}
$mml .= "\n";
}
use strict;
my @clusters = qw(
e0d+0d0c+0c16
f0e0d+0d0c+16
f+0f0e0d+0d16
g0f+0f0e0d+16
g+0g0f+0f0e16
a0g+0g0f+0f16
a+0a0g+0g0f+16
b0a+0a0g+0g016
);
my @times;
# snipped
# times are set...
my $mml = '';
for my $i(0 .. $#times) {
# preparing...
# snipped
# see the script of Shinagawa Station
# determing octave
$mml .= 'o' . (8 - $i);
# cluster index
my $index = 0;
foreach my $time(split(/\n/, $current_times)) {
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
# selecting tone cluster
if (($i * $h + $m) % 2) {
$index++;
} else {
$index--;
}
# be sure not to overflow
if ($index > $#clusters) {
$index = $#clusters;
}
if ($index < 0){
$index = 0;
}
# generating mml
$mml .= $clusters[$index];
# misc...
$prev_minutes = $minutes;
}
$mml .= "\n";
}
use strict;
my @times;
# snipped
# times are set...
my $mml = '';
for my $i(0 .. $#times) {
# preparing...
# snipped
# see the script of Shinagawa Station
foreach my $time(split(/\n/, $current_times)) {
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
# "shifting 256th rest * i" will be done manually...
$mml .= 'c';
$prev_minutes = $minutes;
}
$mml .= "\n";
}
use strict;
my @times;
# snipped
# times are set...
my $mml = '';
for my $i(0 .. $#times) {
# preparing...
# snipped
# see the script of Shinagawa Station
foreach my $time(split(/\n/, $current_times)) {
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
$mml .= 'c';
$prev_minutes = $minutes;
}
$mml .= "\n";
}
use strict;
# overtones are assiged to these notes
my @all_notes = qw(
o1c o1c+ o1d o1d+ o1e o1f o1f+ o1g o1g+ o1a o1a+ o1b
o2c o2c+ o2d o2d+ o2e o2f o2f+ o2g o2g+ o2a o2a+ o2b
o3c o3c+ o3d o3d+ o3e
);
my @riffs;
for my $i(4 .. 25) {
$riffs[$i] = [@all_notes[($i - 4) .. ($i - 4 + 7)]];
}
my @times;
# snipped
# times are set...
# calculating note for departures
my @time_hashes;
for my $i(0 .. $#times) {
my $current_times = $times[$i];
next unless defined $current_times;
$time_hashes[$i] = {};
my $j = 0;
my $prev_h;
foreach my $time(split(/\n/, $current_times)) {
my($h, $m) = split(/\s+/, $time);
$h =~ tr/0-9//cd;
$m =~ tr/0-9//cd;
if ($h ne $prev_h) {
# reset riff index when the hour is changed
$prev_h = $h;
$j = 0;
}
$time_hashes[$i]->{sprintf('%02d%02d', $h, $m)} = $riffs[int($h)]->[$j];
$j = ($j + 1) % @{$riffs[int($h)]};
}
}
my $mml = '';
for my $i(0 .. $#times) {
# preparing...
# snipped
# see the script of Shinagawa Station
foreach my $time(split(/\n/, $current_times)) {
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
# determing note
my $this_note = $time_hashes[$i]->{sprintf('%02d%02d', $h, $m)} . '16';
# compressing octaves
# see the script of Shinagawa Station
# misc...
$mml .= $this_note;
$prev_minutes = $minutes;
}
$mml .= "\n";
}
use strict;
my @times;
# snipped
# times are set...
my $mml = '';
for my $i(0 .. $#times) {
# preparing...
# snipped
# see the script of Shinagawa Station
foreach my $time(split(/\n/, $current_times)) {
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
# performing rests
$mml .= 'r16';
# misc...
$prev_minutes = $minutes;
}
$mml .= "\n";
}
use strict;
my %notes;
$notes{4} = {
1 => [qw(
o4c16 o4d16 o4e16 o4f+16 o4g+16 o4a+16 o5c16
o4a+16 o4g+16 o4f+16 o4e16 o4d16 o4c16
)],
2 => [qw(
o3c16 o3d16 o3e16 o3f+16 o3g+16 o3a+16 o4c16
o3a+16 o3g+16 o3f+16 o3e16 o3d16 o3c16
)],
3 => [qw(
o2c16 o2d16 o2e16 o2f+16 o2g+16 o2a+16 o3c16
o2a+16 o2g+16 o2f+16 o2e16 o2d16 o2c16
)],
4 => [qw(
o3c0e0g+16 o3d0f+0a+16 o3e0g+0o4c16
o3d0f+0a+16 o3c0e0g+16
)],
};
$notes{5} = $notes{4};
$notes{6} = $notes{4};
$notes{7} = {
1 => [qw(
o4c16 o4d-16 o4e-16 o4e16 o4f+16 o4g16 o4a16 o4b-16 o5c16
o4b-16 o4a16 o4g16 o4f+16 o4e16 o4e-16 o4d-16 o4c16
)],
2 => [qw(
o3c16 o3d-16 o3e-16 o3e16 o3f+16 o3g16 o3a16 o3b-16 o4c16
o3b-16 o3a16 o3g16 o3f+16 o3e16 o3e-16 o3d-16 o3c16
)],
3 => [qw(
o2c16 o2d-16 o2e-16 o2e16 o2f+16 o2g16 o2a16 o2b-16 o3c16
o2b-16 o2a16 o2g16 o2f+16 o2e16 o2e-16 o2d-16 o2c16
)],
4 => [qw(
o3c0e-0f+16 o3d-0e0g16 o3e-0f+0a16 o3e0g0b-16 o3f+0a0o4c16
o3e0g0b-16 o3e-0f+0a16 o3d-0e0g16 o3c0e-0f+16
)],
};
$notes{8} = $notes{7};
$notes{9} = $notes{7};
$notes{10} = {
1 => [qw(
o4c16 o4d16 o4e-16 o4e16 o4f+16 o4g16 o4a-16 o4b-16 o4b16 o5c16
o4b16 o4b-16 o4a-16 o4g16 o4f+16 o4e16 o4e-16 o4d16 o4c16
)],
2 => [qw(
o3c16 o3d16 o3e-16 o3e16 o3f+16 o3g16 o3a-16 o3b-16 o3b16 o4c16
o3b16 o3b-16 o3a-16 o3g16 o3f+16 o3e16 o3e-16 o3d16 o3c16
)],
3 => [qw(
o2c16 o2d16 o2e-16 o2e16 o2f+16 o2g16 o2a-16 o2b-16 o2b16 o3c16
o2b16 o2b-16 o2a-16 o2g16 o2f+16 o2e16 o2e-16 o2d16 o2c16
)],
4 => [qw(
o3c0e-0f+16 o3d0e0g16 o3e-0f+0a-16 o3e0g0b-16 o3f+0a-0b16 o3g0b-0o4c16
o3f+0a-0b16 o3e0g0b-16 o3e-0f+0a-16 o3d0e0g16 o3c0e-0f+16
)],
};
$notes{11} = $notes{10};
$notes{12} = $notes{10};
$notes{13} = {
1 => [qw(
o4c16 o4d-16 o4d16 o4f16 o4f+16 o4g16 o4a-16 o4b16 o5c16
o4b16 o4a-16 o4g16 o4f+16 o4f16 o4d16 o4d-16 o4c16
)],
2 => [qw(
o3c16 o3d-16 o3d16 o3f16 o3f+16 o3g16 o3a-16 o3b16 o4c16
o3b16 o3a-16 o3g16 o3f+16 o3f16 o3d16 o3d-16 o3c16
)],
3 => [qw(
o2c16 o2d-16 o2d16 o2f16 o2f+16 o2g16 o2a-16 o2b16 o3c16
o2b16 o2a-16 o2g16 o2f+16 o2f16 o2d16 o2d-16 o2c16
)],
4 => [qw(
o3c0d0f+16 o3d-0f0g16 o3d0f+0a-16 o3f0g0b16 o3f+0a-0o4c16
o3f0g0b16 o3d0f+0a-16 o3d-0f0g16 o3c0d0f+16
)],
};
$notes{14} = $notes{13};
$notes{15} = $notes{13};
$notes{16} = {
1 => [qw(
o4c16 o4d-16 o4f16 o4f+16 o4g16 o4b16 o5c16
o4b16 o4g16 o4f+16 o4f16 o4d-16 o4c16
)],
2 => [qw(
o3c16 o3d-16 o3f16 o3f+16 o3g16 o3b16 o4c16
o3b16 o3g16 o3f+16 o3f16 o3d-16 o3c16
)],
3 => [qw(
o2c16 o2d-16 o2f16 o2f+16 o2g16 o2b16 o3c16
o2b16 o2g16 o2f+16 o2f16 o2d-16 o2c16
)],
4 => [qw(
o3c0f0g16 o3d-0f+0b16 o3f0g0o4c16
o3d-0f+0b16 o3c0f0g16
)],
};
$notes{17} = $notes{16};
$notes{18} = $notes{16};
$notes{19} = {
1 => [qw(
o4c16 o4d16 o4e16 o4f16 o4f+16 o4g+16 o4a+16 o4b16 o5c16
o4b16 o4a+16 o4g+16 o4f+16 o4f16 o4e16 o4d16 o4c16
)],
2 => [qw(
o3c16 o3d16 o3e16 o3f16 o3f+16 o3g+16 o3a+16 o3b16 o4c16
o3b16 o3a+16 o3g+16 o3f+16 o3f16 o3e16 o3d16 o3c16
)],
3 => [qw(
o2c16 o2d16 o2e16 o2f16 o2f+16 o2g+16 o2a+16 o2b16 o3c16
o2b16 o2a+16 o2g+16 o2f+16 o2f16 o2e16 o2d16 o2c16
)],
4 => [qw(
o3c0e0f+16 o3d0f0g+16 o3e0f+0a+16 o3f0g+0b16 o3f+0a+0o4c16
o3f0g+0b16 o3e0f+0a+16 o3d0f0g+16 o3c0e0f+16
)],
};
$notes{20} = $notes{19};
$notes{21} = $notes{19};
$notes{22} = {
1 => [qw(
o4c16 o4c+16 o4d16 o4e-16 o4f16 o4f+16 o4g16 o4g+16 o4a16 o4b16 o5c16
o4b16 o4a16 o4g+16 o4g16 o4f+16 o4f16 o4e-16 o4d16 o4c+16 o4c16
)],
2 => [qw(
o3c16 o3c+16 o3d16 o3e-16 o3f16 o3f+16 o3g16 o3g+16 o3a16 o3b16 o4c16
o3b16 o3a16 o3g+16 o3g16 o3f+16 o3f16 o3e-16 o3d16 o3c+16 o3c16
)],
3 => [qw(
o2c16 o2c+16 o2d16 o2e-16 o2f16 o2f+16 o2g16 o2g+16 o2a16 o2b16 o3c16
o2b16 o2a16 o2g+16 o2g16 o2f+16 o2f16 o2e-16 o2d16 o2c+16 o2c16
)],
4 => [qw(
o3c0d0f16 o3c+0e-0f+16 o3d0f0g16 o3e-0f+0g+16 o3f0g0a16 o3f+0g+0b16 o3g0a0o4c16
o3f+0g+0b16 o3f0g0a16 o3e-0f+0g+16 o3d0f0g16 o3c+0e-0f+16 o3c0d0f16
)],
};
$notes{23} = $notes{22};
$notes{24} = $notes{22};
$notes{25} = $notes{22};
my @times;
# snipped
# times are set...
my $mml = '';
for my $i(0 .. $#times) {
# preparing...
# snipped
# see the script of Shinagawa Station
foreach my $time(split(/\n/, $current_times)) {
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
# determing tone series
my @this_notes = @{$notes{int($h)}->{$i}};
$mml .= 'k' . ($h * 4 + 40) . $this_notes[($i * $h + $m) % @this_notes];
# misc...
$prev_minutes = $minutes;
}
$mml .= "\n";
}
# nothing to be done...
use strict;
my @notes = qw(b- a >c< b);
my @times;
# snipped
# times are set...
my $mml = '';
for my $i(0 .. $#times) {
# preparing...
# snipped
# see the script of Shinagawa Station
my $index = 0;
foreach my $time(split(/\n/, $current_times)) {
# setting hour, minute and information
# cleaning noises
# and so on...
# see the script of Shinagawa Station
$mml .= $notes[$index] . '16';
$index = ($index + 1) % @notes;
$prev_minutes = $minutes;
}
$mml .= "\n";
}
Music by HAGIHARA Yoshiaki with Perl scripts.
Sleeve design and artwork by AKIYAMA Mimico.
Last update: May 31, 2009.