Old 01-07-2014, 04:34 AM   #41
EvilDragon
Human being with feelings
 
EvilDragon's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 24,790
Default

Quote:
Originally Posted by Tronic View Post
Please make this thing possible....

midisyxrecv

this is very useful to create dashboards for every HW very quickly

..and midisyxsend, too, of course.
EvilDragon is offline   Reply With Quote
Old 01-07-2014, 04:42 AM   #42
Tronic
Human being with feelings
 
Tronic's Avatar
 
Join Date: Jan 2012
Posts: 104
Default

Quote:
Originally Posted by EvilDragon View Post
..and midisyxsend, too, of course.
midisyx
this command already exists and sends a buffer prefilled.

i'm wait for the receive version

midisyx(offset,msgptr,len)
Example:

buf[0] = $xAA|0;
buf[1] = $xBB|0;
midisyx(offset,buf,2); // send sysex: F0 AA BB F7
Tronic is offline   Reply With Quote
Old 01-07-2014, 06:22 PM   #43
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

In pre8, you can now do:
Code:
sprintf(str, "this is a number %d and this is a string %s", 32, "hello");
...etc, normal C style things... you can also do the %{globalvarname}s if you prefer, or mix/match like:
Code:
sprintf(str,"fn=%{fn}s, foo=%d\n",foo);
Same goes for match(), and gfx_printf().
Justin is offline   Reply With Quote
Old 01-07-2014, 06:27 PM   #44
ijijn
Human being with feelings
 
ijijn's Avatar
 
Join Date: Apr 2012
Location: Christchurch, New Zealand
Posts: 482
Default

Wow, that's REALLY flexible. Thanks Justin!
ijijn is offline   Reply With Quote
Old 01-08-2014, 04:22 PM   #45
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
Default

I wish to copy a string into an array. What is the best way to do it?

Using brute force I have come up with:
Code:
idx = 0;
loop(strlen(string_idx]),
    dest_ptr[idx] = str_getchar[string_idx], idx); 
    idx +=1;
);

// copying the characters, one at a time, into the addresses from dest_ptr onwards.
But surely there is a better way ... ?
__________________
DarkStar ... interesting, if true. . . . Inspired by ...

Last edited by DarkStar; 01-09-2014 at 02:09 AM.
DarkStar is online now   Reply With Quote
Old 01-08-2014, 09:33 PM   #46
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Just posted pre9, and updated docs here: http://www.reaper.fm/sdk/js/gfx.php

Darkstar, that is sort of the way... though in pre9 you can now embed/extract raw (and optionally big-endian) ints/shorts/floats/doubles as floats as well... so if you want to embed a bunch of data in a string for saving to configuration or file, you can do that too...

also, in pre9: gfx_setfont(), and some more obscure LICE blitting functions, including gfx_transformblit().

Ha ha
Justin is offline   Reply With Quote
Old 01-09-2014, 12:19 AM   #47
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
Default

Quote:
Originally Posted by Justin View Post
also, in pre9: gfx_setfont(), and some more obscure LICE blitting functions, including gfx_transformblit().

Ha ha
Coooool!
Tale is offline   Reply With Quote
Old 01-09-2014, 01:56 AM   #48
ijijn
Human being with feelings
 
ijijn's Avatar
 
Join Date: Apr 2012
Location: Christchurch, New Zealand
Posts: 482
Default

Quote:
Originally Posted by Justin View Post
Just posted pre9, and updated docs here: http://www.reaper.fm/sdk/js/gfx.php
...
also, in pre9: gfx_setfont(), and some more obscure LICE blitting functions, including gfx_transformblit().

Ha ha
Blit-blam-blizzle!

So .. does any of this do 9-slicing yet? I'm still trying to decipher the cuneiform on the JS temple walls...

I was thinking of putting a little solution for that together, but if you can do it already then I'll focus my efforts elsewhere.

