Lazarus

Free Pascal => Beginners => Topic started by: bob67 on July 12, 2019, 04:05:24 pm

Title: Sound generation
Post by: bob67 on July 12, 2019, 04:05:24 pm
I am new to Lazarus programming.

I would like write code to generate sound or tones  Can anyone guide me on where to start please.

Many thanks

Bob
Title: Re: Sound generation
Post by: Thaddy on July 12, 2019, 04:15:21 pm
Can you describe some more?
E.g. Do you know about sample rate and sine waves?
I can give many examples, but the above is - by far - the easiest.
If you know that relationship I have lots of code to help you.
Title: Re: Sound generation
Post by: bob67 on July 12, 2019, 04:47:08 pm
Thanks Thaddy for your response.

My knowledge of sine waves is more from mathematics.  I know what a sine wave is and what shape it takes.  I just don;t have the programming knowledge to product sound.  For example I know that  if I insert the line " beep " in my code I can hear the standard beep.  How can I produce different sounds.

Most of my programming experience has been number crunching ( applied to engineering and mathematical applications).  I am trying to learn new areas of programing  and being a musician as well, producing sounds seems an obvious diversion.

Many thanks

Bob
Title: Re: Sound generation
Post by: avra on July 12, 2019, 05:38:53 pm
You can try to look into source of this Delphi application:
https://web.archive.org/web/20150829211417/http://delphiforfun.org/Programs/soundgen.htm
Title: Re: Sound generation
Post by: bob67 on July 12, 2019, 07:14:20 pm
Thanks Avra
Title: Re: Sound generation
Post by: kupferstecher on July 12, 2019, 10:39:01 pm
You can use PortAudio.

https://wiki.lazarus.freepascal.org/Multimedia_Programming#PortAudio

It's a very basic sound library, where you provide the sound data repeatedly via a callback function. Because you provide the data yourself, you have full control and you can experiment around (Like creating sine waves, manipulate given sounds etc). For reading soundfiles you have to use other libraries, the audio data then can be processed and played with portaudio.
Title: Re: Sound generation
Post by: jamie on July 12, 2019, 11:57:00 pm
https://torry.net/quicksearchd.php?String=mixer&amp%3BTitle=Yes

Go there, there is a complete set of code that will do something for you, it is a Delphi set of
files but Lazarus converts them so you should be able to get it working..

It goes up to D7 so there shouldn't be anything current in Delphi that is being used to get in your
way..
Title: Re: Sound generation
Post by: Thaddy on July 13, 2019, 09:46:36 am
You can try to look into source of this Delphi application:
https://web.archive.org/web/20150829211417/http://delphiforfun.org/Programs/soundgen.htm
Yes, old but good as a minimal explanation! And works for Windows only, note that.
There are more cross platform solutions available, though.
Title: Re: Sound generation
Post by: jamie on July 13, 2019, 05:58:40 pm
I have a complete set of digital files that will compile for both Linux and windows . Both include the
methods of accessing the sound system in the PC so what isn't an issue if the material is asked for..

 I forgot where I got it from but It also has DSP stuff in it, FFT, DFT , IDFT etc...
TinyPortal © 2005-2018