Recent

Author Topic: Lazarus sample projects  (Read 18175 times)

tr_escape

  • Sr. Member
  • ****
  • Posts: 437
  • sector name toys | respect to spectre
    • Github:
Lazarus sample projects
« on: June 16, 2015, 09:55:42 am »
Hello everyone,

I am collecting some samples about delphi / lazarus for beginners.
You may found in that link:

https://sourceforge.net/projects/lazprojects/

For now that projects included:

1- Box2d Lazarus.
2- LazMaze
3- LazScrollingLeds
4- LazCompass
5- LazAstroDemo
6- LazMolecules
7- LazCannonBall
8- LazSimpleSokoban
9- LazOpenGLSample  : Not I used bmp images, jpg files gives some errors.
10 - LazAggPas : AggPas library for fpc/lazarus
11 - LazPlayMidi : A mini midi player from jc99 lazarus user.


Not: All projects converted from Delphi please be ensure delphi mode of lazarus.

Please don't use for commercial issues/projects.

NOTE: All projects compiled in Windows7 with Lazarus 1.4 fpc 2.6.4.

Have fun.
« Last Edit: June 22, 2015, 10:02:09 am by tr_escape »

jc99

  • Hero Member
  • *****
  • Posts: 553
    • My private Site
Re: Lazarus sample projects
« Reply #1 on: June 21, 2015, 03:48:57 pm »
WOW !
There you have some really cool starter-pojects at your hand:
(Y)
WTG
PS: Seems like something audio/multimedia is missing
if you want you can use my Playmidi-prj someone (only) has to remove the Win-Only-Dependency.
see: http://forum.lazarus.freepascal.org/index.php/topic,28809.msg181045
OS: Win XP x64, Win 7, Win 7 x64, Win 10, Win 10 x64, Suse Linux 13.2
Laz: 1.4 - 1.8.4, 2.0
https://github.com/joecare99/public
'~|    /''
,_|oe \_,are
If you want to do something for the environment: Twitter: #reduceCO2 or
https://www.betterplace.me/klimawandel-stoppen-co-ueber-preis-reduzieren

tr_escape

  • Sr. Member
  • ****
  • Posts: 437
  • sector name toys | respect to spectre
    • Github:
Re: Lazarus sample projects
« Reply #2 on: June 22, 2015, 07:13:16 am »
hello jc99,

Yes actually sound issues will a good idea for this library.
I can add your sample into laz-projects as LazPlayMidi.rar

But I think there is some units missing "Unt_PlayMidi".
Could you add as attach in this topic?


thank you !

best regards

« Last Edit: June 22, 2015, 07:20:16 am by tr_escape »

jc99

  • Hero Member
  • *****
  • Posts: 553
    • My private Site
Re: Lazarus sample projects
« Reply #3 on: June 22, 2015, 09:13:41 am »
OMG, you are right, then I have to apologize in the other thread:
it's here:
Code: [Select]
unit Unt_PlayMidi;

{$IFDEF FPC}
  {$MODE Delphi}
{$ENDIF}

interface

uses FileUtil;

type TPlayNotify=procedure(Sender:Tobject;Position,Length:string;var Break:boolean) of object;
procedure Midi(const aResName: String;Notify:TPlayNotify=nil);

implementation

uses
{$IFnDEF FPC}

{$ELSE}
  LCLIntf, LCLType,
{$ENDIF}
   windows,dialogs,forms,     mmSystem,classes,sysutils;

resourcestring
  {$IFDEF GERMAN}
  SResourceNotFound = 'Die Ressource kann nicht gefunden werden.';
  {$ELSE}
  SResourceNotFound = 'The resource can not be found.';
  {$ENDIF}

procedure Midi;
const
  Len: Cardinal = MAX_PATH;
  tmpFile: String = '~tmpFile01'; // Name of temporary file
var
  Stream: TCustomMemoryStream;
  BufLen, BufPos, tmpPath: String;
  breakFlag: Boolean;
  lBuflen: integer;
  lBufPos: integer;
