|
RAW
Oct 7, 2021 21:16:16 GMT
via mobile
Post by KindWiz424 on Oct 7, 2021 21:16:16 GMT
I'm trying to set up a program where you can play data based on sine waves that you draw
Not sure how ittl turn out with multiple coordinates on the same point but I'm willing to find out
--[[RAW]]-- x=1 y=1
draw.setscreen(1) draw.touchmoved(touches)
q={} v={}
while(a==true) do o=o+1 i=i+1 a=touches[o].x r=touches.y draw.point(a,r,draw.black) table.insert(q,a) table.insert(v,r) end
sleep(1000)
while(q==true) do rate=44100 channels=2 bits=16 data={q[h] * 2 * v[h]} buffer={rate, channels, bits, data} audio.playebuffer( buffer, 27, 369, 0 ) end
Why is touchmoved undefined Is there anything else I absolutely need to do?
|
|
|
RAW
Oct 8, 2021 8:45:13 GMT
Post by Admin on Oct 8, 2021 8:45:13 GMT
You should define touchmoved for example:
function touchMoved(touches) — some code that reads touches — x = touches[1].x end draw.touchmoved = touchMoved
Also touches variable should be read inside touchMoved function.
Please read some intro documentation for lua then read touch examples like paint.lua
|
|
|
RAW
Oct 8, 2021 15:28:33 GMT
via mobile
Post by Lol on Oct 8, 2021 15:28:33 GMT
This is my (faulty) interpretation of this
--[[RAW]]--
v = sys.input("record for:") x=1 y=1
draw.setscreen(1)
q={} k={} function touchMoved(touches) draw.lineto(touches[1].x, touches[1].k, gray) end sleep(v) draw.touchmoved=touchMoved
while(a==true) do o=o+1 i=i+1 a=touches[o].x r=touches.y draw.point(a,r,draw.black) table.insert(q,a) table.insert(k,r) end
sleep(1000)
while(q==true) do rate=44100 channels=2 bits=16 data={q[h] * 2 * k[h]} buffer={rate, channels, bits, data} audio.playebuffer( buffer, 27, 369, 0 ) end
Do I need touch began and touch ended on this?
If not why won't it do anything
|
|
|
RAW
Oct 8, 2021 15:45:04 GMT
via mobile
Post by KindWiz424 on Oct 8, 2021 15:45:04 GMT
I added the touch began and end
record for:456
Runtime Error: RAW.lua:29: RAW.lua:13: bad argument #3 to 'lineto' (table expected, got nil)
< Program Ended >
Is what I get
Do you know how to fix it so it at least does something?
|
|
|
RAW
Oct 8, 2021 15:59:25 GMT
via mobile
Post by lol on Oct 8, 2021 15:59:25 GMT
"Grey" through me off
So it needs to be read inside a function
This might take a while
|
|
|
RAW
Oct 8, 2021 18:49:19 GMT
via mobile
Post by Lol on Oct 8, 2021 18:49:19 GMT
Ahh! I have to append
function touchMoved(touches) draw.lineto(touches[1].x, touches[1].y, draw.black) end
I need to use all the touches[1]
|
|
|
RAW
Oct 8, 2021 18:51:47 GMT
Post by Admin on Oct 8, 2021 18:51:47 GMT
I added the touch began and end record for:456 Runtime Error: RAW.lua:29: RAW.lua:13: bad argument #3 to 'lineto' (table expected, got nil) < Program Ended > Is what I get Do you know how to fix it so it at least does something? did you import draw library: require "draw" please take it step by step and learn Lua first
|
|
|
RAW
Oct 8, 2021 18:59:13 GMT
via mobile
Post by KindWiz424 on Oct 8, 2021 18:59:13 GMT
Well I got it so it draws from point 1 to another point 1 ect
But it barely makes a sound
How do I make "touches" a table of all [1]s?
I know you just said to learn it myself though so I'm not expecting a response
|
|
|
RAW
Oct 8, 2021 19:47:16 GMT
via mobile
Post by Lol on Oct 8, 2021 19:47:16 GMT
I gotta ask How do you achieve greater touch[id]?
|
|
|
RAW
Oct 8, 2021 19:50:49 GMT
Post by Admin on Oct 8, 2021 19:50:49 GMT
Well I got it so it draws from point 1 to another point 1 ect But it barely makes a sound How do I make "touches" a table of all [1]s? I know you just said to learn it myself though so I'm not expecting a response you can read one touch at a time and add it to some global table. To deal with tables, I recommend to read and apply this tutorial on lua console: lua-users.org/wiki/TablesTutorialif you still find it hard to understand start reading from the beginning: lua-users.org/wiki/TutorialDirectoryif you want to become a programmer, you need to get used to read documentation good luck
|
|