Recent

Author Topic: Component for Audio  (Read 20268 times)

DM

  • Newbie
  • Posts: 6
Component for Audio
« on: August 08, 2013, 10:40:38 am »
Why isn't there a component for audio?

What I would like is just a component for setting the sample-rate and buffer-size. And then you double click on the component you come to a procedure, there you can put a loop to fill the audio buffer with data. Nothing more, nothing less.

That would be a great component for making music-programs that can be ported between platforms. You actually don't need more than that to make audio applications for making music. It could also be used for games and more.

I think that it would not be that hard to make if you know system programming, but if everyone for all history has to start messing to get audio working, it's a huge wast of time. Solve it once and for all. I think this problem can be solved within the Lazarus project. It would be totally fantastic if Lazarus had support for setting up a audio-buffer as standard, or else they will use some C derivate as it's easier for getting started.

If someone make a sound-buffer component, and we can make it a part of Lazarus. I will personally write some audio synthesis tutorials for beginners, dedicated to Lazarus. I think it also will be a great reason to use Lazarus over many other tools out there.

If someone is not sure that this alone is enough, I can assure that it is. When you make audio applications, it's important to be in full control of the audio-stream, and the only way, is just to use a audio buffer and nothing more. Thats how all professionals do it.

You can't rely on the timing in a operating system. You always hardcode the positions of sounds in music programs to the buffer. By this, you always get 100% accuracy of sample playback, with over 100 times higher accuracy than ever possible otherwise.

Lets say you could be 100% sure that the OS always responded i the exact millisecond, every millisecond; that would still be less accurate. Thats why you calculate the exact sample everything happens and just write it in to the sample buffer. It's not harder than that. And thats why you only want the buffer and nothing more.

I truly believe that Lazarus could make a change in this world. It has the power to do it, by making things like this standard. And a audio-buffer is very basic and at the same time the most professional.

Thats why it will be accepted by people that know that the are doing, and can give Lazarus good reputation for being fast to use, and get the job done.

Ok, maybe they want a buffer from audio-in also, but thats it. This can get you started fast. But the thing is to make people choosing Lazarus as their platform, by starting to use it, and spend some time with it.

You don't want to make research for a few weeks, to make sore that you can use Lazarus to get the job done. It that case Lazarus will all-ways fail 99% or more of the times, when it comes to audio. Lets change that.


BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Component for Audio
« Reply #1 on: August 08, 2013, 10:42:37 am »
Looking forward to your component!
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1260
Re: Component for Audio
« Reply #2 on: August 08, 2013, 11:10:54 am »
As do I :-)

In the meantime, read through here.  There may be something that meets your requirements.

http://wiki.lazarus.freepascal.org/Multimedia_Programming

and http://wiki.lazarus.freepascal.org/ACS (which was linked from the previous page anyway)
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

DM

  • Newbie
  • Posts: 6
Re: Component for Audio
« Reply #3 on: August 08, 2013, 11:59:51 am »
Well I have spent a few days looking and trying out a working solution. And I have already read that and tested out many other things. And Lazarus don't fit my requirements. Usually I would not care. But the thing was that I was writing a Calculator with some new concepts, and I first used Python and Kivy, trying to solve it. And I got frustrated after a few hours. And then i started up Lazarus and wrote the calculator in a few hours. I programed in Delphi in the 90s and newer used it or pascal since then.

That it was possible to make this calculator so fast in Lazarus, made me realize that it the basic RAD concept is fast. Much faster than anything thats more common today. But a language like freepascal and Lazarus can get you stuck, and it's gets a lot easier to use other more common languages. If you use something like Lazarus than it's because you want to solve things fast. 

But I'm not the right person for making this audio buffer component. I don't know how to write that, and a don't use Linux and Mac. I like strait forward programming and to get things done. That's why I have mostly coded for embedded systems. For me it's easier to make new circuit board and code a ARM processor by hand without a OS, than to investigate others mess. We are all different. For me it would take months, as there would be to much new stuff to learn that doesn't have anything to do with audio what so ever. And thats a great problem if someone wants to solve it. Things like this, can shave away thousands of beards just over a night.

I'm just pointing out that dephi and all the others, has lacked one of the most basic parts of computing since it's beginning.  It's not good that things like this was easier to program in the 80s on your Amiga or PC. Computers should get easier to program, not harder. Computers is there to make things fast, not slow.

Instead of writing a audio application like a drum machine in a few hours, it would take a few weeks and most likely not Lazarus to get the job done. And thats sad because, some parts of Lazarus i great, and others just plain extra super hard. If I had money I would pay someone to change it, but I don't. But this ain't about money, this is about pride and making something worthwhile. I can see thats it's a common problem in the computer world that most programmers don't understand the basic need for a audio buffer. Instead they are more likely to spend ten thousands of hours making a audio library that no one will ever use, because they don't understand  that professional audio programmers newer use libraries for such stuff. If you want a mixer you can write it yourself within seconds. It's just adding numbers.

Audio is about style, and everyone programs audio routines in their special unique way, to get a special sound. Thats why the same functionality can be worthless or cost thousands of dollars, depending on what people do different. Thats why professionals don't use other peoples libraries, but write everything them selfs. And they always write the data strait to the audio-buffer because of the timing issues i mentioned before.

