Old 01-06-2017, 03:27 AM   #1
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,960
Default MPL Isomorphic keyboard

UPD 10.04.2023 as it has SWS dependent stuff it was moved to https://github.com/MichaelPilyavskiy...ipt_Additional

Hi.
Today I`m gonna show you some new ReaScript stuff I`ve coded just for fun and for self education.

My new script is called MPL Isomorphic keyboard.
There are already some analogs of this, but all of them were created as common MIDI or OSC protocol based solutions. So while developing I took as a reference Musix Pro app for iOs, IsoKeys for android and partually Xotopad for Windows. All of them are pretty cool, but have too high price or impossible or hard to modify, in other words I found them not enough open for users.

At first sight you see the main window. You can see here keys, key names, and special section. By clicking on keys script sends 3-byte MIDI message to the native Virtual keyboard. Note, you dont need to keep Virtual keyboard open. On the first run it loads colors, Wicki-haiden layout and major scale from the ini file which is actually a human readable and editable configuration. It is automatically created at the same path where the script actually placed.

On the right panel there are three buttons.
The first button is a preview button. It sets track monitoring on, arm track and set input to all channels of virtual keyboard.
Drag button let you scroll layout with x axis offset from x direction and octave offset from y direction.
Option button opens dedicated window with some settings. Here we have interface setting, so you can change layout, key names, color, root key or scale. Magnet area allows you to play keys which placed closer each other with one finger.
Release behavior defines how note off messages should be sent. Just try every menu item and you`ll hear whats the difference.

I hope you will enjoy this tool. Dont hesitate to post your thoughts. Please donate me if you find this tool useful for yourself. Thanks.

Accessible via ReaPack extension.

Requirements: last REAPER and SWS extension releases.


Last edited by mpl; 04-10-2023 at 11:22 AM.
mpl is offline   Reply With Quote
Old 01-06-2017, 06:54 AM   #2
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Impressive scripting work !!
X-Raym is offline   Reply With Quote
Old 01-06-2017, 07:00 AM   #3
kawa_
Human being with feelings
 
kawa_'s Avatar
 
Join Date: Mar 2016
Posts: 117
Default

Great Work! thank you! and X-Raym Good to see you Again. (sorry, my English skill is still badly..:
__________________
web | kawaScripts | donate | twitter |

Last edited by kawa_; 01-06-2017 at 07:05 AM.
kawa_ is offline   Reply With Quote
Old 01-06-2017, 09:37 AM   #4
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Awesome.
IXix is offline   Reply With Quote
Old 01-06-2017, 09:47 AM   #5
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

First thing that occurs to me is latching. Something like hold shift when click/dragging notes to keep them held until next time they're clicked. Maybe hold alt when clicking new notes to clear latched notes? Not thought anything through, just off the top of my head. Great script.
IXix is offline   Reply With Quote
Old 01-06-2017, 12:06 PM   #6
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,960
Default

IXix, did you try change release behaviour?
Anyway, ctrl/alt/shift + click is a nice idea for some of these modes.
I don`t know is it works on multitouch screens (can`t test) ever?

Currently working on trying to send microtones properly (split by channel and use pitchs+pitchshifts pair).

Last edited by mpl; 01-06-2017 at 12:53 PM.
mpl is offline   Reply With Quote
Old 01-06-2017, 02:04 PM   #7
PopstarWannabe
Human being with feelings
 
Join Date: Nov 2016
Posts: 13
Default

I CAN'T RUN IT !!

I installed it via ReaPack, I went to "Actions" and run it but I get this error message:

1466: attempt to call a nil value (field 'BR_Win32_GetPrivateProfileString')
PopstarWannabe is offline   Reply With Quote
Old 01-06-2017, 02:12 PM   #8
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,960
Default

Sorry, I forgot to mention. Install last SWS extension.
mpl is offline   Reply With Quote
Old 01-06-2017, 02:48 PM   #9
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

I'm not IXix, and I don't even know what programming language you are using (Lua, right?), but...

Code:
  0xE1, -- let it be pitchbend to the first channel
I think that's MIDI channel #2. MIDI channel #1 would be 0xE0.

Quote:
Originally Posted by mpl View Post
(64 is 'no bend', right?)
Right.

Quote:
Originally Posted by mpl View Post
I guess something wrong with MSB/LSB pair but what?
I think the MSB and LSB are the wrong way around i.e. it's 0xE0 LSB MSB.
Tale is offline   Reply With Quote
Old 01-06-2017, 02:59 PM   #10
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,960
Default

Thanks Tale, seems I found solution.

So the center pitchbend for the first channel will looks like:
Code:
pitchbend = 8192
reaper.StuffMIDIMessage( 0, 0xE0, pitchbend  & 0x7F, pitchbend  >> 7)
Also just updated to 1.03 for MIDI support microtonal layouts

Last edited by mpl; 01-06-2017 at 03:10 PM.
mpl is offline   Reply With Quote
Old 01-06-2017, 04:34 PM   #11
Commala
Human being with feelings
 
Join Date: Feb 2014
Posts: 615
Default

This is amazing! I love isomorphic layouts, particularly the harmonic table. Thank you for this. Now if only I had a touchscreen to play it on...

Is there a way to change the note display offset? So to make middle C = C4?

Also, I can't seem to set the key root to Eb (D# in menu), it just gives me D

Edit: wait, I'm sorry, I did manage to set it to Eb, but I did so by selecting E (with C-Db selected in key name)

Last edited by Commala; 01-06-2017 at 04:39 PM.
Commala is offline   Reply With Quote
Old 01-06-2017, 05:00 PM   #12
PopstarWannabe
Human being with feelings
 
Join Date: Nov 2016
Posts: 13
Default

Note: I have latest Reaper and SWS installed and a very good tablet.

I suppose you somehow "linked" your Isomorphic keyboard to Reaper's virtual midi keyboard, so here's some early feedback about both:

1) On both the Iso keyboard and Reaper's keayboard multi touch does NOT work.

2) The response on the Isomorphic keyboard is a bit delayed. The response on Reaper's keyboard is instant but ONLY if you slide your finger. Like you would want to clean the dust very fast! If you simply touch and lift it does not work!
PopstarWannabe is offline   Reply With Quote
Old 01-06-2017, 05:32 PM   #13
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Cool stuff, mpl.

- The images start to get pretty messy if you resize the window. Maybe stop updating the elements until the user stops?

- Dragging the window is a huge drain on my CPU, enough that the window wouldn't actually drag smoothly on the screen. Again, maybe freeze it while the window is being moved?
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 01-07-2017, 12:02 AM   #14
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,960
Default

Thanks for catch Commala!

Key root bug should be fixed with 1.04. And I added octave shift selector (It is only visual. For regular vertical shift use 'Drag' button).

Lokasenna, the problem - hexagons are drawn only within gfx.w/gfx.h to the blit buffer, because of large CPU usage if you draw the whole matrix. That means I still need to redraw matrix when changing x,y,w,h of the window. They also update the config, so after new run window will be at the same position, width/height and dock state. There are already some checks for stop redraw it constantly to blit buffer. Also there are always 2 blitbuffers (#10 and #11 in the code) with moving mirrored alpha for smoothing each other. Maybe I will decrease some CPU if will have a dedicated buffer for circles response of user touches, but they will be not smooth (so I`ll do that is CPU usage will be really decreased a lot).

