|
|
|
01-07-2014, 04:34 AM
|
#41
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 24,790
|
Quote:
Originally Posted by Tronic
Please make this thing possible....
midisyxrecv
this is very useful to create dashboards for every HW very quickly
|
..and midisyxsend, too, of course.
|
|
|
01-07-2014, 04:42 AM
|
#42
|
Human being with feelings
Join Date: Jan 2012
Posts: 104
|
Quote:
Originally Posted by EvilDragon
..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
|
|
|
01-07-2014, 06:22 PM
|
#43
|
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,721
|
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().
|
|
|
01-07-2014, 06:27 PM
|
#44
|
Human being with feelings
Join Date: Apr 2012
Location: Christchurch, New Zealand
Posts: 482
|
Wow, that's REALLY flexible. Thanks Justin!
|
|
|
01-08-2014, 04:22 PM
|
#45
|
Human being with feelings
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
|
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.
|
|
|
01-08-2014, 09:33 PM
|
#46
|
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,721
|
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
|
|
|
01-09-2014, 12:19 AM
|
#47
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
|
Quote:
Originally Posted by Justin
also, in pre9: gfx_setfont(), and some more obscure LICE blitting functions, including gfx_transformblit().
Ha ha
|
Coooool!
|
|
|
01-09-2014, 01:56 AM
|
#48
|
Human being with feelings
Join Date: Apr 2012
Location: Christchurch, New Zealand
Posts: 482
|
Quote:
Originally Posted by Justin
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!
|
|
|
01-09-2014, 04:42 AM
|
#49
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
|
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;
);
|
|
|
01-09-2014, 07:22 AM
|
#50
|
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,721
|
Quote:
Originally Posted by Tale
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.
|
|
|
01-09-2014, 10:29 AM
|
#51
|
Human being with feelings
Join Date: Dec 2008
Posts: 2,111
|
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
|
|
|
01-09-2014, 11:11 AM
|
#52
|
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,721
|
Quote:
Originally Posted by jnif
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?
|
|
|
01-09-2014, 09:17 PM
|
#53
|
Human being with feelings
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,467
|
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?
|
|
|
01-12-2014, 07:11 AM
|
#54
|
Human being with feelings
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
|
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 ...
|
|
|
01-12-2014, 08:35 AM
|
#55
|
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,721
|
Quote:
Originally Posted by DarkStar
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
|
|
|
01-12-2014, 10:54 AM
|
#56
|
Human being with feelings
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
|
^^^^
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 ...
|
|
|
01-13-2014, 03:35 AM
|
#57
|
Human being with feelings
Join Date: Apr 2010
Location: Portland OR
Posts: 217
|
Quote:
Originally Posted by Tronic
Please make this thing possible....
midisyxrecv
this is very useful to create dashboards for every HW very quickly
|
Yes, please!
|
|
|
01-13-2014, 05:57 AM
|
#58
|
Human being with feelings
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
|
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...
|
|
|
01-13-2014, 07:14 AM
|
#59
|
Human being with feelings
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
|
^^^^
... works OK here (just copied and pasted into another JS FX); "world" is lower down than "hello".
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
|
|
|
01-13-2014, 07:15 AM
|
#60
|
Human being with feelings
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
|
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 ...
|
|
|
01-13-2014, 07:45 AM
|
#61
|
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,721
|
Quote:
Originally Posted by DarkStar
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);
);
|
|
|
01-13-2014, 07:46 AM
|
#62
|
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,721
|
Quote:
Originally Posted by IXix
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 =)
|
|
|
01-13-2014, 08:16 AM
|
#63
|
Human being with feelings
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
|
Quote:
Originally Posted by Justin
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!
|
|
|
01-13-2014, 08:38 AM
|
#64
|
Human being with feelings
Join Date: Dec 2008
Posts: 117
|
Quote:
Originally Posted by Justin
Got it, fixing =)
|
Thanks! Indeed, gfx_texth == 0 until first call to gfx_setfont().
|
|
|
01-13-2014, 09:56 AM
|
#65
|
Human being with feelings
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
|
gfx_texth: I wonder why it is working for me, as I have not yet graduated to gfx_setfont().
Quote:
Originally Posted by Justin
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 ...
|
|
|
01-13-2014, 12:16 PM
|
#66
|
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,721
|
Quote:
Originally Posted by DarkStar
gfx_texth: I wonder why it is working for me, as I have not yet graduated to gfx_setfont().
|
It was sometimes set...
|
|
|
01-13-2014, 01:29 PM
|
#67
|
Human being with feelings
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
|
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).
|
|
|
01-13-2014, 01:38 PM
|
#68
|
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,721
|
Quote:
Originally Posted by IXix
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.
|
|
|
01-13-2014, 01:46 PM
|
#69
|
Human being with feelings
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
|
Quote:
Originally Posted by Justin
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);
|
|
|
01-13-2014, 02:27 PM
|
#70
|
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,721
|
Quote:
Originally Posted by IXix
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.
|
|
|
01-13-2014, 02:29 PM
|
#71
|
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,721
|
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...
|
|
|
01-13-2014, 05:57 PM
|
#72
|
Human being with feelings
Join Date: Jul 2006
Location: Cowtown
Posts: 1,562
|
Quote:
Originally Posted by Justin
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...
|
|
|
01-14-2014, 04:46 AM
|
#73
|
Human being with feelings
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
|
Quote:
Originally Posted by Justin
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
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.
|
|
|
01-14-2014, 10:50 AM
|
#74
|
Human being with feelings
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
|
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 ...
|
|
|
01-14-2014, 12:39 PM
|
#75
|
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,721
|
Quote:
Originally Posted by DarkStar
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).
|
|
|
01-15-2014, 09:39 AM
|
#76
|
Human being with feelings
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
|
Yep, that did it, thank you.
[is my level of ignorance showing? ]
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
|
|
|
01-15-2014, 03:12 PM
|
#77
|
Human being with feelings
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
|
Quote:
Originally Posted by DarkStar
[assorted arcane string parsing questions]
|
What on earth are you up to?
|
|
|
01-15-2014, 05:22 PM
|
#78
|
Human being with feelings
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,467
|
Quote:
Originally Posted by IXix
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..
|
|
|
01-16-2014, 02:21 AM
|
#79
|
Human being with feelings
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
|
Mwah hah hah ....
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
|
|
|
01-16-2014, 11:09 AM
|
#80
|
Human being with feelings
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
|
Meanwhile, I have this line in my text file:
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 ...
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 07:47 AM.
|