Tone
From Avisynth wiki
(Difference between revisions)
Raffriff42 (Talk | contribs) m (one more touch-up) |
(add link to avs+ documentation) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | This will generate sound at a given {{FuncArg|frequency}} for a given {{FuncArg|length}} of time in seconds. | + | <div {{BlueBox2|40|0|3px solid purple}} > |
+ | {{AvsPlusFullname}}<br> | ||
+ | Up-to-date documentation: [https://avisynthplus.readthedocs.io/en/latest/avisynthdoc/corefilters/tone.html https://avisynthplus.readthedocs.io] | ||
+ | </div> | ||
+ | |||
+ | |||
+ | This will generate sound (a waveform) at a given {{FuncArg|frequency}} for a given {{FuncArg|length}} of time in seconds. | ||
Line 36: | Line 42: | ||
|} | |} | ||
</div> | </div> | ||
− | :In the figure above, a sinus is generated (on a gray clip with framerate 24 fps). | + | :In the figure above, a sinus is generated (on a gray clip with framerate 24 fps). The period of the waveform (in frames) is the ''framerate'' divided by ''frequency'' (or fps/freq, which is 24/2=12 frames in our example). The part of the graph which is light-green represents all samples of the frame under consideration (which is frame 1 here). The number of samples in a particular frame is given by the ''samplerate'' divided by the ''framerate'' (which is 48000/24 = 2000 samples in our example). |
:More generally, the waveform above is described by | :More generally, the waveform above is described by | ||
Line 55: | Line 61: | ||
|- | |- | ||
| v2.56 | | v2.56 | ||
− | | Added Level | + | | Added Level. |
|- | |- | ||
| v2.54 | | v2.54 |
Latest revision as of 05:51, 18 September 2022
AviSynth+
Up-to-date documentation: https://avisynthplus.readthedocs.io
This will generate sound (a waveform) at a given frequency for a given length of time in seconds.
Tone( [ float length, float frequency, int samplerate, int channels, string type, float level ] )
- float length = 10.0
- Length of time in seconds.
- float frequency = 440
- Tone frequency.
- int samplerate = 48000
- Audio sample rate.
- int channels = 2
- Number of audio channels.
- string type = "Sine"
- "Silence", "Sine", "Noise", "Square", "Triangle" or "Sawtooth".
- float level = 1.0
The audio sample type is 32-bit float. Use ConvertAudio if this is not what you want.
[edit] Discussion
- In the figure above, a sinus is generated (on a gray clip with framerate 24 fps). The period of the waveform (in frames) is the framerate divided by frequency (or fps/freq, which is 24/2=12 frames in our example). The part of the graph which is light-green represents all samples of the frame under consideration (which is frame 1 here). The number of samples in a particular frame is given by the samplerate divided by the framerate (which is 48000/24 = 2000 samples in our example).
- More generally, the waveform above is described by
- g(n,s) = level · sin(2 · pi · (frequency · n / framerate + s · frequency / samplerate))
- with n the frame and s the sample under consideration (note that s runs from 0 to samplerate/framerate - 1).
- In the example above, this reduces to
- g(n,s) = 0.4 · sin(2 · pi · (2 · n / 24 + s · 2 / 48000))
- with n the frame and s the sample under consideration (note that s runs from 0 to 1999).
- Note that the bars are made with Histogram and the graph with the AudioGraph plugin.
[edit] Examples
- We Wish You a Merry Christmas, in harmony (author hanzfrunz)
[edit] Changes
v2.56 | Added Level. |
v2.54 | Initial Release. |