Recent

Author Topic: Sound generation  (Read 642 times)

bob67

  • Newbie
  • Posts: 3
Sound generation
« 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

Thaddy

  • Hero Member
  • *****
  • Posts: 9183
Re: Sound generation
« Reply #1 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.
also related to equus asinus.

bob67

  • Newbie
  • Posts: 3
Re: Sound generation
« Reply #2 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

avra

  • Hero Member
  • *****
  • Posts: 1717
    • Additional info
Re: Sound generation
« Reply #3 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
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

bob67

  • Newbie
  • Posts: 3
Re: Sound generation
« Reply #4 on: July 12, 2019, 07:14:20 pm »
Thanks Avra

kupferstecher

  • Sr. Member
  • ****
  • Posts: 303
Re: Sound generation
« Reply #5 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.

jamie

  • Hero Member
  • *****
  • Posts: 2083
Re: Sound generation
« Reply #6 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..
Number 1 at blue screen app creations!

Thaddy

  • Hero Member
  • *****
  • Posts: 9183
Re: Sound generation
« Reply #7 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.
also related to equus asinus.

jamie

  • Hero Member
  • *****
  • Posts: 2083
Re: Sound generation
« Reply #8 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...
Number 1 at blue screen app creations!