PS: Yay! More amazing updates!
ijijn is offline   Reply With Quote
Old 01-09-2014, 04:42 AM   #49
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
Default Crash calling gfx_setfont in @init

I have crashed REAPER by calling gfx_setfont() in @init, but I guess I am not supposed to do that, right? I just thought it was wasteful to setup fonts each @gfx call, but I guess there are better ways to accomplish that, e.g.:

Code:
@gfx
!init ? (
  gfx_setfont(1, "Arial", 100);
  gfx_setfont(2, "Times", 50);
  init = 1;
);
Tale is offline   Reply With Quote
Old 01-09-2014, 07:22 AM   #50
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Quote:
Originally Posted by Tale View Post
I have crashed REAPER by calling gfx_setfont() in @init, but I guess I am not supposed to do that, right? I just thought it was wasteful to setup fonts each @gfx call, but I guess there are better ways to accomplish that, e.g.:

Code:
@gfx
!init ? (
  gfx_setfont(1, "Arial", 100);
  gfx_setfont(2, "Times", 50);
  init = 1;
);
Oops, you should definitely only call gfx_* in @gfx, but it shouldn't crash at least in @init, will look into.

Also, calling gfx_setfont(1,"Times", 50) over and over with the same flags will be very fast, it will check for no changes (though of course doing an init check like that will be even faster).

Last edited by Justin; 01-09-2014 at 07:58 AM.
Justin is offline   Reply With Quote
Old 01-09-2014, 10:29 AM   #51
jnif
Human being with feelings
 
jnif's Avatar
 
Join Date: Dec 2008
Posts: 2,111
Default

Is the vertical positioning different for default bitmapped font and other fonts like Arial?
It looks like Arial font is drawn about half character height lower than default bitmapped font.

jnif
jnif is offline   Reply With Quote
Old 01-09-2014, 11:11 AM   #52
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Quote:
Originally Posted by jnif View Post
Is the vertical positioning different for default bitmapped font and other fonts like Arial?
It looks like Arial font is drawn about half character height lower than default bitmapped font.

jnif
Hmm, looks like gfx_texth is being reset to 8, which causes it to be not correct for other fonts (will be fixed in the next build). For now, and future, maybe you should use gfx_measurestr() to figure out where to position?
Justin is offline   Reply With Quote
Old 01-09-2014, 09:17 PM   #53
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,467
Default

experimenting, I made a plug that displays;

"your Mom says turn it down!"

when ever the RMS level went over -12...



totally stupid, yet completely educational... lol


Who's made something actually useful?
James HE is offline   Reply With Quote
Old 01-12-2014, 07:11 AM   #54
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
Default

Is there a way break a match pattern into multiple lines to make it readable in the JS FX window (without scrolling sideways)?