PopstarWannabe, I guess, response is a bit delayed because of script update frequency for redraw gfx (for me it is about 0.1-0.2 seconds in empty project), so can`t do something with this.

Sorry if I explained a bit wrong, English is not my native language.

Last edited by mpl; 01-07-2017 at 02:55 AM.
mpl is offline   Reply With Quote
Old 01-07-2017, 03:50 AM   #15
PopstarWannabe
Human being with feelings
 
Join Date: Nov 2016
Posts: 13
Default

What about multi touch? At the moment we can only play one note at a time. No chords.
PopstarWannabe is offline   Reply With Quote
Old 01-07-2017, 05:46 AM   #16
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,960
Default

Turn Up magnet area + set release behaviour to the first or second item.
The "true" multitouch depending on how reascript react on multiple touches. If the touches are produced at the "same" time, here we should ask Justin how ReaScript should know xy position of every touch.
mpl is offline   Reply With Quote
Old 01-07-2017, 09:48 AM   #17
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Quote:
Originally Posted by mpl View Post
IXix, did you try change release behaviour?
Anyway, ctrl/alt/shift + click is a nice idea for some of these modes.
I don`t know is it works on multitouch screens (can`t test) ever?
No I didn't try that. Only had a super quick try . I can't test multitouch either, sorry.

Quote:
Originally Posted by mpl View Post
IXix, can you help me a bit?
Sorry, too late. Tale to the rescue (he's way better at this stuff than me anyway).
IXix is offline   Reply With Quote
Old 01-07-2017, 10:19 AM   #18
PopstarWannabe
Human being with feelings
 
Join Date: Nov 2016
Posts: 13
Default

In the actual state, it is not playable. The delay is too big. 0,2 seconds is huge. Lack of multitouch is also not acceptable. It works, but only on adjacent keys.

"Release behaviour" is confusing as a name. You should call it "Drag behaviour" because it determines what happens with the notes when you drag your finger over the screen.

If you based the Iso keyboard on Reaper's keyboard, then it's wrong from the start, because Reaper's keyboard is flawed in multi touch.

I believe this little project has huge potential if done properly.
PopstarWannabe is offline   Reply With Quote
Old 01-07-2017, 10:50 AM   #19
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,960
Default

Try some tweaking external osc/midi stuff. Also http://www.tallkite.com/alt-tuner.html for microtonal stuff if needs. Not a ReaScript one.

Last edited by mpl; 03-23-2017 at 09:19 PM.
mpl is offline   Reply With Quote
Old 01-07-2017, 11:06 AM   #20
PopstarWannabe
Human being with feelings
 
Join Date: Nov 2016
Posts: 13
Default

Ok, don't take it like that. I am sorry if it sounded like that. I didn't mean to offend you.

I don't know how many hours you spent, but let's not forget you also had inspiration (code shared by IsoKeys) plus me writing and guiding you all along: I showed you what's on the market, and what their limitations are. I gave you an idea and still believe it is a good idea for Windows touch market.

At the moment your keyboard gets zero attention because no one knows about it. If I play some songs on it and post it on Youtube, it will get attention. But right now it's not functional and I can not play songs on it.

I didn't know of API limitations. That was your responsibility.

You will get money if it is functional, because people will SEE it and will LIKE it.

I will donate something to you for your efforts.
PopstarWannabe is offline   Reply With Quote
Old 01-07-2017, 11:49 AM   #21
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

- The Virtual MIDI Keyboard is the *only* way a ReaScript can play MIDI at present. I've got a feature request open about it, but there's been no response as of yet. Feel free to chime in there: http://forum.cockos.com/showthread.php?t=185366

- If you didn't specify your needs (response time, multi-touch) beforehand, it's pretty rude to complain that it's not exactly what you wanted and therefore not functional. You wanted an isomorphic keyboard and you got one, with a bunch of cool options. It works, it's playable, it's just a bit clunky. The areas that need improvement are currently held back by Reaper's API, and if the API is ever updated it'll be fairly easy for mpl to make the necessary fixes.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 01-07-2017, 12:23 PM   #22
PopstarWannabe
Human being with feelings
 
Join Date: Nov 2016
Posts: 13
Default

I already apologized. However I did specify my needs by setting as example iOS's Musix Pro app.

It's true indeed that mpl said many times he was not a musician, so maybe he didn't understand that one has to play with multiple fingers and hear immediate feedback.

It's also possible that he himself didn't know of those API limitations.

I do love the end result, but it's still not functional FOR A MUSICIAN.

If the 2 problems (multi touch and delay) were solved, it would be a PERFECT product.

And as I said, I will still donate something.
PopstarWannabe is offline   Reply With Quote
Old 01-07-2017, 01:10 PM   #23
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,960
Default

I guess Cockos will NOT touch a rescript refresh time, so the only thing left is using external stuff (like the Musix one) + JSFX stuff for microtonality (JSFX is way better for stuff like that in refresh rate context, ex. distributing pitch bends). Maybe JSFX is the goto of possible solution for you, but that is out of my league, sorry, PopstarWannabe.

Me also not want to sound as a guy who do everything only for money. It was just a though I noted. I knew I get this before you suggested to code and before I started to code. It just REAPER community mentality. I just live with that, all this is expected.

Last edited by mpl; 01-07-2017 at 02:19 PM.
mpl is offline   Reply With Quote
Old 01-08-2017, 04:39 AM   #24
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Quote:
Originally Posted by mpl View Post
Maybe JSFX ... but that is out of my league
I doubt that.
IXix is offline   Reply With Quote
Old 01-08-2017, 05:13 AM   #25
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,960
Default

JSFX reference:
Quote:
@gfx [width] [height]
The @gfx section gets executed around 30 times a second when the plug-ins GUI is open. You can do whatever processing you like in this (Typically using gfx_*()). Note that this code runs in a separate thread from the audio processing, so you may have both running simultaneously which could leave certain variables/RAM in an unpredictable state.
1 / 30 is approximately 0.03 which is the same as in reascript. So it is seems ReaScript should perform some operations in other thread with faster refresh rate, it is impossible now.
mpl is offline   Reply With Quote
Old 01-08-2017, 09:20 AM   #26
eugen2777
Human being with feelings
 
eugen2777's Avatar
 
Join Date: Aug 2012
Posts: 271
Default

mpl, Thank you, I need to test your keyboard on the tablet later.
Some glitches in the graphic, but it seems to be very interesting especially for touch screen!
===
Quote:
Originally Posted by mpl View Post
JSFX reference:
1 / 30 is approximately 0.03 which is the same as in reascript. So it is seems ReaScript should perform some operations in other thread with faster refresh rate, it is impossible now.
Yes, You are right, I checked it a long time ago.
Moreover, I have found only one virtual keyboard that works without significant delay.
(Короче, на русском - на Винде я нашел только одну! нормальную вирт. клавиатуру, обычное пиано, которая работает без задержки. И это отдельное приложение).
__________________
ReaScripts

Last edited by eugen2777; 01-08-2017 at 09:42 AM.
eugen2777 is offline   Reply With Quote
Old 01-08-2017, 12:41 PM   #27
eugen2777
Human being with feelings
 
eugen2777's Avatar
 
Join Date: Aug 2012
Posts: 271
Default

I'm sorry, some Russian
Сделал простой тест. Быстрее, конечно, но тут нет вообще ничего.
Code:
desc: SimpleTest

slider1:48<0,127,1>note
slider2:100<0,127,1>velo

@init
str = " TEST: Set note, velo, press and drag(up-down) ";

@slider
offset = 0;
note = slider1;
velo = slider2;

@block
mouse_down ? (midisend(offset, 144, note, velo); gfx_clear=-1;);
mouse_up ? midisend(offset, 128, note, velo);


mouse_cap&1 ? (
  V = 8192 + (16384/gfx_h) * (mouse_down_y-mouse_y);
  PitchBend = floor( min(max(V,0),16383) );
  lsb = PitchBend & 0x7F;
  msb = PitchBend >> 7 ;
  midisend(offset, 224, lsb, msb);
);

mouse_up ? midisend(offset, 224, 0, 8192);

@gfx 300 300
gfx_r=gfx_g=gfx_b=gfx_a=1;
gfx_x = gfx_y = 20;
gfx_drawstr(str); //-- REAPER 4.59+

mouse_down = mouse_cap&1 && !(last_mouse_cap&1);
mouse_up = last_mouse_cap&1 && !(mouse_cap&1);

mouse_down ? (mouse_down_x=mouse_x; mouse_down_y=mouse_y;);
mouse_down ? (gfx_clear=-1; gfx_line(0, mouse_y, gfx_w, mouse_y););
mouse_up ? gfx_clear=0;
mouse_cap&1 ? (gfx_line(last_mouse_x, last_mouse_y, mouse_x, mouse_y ) ;);


last_mouse_cap = mouse_cap;
last_mouse_x = mouse_x;
last_mouse_y = mouse_y;

Задержку еще добавляет скорость расчета и прорисовки. Если картинка рисуется, например, одну секунду(утрированно), "не успевая", то след. цикл defer(или в JS - @gfx) будет именно так, через секунду, и задержка такая же. То есть, грубо говоря, графика тормозит реакцию. Михаил, я не уверен, конечно, тебе виднее, но не использовал бы здесь blit

How to make a spoiler? Standard tags do not work, I do not want to clutter up an interesting topic.
__________________
ReaScripts

Last edited by eugen2777; 01-08-2017 at 02:15 PM.
eugen2777 is offline   Reply With Quote
Old 01-08-2017, 02:35 PM   #28
PopstarWannabe
Human being with feelings
 
Join Date: Nov 2016
Posts: 13
Default

Why did you remove the picture with the haxagons? That was very representative of the thread's subject.
PopstarWannabe is offline   Reply With Quote
Old 01-08-2017, 02:53 PM   #29
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 4,171
Default

Hi Mpl,

I love this. I agree it's just waiting for multi-touch support in Reascript - but hopefully that won't be too long a wait (I have my fingers crossed too!)

Regarding CPU, smoothness, dragging and delay. I can think of a few ways to improve things. They will have downsides (doesn't everything) - but at the moment - whenever a note is clicked or the screen is dragged - you are making multiple calls to redraw all the graphics to the buffer. This is pretty slow - as the graphics are pretty and quite complex (and GUI_note is called for - at least - every visible note). Sometimes - this is done more than once on a single click.

Have you considered drawing the entire grid of notes onto a single bitmap? This gets drawn once - onto say backbuffer 1 - whenever the layout is changed.

keep this backbuffer static - until the layout changes.

Then use a second backbuffer of the size of the script window - so each time you call the graphics routine - you just blit the visible bit of backbuffer 1 (bb1) onto backbuffer 2 (bb2), and bb2 to main window.

Then when dragging - you just need to adjust x and y offset values and to re-blit the visible area of bb1 to bb2 and blit bb2 to the graphics window. - super fast and smooth. No complex drawing required for basic screen redraw and almost entirely done in the graphics processing thread.

To change pressed state of a button - just draw that single button (or whatever buttons are pressed) onto bb2 before displaying. If the screen is not dragged - you may not even require to blit bb1 to bb2 (depends on how button releases are dealt with etc).

So effectively - each draw routine call does 1 or 2 largish (script window size) graphics blits (really quick and done in graphics thread), plus draws however many notes are pressed/have changed state.

There is a downside in that (from documentation) I think the limit of a created bitmap is 2048x2048 pixels. This won't be enough when using larger keys. You can scale this image when drawing (which looks a bit rubbish - but would still be functional - and as the basic hexagons are pretty uniform - may not be too hideous.).

Alternatively - if you want to keep resolution - use 2 or 4 bitmaps for bb1 (and bb2 EDIT - not necessary for bb2 if just same as window size) - and 'stitch' them together when drawing to bb2 (EDIT). Adds slightly more simple maths complexity to blitting routines but not too taxing.

It does make the graphics drawing routine a little more complex - but it will make the graphics much more smooth - and should reduce the delay somewhat. I don't know about any delay calling the Reaper midi keyboard thingy, and how much your graphics drawing is adding to the delay - but it will help a bit.

CPU wise - will drop to nearly nothing. RAM use will be much more (for the extra backbuffers - but RAM is usually less of an issue).

My Stripper script relies heavily on 2 large backbuffers - (and several smaller ones) - to prevent having to redraw complex sets of controls unless it has to. Then the logic in the runloop/draw routine works out whether backbuffers need updating or just blitting.

Anyway - I just thought I'd offer my thoughts to maybe help with your project or give you a few more ideas - I'm sure it's only a matter of time before Reascript gets some sort of multitouch (I'm being hopeful - but I don't see it as being more complex as passing a table of touch points).

It wasn't long ago that you inadvertently got me into Reascript - and gave me a simple enough framework to get going. If I ever get my butt in gear and arrange a donation button - and receive anything for my scripts - you have my word I will donate some your way. At the moment I'm broke and can only offer advice - although your maths seems way beyond mine - and your code style is far more pretty and neat

Anyway - thanks for the scripts and all your hard work - it is appreciated by many
__________________
Projects - Reascripts - Lua:
Smart Knobs 2 | LBX Stripper | LBX Floating FX Positioner
Donate via Paypal | LBX Tools Website

Last edited by lb0; 01-08-2017 at 04:00 PM.
lb0 is offline   Reply With Quote
Old 01-08-2017, 09:32 PM   #30
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,960
Default

PopstarWannabe, brought it back.

lb0, nice though, I didn`t spend much time on thinking about blitbuffers, but what you say about is way better for some directions (easier code, RAM usage), so thanks for it. I thought about to draw the whole matrix with hi-res and then use xy offsets and zooming, but yes, when blitting raster graphics, it looks awful. Currently the way I can improve it, it is just using dedicated additional buffer for touch circles (response to clicks), since I don`t redraw the part of matrix (which drawn only inside gfx.w/gfx.h) if nothing happens except touches. So when click happens I`ll redraw only response circles, and other stuff will not be redrawn.
But again this will not help in context of touch delay since ReaScript has not dedicated sample-accurate parallel thread for Audio/MIDI or mouse response stuff.

eugen2777, spoilers dosn`t work at Cockos forum.
Blitting graphics way faster especially if you need to draw a lot of stuff (so you loop many things, go through different checks etc, and with with blit you perform only one operation). Yes, it also take RAM but not too much (well, depending on what you draw actually).
I don`t think reducing response delay is possible with reascript or JSFX anyway (cause mouse clicks are part of gfx which redraw at least 30 times a second even with empty graphics as I noted before). Maybe it is possible to deal with it via C++ extension, but not sure.

Last edited by mpl; 01-08-2017 at 09:53 PM.
mpl is offline   Reply With Quote
Old 01-08-2017, 09:42 PM   #31
Commala
Human being with feelings
 
Join Date: Feb 2014
Posts: 615
Default

Hey mpl, thank you for allowing octave shift in this script.

There is a minor detail though that I am confused about - if middle C is always midi note 60, and I wish to label this as C4, to do so I have to select the octave shift 'C3 = midi note 72' in your script. This doesn't appear to make sense to me, shouldn't C3 be midi note 48 when C4 is 60?
Commala is offline   Reply With Quote
Old 01-08-2017, 10:02 PM   #32
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,960
Default

Commala, I think menu items (c=48 / c= 72) should be moved way around, thanks for catch.
mpl is offline   Reply With Quote
Old 01-09-2017, 08:04 AM   #33
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 4,171
Default

Quote:
Originally Posted by mpl View Post
PopstarWannabe, brought it back.

lb0, nice though, I didn`t spend much time on thinking about blitbuffers, but what you say about is way better for some directions (easier code, RAM usage), so thanks for it. I thought about to draw the whole matrix with hi-res and then use xy offsets and zooming, but yes, when blitting raster graphics, it looks awful. Currently the way I can improve it, it is just using dedicated additional buffer for touch circles (response to clicks), since I don`t redraw the part of matrix (which drawn only inside gfx.w/gfx.h) if nothing happens except touches. So when click happens I`ll redraw only response circles, and other stuff will not be redrawn.
But again this will not help in context of touch delay since ReaScript has not dedicated sample-accurate parallel thread for Audio/MIDI or mouse response stuff.

eugen2777, spoilers dosn`t work at Cockos forum.
Blitting graphics way faster especially if you need to draw a lot of stuff (so you loop many things, go through different checks etc, and with with blit you perform only one operation). Yes, it also take RAM but not too much (well, depending on what you draw actually).
I don`t think reducing response delay is possible with reascript or JSFX anyway (cause mouse clicks are part of gfx which redraw at least 30 times a second even with empty graphics as I noted before). Maybe it is possible to deal with it via C++ extension, but not sure.
Ok - sounds like you know what you want to do for the graphics updates

May I just mention a couple of other things. I'm happy for you to completely ignore me if you wish -

Inside your main runloop - you are calling functions:

DEFINE_Objects
DEFINE_GUI_vars
DEFINE_Notes

each and every iteration of the runloop.

I would say DEFINE_GUI_vars - should just be put into a global table - gui and called just once. Yeah - it's a short function - but CPU cycles are CPU cycles - and the data the function creates never changes - so why call it more than once.

DEFINE_Objects also doesn't need to be called every iteration - although it may require calling again if the layout changes or something like that. I would again only call this when required and not each iteration.

Now - I'm not sure when DEFINE_notes needs to be called - but would hazard a guess again that it doesn't need to be called each time through the runloop. Can you again only call this function when note info needs to be updated?

DEFINE_notes contains multiple nested loops through all rows and columns - that's 50x50 (2500) times several times on the def setup. This is what's causing a lot of CPU to be used up. Also in the GUI_notes function you have similar nested loops which might be reduced somehow (using the backbuffer and only redrawing notes that change - maybe have a separate table of active notes)?

Now - I don't understand exactly how all of your functions work - especially DEFINE_notes which seems to be associated with setting up the different note layouts. But why do they need to be called each time through the runloop?

When idle - your script runs at about 10% CPU on my laptop (gets the fan running!) - but I would hazard a guess a few simple changes and a little re-arrangement would reduce this to nearly nothing.

The mouse_get function is possibly the only function that needs to do any work within the runloop.

Just a few thoughts I had with regard to reducing CPU. I understand you are essentially doing this for free - and don't expect you to make any changes I suggest - but thought I'd offer you some ideas as CPU is something a few people have commented on and as soon as multitouch arrives - this will be the ultimate touch keyboard interface for Reaper!
__________________
Projects - Reascripts - Lua:
Smart Knobs 2 | LBX Stripper | LBX Floating FX Positioner
Donate via Paypal | LBX Tools Website
lb0 is offline   Reply With Quote
Old 06-17-2020, 09:36 AM   #34
Metrobot
Human being with feelings
 
Join Date: Feb 2018
Posts: 205
Default

MPL
I've just discovered this and it's great work. I have a few questions:
1) What does microtonal mode do and how does it work?
2) Can I define the Key names with ratios (5/4, 9/8..etc) or alternate notation?
3) Is it possible to edit scales and note names by editing the ini file?
If so, where is the ini file placed?

My primary focus is on microtonal music.

Do you have any scrips that allow for one to define chords and voicings similar to 'chord gun'?
I usually retune my virtual instruments with more than 12 tones to the octave so traditional chord tools don't really work.
-M

Last edited by Metrobot; 06-18-2020 at 09:39 AM.
Metrobot is offline   Reply With Quote
Old 06-09-2021, 04:43 AM   #35
Steviekeys
Human being with feelings
 
Join Date: Jun 2016
Location: UK
Posts: 285
Default

Quote:
Originally Posted by Metrobot View Post
MPL
I've just discovered this and it's great work. I have a few questions:
1) What does microtonal mode do and how does it work?
2) Can I define the Key names with ratios (5/4, 9/8..etc) or alternate notation?
3) Is it possible to edit scales and note names by editing the ini file?
If so, where is the ini file placed?


-M
just found this myself.

1) Pass. Doesn't appear to put out any note on messages! (midi 2.0?)

2) Not that I can see. You can turn the labels off so It's less confusing.

3) It is possible to edit the number of intervals between hexagons/squares.
7="Gerhard31" 10 2 2 0
8="Janko31" 5 3 1 0
These are two I made for 31TET
Labels obviously are wrong in this case

You can also edit scales, not tried it, have a feeling it wont be useful for anything other than 12 notes but I could be wrong.
Steviekeys is online now   Reply With Quote
Old 06-09-2021, 10:08 PM   #36
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,960
Default

Quote:
Originally Posted by Steviekeys View Post
just found this myself.
1) Pass. Doesn't appear to put out any note on messages! (midi 2.0?)
The script trigger messages into Virtual Keyboard MIDI stream. So turn on monitoring, record arm and set input to MIDI Virtual keyboard. Or click specific button in the script (speaker) to prepare track input.

Quote:
Not that I can see. You can turn the labels off so It's less confusing.
Sorry, the script is too old. Adding features would be a big mess.

Quote:
You can also edit scales, not tried it, have a feeling it wont be useful for anything other than 12 notes but I could be wrong.
Nope, it doesn`t really support non-12 tunings, you`d better use some modern apps (there are some really great of them).

Quote:
Originally Posted by Metrobot View Post
What does microtonal mode do and how does it work?
My primary focus is on microtonal music.
The microtonal mode was a really rough test of sending Pitch+Pitchbend. Real microtonal mode seems a task for JSFX rather ReaScript. From reascript it is near impossible to implement without crazy tricks and additional JSFX. I`d forward this script tasks to JSXF coders. From JSFX point of view there is LOT of possibilities can be created without pain I have when creating this script back in 2017. Meanwhile this is really dirty uneditable code and should be removed or get complete rebuild.
mpl is offline   Reply With Quote
Old 06-09-2021, 10:11 PM   #37
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,960
Default

Quote:
Originally Posted by lb0 View Post
Ok - sounds like you know what you want to do for the graphics updates

May I just mention a couple of other things. I'm happy for you to completely ignore me if you wish -

Inside your main runloop - you are calling functions:

DEFINE_Objects
DEFINE_GUI_vars
DEFINE_Notes

each and every iteration of the runloop.

I would say DEFINE_GUI_vars - should just be put into a global table - gui and called just once. Yeah - it's a short function - but CPU cycles are CPU cycles - and the data the function creates never changes - so why call it more than once.

DEFINE_Objects also doesn't need to be called every iteration - although it may require calling again if the layout changes or something like that. I would again only call this when required and not each iteration.

Now - I'm not sure when DEFINE_notes needs to be called - but would hazard a guess again that it doesn't need to be called each time through the runloop. Can you again only call this function when note info needs to be updated?

DEFINE_notes contains multiple nested loops through all rows and columns - that's 50x50 (2500) times several times on the def setup. This is what's causing a lot of CPU to be used up. Also in the GUI_notes function you have similar nested loops which might be reduced somehow (using the backbuffer and only redrawing notes that change - maybe have a separate table of active notes)?

Now - I don't understand exactly how all of your functions work - especially DEFINE_notes which seems to be associated with setting up the different note layouts. But why do they need to be called each time through the runloop?

When idle - your script runs at about 10% CPU on my laptop (gets the fan running!) - but I would hazard a guess a few simple changes and a little re-arrangement would reduce this to nearly nothing.

The mouse_get function is possibly the only function that needs to do any work within the runloop.

Just a few thoughts I had with regard to reducing CPU. I understand you are essentially doing this for free - and don't expect you to make any changes I suggest - but thought I'd offer you some ideas as CPU is something a few people have commented on and as soon as multitouch arrives - this will be the ultimate touch keyboard interface for Reaper!
Just for the history - this message was soooo helpful to understand where to reduce and clean whole script structure and improve performance in most places in the code. So thanks lb0!
mpl is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 07:45 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.