How can I reproduce a single tone or user wave with Delphi?

I was looking for the code, it seems that everything creates some mathematical wave functions, but I want a single tone or a custom wave made using individual tones.

I read this. How can I generate continuous tones with different frequencies?

This is close to my answer. Assumin I am going to use waveOutWrite, as in the link above, I cannot understand how the gain / frequency is calculated for each sample in HWAVEOUT.

In the code from the link This is done as follows: Samples[i] := round(vol*sin(omega*t));

Assuming that I want a single tone with a frequency of 15 kHz with some amplifier (no matter which one), how will the sample be calculated [1]?

+7
source share
1 answer

A continuous (in time) sine wave can be defined as A*sin(2*PI*f*t) , where A is a certain amplitude, PI , well, 3.14 ..., f is the tone frequency in hertz and t is time in seconds.

Now, since you do not have continuous time, since your time is discrete, you replace dt*i instead of t and get A*sin(2*PI*f*dt*i) , where dt is the time between samples or 1/sample rate and i are the sample number. You can specify it as A*sin(2*PI*(f/Fs)*i) . Remember that if you select a specific sampling frequency Fs (in samples / seconds or just Hz), the highest tone can never exceed Fs/2 Hz.

+9
source

All Articles