From
Code:
        match("%-2{textline_pidx}d%1s%-2{textline_psubidx}d%1s%-3{textline_v1}d%1s%-3{textline_v2}d%1s%-3{textline_v3}d%1s%{textline_name}s",textline_str) ? (
to
Code:
        match("%-2{textline_pidx}d %1s
                   %-2{textline_psubidx}d %1s
                   %-3{textline_v1}d %1s
                   %-3{textline_v2}d %1s
                   %-3{textline_v3}d %1s
                   %{textline_name}s",textline_str) ? (
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is online now   Reply With Quote
Old 01-12-2014, 08:35 AM   #55
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Quote:
Originally Posted by DarkStar View Post
Is there a way break a match pattern into multiple lines to make it readable in the JS FX window (without scrolling sideways)?

From
Code:
        match("%-2{textline_pidx}d%1s%-2{textline_psubidx}d%1s%-3{textline_v1}d%1s%-3{textline_v2}d%1s%-3{textline_v3}d%1s%{textline_name}s",textline_str) ? (
Yes,
Code:
match("%-2{textline_pidx}d%1s%-2{textline_psubidx}d"
      "%1s%-3{textline_v1}d%1s%-3{textline_v2}d%1s%-3{textline_v3}d"
      "%1s%{textline_name}s",textline_str) ? (
Multiple "string" blocks with nothing between them will concatenated at compile-time:
Code:
a = "hello wor" "ld";
b = "hello world";
a and b end up with the same value
Justin is offline   Reply With Quote
Old 01-12-2014, 10:54 AM   #56
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
Default

^^^^
Thank you; that makes it a lot easier to read, and to see the pattern matching for each sub-string
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is online now   Reply With Quote
Old 01-13-2014, 03:35 AM   #57
Kite
Human being with feelings
 
Join Date: Apr 2010
Location: Portland OR
Posts: 217
Default

Quote:
Originally Posted by Tronic View Post
Please make this thing possible....

midisyxrecv

this is very useful to create dashboards for every HW very quickly
Yes, please!
__________________
alt-tuner: a microtonal midi plug-in: www.TallKite.com/alt-tuner.html
The Kite Guitar, a playable 41-ET guitar: www.KiteGuitar.com
Kite is offline   Reply With Quote
Old 01-13-2014, 05:57 AM   #58
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

gfx_texth seems to be broken
Code:
@gfx
gfx_x = gfx_y = 5;
gfx_a = gfx_r = gfx_g = gfx_b = 1;
gfx_drawstr("hello");
gfx_y += gfx_texth;
gfx_drawstr("world");
gives me this...

IXix is offline   Reply With Quote
Old 01-13-2014, 07:14 AM   #59
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
Default

^^^^
... works OK here (just copied and pasted into another JS FX); "world" is lower down than "hello".
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is online now   Reply With Quote
Old 01-13-2014, 07:15 AM   #60
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
Default CR LF Tip? Nit-pick?

Back on the topic of CR LF (LF CR?) at the end of lines in a .txt file
(a) If there is another line of text, then the current line will end with these two control characters AND they will be included in the str_len().

(b) If the text file ends immediately after the last printable character of the last line, then that line does NOT end with the two control characters.
I was dealing with (a) by reducing the string length by 2. However this was chopping the last two characters off the last line. To work around it I (try to) remember that I must hit 'Enter' after the last line of text when editing the text file.
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is online now   Reply With Quote
Old 01-13-2014, 07:45 AM   #61
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Quote:
Originally Posted by DarkStar View Post
Back on the topic of CR LF (LF CR?) at the end of lines in a .txt file
(a) If there is another line of text, then the current line will end with these two control characters AND they will be included in the str_len().

(b) If the text file ends immediately after the last printable character of the last line, then that line does NOT end with the two control characters.
I was dealing with (a) by reducing the string length by 2. However this was chopping the last two characters off the last line. To work around it I (try to) remember that I must hit 'Enter' after the last line of text when editing the text file.
Yeah, this is so you can read the file exactly as is. rtrimnl(str) after getting each line to have it remove any trailing newlines:

Code:
function rtrimnl(x) local(c,p) 
(
  p = strlen(x);
  while (p>=1 && ((c=str_getchar(x,p-1))=='\r' || c=='\n')) ( p-=1 );
  str_setlen(x,p);
);
Justin is offline   Reply With Quote
Old 01-13-2014, 07:46 AM   #62
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Quote:
Originally Posted by IXix View Post
gfx_texth seems to be broken
Code:
@gfx
gfx_x = gfx_y = 5;
gfx_a = gfx_r = gfx_g = gfx_b = 1;
gfx_drawstr("hello");
gfx_y += gfx_texth;
gfx_drawstr("world");
gives me this...

Got it, fixing =)
Justin is offline   Reply With Quote
Old 01-13-2014, 08:16 AM   #63
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Quote:
Originally Posted by Justin View Post
Got it, fixing =)
Cool. Found another little nitpick thing, trying out setfont for the first time (sorry, I'm slow I know)...
Code:
gfx_x = gfx_y = 5;
gfx_a = gfx_r = gfx_g = gfx_b = 1;
gfx_setfont(1, Arial, 20, 'iub');
gfx_drawstr("hello");
gfx_x = 5;
gfx_y += gfx_texth;
gfx_drawstr("world")
gives this...



...which looks kinda cool but is a bit wrong.

4.59rc2 win7 32bit

Loving all the recent improvements!
IXix is offline   Reply With Quote
Old 01-13-2014, 08:38 AM   #64
off&on
Human being with feelings
 
off&on's Avatar
 
Join Date: Dec 2008
Posts: 117
Default

Quote:
Originally Posted by Justin View Post
Got it, fixing =)
Thanks! Indeed, gfx_texth == 0 until first call to gfx_setfont().
off&on is offline   Reply With Quote
Old 01-13-2014, 09:56 AM   #65
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
Default

gfx_texth: I wonder why it is working for me, as I have not yet graduated to gfx_setfont().

Quote:
Originally Posted by Justin View Post
Yeah, this is so you can read the file exactly as is. rtrimnl(str) after getting each line to have it remove any trailing newlines:

Code:
function rtrimnl(x) local(c,p) 
(
  p = strlen(x);
  while (p>=1 && ((c=str_getchar(x,p-1))=='\r' || c=='\n')) ( p-=1 );
  str_setlen(x,p);
);
Oops, I think you mentioned that before, my mistake
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is online now   Reply With Quote
Old 01-13-2014, 12:16 PM   #66
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Quote:
Originally Posted by DarkStar View Post
gfx_texth: I wonder why it is working for me, as I have not yet graduated to gfx_setfont().
It was sometimes set...
Justin is offline   Reply With Quote
Old 01-13-2014, 01:29 PM   #67
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Any chance you could either implement a gfx_getfont() or make gfx_setfont() return the previous font index? I'd like to be able to set the font temporarily and restore the old one when I'm done (for drawing my debug helper).
IXix is offline   Reply With Quote
Old 01-13-2014, 01:38 PM   #68
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Quote:
Originally Posted by IXix View Post
Any chance you could either implement a gfx_getfont() or make gfx_setfont() return the previous font index? I'd like to be able to set the font temporarily and restore the old one when I'm done (for drawing my debug helper).
Edit: gfx_getfont() coming in the final 4.59.

Last edited by Justin; 01-13-2014 at 01:56 PM.
Justin is offline   Reply With Quote
Old 01-13-2014, 01:46 PM   #69
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Quote:
Originally Posted by Justin View Post
After 4.59 I will
Cool, thanks!

Should this work? I thought it would write v with p decimal places into str but it ends up empty. Am I expecting too much?
Code:
sprintf(#str, "%0.*f", p, v);
IXix is offline   Reply With Quote
Old 01-13-2014, 02:27 PM   #70
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Quote:
Originally Posted by IXix View Post
Cool, thanks!

Should this work? I thought it would write v with p decimal places into str but it ends up empty. Am I expecting too much?
Code:
sprintf(#str, "%0.*f", p, v);
Yeah we don't support %*f yet, for now you have to do sprintf(#str,sprintf(#,"%%.%df",p),v), which is ugly I know.
Justin is offline   Reply With Quote
Old 01-13-2014, 02:29 PM   #71
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

btw I just pushed a bunch of commits to the public WDL repository, which includes all of the language updates of EEL in 4.59, as well as reusable code for using EEL with string/fft/mdct/atomic/file I/O/network/LICE(gfx_*). test.cpp has a pretty good example of most of these too...
Justin is offline   Reply With Quote
Old 01-13-2014, 05:57 PM   #72
sstillwell
Human being with feelings
 
Join Date: Jul 2006
Location: Cowtown
Posts: 1,562
Default

Quote:
Originally Posted by Justin View Post
btw I just pushed a bunch of commits to the public WDL repository, which includes all of the language updates of EEL in 4.59, as well as reusable code for using EEL with string/fft/mdct/atomic/file I/O/network/LICE(gfx_*). test.cpp has a pretty good example of most of these too...
Firing up the ol' gitmobile...
__________________
https://www.stillwellaudio.com/
sstillwell is offline   Reply With Quote
Old 01-14-2014, 04:46 AM   #73
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Quote:
Originally Posted by Justin View Post
Yeah we don't support %*f yet, for now you have to do sprintf(#str,sprintf(#,"%%.%df",p),v), which is ugly I know.
That's okay, I can live with ugly (resist temptation for wife joke).

Quote:
Originally Posted by Justin View Post
btw I just pushed a bunch of commits to the public WDL repository, which includes all of the language updates of EEL in 4.59, as well as reusable code for using EEL with string/fft/mdct/atomic/file I/O/network/LICE(gfx_*). test.cpp has a pretty good example of most of these too...
Good of you to share all this goodness.
IXix is offline   Reply With Quote
Old 01-14-2014, 10:50 AM   #74
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
Default

Next question:

Say I have a .txt file with lines such as
Code:
0	aaa	bbbb
1	cccccccccc	ddddddddddd
2	eeeee	ffffffff
That is, a line number and 2 variable-length text strings, separated by tabs

What match specifier do I need to extract those fields? I've puzzled over the JS FX documentation but could not fathom what I needed (I've never used Python or C or a similar programming language).

Or is there a comprehensive guide to these specifiers somewhere?


If that's not possible, how would you do it?
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is online now   Reply With Quote
Old 01-14-2014, 12:39 PM   #75
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Quote:
Originally Posted by DarkStar View Post
Next question:

Say I have a .txt file with lines such as
Code:
0	aaa	bbbb
1	cccccccccc	ddddddddddd
2	eeeee	ffffffff
That is, a line number and 2 variable-length text strings, separated by tabs

What match specifier do I need to extract those fields? I've puzzled over the JS FX documentation but could not fathom what I needed (I've never used Python or C or a similar programming language).

Or is there a comprehensive guide to these specifiers somewhere?


If that's not possible, how would you do it?

The JS documentation have a reference, but not so much comprehensive documentation. I would use:
Code:
rtrimnl(#line);
match("%d\t%s\t%s",#line, line_number, #field1, #field2) ? (
 // valid line
);
If there are more than two tab-delimited fields in the line, #field1 will get the extra tab/strings - if you want #field2 to get them instead, replace the first %s with %S (which makes #field1's matching lazy).
Justin is offline   Reply With Quote
Old 01-15-2014, 09:39 AM   #76
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
Default

Yep, that did it, thank you.

[is my level of ignorance showing? ]
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is online now   Reply With Quote
Old 01-15-2014, 03:12 PM   #77
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Quote:
Originally Posted by DarkStar
[assorted arcane string parsing questions]
What on earth are you up to?
IXix is offline   Reply With Quote
Old 01-15-2014, 05:22 PM   #78
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,467
Default

Quote:
Originally Posted by IXix View Post
What on earth are you up to?
I have a hunch...

hes making sort of a 'generic' interface (for MIDI instruments?) that can change the displayed names for parameters dynamically - based on text? files or something?


http://forum.cockos.com/showpost.php...38&postcount=2


I am quite intrigued..
James HE is offline   Reply With Quote
Old 01-16-2014, 02:21 AM   #79
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
Default

Mwah hah hah ....
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is online now   Reply With Quote
Old 01-16-2014, 11:09 AM   #80
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
Default

Meanwhile, I have this line in my text file:
Code:
lines	20
two fields, separated by a Tab. This match() did not work:
Code:
        match("%s\t%d",textline_str, TS_name, TS_count) ? (
In the end, I added a dummy text string and this match then worked:
Code:
lines	20	dummytext

    match("%s\t%d\t%s",textline_str, TS_name, TS_count, TS_dummy) ? (
Once again, what have I got wrong in the first case?
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is online now   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:47 AM.


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