Triggering sound using my computer's keyboard
Relatively new user. I’m a little lost as to how I can play sounds (like a simple sine wave using the cycle~ function) using different keys on my keyboard. I used the key function to figure out the number of the keys (ex: B is 98, A is 97) but I’m not sure how to connect them so they play the sound. I know the select function has something to do with this too as I was looking at some built-in tutorials.
you’re almost there, but you don’t specify exactly what you wish to do with the keystrokes. To control frequency, for example, use [key] to identify ascii numbers, then send its left outlet to [* 10]. Send the result to the [cycle~] left inlet. Now you’re controlling frequency with the keys. [select] will issue bangs depending on the arguments you specify, so [select 49 50] will give a bang for keys "1" and "2".
Right/ctrl clicking on any object in edit mode brings up a helpfile patcher.
The last post has a QWERTY keyboard MIDI controller. Put the pitch output from the patcher into a mtof and feed it into a cycle~. Not sure if thats what yr after but – it’s handy and will do something like what you want one way or another.
Also available as part of my MaxMSP Library download available here in the Code section. It comes with some other abstractions you might find useful and updated help files.
Thanks everyone. I’m getting there, slowly. I connected the key to the B and when I hit B on my keyboard, the button goes yellow so that means it’s working. But I’m having troubles attaching or getting sound out of it.
Check attachment please.
edit: Sorry, the attachments don’t seem to be working. One moment…
edit 2: See here – http://imageshack.us/f/829/maxmsp.jpg/
Download the library I just linked to, pop it somewhere in your max search path (or add it under Options > File Preferences) and then try this super simple patch. The object basically makes your computer keyboard mimic a MIDI keyboard. The example patch turns the MIDI notes to frequency values with [mtof], generates a sine wave at this pitch with [cycle~] and finally sends it to your speakers.
----------begin_max5_patcher---------- 355.3ocwS1saBCBFF9X5UAgi6LEpc1ry10whYAonxVKXDZVUi6Ze.8G6V7m5 zrcBD99nu799TXW..MSUw0H3SvWf.vt..vWxU.zrFfJnUrbp1uMDeaFk8IJr tkrrPHy4FeORSwUTCaoPt300bloVa7jIihBgjDhaZbR6HbZy2Hx7pql81Ci6 Itpzzpdjq39f.2P3.Mqj+gUwV8L7JucPrMrbdWFpOCylU7ZuhzhERZNpyayU RiVr02F6BvuK6jjCYmDc7rGi5clRZg+LQOuVX8yQoB99QkBiZ9IYx0QC7koQ TraJd74nA4ejF4KG8Nei9j.QHMnvto6MdvoX+kkzygG70hm3d3wKHJWH+4ye uob0+Nyzpx0r1v2bUEdvVYbsQHoFgR1aO1mxPb2dVJxx391sToPjsRYQXiEv oONJwl2lXawW6J3zi9m8d60ng60azQjA3n3+TGgGfiH2firK1G7EqrJduA -----------end_max5_patcher-----------
Is there a simpler way? I just want different sounds to be produced (of sine waves) when I press certain keys on my keyboard. I was getting sound before but wasn’t sure how to connect it to the button so the keys would trigger it. Yeah, I’m struggling. Sorry to be a pain.
Here’s what I have right now – http://cl.ly/8OSq. But I don’t know how to make it so the sound triggers only when those keys are pressed. And I need to product different sounds (sine wave) for each key.
(copy all the text below, and go File/New From Clipboard; then go here:
----------begin_max5_patcher---------- 821.3oc4XtsaaBCFG+5To9NXwkSYUXaLAuGjcyzzjK3kRavDUHZ8f1d1mODV RSicLzzZP6lXEiA++6GemLOe4Eyhtt9AdSD3KfuAlM6Y4LyzyolYV2DyhpXO juh0nWXTdcUEWzFMe6Ea4Ozpuvc7Ga.v4.zb.FvDEfj+sFwlpRwJdq9I.6lc MqM+lRwxebOOu0HBTB7pX4iHQ8KjDq+i7Wv26toxB8lUe8seFkt+FTuosaGh 6l9m0hVAqhqukuxuufIXQ6ewlxmzWDJ2V8z+9xKTixg4dSjJdSCaI+0DIgdb BfbP.JQYyoZ.XreXlM6Owh8C8x9M2P6iq4lcNJZ2tb1Xif+KoTeMZVUyJTbS 9zi6uaBQCITpdHagauDzzkRM7UfDpzO.Pf.Bp+fBmf0tPXS.ULxIpfTKnhLL TcMSrLZt8w2CTZMXLt+whczKMUMfQWQbDMBylt9YxT2aVeb9D6AeLtUDphO1 ctrksNYX7oTUC5XCuCbi+TAK+O82ABRzwcXLUMjP5983.hXqb1f08RVoXHxN 0jmfZp+.wac+snaakgPVe20TtTvVs6E14u7RofO.CGYdQgPYZKl5NaI9T1c+ bn2AEc9wOvv+0r76.kxxLClXvsss.cSrIbo3O8FhiLCRD4L+H77BmstSefHp U5CA6eOJPiWCzj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