Recent

Author Topic: PlaySound: my comments  (Read 6619 times)

AlexTP

  • Hero Member
  • *****
  • Posts: 2402
    • UVviewsoft
PlaySound: my comments
« on: May 25, 2017, 06:21:38 pm »
PlaySound package by minesadorada

a)  better name - TPlaySound in camel case

b)  RegisterComponents('LazControls', [Tplaysound]);
please, use 'Misc' tab, coz LazControls tab is hard to see on start, Misc is shown better. (I dont see LazControls tab on start)

c) procedure Tplaysound.PlaySound(const szSoundFilename: string);
Better make 2 procedures, inside ifdefs, not make 1 procedure with ifdefs
It is better separation

d) good to name func parameters as "A"+text, eg AFileName
« Last Edit: May 25, 2017, 06:51:30 pm by Alextp »

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: PlaySound: my comments
« Reply #1 on: May 25, 2017, 06:36:45 pm »
What are you talking about?

AlexTP

  • Hero Member
  • *****
  • Posts: 2402
    • UVviewsoft
Re: PlaySound: my comments
« Reply #2 on: May 25, 2017, 06:38:40 pm »
PlaySound package in OnlinePackageManager by minesadorada.

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: PlaySound: my comments
« Reply #3 on: May 25, 2017, 06:44:00 pm »
PlaySound package in OnlinePackageManager by minesadorada.

Why would you want to use that? Beginners should use beep, intermediate programmers sound, and real programmers use a decent sound library or write one.
But minesadorada's effort simply works without your comments.  O:-) He clearly belongs to the latter, you see?  :D
« Last Edit: May 25, 2017, 06:47:41 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

AlexTP

  • Hero Member
  • *****
  • Posts: 2402
    • UVviewsoft
Re: PlaySound: my comments
« Reply #4 on: May 25, 2017, 06:49:56 pm »
Why not to give comments.

Why i want it, it plays WAV files, i don't know how to play them.

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: PlaySound: my comments
« Reply #5 on: May 25, 2017, 07:28:51 pm »
Alex, do you know that you can rearrange the assignment of components to palettes? Right-click component palette, "Options". In the left list, select the palette with TPlaySound, click on TPlaySound in the right list and drag it to the palette in which you want to have it.

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: PlaySound: my comments
« Reply #6 on: May 25, 2017, 07:30:38 pm »
Why would you want to use that?
Maybe he wants to play a soundfile in a simple way on Windows and/or Linux systems using the same code...

Handoko

  • Hero Member
  • *****
  • Posts: 5153
  • My goal: build my own game engine using Lazarus
Re: PlaySound: my comments
« Reply #7 on: May 25, 2017, 09:05:33 pm »
d) good to name func parameters as "A"+text, eg AFileName

I don't think this below is good:
Code: Pascal  [Select][+][-]
  1. procedure DrawCircle(AX, AY, ARadius: integer; AFillColor, ABorderColor: TColor; ABorderThickness: integer);

But in some cases it is good, for example the parameter name is a reserved word:
Code: Pascal  [Select][+][-]
  1. procedure AddToList(anObject: TObject);

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: PlaySound: my comments
« Reply #8 on: May 25, 2017, 10:44:51 pm »
I don't think this below is good:
Code: Pascal  [Select][+][-]
  1. procedure DrawCircle(AX, AY, ARadius: integer; AFillColor, ABorderColor: TColor; ABorderThickness: integer);
What's wrong with it? All variables beginning with an "A" tell me that they are parameters passed as procedure arguments. And it avoids the problem of {$mode objfpc} which requests procedure arguments to be named differently from class variables.

Handoko

  • Hero Member
  • *****
  • Posts: 5153
  • My goal: build my own game engine using Lazarus
Re: PlaySound: my comments
« Reply #9 on: May 26, 2017, 03:57:28 am »
Nothing wrong. I personally prefer without the "A" because it does not make it more readable, but in some cases I use it because it is needed.

minesadorada

  • Sr. Member
  • ****
  • Posts: 452
  • Retired
Re: PlaySound: my comments
« Reply #10 on: May 26, 2017, 08:46:31 am »
PlaySound package by minesadorada

a)  better name - TPlaySound in camel case

b)  RegisterComponents('LazControls', [Tplaysound]);
please, use 'Misc' tab, coz LazControls tab is hard to see on start, Misc is shown better. (I dont see LazControls tab on start)

c) procedure Tplaysound.PlaySound(const szSoundFilename: string);
Better make 2 procedures, inside ifdefs, not make 1 procedure with ifdefs
It is better separation

d) good to name func parameters as "A"+text, eg AFileName


Hi @Alextp
The spirit of open source is improvement through collaboration.

With any code I submit to this community - I hope for suggestions and positive criticisms which will improve the contribution.

Thank you for your comments and suggestions about TPlaySound, which I think have merit.

Feel free to improve the code and submit the result.

The component was written as a very simple solution to a common problem - playing WAV files in Linux.   I welcome any improvements, as I am not a regular Linux user.
GPL Apps: Health MonitorRetro Ski Run
OnlinePackageManager Components: LazAutoUpdate, LongTimer, PoweredBy, ScrollText, PlaySound, CryptINI

 

TinyPortal © 2005-2018