Recent

Author Topic: A fairly simple sound solution? [SOLVED]  (Read 3571 times)

Giorgos

  • New Member
  • *
  • Posts: 14
A fairly simple sound solution? [SOLVED]
« on: April 18, 2024, 05:02:30 pm »
Hi!   8-)

Is there any fairly simple sound solution, one can use at a (rather simple) Pascal program?

Beep and Sound didn't work for me and I found other suggestions, but they're way too old (and irrelevant), for today's Linux standards, or much complicated (eg. using sophisticated C routines etc).

Please keep in mind, that Pascal (amongst many other things) is also an educational tool and I'm in need of a rather simple solution (like the above mentioned-but no working commands Beep and Sound) and not for excellent but sophisticated C or Java like code, which are all good and well, but I'll have a really hard time, trying to demonstrate them to novice learners.

TIA!   8)
G.
« Last Edit: April 23, 2024, 11:45:47 am by Giorgos »

Handoko

  • Hero Member
  • *****
  • Posts: 5341
  • My goal: build my own game engine using Lazarus
Re: A fairly simple sound solution?
« Reply #1 on: April 18, 2024, 05:24:43 pm »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: A fairly simple sound solution?
« Reply #2 on: April 18, 2024, 07:01:52 pm »
If its about learning, I suggest to give BASS a try. That is not a ready made class that you just feed with a file, that is a complete audio framework that needs to be controlled over their API, Delphi headers are existing, I hope compatible to FPC. Many demos available, extendable with more plugins, read EULA about prices but I assume in your case it can stay total free. To get out a sound such you learn within minutes, either by reading the good made documentation or open some demos to learn from. Its partly crossplatform, read on homepage for yourself what target systems are supported.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

Giorgos

  • New Member
  • *
  • Posts: 14
Re: A fairly simple sound solution?
« Reply #3 on: April 19, 2024, 01:37:13 pm »
THANKS guys for your help!!!   :D

@Handoko:

I already read this topic amongst other similar.
Don't take it wrong, but these posts are 7-8yo.
Linux (unlike Windows) is somewhat  hostile, against older versions or aged software.
Try running binaries, or compile code so old...well...good luck with it!   :D

@ KodeZwerg:

I'll definitely try it, but it isn't what I was looking for.
For an enhanced "Hello World" program, maybe with colorized output (eg. Cyan instead of white letters) and wanting to make a simple sound (just to demonstrate the ability), messing with complex RAD functions, is not really helpful.

THANKS again!!!   :)

paweld

  • Hero Member
  • *****
  • Posts: 1250
Re: A fairly simple sound solution?
« Reply #4 on: April 19, 2024, 01:46:11 pm »
Best regards / Pozdrawiam
paweld

Giorgos

  • New Member
  • *
  • Posts: 14
Re: A fairly simple sound solution?
« Reply #5 on: April 23, 2024, 11:45:19 am »
I found a simple solution, based on executing shell programs.
(In this case, a console media player).

Code: Pascal  [Select][+][-]
  1. program sound;
  2.  
  3. uses Unix;
  4.  
  5. begin
  6.   fpSystem('play -q ~/TEMPG/SAMPLE.WAV');
  7. end.

A short WAV file, somewhere in the filesystem will do.
I used play, but also aplay, paplay or any console media player will do.

PS. It written ages ago. Today's FPC, throughs a warning (although the program compiles and run flawlessly).

Code: Pascal  [Select][+][-]
  1. >fpc PLAY.PAS
  2. Free Pascal Compiler version 3.0.4+dfsg-22 [2019/01/24] for x86_64
  3. Copyright (c) 1993-2017 by Florian Klaempfl and others
  4. Target OS: Linux for x86-64
  5. Compiling PLAY.PAS
  6. PLAY.PAS(6,7) Warning: Symbol "fpSystem" is deprecated: "use ansistring version"
  7. Linking PLAY
  8. /usr/bin/ld.bfd: warning: link.res contains output sections; did you forget -T?
  9. 7 lines compiled, 0.2 sec
  10. 1 warning(s) issued
  11. >

VisualLab

  • Hero Member
  • *****
  • Posts: 541
Re: A fairly simple sound solution? [SOLVED]
« Reply #6 on: April 23, 2024, 12:48:08 pm »
Hi!   8-)

Is there any fairly simple sound solution, one can use at a (rather simple) Pascal program?

Beep and Sound didn't work for me and I found other suggestions, but they're way too old (and irrelevant), for today's Linux standards, or much complicated (eg. using sophisticated C routines etc).

Please keep in mind, that Pascal (amongst many other things) is also an educational tool and I'm in need of a rather simple solution (like the above mentioned-but no working commands Beep and Sound) and not for excellent but sophisticated C or Java like code, which are all good and well, but I'll have a really hard time, trying to demonstrate them to novice learners.

This is an operating system modeled on the old OS designed for mainframe machines. It is constantly being developed mainly to support networks, servers, etc. solutions. And it works well there. Unfortunately, Linux is not suitable for teaching or presenting multimedia solutions (audio, video, animations, fancy graphics, etc.). Yes, there are attempts to use Linux for specific multimedia applications (e.g. video editing -> DaVinci), but they are not suitable for programming education.

