Next 8tel of the noch fehlenden 4tel steps, ne?
Ein Achtelschritt des noch ausstehenden Viertelschrittes ist hiermit geschritten:
Ein Achtel bleibt noch ausständig: Das gekonnte Verbinden der Progressionen + 6 noch nicht eingepflegte derselben.
Code
#!/usr/bin/perl
# konzeptentwickler-2.3.pl
use strict;
use warnings;
# Variablen
my %chordtypes = (
"DurMaj7" => ["DurMaj7", "0", "4", "7", "11"],
"Dur7" => ["Dur7", "0", "4", "7", "10"],
"MollMaj7" => ["MollMaj7", "0", "3", "7", "11"],
"Moll7" => ["Moll7", "0", "3", "7", "10"],
"Moll7b5" => ["Moll7b5", "0", "3", "6", "10"],
"Dim7" => ["Dim", "0", "3", "6", "9"]
);
my %chroma = (
"C-" => 0,
"C" => 1,
"D-" => 2,
"D" => 3,
"E-" => 4,
"E" => 5,
"F-" => 5,
"F" => 6,
"G-" => 7,
"G" => 8,
"A-" => 9,
"A" => 10,
"B-" => 11,
"B" => 12 );
my %chroma_inv = (
"0" => "C-",
"1" => "C",
"2" => "D-",
"3" => "D",
"4" => "E-",
"5" => "E",
"6" => "F",
"7" => "G-",
"8" => "G",
"9" => "A-",
"10" => "A",
"11" => "B-",
"12" => "B" );
my %progressions = (
"1" => ["2", "Moll7", "7", "Dur7", "0", "DurMaj7", "0", "DurMaj7"],
"2" => ["0", "DurMaj7", "9", "Moll7", "2", "Moll7", "7", "Dur7", "4", "Moll7", "9", "Dur7", "2", "Moll7", "7", "Dur7"],
"3" => ["0", "DurMaj7", "0", "DurMaj7", "0", "Moll7", "7", "Dur7",
"10", "DurMaj7", "10", "DurMaj7", "10", "Moll7", "5", "Dur7", "8",
"DurMaj7", "8", "DurMaj7", "8", "Moll7", "3", "Dur7"],
"4" => ["0", "DurMaj7", "1", "Dim7", "2", "Moll7", "3", "Dim7", "4", "Moll7", "9", "Dur7"] );
my @buchse;
my $stecker = "0";
my @chordprogression;
# Programm
## Grundton erfragen
print "\nWelcher Grundton? (C, D, E, F, G, A oder B mit - oder + angeben!)\n";
my $grundton_init = <STDIN>;
chomp $grundton_init;
## Vier Zufallsprogressionen mit Steckverbindung
for ( my $round = 1; $round < 5; $round++ ) {
## Stecker, falls Buchse vorhanden (nach erster Runde)
if ( $round > 1 ) { $stecker = int rand(scalar @buchse); $grundton_init = $buchse[$stecker] }
print "\nDer Stecker sei: $stecker => $grundton_init!\n\n";
## Progression per Zufall aussuchen
my $progression_choice = int rand(scalar keys %progressions) + 1;
print "\n\nDie ausgewählte Progression hat die Nummer: $progression_choice.\n\n";
my $progression_ref = $progressions{$progression_choice};
my @progression = @$progression_ref;
### Progression transformieren
foreach ( @progression ) {
if ( $_ =~ m/^[0-9]+/ ) { $_ = $chroma{$grundton_init} + $_ }
if ( $_ =~ m/^[0-9]+/ && $_ > 12 ) { $_ = $_ - 12 }
if ( $_ =~ m/^[0-9]+/ ) { $_ = $chroma_inv{$_} }
}
### Progression ausdrucken
print "\n";
for ( my $p = 0; $p < scalar @progression; $p+=2 ) {
print "\nScalar Progression: ", scalar @progression, "\n";
# Ausgabe der Progressions-Taktnummer
print "Progressions-Takt Nr.: ", ($p + 2)/2, "\n";
# Akkordtyp, Akkordarray und Grundton pro Schritt ermitteln
my $grundton = $progression[$p];
my $chordtype = $progression[$p + 1];
my $chord_ref = $chordtypes{$chordtype};
my @chord = @$chord_ref;
## Akkordbezeichnung
$chord[0] = "$grundton-".$chord[0];
## Akkordtöne
for ( my $i = 1; $i < 5; $i++ ) {
$chord[$i] = $chroma{$grundton} + $chord[$i];
if ( $chord[$i] > 12 ) { $chord[$i] = $chord[$i] - 12 }
$chord[$i] = $chroma_inv{$chord[$i]};
}
# Ausgabe der Töne
print "\nDer Akkord zum Grundton $grundton ist:\n\n";
print map { $_, "\n" } @chord;
print "\n";
# Array of Array (Akkordfolge) füllen
push @chordprogression, [$chord[1],$chord[2],$chord[3],$chord[4]];
# Buchsenarray einlesen
if ( $p == (scalar @progression) - 2 ) {
$buchse[0] = $chord[1];
$buchse[1] = $chord[2];
$buchse[2] = $chord[3];
$buchse[3] = $chord[4]
} else { next }
}
print "\nDie Buchse ist:\n\n";
print map { $_, "\n" } @buchse;
print "\n";
print "\n";
}
### Akkordprogression ausgeben
print "\nAkkord-Folge im Gesamten:\n\n";
print map { @$_, "\n" } @chordprogression;
print "\n";
### Akkordprogression transformieren
my @chordprogression_transformed;
foreach ( @chordprogression ) {
my ($n1,$n2,$n3,$n4) = (@$_[0],@$_[1],@$_[2],@$_[3]);
push @chordprogression_transformed, [$n1,"2",$n2,"4",$n3,"4",$n4,"5"];
}
### Transformierte Akkordprogression ausgeben
print "\nTransformierte Akkord-Folge im Gesamten:\n\n";
print map { @$_, "\n" } @chordprogression_transformed;
print "\n";
#### midipatternwriter-Unit
### Array-Transformation
my @arrays = @chordprogression_transformed;
foreach ( @arrays ) {
my $tmparray_ref = $_;
foreach ( @$tmparray_ref ) {
$_ =~ s/([CDEFGAB])/<step>$1<\/step>/;
$_ =~ s/([1234567])/<octave>$1<\/octave>/;
$_ =~ s/([-+])/<alter>$1X<\/alter>/;
$_ =~ s/X/1/;
print "$_\n";
}
}
## Array-Einträge in Vorlage beamen
### Takte erstellen
my $takte = "";
my $measure_count = 0;
my $measure_temp;
foreach ( @arrays ) {
my $chord_ref = $_;
my $vier4tel_takt_temp = ' <note>
<pitch>
'.$$chord_ref[2].'
'.$$chord_ref[3].'
</pitch>
<duration>2</duration>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
<staff>1</staff>
</note>
<note>
<chord/>
<pitch>
'.$$chord_ref[4].'
'.$$chord_ref[5].'
</pitch>
<duration>2</duration>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
<staff>1</staff>
</note>
<note>
<chord/>
<pitch>
'.$$chord_ref[6].'
'.$$chord_ref[7].'
</pitch>
<duration>2</duration>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
<staff>1</staff>
</note>
<note>
<pitch>
'.$$chord_ref[2].'
'.$$chord_ref[3].'
</pitch>
<duration>2</duration>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
<staff>1</staff>
</note>
<note>
<chord/>
<pitch>
'.$$chord_ref[4].'
'.$$chord_ref[5].'
</pitch>
<duration>2</duration>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
<staff>1</staff>
</note>
<note>
<chord/>
<pitch>
'.$$chord_ref[6].'
'.$$chord_ref[7].'
</pitch>
<duration>2</duration>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
<staff>1</staff>
</note>
<backup>
<duration>4</duration>
</backup>
<note>
<pitch>
'.$$chord_ref[0].'
'.$$chord_ref[1].'
</pitch>
<duration>4</duration>
<voice>5</voice>
<type>whole</type>
<staff>2</staff>
</note>
</measure>';
$measure_count++;
if ( $measure_count != 1 ) { $measure_temp = '<measure number="'.$measure_count.'">'."\n" }
elsif ( $measure_count == 1 ) { $measure_temp = "" }
$takte = $takte.$measure_temp.$vier4tel_takt_temp;
}
### Midi-Pattern erstellen
my $midi_muster = '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 3.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise>
<work>
<work-title>Midi-Muster</work-title>
</work>
<identification>
<creator type="composer">Zarko Maroli</creator>
<creator type="lyricist">Hembel</creator>
<encoding>
<software>MuseScore 2.0.2</software>
<encoding-date>2019-02-16</encoding-date>
<supports element="accidental" type="yes"/>
<supports element="beam" type="yes"/>
<supports element="print" attribute="new-page" type="yes" value="yes"/>
<supports element="print" attribute="new-system" type="yes" value="yes"/>
<supports element="stem" type="yes"/>
</encoding>
</identification>
<defaults>
<scaling>
<millimeters>7.05556</millimeters>
<tenths>40</tenths>
</scaling>
<page-layout>
<page-height>1683.36</page-height>
<page-width>1190.88</page-width>
<page-margins type="even">
<left-margin>56.6929</left-margin>
<right-margin>56.6929</right-margin>
<top-margin>56.6929</top-margin>
<bottom-margin>113.386</bottom-margin>
</page-margins>
<page-margins type="odd">
<left-margin>56.6929</left-margin>
<right-margin>56.6929</right-margin>
<top-margin>56.6929</top-margin>
<bottom-margin>113.386</bottom-margin>
</page-margins>
</page-layout>
<word-font font-family="FreeSerif" font-size="10"/>
<lyric-font font-family="FreeSerif" font-size="11"/>
</defaults>
<credit page="1">
<credit-words default-x="595.44" default-y="1626.67"
justify="center" valign="top"
font-size="24">Midi-Muster</credit-words>
</credit>
<credit page="1">
<credit-words default-x="1134.19" default-y="1526.67"
justify="right" valign="bottom" font-size="12">Zarko
Maroli</credit-words>
</credit>
<credit page="1">
<credit-words default-x="56.6929" default-y="1526.67" justify="left"
valign="bottom" font-size="12">Hembel</credit-words>
</credit>
<part-list>
<score-part id="P1">
<part-name>Piano</part-name>
<part-abbreviation>Pno.</part-abbreviation>
<score-instrument id="P1-I1">
<instrument-name>Piano</instrument-name>
</score-instrument>
<midi-device id="P1-I1" port="1"></midi-device>
<midi-instrument id="P1-I1">
<midi-channel>1</midi-channel>
<midi-program>1</midi-program>
<volume>78.7402</volume>
<pan>0</pan>
</midi-instrument>
</score-part>
</part-list>
<part id="P1">
<measure number="1" width="299.86">
<print>
<system-layout>
<system-margins>
<left-margin>21.00</left-margin>
<right-margin>0.00</right-margin>
</system-margins>
<top-system-distance>170.00</top-system-distance>
</system-layout>
<staff-layout number="2">
<staff-distance>65.00</staff-distance>
</staff-layout>
</print>
<attributes>
<divisions>1</divisions>
<key>
<fifths>0</fifths>
</key>
<time>
<beats>4</beats>
<beat-type>4</beat-type>
</time>
<staves>2</staves>
<clef number="1">
<sign>G</sign>
<line>2</line>
</clef>
<clef number="2">
<sign>F</sign>
<line>4</line>
</clef>
</attributes>
'.$takte.'
</part>
</score-partwise>';
# Pattern speichern
open ( my $fh, '>', "midi-pattern_xtended_konzeptentwickler-2-3.xml" );
print $fh $midi_muster;
close $fh;
Output-Ausschnitt
...
E-G-B-D-
A-CE-G-
D-EA-B
G-B-D-E
Transformierte Akkord-Folge im Gesamten:
E-2G4B-4D5
C2E-4G4B-5
F2A-4C4E-5
B-2D4F4A-5
G2B-4D4F5
C2E4G4B-5
F2A-4C4E-5
B-2D4F4A-5
B-2D4F4A5
B-2D4F4A5
B-2D-4F4A-5
F2A4C4E-5
A-2C4E-4G5
A-2C4E-4G5
A-2B4E-4G-5
E-2G4B-4D-5
G-2B-4D-4F5
G-2B-4D-4F5
G-2A4D-4E5
D-2F4A-4B5
D-2E4A-4B5
G-2B-4D-4E5
B2E-4G-4B-5
B2E-4G-4B-5
B2E-4G-4B-5
A-2B4E-4G-5
D-2E4A-4B5
G-2B-4D-4E5
E-2G-4B-4D-5
A-2C4E-4G-5
D-2E4A-4B5
G-2B-4D-4E5
<step>E</step><alter>-1</alter>
<octave>2</octave>
<step>G</step>
<octave>4</octave>
<step>B</step><alter>-1</alter>
<octave>4</octave>
<step>D</step>
<octave>5</octave>
...
Funzt! Wunnebar!
Ein Achtel bleibt noch ausständig: Das gekonnte Verbinden der Progressionen + 6 noch nicht eingepflegte derselben.
Kommentare
Kommentar veröffentlichen