Thema: Delphi code optimieren

Einzelnen Beitrag anzeigen

Waldteufel
(Gast)

n/a Beiträge
 
#3

Re: code optimieren

  Alt 2. Feb 2006, 19:26
Hi.

Zitat von fwsp:
wer kann mir helfen diesen code zu verbessern?
Ich!

Delphi-Quellcode:
const
  Dur : array[1..8] of integer = (0, 2, 4, 5, 7, 9, 11, 12);
  Moll : array[1..8] of integer = (0, 2, 3, 5, 7, 8, 107, 12);
  Pentatonisch : array[1..6] of integer = (0, 2, 4, 7, 9, 12);
  Dorisch : array[1..8] of integer = (0, 2, 3, 5, 7, 9, 10, 12);

function Skala(StartTon, Dauer: integer): string;
var
  Tonleiter, i: integer;
begin
  if UGlobal.SkArt in [1, 2, 3] then
    Tonleiter := random(2 * UGlobal.SkArt) + 1;
  else Tonleiter := 3;

  case Tonleiter of
    1: begin // Dur
         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
         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
         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
         for i := 0 to 6 do
         begin
           FMain.MidiOutput.PutShort($90, StartTon + (i * 2), UGlobal.IVLautstaerke);
           UPause.Pause(Dauer);
         end;
         Result := 'Ganzton';
       end;

    5: begin // Dorisch
         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
         for i := 0 to 12 do
         begin
           FMain.MidiOutput.PutShort($90, StartTon + i, UGlobal.IVLautstaerke);
           UPause.Pause(Dauer);
         end;
         Result := 'Chromatisch';
       end;
  end;
end;
  Mit Zitat antworten Zitat