Recent

Author Topic: MIDI file generator - work in progress  (Read 22265 times)

sash

  • Sr. Member
  • ****
  • Posts: 366
Re: MIDI file generator - work in progress
« Reply #15 on: December 05, 2018, 12:08:59 pm »
Ubuntu Linux 18.04, 64 bit.

Random seed: 1562018
Lazarus 2.0.10 FPC 3.2.0 x86_64-linux-gtk2 @ Ubuntu 20.04 XFCE

finlazarus

  • New Member
  • *
  • Posts: 11
Re: MIDI file generator - work in progress
« Reply #16 on: December 05, 2018, 09:05:14 pm »
Hi sash!

Sounds exactly the same as mine mid. Do you have AMD or Intel processor in your PC?

sash

  • Sr. Member
  • ****
  • Posts: 366
Re: MIDI file generator - work in progress
« Reply #17 on: December 05, 2018, 10:18:09 pm »
Code: [Select]
OS: Ubuntu 18.04 bionic
Kernel: x86_64 Linux 4.15.0-42-generic
CPU: AMD FX-6300 Six-Core @ 6x 3.5GHz
GPU: GeForce GTX 1060 3GB
RAM: 2081MiB / 7941MiB
Lazarus 2.0.10 FPC 3.2.0 x86_64-linux-gtk2 @ Ubuntu 20.04 XFCE

finlazarus

  • New Member
  • *
  • Posts: 11
Re: MIDI file generator - work in progress
« Reply #18 on: December 12, 2019, 08:48:37 pm »
Hi there! Added ComboBox for choosing the tempo for the generated MIDI file. Also the default setup is different. All  my PCs have AMD processor and I'm still curious to know if the Pentium generated sequence differs from the AMD one. Does anyone there have a Pentium machine? Could you try this code and send the MIDI file here? I really would like to know if there is a difference  :)

sstvmaster

  • Sr. Member
  • ****
  • Posts: 300
Re: MIDI file generator - work in progress
« Reply #19 on: December 12, 2019, 10:44:58 pm »
Hi,

here Win7 32bit, Pentium T4500, L2.0.6 32bit.

It is different.
greetings Maik

Windows 10,
- Lazarus 2.2.6 (stable) + fpc 3.2.2 (stable)
- Lazarus 2.2.7 (fixes) + fpc 3.3.1 (main/trunk)

finlazarus

  • New Member
  • *
  • Posts: 11
Re: MIDI file generator - work in progress
« Reply #20 on: December 13, 2019, 12:55:48 am »
Thanks sstvmaster!
It's different indeed! Good to know this. A nice piece of (Pentium) music though :D. Interesting start in the melody and kinda nice melodic curves in the middle.
« Last Edit: December 13, 2019, 03:48:11 am by finlazarus »

metis

  • Sr. Member
  • ****
  • Posts: 300
Re: MIDI file generator - work in progress
« Reply #21 on: December 20, 2019, 02:15:21 pm »
@finlazarus

I have no Idea about MIDI-Programming - I only found some Code in my CodeArchive, that might be helpful for You:

i was unable to find pascal headers for libportmidi
-> see attached 'PortMidi.7z' (= downloaded from 'Breakout Box' some Years ago)

'TMidiInput' and 'TMidiOutput':
-> see attached 'midi.7z' (= downloaded from 'Breakout Box' some Years ago)

Quote
At the moment I'm interest in generating random kind of midi music
So this should be the most interesting for You: 'Ramugen v2' (= Random Music Generator) by Greg Fox.
-> see attached 'Ramugen.7z'
(I had to strip all compiled EXE-Files, because of the Limitation of the Attachment to max. 250KB).  %)

Just keep on going - Creating something on Your own is always Fun.  :)
« Last Edit: December 27, 2019, 06:14:42 pm by metis »
Life could be so easy, if there weren't those f*** Details.
My FFmpeg4Lazarus = FFPlay4Laz + FFGrab4Laz + FFInfo4Laz

jelston

  • Newbie
  • Posts: 1
Re: MIDI file generator - work in progress
« Reply #22 on: March 18, 2020, 11:35:14 pm »
G'Day Guys,
I have played around with the pl_win_midi and found a couple of problems namely a memory leak in a couple of components and an error in saving a MIDI file. The changes I made are here:

In file cmpMidiInput.pas
   
destructor TMidiInput.Destroy;
var
  idx : TPortRange;
  i : Integer;
begin
  for idx := Low (TPortRange) to High (TPortRange) do
    ClosePort (idx);

  while fSysexHeaders.Count > 0 do
    TidySysexBuffers;
  fSysexHeaders.free;   //     now no memory leak

  SetRecording (False, Nil);

  for i := 0 to fTakes.Count - 1 do
    TObject (fTakes ).Free;
  fTakes.Free;

  if assigned(fRecordBuffer) then fRecordBuffer.free;
  if assigned(fMidiEchoPort) then fMidiEchoPort.Free;
  inherited;
end;

------------------------------------------------------
Add to cmpMidiOutput.pas
destructor TMidiOutputPort.Destroy;
begin
  Active := False;
  WaitForSysex;
  fSysexHeaders.Free; //  avoid memory leak
 
  inherited
end;

//-------------------------------------
This fixes a problem when saving a MIDI File at runtime
in cmpMidiData.pas
Change NoTracks property to word type
 
 
function  GetNoTracks : word;       
property NoTracks : Word read GetNoTracks;
function TMidiData.GetNoTracks: word;

Sample Code to creatre a MIDI file at runtime
var
  mf:TMIDIData;
  eD:TEventData;   
begin
   mf:= TMIDIData.create(self);
   mf.AddNewTrack(0);
  ed.status := $90; ed.b2 := 60; ed.b3:= 100; // note on
    m.Tracks[0].InsertEvent(0,eD,0);

    ed.status := $80; ed.b2 := 60; ed.b3:= 0;  // note off
    m.Tracks[0].InsertEvent(180,eD,0);         
 
   mf.FileName:='test.mid';
   mf.Save;
   
   mf.free;
end;       
   

avra

  • Hero Member
  • *****
  • Posts: 2532
    • Additional info
Re: MIDI file generator - work in progress
« Reply #23 on: March 19, 2020, 10:18:07 am »
G'Day Guys,
I have played around with the pl_win_midi and found a couple of problems namely a memory leak in a couple of components and an error in saving a MIDI file.
The origin of that package is CodeTyphon fork of Lazarus. You should report bug fixes for CodeTyphon packages in their forum: https://www.pilotlogic.com/sitejoom/index.php/forum.html
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

bycyclepost

  • Newbie
  • Posts: 1
Re: MIDI file generator - work in progress
« Reply #24 on: April 23, 2023, 03:44:13 am »
hi group
im new here and have taken a couple years away from coding , i enjoy midi and auto generating midi files ..is the author of this topic still active here , id be interested to modify and add to the 2 trk source ,,,
b.p.

germona

  • Newbie
  • Posts: 2
Re: MIDI file generator - work in progress
« Reply #25 on: November 30, 2024, 01:38:52 pm »
Yes, this code works fine with my Lazarus IDE v3.4 on Manjaro Linux.
I am also looking for a lazarus program that can do the reverse, so reading a midi file and show in a form or terminal the start of the notes, the duration, and the velocity.
Would that also be possible, or do you know somebody that wrote someting like that?
Thanks
Jean from Belgium.

 

TinyPortal © 2005-2018