begin
  // Get Temp-Directory
  SetLength(tmpPath, Len);
  GetTempPath(Len, PChar(tmpPath));
  tmpPath := StrPas(PChar(tmpPath)) + tmpFile;


  mciSendString('stop mySound', nil, 0, 0);
  mciSendString('close mySound', nil, 0, 0);
  {$IFDEF FPC}
  if FileExistsUTF8(tmpPath) then // delete temporary file, if exists
    DeleteFileUTF8(tmpPath);
  {$ELSE}
  if FileExists(tmpPath) then // delete temporary file, if exists
    DeleteFile(tmpPath);
  {$ENDIF}


  if FindResource(hInstance, PChar(aResName), 'MIDIFILE') <> 0 then
  begin // is Ressource availible ?
    try
      Stream := TResourceStream.Create(hInstance, aResName, 'MIDIFILE'); // create stream
      Stream.SaveToFile(tmpPath); // save temporary file
    finally
      Stream.Free;
    end;
  end
  else
  begin
    MessageBeep(MB_ICONEXCLAMATION);
    MessageDlg(SResourceNotFound, mtError, [mbOk], 0);
    Exit;
  end;


  mciSendString(PChar('open sequencer!' + tmpPath + ' alias mySound'), nil, 0, 0);
  mciSendString('play mySound' , nil, 0, 0);


  SetLength(BufLen, Len);
  SetLength(BufPos, Len);
  breakFlag:=False;
  mciSendString('status mySound length', pchar(BufLen), Len, 0); // get length of midifile ...
  trystrtoint(pchar(BufLen),lBuflen);
  repeat
    mciSendString('status mySound position', Pchar(BufPos), Len, 0); // get actual position ...
     trystrtoint(Pchar(BufPos),lBufPos);
    if assigned(notify) then
      notify(application,Pchar(BufPos), pchar(BufLen),breakFlag);
    Application.ProcessMessages;
    if Application.Terminated then
      break;
  until (lBufPos >= lBuflen) or breakFlag; // ... until end of file reached
  mciSendString('stop mySound', nil, 0, 0);
  mciSendString('close mySound', nil, 0, 0); 

 
  {$IFDEF FPC}
  if FileExistsUTF8(tmpPath) then // delete temporary file
    DeleteFileUTF8(tmpPath);
  {$ELSE}
  if FileExists(tmpPath) then // delete temporary file
    DeleteFile(tmpPath);
  {$ENDIF}
end;

end.

it has to be in "../source" folder.
BTW: Delphi - form is still inside, and .dpr is main file, so it should compile on both lazarus and delphi.
« Last Edit: June 22, 2015, 09:23:30 am by jc99 »
OS: Win XP x64, Win 7, Win 7 x64, Win 10, Win 10 x64, Suse Linux 13.2
Laz: 1.4 - 1.8.4, 2.0
https://github.com/joecare99/public
'~|    /''
,_|oe \_,are
If you want to do something for the environment: Twitter: #reduceCO2 or
https://www.betterplace.me/klimawandel-stoppen-co-ueber-preis-reduzieren

tr_escape

  • Sr. Member
  • ****
  • Posts: 437
  • sector name toys | respect to spectre
    • Github:
Re: Lazarus sample projects
« Reply #4 on: June 22, 2015, 09:37:41 am »
Hello Jc99,

I added your project into

https://sourceforge.net/projects/lazprojects/files/LazPlayMidi/

directory.

Thank you so much.

Best regards

jc99

  • Hero Member
  • *****
  • Posts: 553
    • My private Site
Re: Lazarus sample projects
« Reply #5 on: June 22, 2015, 12:56:19 pm »
Did you try it ? Does it work, for you ?
OS: Win XP x64, Win 7, Win 7 x64, Win 10, Win 10 x64, Suse Linux 13.2
Laz: 1.4 - 1.8.4, 2.0
https://github.com/joecare99/public
'~|    /''
,_|oe \_,are
If you want to do something for the environment: Twitter: #reduceCO2 or
https://www.betterplace.me/klimawandel-stoppen-co-ueber-preis-reduzieren

