Pascal and Musical Tones :D lazarus / 21-General ---------------------------------------------------------------------- OC DelGuy · 2025-01-02 00:49 I got this little bit of code from Chat GPT and it works fine.  Everything in the code block is ChatGPT except that I changed and added to the note values (ChatGPT only gave Hz values[and only 500, 1000, 1500, 2000 and 3000]).  I added the notes (letters) and changed their respective Hz's and I added the additional nine notes.  And I added the last procedure "DoReMi". I'm having trouble with Beeps not playing.  It's just 4 Beeps, but only 3 play.  I know that all 4 notes actually play because when I play them using the BeepButton, they play.  The first Beep is getting skipped. Also, the Label.Caption line seems to be getting skipped.  Only the last Caption shows("Fa"). I thought the Label.Caption would change and then the  BeepAtFrequency would play the respective beep frequency.  Right now it just plays the last 3 beeps and THEN changes the Caption! You're killing me, Lazzy! Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls, Windows; type   { TForm1 }   TForm1 = class(TForm)    BeepButton: TButton;    DoReMi: TButton;    FrequencyComboBox: TComboBox;    FrequencyLabel: TLabel;  procedure DoReMiClick(Sender: TObject);    procedure FormCreate(Sender: TObject);    procedure BeepButtonClick(Sender: TObject);  private   public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormCreate(Sender: TObject);begin  // Populate the frequency combo box with different values (in Hertz).  FrequencyComboBox.Items.Add('C4      - 261.63 Hz');  FrequencyComboBox.Items.Add('C#4/Db4 - 277.18 Hz');  FrequencyComboBox.Items.Add('D4      - 293.66 Hz');  FrequencyComboBox.Items.Add('D#4/Eb4 - 311.13 Hz');  FrequencyComboBox.Items.Add('E4      - 329.63 Hz');  FrequencyComboBox.Items.Add('F4      - 349.23 Hz');  FrequencyComboBox.Items.Add('F#4/Gb4 - 369.99 Hz');  FrequencyComboBox.Items.Add('G4      - 392.00 Hz');  FrequencyComboBox.Items.Add('G#4/Ab4 - 415.30 Hz');  FrequencyComboBox.Items.Add('A4      - 440.00 Hz');  FrequencyComboBox.Items.Add('A#4/Bb4 - 466.16 Hz');  FrequencyComboBox.Items.Add('B4      - 493.88 Hz');  FrequencyComboBox.Items.Add('C5      - 523.25 Hz');  // Set a default selection  FrequencyComboBox.ItemIndex := 0;   // Update the label to show the selected frequency  FrequencyLabel.Caption := 'Frequency: 261.63 Hz'; end; // Procedure to generate a beep at the given frequency (in Hz)procedure BeepAtFrequency(Frequency: Integer);begin  // Use the Windows Beep function to play the beep sound  Beep(Frequency, 500);  // 500 milliseconds durationend; procedure TForm1.BeepButtonClick(Sender: TObject);var  Frequency: Integer;begin  // Get the selected frequency from the combo box  case FrequencyComboBox.ItemIndex of    0: Frequency := 261;    1: Frequency := 277;    2: Frequency := 293;    3: Frequency := 311;    4: Frequency := 329;    5: Frequency := 349;    6: Frequency := 369;    7: Frequency := 392;    8: Frequency := 415;    9: Frequency := 440;   10: Frequency := 466;   11: Frequency := 493;   12: Frequency := 523;  else    Frequency := 261;     // Default to 261 Hz  end;   // Update the label to show the frequency  FrequencyLabel.Caption := 'Frequency: ' + IntToStr(Frequency) + ' Hz';   // Generate the beep with the selected frequency  BeepAtFrequency(Frequency);end; procedure TForm1.DoReMiClick(Sender: TObject);begin  FrequencyLabel.Caption := 'Do';  BeepAtFrequency(261);   FrequencyLabel.Caption := 'Re';  BeepAtFrequency(293);   FrequencyLabel.Caption := 'Mi';  BeepAtFrequency(329);   FrequencyLabel.Caption := 'Fa';  BeepAtFrequency(349); end;  end. ---------------------------------------------------------------------- Fred vS · 2025-01-02 01:00 Hello. Maybe try adding application.processmessages ? : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.DoReMiClick(Sender: TObject);begin  FrequencyLabel.Caption := 'Do';  BeepAtFrequency(261);  application.processmessages;     FrequencyLabel.Caption := 'Re';  BeepAtFrequency(293);  application.processmessages;    FrequencyLabel.Caption := 'Mi';  BeepAtFrequency(329);  application.processmessages;     FrequencyLabel.Caption := 'Fa';  BeepAtFrequency(349);  application.processmessages; end; QuoteEverything in the code block is ChatGPT except that I changed and added to the note values (ChatGPT only gave Hz values[and only 500, 1000, 1500, 2000 and 3000]).You should ask it to uos: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i const   // musical note ==> frequency in hertz  // Latin: Do, Ré, Mi, Fa, Sol, La, Si   // Dièse = _d example la0_d   la0  = 55.0;  la0_d = 58.3;  si0 = 61.7;  do0 =  65.4;  do0_d = 69.3;  re0 = 73.4;  re0_d = 77.8;  mi0  = 82.4;  fa0  = 87.3;  fa0_d = 92.5;  sol0 = 98.0;  sol0_d = 103.8;  la1  = 110.0;  la1_d = 116.5;  si1 = 123.5;  do1 =  130.8;  do1_d = 138.6;  re1 = 146.8;  re1_d = 155.6;  mi1  = 164.8;  fa1  = 174.6;  fa1_d = 185.0;  sol1 = 196.0;  sol1_d = 207.7;  la2 = 220.0;  la2_d = 233.1;  si2 = 2246.9;  do2 =  261.6;  do2_d = 277.2;  re2 = 293.7;  re2_d = 311.1;  mi2  = 329.6;  fa2  = 349.2;  fa2_d = 370.0;  sol2 = 392.0;  sol2_d = 415.3;  la3  = 440.0;  la3_d = 466.2;  si3 = 493.9;  do3 =  523.3;  do3_d = 554.4;  re3 = 587.3;  re3_d = 622.3;  mi3 = 659.3;  fa3  = 698.5;  fa3_d = 740.0;  sol3 = 784.0;  sol3_d = 830.6;  la4 = 880.0;  la4_d = 932.4;  si4 = 987.8;  do4 =  1046.6;  do4_d = 1108.8;  re4 = 1174.6;  re4_d = 1244.6;  mi4 = 1318.6;  fa4  = 1397.0;  fa4_d = 1480.0;  sol4 = 1568.0;  sol4_d = 1661.2;  la5 = 1760.0;   // German music note  // A, B, C, D, E, F, G  a0  = 55.0;  a0_s = 58.3;  b0 = 61.7;  c0 =  65.4;  c0_s = 69.3;  d0 = 73.4;  d0_s = 77.8;  e0  = 82.4;  f0  = 87.3;  f0_s = 92.5;  g0 = 98.0;  g0_s = 103.8;  a1  = 110.0;  a1_s = 116.5;  b1 = 123.5;  c1 =  130.8;  c1_s = 138.6;  d1 = 146.8;  d1_s = 155.6;  e1  = 164.8;  f1  = 174.6;  f1_s = 185.0;  g1 = 196.0;  g1_s = 207.7;  a2 = 220.0;  a2_s = 233.1;  b2 = 2246.9;  c2 =  261.6;  c2_s = 277.2;  d2 = 293.7;  d2_s = 311.1;  e2  = 329.6;  f2  = 349.2;  f2_s = 370.0;  g2 = 392.0;  g2_s = 415.3;  a3  = 440.0;  a3_s = 466.2;  b3 = 493.9;  c3 =  523.3;  c3_s = 554.4;  d3 = 587.3;  d3_s = 622.3;  e3 = 659.3;  f3  = 698.5;  f3_s = 740.0;  g3 = 784.0;  g3_s = 830.6;  a4 = 880.0;  a4_s = 932.4;  b4 = 987.8;  c4 =  1046.6;  c4_s = 1108.8;  d4 = 1174.6;  d4_s = 1244.6;  e4 = 1318.6;  f4  = 1397.0;  f4_s = 1480.0;  g4 = 1568.0;  g4_s = 1661.2;  a5 = 1760.0; ---------------------------------------------------------------------- Fred vS · 2025-01-02 01:14 Re-hello. Maybe you will need also a sleep(duration_of_beep); Like this (sorry I dont have Windows to test): Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     procedure TForm1.DoReMiClick(Sender: TObject);    begin      FrequencyLabel.Caption := 'Do';      BeepAtFrequency(261);      application.processmessages;      Sleep(500);           FrequencyLabel.Caption := 'Re';      BeepAtFrequency(293);      application.processmessages;      Sleep(500);           FrequencyLabel.Caption := 'Mi';      BeepAtFrequency(329);      application.processmessages;      Sleep(500);           FrequencyLabel.Caption := 'Fa';      BeepAtFrequency(349);      application.processmessages;      Sleep(500);    end; ---------------------------------------------------------------------- OC DelGuy · 2025-01-03 06:02 Thanks I'll put those two lines in.  I had already thought about using Delay() to match the tempo of the beeps with a song, but I stopped because I was having the missing beep problem.  And the Delay()'s would go exactly where you put the sleeps. All those extra notes!  I'm not musically inclined.  I'm just writing a short program that generates the tones like in the Rodgers and Hammerstein musical "The Sound of Music".  I might include other little tunes by writing a few more button events, but my knowledge of music is very lacking.  Later on I might add graphic piano keys and TShapes to make a keyboard.  Those notes will come in handy then!  Oh, full disclosure, I got the 13 frequencies (in OP) from ChatGPT too. ---------------------------------------------------------------------- Fred vS · 2025-01-03 14:30 Quote from: OC DelGuy on January 03, 2025, 07:02:41 amLater on I might add graphic piano keys and TShapes to make a keyboard.  Those notes will come in handy then!  You may take inspiration from this project (it uses MSEgui pure Pascal widgetset). ---------------------------------------------------------------------- Thaddy · 2025-01-03 18:50 You can simply use 1.05946 as a const to resolve between notes. Everybody does that: it is the equal tempered 12 note scale. Which happens to be the 12th root of two. But indeed, you can use a lookup table from, say, C-4 upto C+4 to prevent calculations. (mimicing 144 key grand piano) ---------------------------------------------------------------------- Bart · 2025-01-03 19:12 Reminds me of an old "piano" program I once wrote using TP 6.0 and it's graph unit. It supported glissando/staccato (yeah, right) and you could save/read in a simple format. Maybe I even have the code somewhere on a floppy disk (not that I have a floppy drive anymore...). @Thaddy: it used 12th root of 2 (as a constant, used my calculator for that) for the calculations. Those were the days... Bart ---------------------------------------------------------------------- Thaddy · 2025-01-03 20:19 I do not have the code anymore, but my program is still downloadable from: https://www.softpedia.com/get/Multimedia/Audio/Other-AUDIO- Tools/Chord-Finder.shtml I wrote that as a birthday present for a very good friend. She is a star singer/songwriter. (Btw: If I find the code, it also has a piano keyboard control and midi support, see screenshots) Rather flattered it is still available ---------------------------------------------------------------------- Fred vS · 2025-01-04 15:48 Quote from: Thaddy on January 03, 2025, 09:19:19 pmI do not have the code anymore, but my program is still downloadable from: https://www.softpedia.com/get/Multimedia/Audio/Other-AUDIO- Tools/Chord-Finder.shtml Hello Thaddy. Looks nice! But the link for download gives this (see screen-shot). ---------------------------------------------------------------------- Fred vS · 2025-01-04 16:37 Quote from: OC DelGuy on January 02, 2025, 01:49:11 amI got this little bit of code from Chat GPT and it works fine. It helped me to understand the Thaddy/Bart trick of 12th root of 2  : Q: Write a Pascal program to calculate piano note in hertz using root 12 of 2. A: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program PianoNoteFrequency;var  root12of2, baseFrequency, noteFrequency: real;  semitoneOffset: integer;begin  { Calculate the 12th root of 2 }  root12of2 := exp(ln(2) / 12);    { Set the base frequency of A4 (440 Hz) }  baseFrequency := 440.0;    { Input the number of semitones from A4 }  writeln('Enter the number of semitones from A4 (positive for higher notes, negative for lower notes): ');  readln(semitoneOffset);    { Calculate the frequency of the note }  noteFrequency := baseFrequency * exp(ln(root12of2) * semitoneOffset);    { Output the result }  writeln('The frequency of the note is: ', noteFrequency:0:2, ' Hz');end. QuoteKey Points:     root12of2 stores the value of the 12th root of 2, calculated using exp(ln(2) / 12).     baseFrequency is the reference frequency, which is 440 Hz for A4.     semitoneOffset is the number of semitones the note is away from A4. A positive value is for higher notes, and a negative value is for lower notes.     The frequency of the note is calculated as f(n)=f0×(2n12)f(n)=f0​×(212n​), or equivalently, f(n)=baseFrequency×ro ot12of2semitoneOffsetf(n)=baseFrequency×root12of2semitoneOffset. Example:     If you input 0, the output will be 440.00 Hz (which is A4).     If you input -9, the output will be 261.63 Hz (which is C4, 9 semitones below A4). This program can calculate the frequency of any piano note by specifying how many semitones it is away from A4. [EDIT] Q: Ok, now write a Pascal program that calculates the frequency by note name, like A2, A3#, C4b, ... A: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program PianoNoteByName; uses sysutils;var  root12of2, baseFrequency, noteFrequency: real;  noteName: string;  semitoneOffset, octave: integer; { Function to convert note name (with optional sharp or flat) to semitone offset from A4 }function GetSemitoneOffset(note: string; octave: integer): integer;var  notePart: string;  accidental: char;  noteBaseOffset: integer;  hasAccidental: boolean;begin  hasAccidental := false;   { Check if the last character is a sharp (#) or flat (b) }  accidental := note[length(note)];  if (accidental = '#') or (accidental = 'b') then  begin    hasAccidental := true;    notePart := copy(note, 1, length(note) - 1);  { All but the last character (for Bb or A#) }  end  else  begin    notePart := note;  { The entire note (without accidental) }  end;   { Base semitone offsets relative to A4 (using C0 as reference) }  if notePart = 'C' then    noteBaseOffset := -9  { C is 9 semitones below A in the same octave }  else if notePart = 'D' then    noteBaseOffset := -7  else if notePart = 'E' then    noteBaseOffset := -5  else if notePart = 'F' then    noteBaseOffset := -4  else if notePart = 'G' then    noteBaseOffset := -2  else if notePart = 'A' then    noteBaseOffset := 0  else if notePart = 'B' then    noteBaseOffset := 2  else  begin    writeln('Error: Invalid note name!');    halt;  end;   { Adjust for accidentals (sharp '#' or flat 'b') if applicable }  if hasAccidental then  begin    if accidental = 'b' then      noteBaseOffset := noteBaseOffset - 1  { Flat lowers by 1 semitone }    else if accidental = '#' then      noteBaseOffset := noteBaseOffset + 1; { Sharp raises by 1 semitone }  end;   { Calculate total semitone offset relative to A4 }  GetSemitoneOffset := noteBaseOffset + (octave - 4) * 12;end; begin  { Calculate the 12th root of 2 }  root12of2 := exp(ln(2) / 12);    { Set the base frequency of A4 (440 Hz) }  baseFrequency := 440.0;    { Input the note name (e.g., C4, A3, Bb3, A#3) }  writeln('Enter the note (e.g., C4, A3, Bb3, A#3): ');  readln(noteName);    { Extract the octave from the input (the last character) }  octave := StrToInt(noteName[length(noteName)]);  { Last character is the octave number }   { Calculate the semitone offset from A4, based on the note name and octave }  semitoneOffset := GetSemitoneOffset(copy(noteName, 1, length(noteName) - 1), octave);    { Calculate the frequency of the note using the semitone offset }  noteFrequency := baseFrequency * exp(ln(root12of2) * semitoneOffset);    { Output the result }  writeln('The frequency of ', noteName, ' is: ', noteFrequency:0:2, ' Hz');end. QuoteHow It Works:     Input:         You can input note names like C4, A3, Bb3 (B-flat 3), or A#3 (A-sharp 3).     Processing:         The function GetSemitoneOffset computes the semitone offset based on the note's name and octave.         It supports flats (b) and sharps (#) by adjusting the semitone offset accordingly.     Calculation:         The semitone offset is then used to calculate the note's frequency based on the reference frequency of A4 = 440 Hz.         The formula used is f(n)=f0×(2n12)f(n)=f0​×(212n​), which is implemented using the exp(ln(root12of2) * semitoneOffset).     Output:        The frequency of the note is displayed in Hertz (Hz), rounded to 2 decimal places. Example Inputs and Outputs:     Input: C4         Output: The frequency of C4 is: 261.63 Hz     Input: A3         Output: The frequency of A3 is: 220.00 Hz     Input: Bb3         Output: The frequency of Bb3 is: 233.08 Hz     Input: A#3         Output: The frequency of A#3 is: 233.08 Hz (same as Bb3, as they are enharmonic equivalents) Key Features:     Supports both sharps (#) and flats (b) in the note name.     Calculates frequencies for notes across different octaves.     Handles octave numbers properly and calculates semitone offsets from A4 (440 Hz). This program will be user-friendly for musicians who are familiar with both flat and sharp notation and want to calculate the frequency of any note in the equal temperament scale.Wow. ---------------------------------------------------------------------- Thaddy · 2025-01-04 20:17 Quote from: Fred vS on January 04, 2025, 04:48:41 pmBut the link for download gives this (see screen-shot). Maybe I still have it, but need to search some disconnected hard disks. Or maybe it is still on one of mywebservers but out of sight. Have to check. I know for sure it is still in the wild somewhere. BTW, you should really do what Bart and I both suggested: It is a constant distance. So creating a table of 12X12 of singles and precalculate the exp(ln(root12of2) for the matrix will speed up your code considerably since then it becomes a lookup instead of the expensive exp/ln. I would not use the constant I gave you for the lookup table, but calculate the table with the formula for higher precision - it is only once -, although over the range it does not matter much. A lookup also saves many clock cycles that can be used for audio processing. And a 144 note range should be plenty. ---------------------------------------------------------------------- Fred vS · 2025-01-05 02:49 For the fun, this project release to show frequencies of notes. In both notation (german: A2, C#3, Gb1...) or latin solfege (do3, re2, mi#4, ...). It uses the 12th root of 2 trick and MSEgui widgetset. [EDIT] Added conversion of frequency to nearest piano note. [EDIT2] QuoteSo creating a table of 12X12 of singles and precalculate the exp(ln(root12of2) for the matrixOK, this work: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i const  NumNotes = 12;  { Number of semitones per octave }  A4Frequency = 440.0;  { Reference frequency for A4 (440 Hz) }  A4Index = 9;  { A4 is the 10th note in the scale (0-indexed), hence position 9 in the octave }  A4Octave = 4;  { A4 is in the 4th octave (C0 starts at octave 0) } var  frequencies: array[1..NumNotes, 1..NumNotes] of real;  { 12x12 array for frequencies }  i, j, n: integer;  { Loop variables }  powerFactor: real; begin   { Calculate and fill the frequencies array }  for i := 0 to NumNotes-1 do   { i = octave }    for j := 0 to NumNotes-1 do  { j = note in the octave }    begin      { Calculate the number of semitone steps away from A4 (A4 = 440 Hz at octave 4) }      n := (i * NumNotes + j) - (A4Octave * NumNotes + A4Index);      powerFactor := n / 12.0;      frequencies[i+1, j+1] := A4Frequency * exp(powerFactor * ln(2));  { Calculate frequency using exp and ln }  end;end; ---------------------------------------------------------------------- Thaddy · 2025-01-05 08:47 Fred, while searching for the chordfinder code, that I did not fid yet,I found something that may be of interest to you. A 32 bit audio manipulation library I wrote in 2004. Written in 8087 assembly and some mmx. At the time I did all audio processing in the floating point domain before passing the audio to ASIO buffers in the correct format. Should also work with Alsa or Jack buffers. Well documented. Win/Lin. Attached. ---------------------------------------------------------------------- Fred vS · 2025-01-05 20:21 Quote from: Thaddy on January 05, 2025, 09:47:47 amFred, while searching for the chordfinder code, that I did not fid yet,I found something that may be of interest to you. A 32 bit audio manipulation library I wrote in 2004. Written in 8087 assembly and some mmx. At the time I did all audio processing in the floating point domain before passing the audio to ASIO buffers in the correct format. Should also work with Alsa or Jack buffers. Well documented. Win/Lin. Attached. Hello Thaddy. Wow, great project. I dont use Windows anymore (nor Jack) but sure I can find some interesting things. Many thanks and have a perfect year. Fre;D ---------------------------------------------------------------------- Boleeman · 2025-01-06 09:26 Accidentally came across some interesting sound/tone JavaScript programs here while looking for something else: https://github.com/aatishb/stringmath https://github.com/aatishb/springtuning https://github.com/aatishb/preparedpianosynth https://github.com/aatishb/differencetones https://github.com/aatishb/sound-microscope Might be useful to get some ideas for a Lazarus sound/tone explorer. ---------------------------------------------------------------------- Thaddy · 2025-01-11 10:52 Quote from: Fred vS on January 05, 2025, 09:21:30 pmQuote from: Thaddy on January 05, 2025, 09:47:47 amFred, while searching for the chordfinder code, that I did not fid yet, Found it. Windows only. Needs Kol/kol64 and the 3.0.4 compiler. Both keyboard and fretboard notes can be played with a mouse. The most common guitar tunings are supported. Guitar chords can be copied to the clipboard as bitmap. Also supports a midi external keyboard (two ways), by default uses the MS midi synth. 21 years old and still looking good... And just 36 kilobyte, yes kilo. ---------------------------------------------------------------------- Fred vS · 2025-01-11 11:20 Hello Thaddy. Great! I will try it asap (using wine and after installing fpc 3.0.4). Write you soon. Fre;D ---------------------------------------------------------------------- Thaddy · 2025-01-11 12:03 It runs under wine. I tried that at the time. I just noticed this is not the fpc version, so just add {$ifdef fpc}{$mode delphi}{$endif} to the units. That is all the difference. For kol you need to define asmmode intel and purepascal. ---------------------------------------------------------------------- Fred vS · 2025-01-11 13:23 Quote from: Thaddy on January 11, 2025, 01:03:04 pmIt runs under wine. I tried that at the time. Hum, here on XUbuntu 24.4, no luck, see picture. Quote from: Thaddy on January 11, 2025, 01:03:04 pmI just noticed this is not the fpc version, so just add {$ifdef fpc}{$mode delphi}{$endif} to the units. That is all the difference. For kol you need to define asmmode intel and purepascal. OK, added {$mode delphi} in all units and used KOL code from there (is it ok?): https://github.com/rofl0r/KOL/ But error at compilation: (in attachment, the KOL.pas that I used). Quotefred@fred-IdeaPad:~/thaddy/chordfinder/KOL-master$ wine fpc.exe -B -FUunits /home/fred/thaddy/chordfinder/Chordfinder.dpr Free Pascal Compiler version 3.2.2 for i386 Copyright (c) 1993-2024 by Florian Klaempfl and others Target OS: Win32 for i386 Compiling \home\fred\thaddy\chordfinder\Chordfinder.dpr Compiling KOL.pas KOL.pas(228,7) Warning: Virtual methods are used without a constructor in "_TObj " KOL.pas(275,6) Warning: Destructor should be public KOL.pas(391,5) Warning: Destructor should be public KOL.pas(570,5) Warning: Destructor should be public KOL.pas(703,5) Warning: Destructor should be public KOL.pas(855,5) Warning: Destructor should be public KOL.pas(1187,5) Warning: Destructor should be public KOL.pas(2016,5) Warning: Destructor should be public KOL.pas(2535,5) Warning: Destructor should be public KOL.pas(2841,5) Warning: Destructor should be public KOL.pas(9044,5) Warning: Destructor should be public KOL.pas(9145,5) Warning: Destructor should be public KOL.pas(9207,5) Warning: Destructor should be public KOL.pas(10614,5) Warning: Destructor should be public KOL.pas(11886,3) Warning: Some fields coming after "aSetBkColor" were not initia lized KOL.pas(11935,3) Warning: Some fields coming after "aSetBkColor" were not initia lized KOL.pas(12085,3) Warning: Some fields coming after "aSetBkColor" were not initia lized KOL.pas(12449,29) Error: OFFSET used without identifier KOL.pas(12449,29) Error: Invalid constant expression KOL.pas(12449,41) Error: Assembler syntax error in operand KOL.pas(12458,29) Error: OFFSET used without identifier KOL.pas(12458,29) Error: Invalid constant expression KOL.pas(12458,41) Error: Assembler syntax error in operand KOL.pas(12468,28) Error: OFFSET used without identifier KOL.pas(12468,28) Error: Invalid constant expression KOL.pas(12468,40) Error: Assembler syntax error in operand KOL.pas(12483,18) Error: Unknown identifier "SYSTEM.LSTRCLR" KOL.pas(12483,18) Error: Assembler syntax error KOL.pas(12510,19) Warning: No size specified and unable to determine the size of  the operands, using DWORD as default KOL.pas(13104,18) Warning: No size specified and unable to determine the size of  the operands, using DWORD as default KOL.pas(13333,19) Warning: Calling an overload function in assembler KOL.pas(13365,48) Error: Error building record offset KOL.pas(13369,48) Error: Error building record offset KOL.pas(13475,30) Warning: Use of +offset(%ebp) for parameters invalid here KOL.pas(13480,29) Warning: Use of +offset(%ebp) for parameters invalid here KOL.pas(13583,18) Warning: Calling an overload function in assembler KOL.pas(13654,19) Warning: Calling an overload function in assembler KOL.pas(14180,27) Error: OFFSET used without identifier KOL.pas(14180,27) Error: Invalid constant expression KOL.pas(14180,35) Error: Assembler syntax error in operand KOL.pas(14190,25) Error: OFFSET used without identifier KOL.pas(14190,25) Error: Invalid constant expression KOL.pas(14190,33) Error: Assembler syntax error in operand KOL.pas(14623,53) Error: OFFSET used without identifier KOL.pas(14623,53) Error: Invalid constant expression KOL.pas(14623,62) Error: Assembler syntax error in operand KOL.pas(14625,60) Error: OFFSET used without identifier KOL.pas(14625,60) Error: Invalid constant expression KOL.pas(14625,76) Error: Assembler syntax error in operand KOL.pas(14657,53) Error: OFFSET used without identifier KOL.pas(14657,53) Error: Invalid constant expression KOL.pas(14657,61) Error: Assembler syntax error in operand KOL.pas(14659,60) Error: OFFSET used without identifier KOL.pas(14659,60) Error: Invalid constant expression KOL.pas(14659,75) Error: Assembler syntax error in operand KOL.pas(14665,29) Error: OFFSET used without identifier KOL.pas(14665,29) Error: Invalid constant expression KOL.pas(14665,39) Error: Assembler syntax error in operand KOL.pas(14692,53) Error: OFFSET used without identifier KOL.pas(14692,53) Error: Invalid constant expression KOL.pas(14692,60) Error: Assembler syntax error in operand KOL.pas(14694,60) Error: OFFSET used without identifier KOL.pas(14694,60) Error: Invalid constant expression KOL.pas(14694,74) Error: Assembler syntax error in operand KOL.pas(14895,47) Error: Error building record offset KOL.pas(14899,47) Error: Error building record offset KOL.pas(14939,44) Error: Error building record offset KOL.pas(15055,18) Warning: No size specified and unable to determine the size of  the operands, using DWORD as default KOL.pas(15078,18) Warning: No size specified and unable to determine the size of  the operands, using DWORD as default KOL.pas(15176,29) Warning: Use of -offset(%ebp) is not recommended for local var iable access KOL.pas(15191,9) Warning: fdivrp without operand translated into fdivrpP KOL.pas(15191,9) Warning: "fdivrp" without operand translated into "fdivrp %st,% st(1)" KOL.pas(15194,9) Warning: fmulp without operand translated into fmulpP KOL.pas(15201,29) Warning: Use of -offset(%ebp) is not recommended for local var iable access KOL.pas(15205,9) Warning: fmulp without operand translated into fmulpP KOL.pas(15211,9) Warning: fmulp without operand translated into fmulpP KOL.pas(15218,9) Warning: faddp without operand translated into faddpP KOL.pas(15218,9) Warning: "faddp" without operand translated into "faddp %st,%st (1)" KOL.pas(15219,9) Warning: fdivrp without operand translated into fdivrpP KOL.pas(15219,9) Warning: "fdivrp" without operand translated into "fdivrp %st,% st(1)" KOL.pas(15220,9) Warning: faddp without operand translated into faddpP KOL.pas(15220,9) Warning: "faddp" without operand translated into "faddp %st,%st (1)" KOL.pas(15228,9) Warning: fmulp without operand translated into fmulpP KOL.pas(15234,9) Warning: fmulp without operand translated into fmulpP KOL.pas(15263,29) Warning: Use of -offset(%ebp) is not recommended for local var iable access KOL.pas(15282,29) Warning: Use of -offset(%ebp) is not recommended for local var iable access KOL.pas(15352,51) Error: OFFSET used without identifier KOL.pas(15352,51) Error: Invalid constant expression KOL.pas(15352,62) Error: Assembler syntax error in operand KOL.pas(15354,45) Error: Error building record offset KOL.pas(15382,46) Error: Error building record offset KOL.pas(15384,36) Error: Error building record offset KOL.pas(15419,40) Error: Error building record offset KOL.pas(15419,40) Fatal: There were 50 errors compiling module, stopping Fatal: Compilation aborted ---------------------------------------------------------------------- Thaddy · 2025-01-11 13:29 I see. Easy to fix, give a bit of time. Delphi is a bit more leanient with asm syntax.I used to have a Fpc version but that was not on one of my servers (where I found it eventually) As is it compiles with D7, but I will make it compile again in freepascal. You need to define purepascal, then the basm code is skipped altogether. ---------------------------------------------------------------------- Fred vS · 2025-01-11 13:37 Quote from: Thaddy on January 11, 2025, 02:29:10 pmbut I will make it compile again in freepascal. Zeer goed!  (And maybe also a Linux version and dont hesitate to create a github or gitlab or codeberg or gitelse ... project of your wonderful Chordfinder .  ) ---------------------------------------------------------------------- Thaddy · 2025-01-11 22:44 Anyway, while I am busy fixing that, the drawing routines will work in a Lazarus control. As will the midi stuff. ---------------------------------------------------------------------- TBMan · 2025-01-11 23:32 I'm doing this, but its in Borland Pascal. I haven't stepped up to Lazarus as yet although I have it installed. This is a preliminary music unit for a Pac Man clone I'm doing (just for my own entertainment). It uses the old CRT unit for the sound and delay calls. I have only one "dotted" note duration set up as I didn't need any others for the PacMan intro tune. You would need "rests" also, as rest32, rest16, rest8, rest4 etc and also the dotted rests as well set up as duration constants.  The pause procedure used may vary in other runtime environments. YMMV. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Unit Music;Interfaceuses crt; Const  Note32 = 600;  Note32D= 900;  Note16 = 1200;  Note8  = 2400;  Note4  = 4800;  Note2  = 9600;  Note1  = 19200; Type  NoteType = (A1,AS1,B1,C2,CS2,D2,DS2,E2,F2,FS2,G2,GS2,A2,AS2,B2,              C3,CS3,D3,DS3,E3,F3,FS3,G3,GS3,A3,AS3,B3,              C4,CS4,D4,DS4,E4,F4,FS4,G4,GS4,A4);  var  Hz: array[A1..A4] of word; Note:NoteType;   Procedure InitNotes;Procedure PlayNote(N:NoteType;Duration:word);Procedure PacManIntro; Implementation Procedure InitNotes;begin    Hz[a1]  := 55;    Hz[As1] := 58;    Hz[B1]  := 62;    Hz[C2]  := 65;    Hz[CS2] := 69;    Hz[D2]  := 73;    Hz[DS2] := 79;    Hz[E2]  := 82;    Hz[F2]  := 87;    Hz[Fs2] := 93;    Hz[G2]  := 98;    Hz[GS2] := 104;    Hz[A2]  := 110;    Hz[As2] := 117;    Hz[B2]  := 124;    Hz[C3]  := 131;    Hz[Cs3] := 139;    Hz[D3]  := 147;    Hz[Ds3] := 156;    Hz[E3]  := 165;    Hz[F3]  := 175;    Hz[Fs3] := 185;    Hz[G3]  := 196;    Hz[Gs3] := 208;    Hz[A3]  := 220;    Hz[As3] := 233;    Hz[B3]  := 247;    Hz[C4]  := 262;    Hz[Cs4] := 277;    Hz[D4]  := 294;    Hz[Ds4] := 311;    Hz[E4]  := 330;    Hz[F4]  := 349;    Hz[Fs4] := 370;    Hz[G4]  := 392;    Hz[GS4] := 415;    Hz[A4] :=  440;  end;    Procedure Pause;begin  delay(10);end;   Procedure PlayN ote(N:NoteType;Duration:word);beginSound(Hz[N]);delay(Duration);NoSoun d;pause;end; Procedure PacManIntro;beginPlayNote(c2,Note16);Playnote(c 4,Note16);PlayNote(G3,Note16);PlayNote(E3,Note16);  Playnote(g3,Note32 );PlayNote(C4,Note32D);PlayNote(E3,Note8); PlayNote(Cs2,Note16);PlayNo te(cs4,Note16);PlayNote(gs3,Note16); PlayNote(F3,Note16);playnote(gs3, Note32);playnote(cs4,Note32D);PlayNote(f3,Note8);  PlayNote(c2,Note16) ;Playnote(c4,Note16);PlayNote(G3,Note16);PlayNote(E3,Note16);Playnote( g3,Note32);PlayNote(C4,Note32D);PlayNote(E3,Note8);PlayNote(Cs2,Note16 );PlayNote(cs4,Note16);PlayNote(gs3,Note16);PlayNote(F3,Note16);playno te(gs3,Note32);playnote(cs4,Note32D);PlayNote(f3,Note8); PlayNote(c3,N ote16);PlayNote(c4,Note16);PlayNote(g3,Note16);PlayNote(e3,note16);Pla yNote(g3,Note32);PlayNote(c4,Note32d);PlayNote(e3,Note8); PlayNote(g2, Note32);PlayNote(gs2,Note32);PlayNote(a2,Note16);PlayNote(gs2,Note32); PlayNote(a2,Note32);PlayNote(as2,Note16);PlayNote(a2,Note32);PlayNote( as2,Note32);PlayNote(b2,Note16);PlayNote(c3,Note8);end; begininitnotes ; end. ---------------------------------------------------------------------- Roland57 · 2025-01-12 03:11 My contribution: a program which creates a MIDI file from a MML string. https://gitlab.com/rchastain/qbasic-music-to-midi-file