Example JS for OSC send & receive?
- KVRian
- 707 posts since 7 May, 2002 from Phoenix, Arizona, USA
EDIT: I hadn't yet seen Moss' video tutorial part 11 which has a good example of this.
Anyone know of any basic examples/template for setting up bidirectional behavior, particularly receive, for OSC commands? I downloaded all osc related things I found on github. I found one by Charles which had a good simple example of sending out osc:
mw-spring-2019.js
https://github.com/CharlesHolbrow/charles-bitwig-osc
but not one for receive (there is some kind of receive.js test in his pack, but it seems not a self contained js, I don't know enough yet to make use of it).
I'm just beginning with Bitwig and JS (have experience with lemur scripting), watching Moss' videos, and doing other learning materials. Beginning to understand some basics. I have used the excellent OSC script in the DrivenByMoss pack, but I am interested in creating a non bank approach to controlling tracks and user parameters. Perhaps eventually being able to write a script that can target a track based on its name rather than numerical position (so that if the track changes position the controlability will follow).
Thanks!
Anyone know of any basic examples/template for setting up bidirectional behavior, particularly receive, for OSC commands? I downloaded all osc related things I found on github. I found one by Charles which had a good simple example of sending out osc:
mw-spring-2019.js
https://github.com/CharlesHolbrow/charles-bitwig-osc
but not one for receive (there is some kind of receive.js test in his pack, but it seems not a self contained js, I don't know enough yet to make use of it).
I'm just beginning with Bitwig and JS (have experience with lemur scripting), watching Moss' videos, and doing other learning materials. Beginning to understand some basics. I have used the excellent OSC script in the DrivenByMoss pack, but I am interested in creating a non bank approach to controlling tracks and user parameters. Perhaps eventually being able to write a script that can target a track based on its name rather than numerical position (so that if the track changes position the controlability will follow).
Thanks!
Last edited by ericzang on Tue Oct 13, 2020 3:21 am, edited 3 times in total.
- KVRist
- 393 posts since 12 Apr, 2020
Greetings Eric!ericzang wrote: Sun Oct 11, 2020 9:28 am I'm just beginning with Bitwig and JS (have experience with lemur scripting), watching Moss' videos, and doing other learning materials. Beginning to understand some basics. I have used the excellent OSC script in the DrivenByMoss pack, but I am interested in creating a non bank approach to controlling tracks and user parameters. Perhaps eventually being able to write a script that can target a track based on its name rather than numerical position (so that if the track changes position the controlability will follow).
Definetly continue thru the moss tutorials. I would really recommend to do and code every single one. Even it it seems like a waste of time. There are lots of little bits in there that is easy to miss or not understand. For me they cemented the Bitwig way of doing things.
I found a work around to target both CursorTrack and TrackBank to Channel names. The code here is a bit shifty but may help you get your own working. I have since moved onto Java so I probably won't be updating this anytime soon.
viewtopic.php?f=268&t=549982&p=7845621& ... r#p7845621
My last iteration I think is here: https://github.com/kirkwoodwest/worm-bi ... %20Finder/
Still I'm not sure how well it is working and last time I tried to use it with groups there were some issues with retargetting some things. So I'm sorry in advance if its not working to spec. I might get back to it once my Java port is complete.
If you want to do any Non-Banking approaches to controlling devices you'll need to set up a cursor track for each of those devices. I've been able to set up five midifighters to target 8-32 parameters of devices on different tracks so they are all available at once. Assuming you are using Lemur or touch OSC you might consider how many controls you have on a specific page and build your system from there.
One thing I havn't done is try to access the parameters "deep" into the device. Like the ones used in the big list in the device rack for a vst. Is that something you are looking to do?
I'm Also curious about osc bidirectional behavior! Looking forward to seeing your build!
----------------------------------------------------------------------
/CTRL → http://slashctrl.io
Music & mixes → http://soundcloud.com/kirkwoodwest
/CTRL → http://slashctrl.io
Music & mixes → http://soundcloud.com/kirkwoodwest
- KVRian
- Topic Starter
- 707 posts since 7 May, 2002 from Phoenix, Arizona, USA
Hey Kirkwood, we meet again!
Thanks very much for the hints and pointers, have downloaded them, gradually the pieces will come together for me to have a better understanding and facility of things hopefully.
You mentioned Java, and it was a question I asked myself, should I just start learning Java instead of JavaScript? But I got the impression that JS is more beginner friendly, plus it is used not only in Bitwig, but Open-Stage-Control, and MAX MSP, so I figured that'd be a practical way to go. Plus perhaps JS is kind of a primer for Java?
I'm getting the impression with controller scripts and Bitwig that its overall quite flexible, but some approaches I may take for granted are not available or created yet? The main example I know of is seemingly typical bidirectional midi mapping. Coming from Ableton, it is a relatively simple matter to map hundreds of midi ccs to parameters and have bidirectional behavior (not that I want to have to map hundreds of parameters, would rather use OSC in general).
In Bitwig so far I have only found the default Generic MIDI Keyboard controller which is only one way communication, but I think unlimited in its mapping? Then there is Moss' Flexi, which has bidirectionality but works in banks of 8 (I'd like to have many more simultaneously available). Perhaps I've missed something? I'll be looking into understanding the Cursor Track approach you mentioned as related to the midifighters. From the thread you linked to, I see there can be some unclear aspects to implementing it as first.
Thanks again!
You mentioned Java, and it was a question I asked myself, should I just start learning Java instead of JavaScript? But I got the impression that JS is more beginner friendly, plus it is used not only in Bitwig, but Open-Stage-Control, and MAX MSP, so I figured that'd be a practical way to go. Plus perhaps JS is kind of a primer for Java?
I'm getting the impression with controller scripts and Bitwig that its overall quite flexible, but some approaches I may take for granted are not available or created yet? The main example I know of is seemingly typical bidirectional midi mapping. Coming from Ableton, it is a relatively simple matter to map hundreds of midi ccs to parameters and have bidirectional behavior (not that I want to have to map hundreds of parameters, would rather use OSC in general).
In Bitwig so far I have only found the default Generic MIDI Keyboard controller which is only one way communication, but I think unlimited in its mapping? Then there is Moss' Flexi, which has bidirectionality but works in banks of 8 (I'd like to have many more simultaneously available). Perhaps I've missed something? I'll be looking into understanding the Cursor Track approach you mentioned as related to the midifighters. From the thread you linked to, I see there can be some unclear aspects to implementing it as first.
Thanks again!
- KVRist
- 393 posts since 12 Apr, 2020
Cheers Eric! trying to rack my brain where we connected online! Lemur Users? clyphx?ericzang wrote: Sun Oct 11, 2020 9:53 pm Hey Kirkwood, we meet again!Thanks very much for the hints and pointers, have downloaded them, gradually the pieces will come together for me to have a better understanding and facility of things hopefully.
I think .js is a great place to start. Honestly I don't think you can go wrong there... when you are ready take it to the next level Java is there. .js is sweet and simple doesn't need language typing or class definitions. Also plenty of decent bitwig scripts on .js to dig into for code tricks.ericzang wrote: Sun Oct 11, 2020 9:53 pm You mentioned Java, and it was a question I asked myself, should I just start learning Java instead of JavaScript? But I got the impression that JS is more beginner friendly, plus it is used not only in Bitwig, but Open-Stage-Control, and MAX MSP, so I figured that'd be a practical way to go. Plus perhaps JS is kind of a primer for Java?
Java has a bigger learning curve for sure but the IDE helps a ton. Took took me a while to remember since its been over 15 years since I studied but i'm getting there in week 3 of use and hundreds of google searches.
I can't speak to OSC if its better to implement in Java or not.
When you get to the Remote Controls and parameters part of the tutorial it will become clear what you need to do to map on different tracks. for me I have 1 cursor device per track that targets the first device and set up the control bank to control any device within it.ericzang wrote: Sun Oct 11, 2020 9:53 pm In Bitwig so far I have only found the default Generic MIDI Keyboard controller which is only one way communication, but I think unlimited in its mapping? Then there is Moss' Flexi, which has bidirectionality but works in banks of 8 (I'd like to have many more simultaneously available). Perhaps I've missed something? I'll be looking into understanding the Cursor Track approach you mentioned as related to the midifighters. From the thread you linked to, I see there can be some unclear aspects to implementing it as first.
Can't speak to bidirectionality in osc but with midi there is two ways I think to do it...
Update via midi input and then on flush() send the values back to the controller. That keeps them in sync. Also once you get that working, save a copy of the data so you can compare against that and don't send all the midi events back every flush().
The other way is to use the new hardware API but for whatever reason I have still yet to get into this. Moss has a sweet tutorial on it to get rollin.
Hopefully someone else can chime in with some answers to the questions
----------------------------------------------------------------------
/CTRL → http://slashctrl.io
Music & mixes → http://soundcloud.com/kirkwoodwest
/CTRL → http://slashctrl.io
Music & mixes → http://soundcloud.com/kirkwoodwest
- KVRian
- Topic Starter
- 707 posts since 7 May, 2002 from Phoenix, Arizona, USA
We were both on that alternative Lemur forum a while back. Thanks for sharing your insight! Will look into those more.
- KVRAF
- 4898 posts since 13 May, 2004
If you are an experienced developer you can write good JavaScript code. If you are not it is likely a messericzang wrote: Sun Oct 11, 2020 9:53 pm You mentioned Java, and it was a question I asked myself, should I just start learning Java instead of JavaScript? But I got the impression that JS is more beginner friendly, plus it is used not only in Bitwig, but Open-Stage-Control, and MAX MSP, so I figured that'd be a practical way to go. Plus perhaps JS is kind of a primer for Java?
Java guides you a bit into this journey. Setting up the tooling is a bit of work but you will safe a lot of time later on when you need to find a bug, which gets quickly impossible in JavaScript.
Did you look at my OSC implementation? In the latest release you can configure any page size you want. There is also an Open Stage Control template coming with it (bi-directional) but it is designed for pages of 8 (but you can easily change that).ericzang wrote: Sun Oct 11, 2020 9:53 pm In Bitwig so far I have only found the default Generic MIDI Keyboard controller which is only one way communication, but I think unlimited in its mapping? Then there is Moss' Flexi, which has bidirectionality but works in banks of 8 (I'd like to have many more simultaneously available). Perhaps I've missed something?
- KVRian
- Topic Starter
- 707 posts since 7 May, 2002 from Phoenix, Arizona, USA
Thanks Moss! I just realized there is part 11 showing OSC in your video series!
As I design my setup, I will have a better practical understanding of my needs. For now I'm trying to get an understanding of what are the possibilities and limitations of Bitwig, so I can see how I can adapt my ideal setup to fit within the Bitwig environment.
Thank you for your great work. I do see in your OSC implementation the option to expand the page size. I think this could generally work out well for my projected usage as far as I know now. When you have a moment, I'm interested in your comment about a couple observations:
One question I have is concerning User Parameters in your OSC implementation. Not that I need to explain it to you of course, just making sure I understand how it works: I understand that there are 8 User Params per page, so with a page size of 8 = 64 User Params are available. I noticed that feedback to these User Params is only sent according to the currently selected page # (when page 1 is selected it will allow feedback to be sent only to user params 1-8, page 2 to 9-16, etc).
I am imagining a common use case I would like to have is non page based user param feedback, so all 64 can generate feedback regardless of the current page selected. Might this be an optional possibility? This is one of the situations that got me thinking perhaps eventually I can write a relatively simple non page based OSC script primarily for having many direct "user parameters" with bidirectionality.
----------------
The other question I have is perhaps more of a hypothetical issue, and maybe in practice it is not a problem?
I have been experimenting with the page size, and using the Max Console as an OSC monitor. I notice that when the script starts, it sends out a large amount of "initialization" values, proportional to the page size, for example:
Page size of 8 sends 4,066 OSC commands,
size of 16 = 11,746,
size of 64 = 149,441.
When setting page size to its max of 200 (hopefully I'll never need so many!), for me it causes unresponsiveness/freeze in Bitwig and crashed Bitwig once. I'm using an i9900k locked to 4.8Ghz.
I have only the default project loaded (actually I'm still using the demo until I make a final decision to go with Bitwig, which I probably will). It has only two empty tracks. Looking at the commands sent out, most all of them seem not applicable to the minimal empty 2 track state of the project. For example: /track/41/send/64/volume 0, and /track/62/clip/62/name
I understand there should be some amount of initialization of values upon project load, but I wonder if there is any practical way to avoid the sending of the commands related to non existent elements? Seeing that 200 page size clearly creates a problem for me, I haven't yet discovered what is the largest page size that is safe to use for me, and might there be other issues with a large page size that I have yet to encounter?
Thanks again!
As I design my setup, I will have a better practical understanding of my needs. For now I'm trying to get an understanding of what are the possibilities and limitations of Bitwig, so I can see how I can adapt my ideal setup to fit within the Bitwig environment.
Thank you for your great work. I do see in your OSC implementation the option to expand the page size. I think this could generally work out well for my projected usage as far as I know now. When you have a moment, I'm interested in your comment about a couple observations:
One question I have is concerning User Parameters in your OSC implementation. Not that I need to explain it to you of course, just making sure I understand how it works: I understand that there are 8 User Params per page, so with a page size of 8 = 64 User Params are available. I noticed that feedback to these User Params is only sent according to the currently selected page # (when page 1 is selected it will allow feedback to be sent only to user params 1-8, page 2 to 9-16, etc).
I am imagining a common use case I would like to have is non page based user param feedback, so all 64 can generate feedback regardless of the current page selected. Might this be an optional possibility? This is one of the situations that got me thinking perhaps eventually I can write a relatively simple non page based OSC script primarily for having many direct "user parameters" with bidirectionality.
----------------
The other question I have is perhaps more of a hypothetical issue, and maybe in practice it is not a problem?
I have been experimenting with the page size, and using the Max Console as an OSC monitor. I notice that when the script starts, it sends out a large amount of "initialization" values, proportional to the page size, for example:
Page size of 8 sends 4,066 OSC commands,
size of 16 = 11,746,
size of 64 = 149,441.
When setting page size to its max of 200 (hopefully I'll never need so many!), for me it causes unresponsiveness/freeze in Bitwig and crashed Bitwig once. I'm using an i9900k locked to 4.8Ghz.
I have only the default project loaded (actually I'm still using the demo until I make a final decision to go with Bitwig, which I probably will). It has only two empty tracks. Looking at the commands sent out, most all of them seem not applicable to the minimal empty 2 track state of the project. For example: /track/41/send/64/volume 0, and /track/62/clip/62/name
I understand there should be some amount of initialization of values upon project load, but I wonder if there is any practical way to avoid the sending of the commands related to non existent elements? Seeing that 200 page size clearly creates a problem for me, I haven't yet discovered what is the largest page size that is safe to use for me, and might there be other issues with a large page size that I have yet to encounter?
Thanks again!
- KVRAF
- 4898 posts since 13 May, 2004
Yes, this should work but I never tested it.ericzang wrote: Mon Oct 12, 2020 1:45 pm I am imagining a common use case I would like to have is non page based user param feedback, so all 64 can generate feedback regardless of the current page selected. Might this be an optional possibility?
Yes, that is really an issue. I think if you do not need banking and have a very specific use case it makes more sense to write you own implementation, which only implements commands for the data you really need.ericzang wrote: Mon Oct 12, 2020 1:45 pm I understand there should be some amount of initialization of values upon project load, but I wonder if there is any practical way to avoid the sending of the commands related to non existent elements? Seeing that 200 page size clearly creates a problem for me, I haven't yet discovered what is the largest page size that is safe to use for me, and might there be other issues with a large page size that I have yet to encounter?
- KVRian
- Topic Starter
- 707 posts since 7 May, 2002 from Phoenix, Arizona, USA