Please don't take this as an insult or a malicious comment. This is simply the architecture of Linux and this is how its programmers want to develop it (like many other open source projects). And users can use what is available or they can look for a different solution.

Besides, Windows multimedia solutions are not that simple either (although much better designed and operated). Unfortunately, multimedia support requires knowledge of API and/or external libraries. There are no shortcuts here.

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: A fairly simple sound solution? [SOLVED]
« Reply #7 on: April 23, 2024, 01:48:26 pm »
Besides, Windows multimedia solutions are not that simple either (although much better designed and operated). Unfortunately, multimedia support requires knowledge of API and/or external libraries. There are no shortcuts here.
I just typed here in a hurry, should be working without even reading api, so it might be wrong but anyway not overcomplicated.
Code: Pascal  [Select][+][-]
  1. uses
  2.  MMSystem;
  3.  
  4. procedure PlayWavFile(const FileName: string);
  5. begin
  6.  sndPlaySound(PChar(FileName), snd_Async or snd_NoDefault);
  7. end;
  8.  
  9. begin
  10.  PlayWavFile('C:\path\to\your\sound.wav');
  11. end.
Or do it like the OP does and simple execute the wave file to start systems playback (in hope something useful is associated with).
For a more custom type of usage where you have more control over the playback, there are methods to be used and I agree, on that part you should start to read to know how its used correct.
From point of api, you can start at SoundMixer to select an output device over to decode audio to finally feed the output device with the buffered raw audio data.
Possibilities are endless, whatever you wish, the api provide it. If its about Mono/Stereo/Custom, Volume, DSP effects, visualized, equalizer and and and... api can do the job.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

Thaddy

  • Hero Member
  • *****
  • Posts: 16032
  • Censorship about opinions does not belong here.
Re: A fairly simple sound solution? [SOLVED]
« Reply #8 on: April 23, 2024, 06:52:55 pm »
@Videolab
your statements are simply not true. Most professional video editing is done under unix OS's.

More in general, we lack a simple sound interface like python has and that is perfectly capable for educational purposes, including synthesizers. It is just that nobody bothers to write that in FPC. But that can be done. Just like the Raspberry Pi community has proven for python, we can do that in FPC. It has simply not been done yet.
But if playng a simple wav is enough? There are better examples on this forum.
If I smell bad code it usually is bad code and that includes my own code.

VisualLab

  • Hero Member
  • *****
  • Posts: 541
Re: A fairly simple sound solution? [SOLVED]
« Reply #9 on: April 23, 2024, 07:46:18 pm »
@Videolab
your statements are simply not true. Most professional video editing is done under unix OS's.

To confirm this, some public and trustworthy reports would be needed. Probably no one keeps such lists (because it won't be of any use to anyone anyway). I agree that Unix computers are used to perform video (and 3D) rendering (and I didn't deny it). However, it works in batch mode (which is obvious because it is a time-consuming process). And this applies mainly to rendering, rather than editing (apart from "raisins" such as DaVinci Resolve Blackmagic Design, which I mentioned earlier).

More in general, we lack a simple sound interface like python has and that is perfectly capable for educational purposes, including synthesizers. It is just that nobody bothers to write that in FPC. But that can be done. Just like the Raspberry Pi community has proven for python, we can do that in FPC. It has simply not been done yet.
But if playng a simple wav is enough? There are better examples on this forum.

Yes. Agreement.

My entry, however, concerned problems (chaos) with multimedia support in Linux. Because no matter what, the emphasis in Linux development is mainly on the network and servers. And multimedia is more the domain of workstations and desktops. In this respect, Linux is a mess and makeshift solutions (DE fragmentation, lack of agreed solutions at the system level). And the root cause is the disagreement between programmers of different DEs, their stubborn stubbornness towards the adopted solutions, ill-considered decisions, reluctance and laziness to develop and maintain stable APIs, etc. (i.e.: the human factor failed, as usual). This translates into quite real problems for end users, including people who are just starting to learn programming. And the fact that Lazarus does not support multimedia (classes, APIs, etc.) well in Linux is largely a secondary problem (because it is platform dependent).
« Last Edit: April 23, 2024, 07:47:55 pm by VisualLab »

Thaddy

  • Hero Member
  • *****
  • Posts: 16032
  • Censorship about opinions does not belong here.
Re: A fairly simple sound solution? [SOLVED]
« Reply #10 on: April 23, 2024, 08:37:08 pm »
Blender, Da Vinci and Lightworks are cross platform and miles ahead.
Blender is even open source. And it laughs at Windows only solutions.
(and yes you can edit video with blender, before you squick)
« Last Edit: April 23, 2024, 08:41:45 pm by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11868
  • FPC developer.
Re: A fairly simple sound solution? [SOLVED]
« Reply #11 on: April 23, 2024, 09:07:11 pm »
Blender, Da Vinci and Lightworks are cross platform and miles ahead.

But being crossplatform is not the same as being used for the bulk of videoediting. More conclusive evidence please!

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: A fairly simple sound solution? [SOLVED]
« Reply #12 on: April 23, 2024, 09:23:37 pm »
And it laughs at Windows only solutions.
Strange logic you whispering there.
In belonging to multimedia creative solutions, raytracing, CAD, audio and video editing etc, I would switch to the apple products.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

 

TinyPortal © 2005-2018