Recent

Author Topic: Tone Generator  (Read 428 times)

Gigatron

  • Sr. Member
  • ****
  • Posts: 280
  • Amiga Rulez !!
Tone Generator
« on: May 19, 2025, 10:41:46 pm »
Hi

Last days i've sarted a project called Sin table generator
https://forum.lazarus.freepascal.org/index.php/topic,71121.0.html
This new projet is
based on generated sin wave to produce a simple sound (be carefull to play with parameters, sure bugged at now ).
It use mmsystem and fill buffer like players i converted. I will try to improve it to
make an interesting program (missing formula).

Regards GTR


Sub Quantum Technology ! Gigatron 68000 Colmar France;

Thaddy

  • Hero Member
  • *****
  • Posts: 17159
  • Ceterum censeo Trump esse delendam
Re: Tone Generator
« Reply #1 on: May 20, 2025, 11:05:58 am »
Did it occur to you that for a pure sine in audio you just need half the wave and mirror that for the lower part? Or at most one complete sine cycle.
If it is sine, you can simply switch buffers two , not regenerate them.
That would greatly simplify the code and is less demanding on the CPU.
You should also generate the pre-compiled sine waves depending on the sample rate. Adjusting for note value can simply be done with the twelft root of two (~1.05 * note value)
This is how most synthesizers work.
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

Gigatron

  • Sr. Member
  • ****
  • Posts: 280
  • Amiga Rulez !!
Re: Tone Generator
« Reply #2 on: May 20, 2025, 12:28:45 pm »
Hi,

Thank you, I’ll study your recommendations and test the buffer mirroring approach. This could really optimize my code  ,  for now the latest version .

Regards Gtr
« Last Edit: May 20, 2025, 12:37:53 pm by Gigatron »
Sub Quantum Technology ! Gigatron 68000 Colmar France;

 

TinyPortal © 2005-2018