File:Sinc.wav
Summary
| Description |
English: A three-second fragment of the sinc function as audio (three seconds at 44100 Hz; Blackman window applied; frequency 2000 Hz).
Generated by the following Python code. import math
import wave
import struct
# The sinc function.
def sinc(x):
return math.sin(x) / x if not x == 0.0 else 1.0
# The Blackman window.
def blackman(length, i):
t = i / (length - 1)
return 0.42 - 0.5 * math.cos(t * math.pi * 2.0) + 0.08 * math.cos(t * math.pi * 4.0)
# Windowed-sinc function.
def windowed_sinc(length, frequency):
output = []
for i in range(length):
sinc_phase = i - (length - 1) / 2
output.append(sinc(sinc_phase * frequency * math.pi * 2.0) * blackman(length, i))
return output
SAMPLE_RATE = 44100
DURATION = 3
FREQUENCY = 2000.0
with wave.open("sinc.wav", "w") as wavfile:
wavfile.setnchannels(2)
wavfile.setsampwidth(2)
wavfile.setframerate(SAMPLE_RATE)
for sample in windowed_sinc(SAMPLE_RATE * DURATION, FREQUENCY / SAMPLE_RATE):
wavfile.writeframes(struct.pack("<h", int(sample * 32767)) * 2)
|
| Date | |
| Source | Own work |
| Author | SopaXorzTaker |
Licensing
I, the copyright holder of this work, hereby publish it under the following license:
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.