Recent

Author Topic: Tone Generator  (Read 998 times)

Gigatron

  • Sr. Member
  • ****
  • Posts: 401
  • Amiga Rulez !!
    • Gigatron Shader Network Demo
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


Coding faster than Light !

Thaddy

  • Hero Member
  • *****
  • Posts: 18765
  • To Europe: simply sell USA bonds: dollar collapses
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.
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

Gigatron

  • Sr. Member
  • ****
  • Posts: 401
  • Amiga Rulez !!
    • Gigatron Shader Network Demo
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 »
Coding faster than Light !

 

TinyPortal © 2005-2018