McPepic 2024-02-01 20:06 (Edited)
I'm working on an audio-based project and was curious how some of the data is interpreted to form the resulting audio wave.
I'm using a triangle wave and need to recreate the wave given the pitch, pulse width, and volume so that I can sample values from it.
Does anyone know how to create a mathematical expression to create the wave based on the pitch, volume, and pulse width of a triangle wave?
SP4CEBAR 2024-02-01 22:26
I think I know what this is for, Good luck!
McPepic 2024-02-02 16:36
Wait, pulse width only works with square waves?
SP4CEBAR 2024-02-02 23:42
Yes
McPepic 2024-02-02 23:46
I'm going to need to rethink this a bit. I really don't mess with audio on LowRes.
SP4CEBAR 2024-02-03 10:15
If you listen to this frequency sweep
https://lowresnx.inutilis.com/topic.php?id=1890
Without touching the screen, you'll be able to hear some artifacts that may give some information about the bit depth of the audio.
SP4CEBAR 2024-02-03 13:01
@McPepic, I think this is what you are looking for:
https://github.com/timoinutilis/lowres-nx/blob/master/core/machine/audio_chip.c
SP4CEBAR 2024-02-04 16:14 (Edited)
Wait, you wanted a mathematical expression these waveforms in general (not the specific NX sounds), I can give you some:
For the other waves, here are a few approaches that could work:
Y=int(x*2)-2*int(x) (similar to X- X mod 2)
Y=|1-2*X|-2*int(x)
Y=x-int(x)
u = X-int(x)
y=int(2*u)
y=|1-2*u|
y=u
sine
sin(x)>=0
y=asin(sin(x))
y=atan(tan(x))
McPepic 2024-02-05 01:37
Alright, thanks! I'll look into these for the project. God bless you!
SP4CEBAR 2024-02-05 09:46
God bless you too man!