tr_escape

  • Sr. Member
  • ****
  • Posts: 437
  • sector name toys | respect to spectre
    • Github:
Re: Lazarus sample projects
« Reply #6 on: June 22, 2015, 02:19:37 pm »
Yes,

It is working correctly. I changed some little issue but it is working.


JD

  • Hero Member
  • *****
  • Posts: 1913
Re: Lazarus sample projects
« Reply #7 on: June 22, 2015, 02:57:04 pm »
Thanks a lot for sharing these sample projects. I'm impressed.  :D

JD
Linux Mint - Lazarus 4.6/FPC 3.2.2,
Windows - Lazarus 4.6/FPC 3.2.2

mORMot 2, PostgreSQL & MariaDB.

Tim Kieu

  • Newbie
  • Posts: 5
Re: Lazarus sample projects
« Reply #8 on: July 29, 2015, 06:14:01 am »
Hi there,

I cannot make it run in ubuntu 14.04 x64.
When I compile in Lazarus 1.4.2 an error occurs:
Compile Project, Mode: Release1, Target: x86_64-linux/Prj_TstPlayMidi: Exit code 1, Errors: 1
Unt_PlayMidi.pas(23,4) Fatal: Cannot find unit windows used by Unt_PlayMidi of the Project Inspector.


PLease help.

Thaddy

  • Hero Member
  • *****
  • Posts: 19283
  • Glad to be alive.
Re: Lazarus sample projects
« Reply #9 on: July 29, 2015, 07:33:19 am »
That project is for windows only. As jc99 indicated above you have to remove the dependency on windows. The control itself is cross platform.
objects are fine constructs. You can even initialize them with constructors.

jc99

  • Hero Member
  • *****
  • Posts: 553
    • My private Site
Re: Lazarus sample projects
« Reply #10 on: July 29, 2015, 09:10:56 am »
That project is for windows only. As jc99 indicated above you have to remove the dependency on windows. The control itself is cross platform.
Hi Thaddy, you are right, Windows only for now.
I still search for a Linux-way to solve the problem, ( in a slim way, using standard components only)
OS: Win XP x64, Win 7, Win 7 x64, Win 10, Win 10 x64, Suse Linux 13.2
Laz: 1.4 - 1.8.4, 2.0
https://github.com/joecare99/public
'~|    /''
,_|oe \_,are
If you want to do something for the environment: Twitter: #reduceCO2 or
https://www.betterplace.me/klimawandel-stoppen-co-ueber-preis-reduzieren

jc99

  • Hero Member
  • *****
  • Posts: 553
    • My private Site
Re: Lazarus sample projects
« Reply #11 on: December 19, 2015, 03:28:45 pm »
@tr_escape:
With the new 1.6RC1 i made a Project-Group-File.
... And removed some Windows-Dependencies.
  e.G: in Multiscript (sendmessage)
        replaced some shellexecute with OpenURI ...

Would you like them too ?
OS: Win XP x64, Win 7, Win 7 x64, Win 10, Win 10 x64, Suse Linux 13.2
Laz: 1.4 - 1.8.4, 2.0
https://github.com/joecare99/public
'~|    /''
,_|oe \_,are
If you want to do something for the environment: Twitter: #reduceCO2 or
https://www.betterplace.me/klimawandel-stoppen-co-ueber-preis-reduzieren

jc99

  • Hero Member
  • *****
  • Posts: 553
    • My private Site
Re: Lazarus sample projects
« Reply #12 on: December 20, 2015, 01:45:52 pm »
Is it possible, that AgeProblemsolver has a MemLeak-Problem ?
 
OS: Win XP x64, Win 7, Win 7 x64, Win 10, Win 10 x64, Suse Linux 13.2
Laz: 1.4 - 1.8.4, 2.0
https://github.com/joecare99/public
'~|    /''
,_|oe \_,are
If you want to do something for the environment: Twitter: #reduceCO2 or
https://www.betterplace.me/klimawandel-stoppen-co-ueber-preis-reduzieren

 

TinyPortal © 2005-2018