[Csnd] OSC examples, models, tutorials, and maybe a few more opcodes
Date | 2020-03-21 00:08 |
From | "Dr. Richard Boulanger" |
Subject | [Csnd] OSC examples, models, tutorials, and maybe a few more opcodes |
Attachments | I-CubeX Online Store - Motion Sensors for Digital Media Control.webloc |
Hello Csounders,
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Over the past week, I have been working with the iCubeX digitizers and sensors to prepare materials for my Circuit-Bending/Physical Computing Class. It's great stuff. And, there are a lot of excellent Max/MSP models to use as starting points. As you might well imagine, I am trying to make the Csound Connection ;-) And, I am trying to develop a nice set of OSC model .csds that will work with the iCubeX WiDig One of the most difficult things to do was to find the actual OSC handle (message) that was coming from each of the iCubeX inputs. And so, for hours (and days and nights even), I thought that the digitizer wasn't working. Finally, to find out the "default" or "specific" message being sent from each of the many wonderful analog and digital sensors that I was testing, I would have to either: 1. Launch Max/MSP and run its UDP Tester (under the Extras menu) - this would report the specific "message" being "received" on a particular OSC port. Max/MSP told me: /WiDig_0056/Input_01/V and so... I could plug in a "Knob" sensor with the following line of code and map it into my instrument kans1 OSClisten giPort, "/WiDig_0056/Input_01/V", "i", gkin1 But this required me to run another program to get the correct name. I do not think we have an opcode in Csound that will report the name of an OSC message? DO we? The manual only lists: OSCinit, OSCsend, and OSClisten OR To figure out the multiple messages coming from the digital sensors, such as "Orient4D", I had to launch OSCULATOR: https://osculator.net/ a really great OSC receiver/mapper program that would populate a list with the full name/path from every OSC input and light up a little box to indicate that there was activity coming in on that "channel/stream" And so, to read in the Orient4D sensor on input4 of the digitizer, I discovered the following would work to read in the W, X, Y, and Z values from the sensor: kans1 OSClisten giPort, "/WiDig_0056/Input_04/Qw", "i", gk1 ; Orient4D kans2 OSClisten giPort, "/WiDig_0056/Input_04/Qx", "i", gk2 ; Orient4D kans3 OSClisten giPort, "/WiDig_0056/Input_04/Qy", "i", gk3 ; Orient4D kans4 OSClisten giPort, "/WiDig_0056/Input_04/Qz", "i", gk4 ; Orient4D printks "input4 %d %d %d %d %d\\n", .25, gk1, gk2, gk3, gk4 I am sure that there are many command-line tools that would have helped me to discover what I was looking for and it might have saved me a night or two. But, it would be cool if these tools were in Csound, as opcodes. And maybe they are already? (I do realize that OSClisten can "listen" to all sorts of data types, but if you don't know what "message" to receive, then it is totally "deaf". For instance, it would nice to have OSC opcodes that: 1. return the complete name of the message received to the console or to a string (OSCdiscover) 2. scale the received OSC messages. (an OSCscale) 3. smooth the received OSC messages (an OSCsmooth) 4. convert/map the OSC messages (to MIDI CC or MIDI notes or MIDI aftertouch, pressure ...) OSCmidiCC, OSCmidinn, OSCmidiAT, OSCmidiCP 5. set thresholds above or below which a continuous OSC data stream would send a bang/trigger (OSCtrig) 6. send a full-range of the controller when only receiving a certain range of input values for instance, the received input values range from 32-79, but the output values will be between 440-880 or between 0-127 or between 0-1 (OSCscale2) 7. I bet there are many other things that you OSC gurus would have liked to see in an opcode I bet that there are many of you who have been working for a long time with OSC and Csound. Maybe you have an OSC UDO Library to share? Maybe you have some instruments or pieces or systems that you could share. I have a few things to share that my students and I have developed for the P5 data glove and the Muse Brainwave controller. And soon, I will have some nice ones for the iCubeX sensors - inspired by past work and by your work. Hopefully, you will have some OSCthings to share. Hopefully, you will have some OSCexperience to share. Hopefully, you might agree with me that it would be cool to have some more OSCfriendly opcodes in Csound! Take care everyone. Dr.B. _____________________________________________ Dr. Richard Boulanger Professor of Electronic Production and Design Professional Writing and Music Technology Division Berklee College of Music ______________________________________________ OFFICE: 1126 Boylston St., Suite 201 (EPD), Suite 208 (Boulanger) ______________________________________________ President of Boulanger Labs - http://boulangerlabs.com Author & Editor of The Csound Book - http://mitpress.mit.edu/books/csound-book Author & Editor of The Audio Programming Book - http://mitpress.mit.edu/books/audio-programming-book ______________________________________________ about: http://www.boulangerlabs.com/#about about: http://www.csounds.com/community/developers/dr-richard-boulanger/ music: http://www.csounds.com/community/developers/dr-richard-boulanger/dr-richard-boulanger-music/ ______________________________________________ email: rboulanger@berklee.edu facebook: https://www.facebook.com/richard.boulanger.58 |
Date | 2020-03-21 02:30 |
From | David Akbari |
Subject | Re: [Csnd] OSC examples, models, tutorials, and maybe a few more opcodes |
Hello Dr. B, I hope you are well. That sounds like a really cool project! In response to your email I started poking around the Csound sources and I found a number of OSC related opcodes I had not seen before. OSCinit i i OSCinitM i Si OSClisten k iSS OSClisten k iSS* OSCraw S[]k i OSCsend (null) kSk* OSCsend_lo (null) kSkSS* These days I have not been compiling from source so I was excited to see these in my out-of-the-box Csound version 6.11 (double samples) May 11 2018. You might try the following UDO example and see if it works with what you need? All you have to supply is the port an the number of messages you think you'll get (you can change it once you run it once and see there are too many/too little). I tested this using the OpenFrameworks.cc oscSenderExample https://github.com/openframeworks/openFrameworks/tree/master/examples/communication/oscSenderExample/src The UDO just wraps the OSCraw opcode (that I was not previously aware of) and the example is from Oeyvind Brandtsegg and Victor Lazzarini, wrapped in a UDO. The scale, smooth, midi mapping, trigger/hysteresis would be trivial to add on to this idea. Hope this helps! Cheers, David |
Date | 2020-03-21 04:21 |
From | "Dr. Richard Boulanger" |
Subject | Re: [Csnd] OSC examples, models, tutorials, and maybe a few more opcodes |
Thanks so much David! As you might well imagine, I think of you often, and of your great Csound work - especially the stuff you did with with the then new set of OSC opcodes. I love that your models appear in the manual! Happy to hear from you. And thanks again for coming to my aid with more inspiring examples. Take care. Dr. Richard Boulanger Professor Electronic Production and Design Berklee College of Music > On Mar 20, 2020, at 10:30 PM, David Akbari |
Date | 2020-03-21 06:16 |
From | "Dr. Richard Boulanger" |
Subject | Re: [Csnd] OSC examples, models, tutorials, and maybe a few more opcodes |
Attachments | -iCubeX-WiDig-AnalogSensors-OSC.csd -iCubeX-WiDIG-DigitalSensorsOSC.csd |
Thanks again, David. OSCraw seems to hold the key. Ironically, it does not appear in the table of contents, but it does appear in the manual if one opens it via the "show opcode entry" under the help menu - it seems to be a "secret opcode" page and example! - makes me wonder what other opcodes are "hidden" in there ;-) There are some issues with formatting and the line-wrapping of these rapid flood of OSC messages, but it is a huge help. - this clears things us a bit, but it's still not laid out perfectly. - it would be nice for the values from the messages (coming in from up to 8 ports) were to appear in the next column so that one could study the range of values coming in. (these seem to be ints, but some sensors put out floating-point values (like the MUSE Brainwave Interface), and so the UDO might need a little tweaking to support or sense for that as well.) while kn < ka do printf "%s \r", kn+1, Smess[kn] kn += 1 od printf "%d items \n", ka, kn if ka > 0 kgoto top There does seem to be a little bug, in that it only and always reports that there are "3 messages" - when I read in a digital sensor, for example, "Orient4D v1,0" http://infusionsystems.com/catalog/product_info.php/products_id/484 which uses one input on the digitizer, and sends 4 messages: (there might even be a better way of formatting this and using a single OSClisten line per port? Victor? Oeyvind?) kans1 OSClisten giPort, "/WiDig_0056/Input_04/Qw", "i", gk1 ; Orient4D kans2 OSClisten giPort, "/WiDig_0056/Input_04/Qx", "i", gk2 ; Orient4D kans3 OSClisten giPort, "/WiDig_0056/Input_04/Qy", "i", gk3 ; Orient4D kans4 OSClisten giPort, "/WiDig_0056/Input_04/Qz", "i", gk4 ; Orient4D printks "input4 %d %d %d %d %d\\n", .25, gk1, gk2, gk3, gk4 I have attached my two basic iCubeX-monitoring CSD files - one to monitor analog sensors and on to monitor digital (multi-message) sensors THANKS for this. - this OSCraw Utility would have saved hours and will save a lot of time in the future too. Hopefully, Tarmo will "reveal" the page in the manual. ;-) Thanks everyone - take care!!!! We need ALL of you and we NEED you all to be HEALTHY. _____________________________________________ Dr. Richard Boulanger Professor of Electronic Production and Design Professional Writing and Music Technology Division Berklee College of Music ______________________________________________ OFFICE: 1126 Boylston St., Suite 201 (EPD), Suite 208 (Boulanger) ______________________________________________ President of Boulanger Labs - http://boulangerlabs.com Author & Editor of The Csound Book - http://mitpress.mit.edu/books/csound-book Author & Editor of The Audio Programming Book - http://mitpress.mit.edu/books/audio-programming-book ______________________________________________ about: http://www.boulangerlabs.com/#about about: http://www.csounds.com/community/developers/dr-richard-boulanger/ music: http://www.csounds.com/community/developers/dr-richard-boulanger/dr-richard-boulanger-music/ ______________________________________________ email: rboulanger@berklee.edu facebook: https://www.facebook.com/richard.boulanger.58 On Fri, Mar 20, 2020 at 10:30 PM David Akbari <dakbari@gmail.com> wrote: Hello Dr. B, |
Date | 2020-03-21 11:03 |
From | Eduardo Moguillansky |
Subject | Re: [Csnd] OSC examples, models, tutorials, and maybe a few more opcodes |
; giosc OSCinit 9876 instr 1 iport = 9876 Smsgs[] init 30 Smsgs, klen OSCraw iport if klen > 0 then printarray Smsgs, -1 endif endin Smsgs will hold a string array with the elements, where the first two elements are the osc path and the types of each message. Notice that the type str (Ssgs[1]) always begins with a "," On 21.03.20 01:08, Dr. Richard
Boulanger wrote:
|
Date | 2020-03-21 16:00 |
From | "Dr. Richard Boulanger" |
Subject | Re: [Csnd] OSC examples, models, tutorials, and maybe a few more opcodes |
Thank you, Eduardo! Yours is a really clean and elegant solution. It is scalable and prints very nicely to the console. It needs to be added to the Csound Manual! Now... for some model CSD files that show how to: trigger, gate, map, "range" and scale, from a variety of sensors (parsing and mapping continuous controllers - a nice new section for the FLOSS Manual?) - Inspired by Ezine, Journal, Books, Mailing List, Manual and FLOSS examples, and from some of my previous work, I am revising, collecting and organizing some. - I will and will share them in a week or so. Anyone have any to share with the list? <CsoundSynthesizer> <CsOptions> -odac -d </CsOptions> <CsInstruments> sr = 44100 ksmps = 32 nchnls = 2 0dbfs = 1 instr 1 iport = 1979 inumMessages = 3 Smsgs[] init inumMessages Smsgs, klen OSCraw iport if klen > 0 then printarray Smsgs, -1 endif endin </CsInstruments> <CsScore> i1 0 3600 </CsScore> </CsoundSynthesizer> _____________________________________________ Dr. Richard Boulanger Professor of Electronic Production and Design Professional Writing and Music Technology Division Berklee College of Music ______________________________________________ OFFICE: 1126 Boylston St., Suite 201 (EPD), Suite 208 (Boulanger) ______________________________________________ President of Boulanger Labs - http://boulangerlabs.com Author & Editor of The Csound Book - http://mitpress.mit.edu/books/csound-book Author & Editor of The Audio Programming Book - http://mitpress.mit.edu/books/audio-programming-book ______________________________________________ about: http://www.boulangerlabs.com/#about about: http://www.csounds.com/community/developers/dr-richard-boulanger/ music: http://www.csounds.com/community/developers/dr-richard-boulanger/dr-richard-boulanger-music/ ______________________________________________ email: rboulanger@berklee.edu facebook: https://www.facebook.com/richard.boulanger.58 On Sat, Mar 21, 2020 at 7:04 AM Eduardo Moguillansky <eduardo.moguillansky@gmail.com> wrote:
|