So you only need a buffer for music programs.


Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Component for Audio
« Reply #4 on: August 08, 2013, 12:09:30 pm »
Quote
and http://wiki.lazarus.freepascal.org/ACS (which was linked from the previous page anyway)
ACS is somewhat dead (last commit was 3 years ago), I would suggest UOS instead.

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: Component for Audio
« Reply #5 on: August 08, 2013, 12:34:48 pm »
Quote
So you only need a buffer for music programs.

uos works that way... ;)

By the other way, im very interested by your new audio component and how you gonna create it...
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

DM

  • Newbie
  • Posts: 6
Re: Component for Audio
« Reply #6 on: August 08, 2013, 12:40:31 pm »

UOS might be more up to date, but it looks just like something that you don't want to use. Why add something to you program that has 99.9% functionality that you don't need? It only make it hard to use and understand, and makes people grow extra big beards.

There is a reason that professional audio divers (like asio) only supports a fraction of the bullshit that micros*ft has invented.  Thats because they know that you only need the buffer, and steinberg know that because the have written actual professional applications. They would not give programmers the 99.9% bullshit. They recognized the problem this bloat was causing because micros*ft caused huge reliability problems with it (that took 10 years for computer to get enough computing power to get around) and made steinberg to go so far, that they even made new standards to get around it.

But I think it's okay with this underlaying bloat,  built in to wind*ws stuff and so on, as long as you don't build another layer of bloat upon it. Lets not change the unchangeable. A standard for making code portable need simplicity. With simplicity you can built reliability and processional stuff made to last.

 

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: Component for Audio
« Reply #7 on: August 08, 2013, 12:51:53 pm »
Quote
Why add something to you program that has 99.9% functionality that you don't need?

Hum, i don not understand what you want.
Who (or what) gonna deal with the audio port ?

You hate Microsoft, this your right, but for other os, the problem still remains, a buffer cannot do noise (it must be sent to the audio-port).

But, maybe, i misunderstood, you are talking about music programming without sound (with no connection to audio-card).
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Component for Audio
« Reply #8 on: August 08, 2013, 01:13:30 pm »
Quote
UOS might be more up to date, but it looks just like something that you don't want to use. Why add something to you program that has 99.9% functionality that you don't need? It only make it hard to use and understand, and makes people grow extra big beards.
That's the concept of library, not everybody makes use of everything provided, each has his own needs, but that doesn't mean the library has to be truncated to extremely-only-your-own-needs. UOS has modular structure, the buffer, player, filter, etc. are all separated and if all you need is buffer manipulation, just use that. Modular code does require you to think more how to use, but only lazy programmer will complain modularity.

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: Component for Audio
« Reply #9 on: August 08, 2013, 01:21:02 pm »
@ Leledumdo : very clear, as usual, many thanks.  ;)

Quote
are all separated and if all you need is buffer manipulation, just use that.

Yep, if you only need that, only load PortAudio (with Pa_Load()) ...
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

DM

  • Newbie
  • Posts: 6
Re: Component for Audio
« Reply #10 on: August 08, 2013, 01:28:35 pm »
If UOS has the parts. Wy not strip it down to its core?

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Component for Audio
« Reply #11 on: August 08, 2013, 01:39:16 pm »
Quote
If UOS has the parts. Wy not strip it down to its core?
As I said, everyone has different needs. If you just need some, just use some. The library is not designed especially-for-you. A stripped down to its core version will make most people say: "What the heck can this library do? Such a poor functionalities". Moreover, what's the definition of "core"?

DM

  • Newbie
  • Posts: 6
Re: Component for Audio
« Reply #12 on: August 08, 2013, 01:57:35 pm »

Well. How do you set up a audio-buffer with UOS then if it's that basic?




DM

  • Newbie
  • Posts: 6
Re: Component for Audio
« Reply #13 on: August 08, 2013, 03:02:10 pm »
Why not only use PortAudio? Looks more like it.

I downloaded from this place...
http://breakoutbox.de/pascal/pascal.html#PortAudioPlayer

Lazarus compiles the lazarus projects, but crashes when it runs.
 

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Component for Audio
« Reply #14 on: August 08, 2013, 05:25:10 pm »
I don't know about UOS, but unit i wrote about BASS in nxPascal works with quite simple code
Code: [Select]
TForm1 = class(TForm)
    btnPlay: TButton;
    btnStop: TButton;
    procedure btnPlayClick(Sender: TObject);
    procedure btnStopClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    bass: TBassEngine;
    sound: TBassSound;
  public
  end;

var Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.FormCreate(Sender: TObject);
begin
  // Initialize sound engine
  bass:=TBassEngine.Create(handle, false);
  // Make sound buffer (actually MP3's are treated with streaming,
  // they are not loaded all at once in memory)
  sound:=TBassSound.Create('test.mp3', false, 1);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  sound.Free;
  bass.Free;
end;

procedure TForm1.btnPlayClick(Sender: TObject);
begin
  sound.Position:=0; // Don't have to, but it rewinds to beginning
  // Play sound
  sound.Play;
end;

procedure TForm1.btnStopClick(Sender: TObject);
begin
  sound.Stop;
end;
But obviously the wrapper comes with more features like 3D sounds, automatic sound looping, volume/frequency changings and so on... If you look for smallest possible library, this is not it.
« Last Edit: August 08, 2013, 05:31:54 pm by User137 »

 

TinyPortal © 2005-2018