AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

code optimieren

Ein Thema von fwsp · begonnen am 2. Feb 2006 · letzter Beitrag vom 2. Feb 2006
 
Benutzerbild von Khabarakh
Khabarakh

Registriert seit: 18. Aug 2004
Ort: Brackenheim VS08 Pro
2.876 Beiträge
 
#4

Re: code optimieren

  Alt 2. Feb 2006, 19:58
Fertig, kurz genug ?
Delphi-Quellcode:
function Skala(StartTon, Dauer: integer): string;
const
  Scales: array[0..3 * 8 + 6 - 1] of Integer =
  (0, 2, 4, 5, 7, 9, 11, 12, // Dur
   0, 2, 3, 5, 7, 8, 10, 12, // Moll
   0, 2, 4, 7, 9, 12, // Pentatonisch
   0, 2, 3, 5, 7, 9, 10, 12); // Dorisch
  Starts: Array[0..4] of Integer = (0, 8, 8 + 6, 2 * 8 + 6, 3 * 8 + 6);
  Names: Array[0..5] of string = ('Dur', 'Moll', 'Pentatonisch', 'Dorisch',
                                  'Ganzton', 'Chromatisch');
var
  Scale, i: Integer;

  procedure PutIt(const Tone: Integer);
  begin
    // Ieeks, globale Variablen
    FMain.MidiOutput.PutShort($90, Tone, UGlobal.IVLautstaerke);
    UPause.Pause(Dauer);
  end;

begin
  if UGlobal.SkArt in [1, 2, 3] then
    Scale := Random(2 * UGlobal.SkArt);
  else
    Scale := 2;

  case Scale of
    0..3:
      for i := Starts[Scale] to Starts[Scale + 1] - 1 do
        PutIt(Startton + Scales[i]);

    4: // Ganzton
      for i := 0 to 6 do
        PutIt(Startton + 2 * i);

    5: // Chromatisch
      for i := 0 to 12 do
        PutIt(Startton + i);
  end;

  Result := Names[Scale];
end;
Vielleicht sind noch kleine Fehler drin, aber die kannst du ja selbst verbessern.
Sebastian
Moderator in der EE
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 13:28 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz