Sep-25-2019, 03:53 AM
I finally found out how to use python to make .wav files. It requires the modules numpy and scipy (the latter just for the ability to write .wav files).
I was able to get a formula from a youtube video that showed how to generate a sine wav (note that I imported numpy as np):
freq: frequency, herz, or pitch in layman's terms
duration: length of the the note is played
sps: samples per second (don't really know what that means)
Looking at the wikipedia articles on waves, I found that a square wave can be generated from a sine wave simply by finding its 'sign', which in python code looks like this:
However, I don't understand the mathematics for triangular and sawtooth waves. They both involve an 'epsilon' symbol, whose meaning I do not know. Obviously, I'm far from an expert on mathematics. And even then, I haven't the faintest idea how to convert these formulas into, well, computer formulas.
Does anyone know how to do this?
I was able to get a formula from a youtube video that showed how to generate a sine wav (note that I imported numpy as np):
eachSampleNumber=np.arange(duration*sps) waveform=np.sin(2*np.pi*eachSampleNumber*freq/sps)This uses three variables:
freq: frequency, herz, or pitch in layman's terms
duration: length of the the note is played
sps: samples per second (don't really know what that means)
Looking at the wikipedia articles on waves, I found that a square wave can be generated from a sine wave simply by finding its 'sign', which in python code looks like this:
np.sign(np.sin(2*np.pi*eachSampleNumber*freq/sps)And I have checked the arrays these generate, the latter does in fact produce a square wave.
However, I don't understand the mathematics for triangular and sawtooth waves. They both involve an 'epsilon' symbol, whose meaning I do not know. Obviously, I'm far from an expert on mathematics. And even then, I haven't the faintest idea how to convert these formulas into, well, computer formulas.
Does anyone know how to do this?