Thema: Delphi code optimieren

Einzelnen Beitrag anzeigen

fwsp
(Gast)

n/a Beiträge
 
#1

code optimieren

  Alt 2. Feb 2006, 19:15
wer kann mir helfen diesen code zu verbessern?

Delphi-Quellcode:
function Skale(StartTon, Dauer: integer): string;
var Dur: array[1..8] of integer;
    Moll: array[1..8] of integer;
    Pentatonisch: array[1..6] of integer;
    Ganzton: array[1..7] of integer;
    Dorisch: array[1..8] of integer;
    Chromatisch: array[1..13] of integer;
    Zufall, i: integer;
begin
 case UGlobal.SkArt of
  1: Zufall:= random(2) + 1; //Dur, Moll
  2: Zufall:= random(4) + 1; //Dur, Moll, Pentatonisch, Ganzton
  3: Zufall:= random(6) + 1; //Dur, Moll, Pentatonisch, Ganzton, Dorisch, Chromatisch
  else Zufall:= 3;
  end;

 case Zufall of
  1: begin //Dur
      Dur[1]:= 0;
      Dur[2]:= 2;
      Dur[3]:= 4;
      Dur[4]:= 5;
      Dur[5]:= 7;
      Dur[6]:= 9;
      Dur[7]:= 11;
      Dur[8]:= 12;
      for i:= 1 to Length(Dur) do
       begin
        FMain.MidiOutput.PutShort($90, StartTon + Dur[i], UGlobal.IVLautstaerke);
        UPause.Pause(Dauer);
       end;
      Result:= 'Dur';
     end;

  2: begin //Moll
      Moll[1]:= 0;
      Moll[2]:= 2;
      Moll[3]:= 3;
      Moll[4]:= 5;
      Moll[5]:= 7;
      Moll[6]:= 8;
      Moll[7]:= 10;
      Moll[8]:= 12;
      for i:= 1 to Length(Moll) do
       begin
        FMain.MidiOutput.PutShort($90, StartTon + Moll[i], UGlobal.IVLautstaerke);
        UPause.Pause(Dauer);
       end;
      Result:= 'Moll';
     end;

  3: begin //Pentatonisch
      Pentatonisch[1]:= 0;
      Pentatonisch[2]:= 2;
      Pentatonisch[3]:= 4;
      Pentatonisch[4]:= 7;
      Pentatonisch[5]:= 9;
      Pentatonisch[6]:= 12;
      for i:= 1 to Length(Pentatonisch) do
       begin
        FMain.MidiOutput.PutShort($90, StartTon + Pentatonisch[i], UGlobal.IVLautstaerke);
        UPause.Pause(Dauer);
       end;
      Result:= 'Pentatonisch';
     end;

  4: begin //Ganzton
      Ganzton[1]:= 0;
      Ganzton[2]:= 2;
      Ganzton[3]:= 4;
      Ganzton[4]:= 6;
      Ganzton[5]:= 8;
      Ganzton[6]:= 10;
      Ganzton[7]:= 12;
      for i:= 1 to Length(Ganzton) do
       begin
        FMain.MidiOutput.PutShort($90, StartTon + Ganzton[i], UGlobal.IVLautstaerke);
        UPause.Pause(Dauer);
       end;
      Result:= 'Ganzton';
     end;

  5: begin //Dorisch
      Dorisch[1]:= 0;
      Dorisch[2]:= 2;
      Dorisch[3]:= 3;
      Dorisch[4]:= 5;
      Dorisch[5]:= 7;
      Dorisch[6]:= 9;
      Dorisch[7]:= 10;
      Dorisch[8]:= 12;
      for i:= 1 to Length(Dorisch) do
       begin
        FMain.MidiOutput.PutShort($90, StartTon + Dorisch[i], UGlobal.IVLautstaerke);
        UPause.Pause(Dauer);
       end;
      Result:= 'Dorisch';
     end;

  6: begin //Chromatisch
      Chromatisch[1]:= 0;
      Chromatisch[2]:= 1;
      Chromatisch[3]:= 2;
      Chromatisch[4]:= 3;
      Chromatisch[5]:= 4;
      Chromatisch[6]:= 5;
      Chromatisch[7]:= 6;
      Chromatisch[8]:= 7;
      Chromatisch[9]:= 8;
      Chromatisch[10]:= 9;
      Chromatisch[11]:= 10;
      Chromatisch[12]:= 11;
      Chromatisch[13]:= 12;
      for i:= 1 to Length(Chromatisch) do
       begin
        FMain.MidiOutput.PutShort($90, StartTon + Chromatisch[i], UGlobal.IVLautstaerke);
        UPause.Pause(Dauer);
       end;
      Result:= 'Chromatisch';
     end;

  end;
end;
danke.
  Mit Zitat antworten Zitat