|
Silence
Dec 2, 2020 0:59:42 GMT
via mobile
Post by Weird... on Dec 2, 2020 0:59:42 GMT
for i = 1, count do t = (i-1) * slice v = ((2*amplitude)/math.pi)*(math.atan*math.tan)*(2*math.pi*time-count)/frequency if buffer.channels == 2 then table.insert(buffer.data, v) end end ———————————————— HTBO.lua:18: attempt to perform arithmetic on field 'atan' (a function value) ———————————————— why can I not use math.atan?
|
|
|
Post by Admin on Dec 2, 2020 11:50:16 GMT
math.atan is a function, you can't use it in an expression as a number. use instead: math.atan(angle)
|
|
|
Silence
Dec 2, 2020 18:43:53 GMT
via mobile
Post by Weird... on Dec 2, 2020 18:43:53 GMT
Now all I’m getting is silence...
v = ((2*amplitude)/math.pi)*(math.atan(math.tan(2*math.pi*time-count)/frequency))
|
|
|
Silence
Dec 4, 2020 19:38:48 GMT
via mobile
Post by Weird... on Dec 4, 2020 19:38:48 GMT
Op! I hear a dot!
v = ((2*amplitude)/math.pi)*math.atan(math.tan(2*math.pi*time-count/frequency))
|
|
|
Silence
Dec 5, 2020 15:03:37 GMT
via mobile
Post by Weird... on Dec 5, 2020 15:03:37 GMT
Got it!
v = ((2*amplitude)/math.pi)*math.atan(math.tan(2*math.pi*time-count/frequency*t))
|
|
|
Silence
Dec 5, 2020 17:00:03 GMT
via mobile
Post by Weird... on Dec 5, 2020 17:00:03 GMT
—I have this guitar sound I want to make sound more natural— g = require 'nitro.graphics' g.showscreen() g.settitle('HTBO')
buffer = {} buffer.rate = 44100 buffer.channels = 2 buffer.bits = 16 buffer.data = {}
time = 1 frequency = 100 amplitude = 40000 slice = 1 / buffer.rate count = buffer.rate * time --[[ for i = 1, count*4.5 do t = (i-1) * slice amplitude=amplitude+100 v = amplitude*math.sin((2*math.pi*time-count)/frequency*t) if buffer.channels == 2 then table.insert(buffer.data, v)
t = (i-1) * slice v = ((2*amplitude)/math.pi)*math.atan(math.tan(2*math.pi*time-count/frequency*t))
if buffer.channels == 2 then table.insert(buffer.data, v) end end end ]]-- audio.playbuffer(buffer, 1, 1, 0) time = 1 frequency = 100 amplitude = 40000 slice = 1 / buffer.rate count = buffer.rate * time for i = 1, count*2.5 do amplitude=amplitude+1 t = (i-1) * slice v = ((2*amplitude)/math.pi)*math.atan(math.tan(2*math.pi*time-count/frequency*2*t)) if buffer.channels == 2 then table.insert(buffer.data, v)
if buffer.channels == 2 then table.insert(buffer.data, v) end end end audio.playbuffer(buffer, 1, 1, 0) sleep(count*4.5*2)
—I think I need a couroutine to do this, and that would help for sequencing as well—
—I can’t find a good example of a couroutine anywhere online... please help!—
|
|