Re: scrCopy BlendMode
>>1. If you quote the modes then it works. hh wrote : > set the ink of img "DSC03103.jpeg" to "srcCopy" Thanks, that works. As for info about blendmodes, hh wrote : > https://en.wikipedia.org/wiki/Blend_modes I had seen this site, but was wondering about the other blend modes in LC. Including the old (Legecy ones). Where do I find a mathematical description of how these specific LC modes work? Thanks, Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
scrCopy BlendMode
A couple of questions about BlendModes in LC. 1. The 'normal' blendMode is scrCopy (the mode all objects get when they are created). I can change that blendmode and later put it back to scrCopy in the Inspector. But setting the ink to scrCopy by script does not work. I type in the messagebox : *set the ink of img "DSC03103.jpeg" to scrCopy* I get the following error : *Message execution error:* *Error description: Property: invalid enumeration value* *Hint: * Can anyone tell me how to set the blendMode of an image to scrCopy by script? 2. What happened to the blendModes that do not work either, like : BlendScr, BlendScrOver, NotSreenAnd and 15 others? Why are they available in the choices, but do not seem to work (execution error). 3. Where can I find detailed info about the different blend modes. I'm looking for the math on what they all do. Kind regards, Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Get RGB color of a specific screen location
I have used the export snapshot and then the averaging. Works great. I had forgotten about the export function (have been away from coding for 3 years). I also had to implement Phil Davis' "set the screenMouseLoc to globalLoc(tLocWithinMyStack)". The average I got first (with only the mouseLoc) was offsetted to where I clicked. Now it purs :-) Thanks again, Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Get RGB color of a specific screen location
Thanks everyone for the many suggestions. I will try them out and see which one will work best. Appreciate the multitude of ideas. Cheers, Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Get RGB color of a specific screen location
I have asked this befor, but for the first time did not get any answer on my post. So I hope you don't mind that I try again :-) How do I get the RGB color of a pixel of an image? I know the function the MouseColor, which gives me the RGB numbers under the cursor. What I need is to get the RGB of a specific screen location - I need to make an avarage of e.g. 5x5 pixels. So how do I get the RGB numbers of e.g. location "30,200"? Cheers, Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Get RGB color of a specific screen location
How do I get the RGB color of a pixel of an image? I know the function the MouseColor, which gives me the RGB numbers under the cursor. What I need is to get the RGB of a specific screen location - I need to make an avarage of e.g. 5x5 pixels. So how do I get the RGB numbers of e.g. location "30,200"? Cheers, Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Intersect Function
Thanks Craig, I was already afraid of that. Yes, I guess I could figure out the math. I will have the 2 functions of the lines and if I set them equal, I could solve the intersection point of the two. Your way is also valid, but as I need to determine many intersection points, the script might get slow. Of course your way might prove better if we're looking at curves. The amount of points in a curved line increases some in comparison to a straight line, but in setting the functions equal, I'd have to deal with quadratic functions. It just comes to me, that that is quite doable : move everything to one side of the equal sign and apply the famous 'abc formula' (at least that it was called in my high school years in Holland). It's used to solve a quadratic equation. Once the 'x' is known, I can put it into one of the functions to get the 'y' coordinate. I will see what goes faster. Cheers, Beat On Mon, Sep 24, 2018 at 3:15 PM dunbarxx via use-livecode < use-livecode@lists.runrev.com> wrote: > Hi. > > No. > > But you can determine the points of a line graphic, and calculate all the > pixels it "contains" from its starting point to its ending point. Do the > same for a second line. > > Then you can determine the point that seems to be common to both lines. I > say seems, because when you do the math, that is, using the slope of each > line and calculating the points using that information, you may find that > there are no exact matches. But you can allow a small differential, and the > closest pair of points will be the one you want. > > Can you do the math? > > Craig Newman > > > > -- > Sent from: > http://runtime-revolution.278305.n4.nabble.com/Revolution-User-f278306.html > > ___ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your > subscription preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode > ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Intersect Function
Is there a function to determine the intersection point (x,y) of two lines? The intersect function in LC only gives me a true or false, and I need the exact location (x,y) of the intersection. Thanks, Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Loading clips into a player
Thanks for all suggestions. I'll go with solution which was offered by Francis. Nice link, Richmond. I've always been a fan of the Bonzo Dog Band and Vivian Stanshall, but I did't know this one. :-) Cheers , Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Loading clips into a player
on Sun, 14 Sep 2014 Richmond wrote : > So, you have imported your audioClip / videoClip into your stacks. > play audioClip "myJazz.aiff" Thanks for your reply, Richmond. The thing is that I want to have the clip inside a visible player. In that way I have more control over how to play the clip. E.g. visibly nudging back a bit, changing the play speed, seeing at what time the clip is so I can mark it, etc. So I need to load the clip into a player, but not from disc, but from inside my stack. So my question is still open. Anyone? Thanks, Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Loading clips into a player
How can I load an already imported audio- or video clip into a player. The Clip is already in the stack. I want to have the audio- and video clips residing in my stack, but through a popUp menu being able to load them into a player. set the filename of player "Player 1" to myClipName - this does not work. It only works if myClipName is a file path to the wanted file on disc. Not if the file is inside my stack. There is no info on this anywhere in the LC user guide (5.1). Thanks, Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Nameservers
I have on-rev hosting for my website but my domain name (www.Step-Beyond.nl) is registered with a company called Hostnet. I am a total beginner at this, so please bear with me. I want to change the nameservers (if I am correct), so that people can send emails to i...@stepbeyond.nl. I have found the page on the Hostenet site where I can change the nameservers, but I have no idea what I should fill in there. What are the on-rev names (addresses) that I need to use? Thanks, Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Making data plots
Hi William, If you have a line plot, I would use one single line and set the points of the line to the desired data points. If you have multiple elements, the following might help. I use it to make grids, but I think the principle can be used for charts as well. You'll create a template object, which you clone all the time. For each cloned element, you set the selected to true and when you have enough, you group them (all the selected objects). Then you set the name of the last created group to whatever you like. You can now also delete that group by name. Here's an example : The part in bold is the core of it. The rest you'll need to adapt to your needs on mouseUp set the cursor to busy -- ** Fld "Input" contais data about the grid put line 1 of fld "Input" into OffsetX put line 2 of fld "Input" into OffsetY put line 3 of fld "Input" into NrColums put line 4 of fld "Input" into NrRows put line 5 of fld "Input" into SizeX put line 6 of fld "Input" into SizeY put line 7 of fld "Input" into GridX put line 8 of fld "Input" into GridY put line 9 of fld "Input" into BorderBreedte put line 10 of fld "Input" into NameStart repeat with x = 1 to NrColums repeat with y = 1 to NrRows clone grc "Grc template"-- ** The Template -- ** Stuff to arrange and size the grid cells set the width of it to SizeX set the height it to SizeY set the lineSize of it to BorderBreedte set the left of it to x * GridX - (BorderBreedte * (x-1)) + OffsetX set the bottom of it to y * GridY - (BorderBreedte * (y-1)) + OffsetY set the lockLoc of it to true set the selected of it to true put NameStart & y & "-" & x into tName set the name of it to tName end repeat end repeat group set the name of last group to "" select empty set the cursor to Arrow end mouseUp Cheers, Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: permuting a string (was Re: Speed)
Wed, 3 Sep 2014 08:56:11 -0500 Geoff Canyon wrote : > Gah, I forgot one stinkin' line: > put isNewElement into wasNewElement That does the JOB :-) I was playing around with deleting duplicate perms inside the handler, which worked, but Geoff's solution (correct script) is much faster. Thanks again mate, Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: permuting a string (was Re: Speed)
Mon, 1 Sep 2014 19:35:31 -0500 From: Geoff Canyon > I have a set of code that seems to do the trick. It takes as an argument the > number of each element to permute. Great, Geoff, this works fine. Quite clever thinking :-) Mon, 1 Sep 2014 19:47:58 -0500 From: Geoff Canyon > I think this is faster for many arguments. It might be slower for others. Your right. The only thing with this script is, that it sometimes generates too many permutations. E.g. 111223 as input is ok. But 1112223 generates too many permutations. 11122233 is ok again. I haven't figured out why. For the time being I appended a deletion of duplicates, and the right number of Permutations comes out. But it slows the script down, enough to make it slower than the one you posted just before (the long one). It's a pity, because even in generating too many permutations, this last script is faster with large input strings than the other scripts. I'll have a look if I can find where it sometimes goes wrong. Geoff, thanks again, I really appreciate your work and input, as well as the way you think. Very inspiring :-) Cheers, Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: permuting a string (was Re: Speed)
Sat, 30 Aug 2014 09:01:16 -0400 From: Geoff Canyon > This was my initial thought as well, but I didn't like having to work > line-by-line on (potentially) large sets of lines from the initial > not-duplicate set of permutations. Doing the dupes first is weirder > conceptually, but it means that the line-by-line work is done on a much > smaller data set. For example, permuting "cdef" would only require > line-by-line on 8!/(4!*4!) = 70 lines. It will be interesting comparing the > two solutions. I agree, that it would be great if we can avoid working line by line. That is the beauty of Geoff's script for non duplicates, to be able to replace each distractive element in the whole bunch at the same time. This is not possible anymore, as soon as there are duplicate elements in the Permutations. But I agree, doing the duplicates first is faster. But on a par with the script I had, which works line by line and after each new element, deletes the duplicate permutations. So dos it all in one. On my computer : Input : 1112223334568320 mSec Input : 123358 mSec I've trying to figure out something to keep the principle of Geoff to replace each char in the whole bunch at the same time. Either I come up with too many elements (e.g. 112 new element 3 > 31312), OR if I use another number (char) for the duplicates, i cannot delete the duplicate permutations and end up with the same amount as if there were no duplicate elements in the input. I also cannot replace the duplicate element temporarily, (like replace 11 with 1a : 112 > 1a2, as the duplicate 1 occurs in all the combinations (like 121). Still I feel there must be some clever trick to get it to work, but I am not completely sure. This is my fastest script so far : The script first orders the input elements in order of the amour of duplicate occurrences. function BC4_PermMech_Duplicates_Chars ToPermutate set cursor to busy -- ** order input according to most duplicates to least duplicates replace cr with comma in ToPermutate put BC2_CalcNumOccurancesAll_Items (ToPermutate) into tTable sort lines of tTable numeric ascending by item 1 of each sort lines of tTable numeric descending by item 2 of each repeat for each line rLine in tTable repeat item 2 of rLine put item 1 of rLine after ToPermutateOrdered end repeat end repeat put empty into TempPerms2 put the number of items of ToPermutateOrdered into NumElements put char 1 of ToPermutateOrdered & char 2 of ToPermutateOrdered into TempPerms1 put char 3 to -1 of ToPermutateOrdered into tInput3 put 3 into Index repeat for each char rNewElement in tInput3 put empty into TempPerms2 put the number of chars of line 1 of TempPerms1 into NumChars repeat for each line rLine in TempPerms1 put rNewElement & rLine & cr after TempPerms2 repeat with x = 1 to NumChars put char 1 to x of rLine & rNewElement & char x+1 to -1 of rLine & cr after TempPerms2 end repeat end repeat delete char -1 of TempPerms2 put BC2_DeleteEmptyLines_LooseOrder (TempPerms2) into TempPerms1 end repeat choose browse tool -- ** Final deletion of duplicates return BC2_RemoveDuplicate_LooseOrder_Lines (TempPerms1) end BC4_PermMech_Duplicates_Chars Cheers, Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: permuting a string (was Re: Speed)
Sat, 30 Aug 2014 Geoff wrote : > Used Alex's code to generate a list of the permutations of all the characters > that were duplicates. > Substituted in unique characters for each instance of the duplicates. > Ran my permutation code on the rest of the characters, with the addition of > the duplicates-permutation-strings as the base case. I was working on the same line, but from the other end. I start with the characters that are not duplicate and use your very fast code to get all the permutations. The I slot in, one for one, all the duplicate elements on all possible positions. After slotting in each duplicate element, I delete duplicate lines, so in the next run of inserting the next duplicate element, I will have to do less, as the duplicate lines have been deleted. I am not completely finished with the script & testing. I will post it as soon as possible. I also tried to serialise Geoff's script and looked if I could get rid of duplicates inside of the script. I did not manage as yet. But the serialised script is a bit easier for me to play around with, as I can better watch the different variables. This is my serialised version of Geoff's original script : function BC4_PermMech_Geoff_Serial_Chars N put "01" & cr & "10"& cr into T repeat with x = 2 to N repeat with i = 0 to x put T into T2 replace i with x in T2 replace cr with i & cr in T2 put T2 after R end repeat put R into T put empty into R end repeat delete char -1 of T return T end BC4_PermMech_Geoff_Serial_Chars All the best, Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: which is faster for searching?
Bob Sneidar wrote : > T he reason for all this is that to optimize the repeat loop, the engine > makes one pass through the data, and creates an index of pointers to the > delimiters. If you modify the data, the OS may (and probably will) do some > memory shuffling > and the pointers will no longer be valid. What you return > can be bits and pieces of the original data scrambled like eggs, or random > bits of what is now in that memory space. Ick! > > ex. repeat for each line pLine in pData. Don?t alter pLine or pData inside > the repeat control structure. I am on digest list form, so there probably have been people before me to address this. To be sure, here goes : I think the first part of what Bob says is true, you cannot alter the original data. But as you go into each turn of the loop and take rLine (see) below as a chunck, you can do with rLine whatever you like. I do that all the time. Only if you change the original data ( e.g. tPermutations) then the thing fouls. As an example : on mouseUp put empty into Changed repeat for each line rLine in tPermutations put 6 into item 3 of rLine -- ** here I change rLine, which does not affect tPermutations put rLine & cr after Changed end repeat end mouseUp Beat Cornaz ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: permuting a string (was Re: Speed)
Thanks Alex, I will mail you off-list about the order of elements in the input and provide some examples. And thanks for the correction of your script. Seems to work fine now. I should have seen that one myself, but it was a bit late last night, sorry :-) Alex, you've explained the recursive functions quite well for me. Great. I will sit down later and dig into your serialised script. And even if it does not turn out to be the fastest, I will gave gotten my head around the concept of recursion, which might prove quite valuable for me in the future. Cheers, Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: permuting a string (was Re: Speed)
Alex wrote : >To make it faster, it *should* be serialized, so that it isn't actually >recursive; that should be quite easy (but will make the code much less > easy to read or understand, so I haven't done it yet). If you think it's > worth pursuing, let me know and I'll have a go at unrolling the recursiveness. Recursive scripts is something I know in principle about, but never have used them before. They are quite compact, but I find it hard to follow, especially as your variables are emptied in each new entry into the script (f.i. t3 in Alex's script). I tried to unroll it and make it serial, but I am having troubles with it. I think I should start in the opposite direction and work back, but it's too late now for me to solve it. First a little sleep. I also tried to serialise Geoff's script, but am running into the same difficulty. I haven't grasped the concept completely I guess. If you could give me a hint, Alex, I'd be happy. As for the Duplicates : Alex wrote : > permut() is the optimized version - optimize simepl cases of 1 or 2 chars, > eliminate duplicates as we go. Well, it does so, but not completely. First, as I discovered in my own script with eliminating duplicates, it needs the input in the form of the most duplicates in the beginning and then trailing off. F.i. 111223 would work , but 112223 or 112333 would not return all of the possible (non duplicate) permutations. Moreover, in the script of Alex, a couple of duplicates slip thru. F.I. 1123 gives 14 permutations i.s.o. 12. In the list below, the # are the doubles. 1123 1132 1213 1231 1312 1321 2113 2131 2311 # 2311 # 3112 3121 3211 # 3211 # An advantage of Alex's script and also my own over other scripts is, that these scripts give a better ordaining of the permutations as a result. In a more systematic way, due to the fact how they are constructed of course. Thanks for all your input, I really appreciate, Cheers, Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: permuting a string (was Re: Speed)
Thanks Peter, your script works, but is in the same speed region as my original script, with the added disadvantage that it can't go beyond 9 chars. As for the duplicate elements : I did the same before - make all the possible permutations and then delete the duplicate ones. But as Geoff rightly points out and I had discovered as well, that doesn't scale well. If we manage to delete duplicates in an earlier stage, many permutations down the line need not to be made, which can make it much faster. I do the deletions of duplicates in my script now as early as possible, which all of a sudden makes it faster than Geoff's script if I have many duplicates in the Input. My script 10 input elements no duplicates - 4407 millisecs Geoff's script idem - 474 millisecs My script 10 input elements duplicates (0001112223) - 56 milli Geoff's script idem with deletion of duplicates at end -534 milli (the normal script + the time for the deletions at the end) So, getting rid of the duplicates inside the script is quite important. I still don't see yet how I can do that in Geoff's script (I will look into that again, as soon as I can find a little time). If we can get that to work, I think we'll have a winner :-) my script : function BC4_PermMech4_Duplicates_Lines ToPermutate set cursor to busy put empty into TempPerms5 put the number of lines of ToPermutate into NumElements -- *** First calc the upper half. put line 1 of ToPermutate & comma & line 2 of ToPermutate & comma into TempPerms1 put line 3 to -1 of ToPermutate into tInput3 put 3 into Index repeat for each line newElement in tInput3 set the cursor to busy repeat for each line tLine in TempPerms1 repeat with y = Index down to 1 put tLine into Temp put newElement & comma before item y of temp put Temp & cr after TempPerms5 end repeat end repeat put BC2_RemoveDuplicate_LooseOrder_Lines (TempPerms5) into TempPerms1 -- HERE IS THE DELETION HANDLER put empty into TempPerms5 add 1 to Index end repeat -- *** Now the second half -- *** Copy first half as second half and replace in the second half put TempPerms1 into TempPerms2 replace 1 with "z" in TempPerms2 replace 2 with 1 in TempPerms2 replace "z" with 2 in TempPerms2 put TempPerms2 after TempPerms1 delete char -1 of TempPerms1 choose browse tool Return TempPerms1 end BC4_PermMech4_Duplicates_Lines --- function BC2_RemoveDuplicate_LooseOrder_Lines pData put ":" & cr into DD replace cr with DD in pData split pData by cr and ":" Return the keys of pData end BC2_RemoveDuplicate_LooseOrder_Lines ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re : Speed
Works like a charm, Geoff. Great way of tackling the thing, very original. function P2 N,B -- N is the depth to permute -- B is the ASCII value to start from -- so P2(1,49) returns 21 cr 12 -- P2(2,53) returns 675 cr 765 cr 756 cr 576 cr 657 cr 567 if N = 0 then return numToChar(B) & cr put P2(N - 1,B) into T add B to N repeat with i = B to N - 1 put T into T2 replace numToChar(i) with numToChar(N) in T2 replace cr with numToChar(i) & cr in T2 put T2 after R end repeat replace cr with numToChar(N) & cr in T return R & T end P2 If I input B =97 I get the permutations in abcd etc. which I often use, so really great If I input B= 48 I get the permutations in numbers 01234 etc. which I also often use. Beyond 9 I can easily make items and replace the ascii chars with 10, 11 etc. The DUPLICATES : I've been working on it to try to include this functionality into your script, but no dice yet. It is not really obvious at first sight. I'll continue to work on it though. If you or anyone has a bright idea, I'd love to hear it. I must say that I am really charmed by this solution of Geoff, it's something I'd never would have thought of. Hats off ! Cheers, Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re : Speed
Now for the permutations. Geoff, great. Your script is by far the fastest. Almost 10 times faster than my own script which comes second. I could improve a little bit even on your script with the suggestion of Kay. -- Kay wrote : I obtained a 10% speed increase by changing this: repeat with n = 3 to 10 to this: put "3,4,5,6,7,8,9,10" into nList repeat for each item n in nList -- Geoff, you mentioned that I would not be to hard to expand the script beyond 10 elements. I been trying, but no dice yet. Any pointers? I also tried to implement a fast way to permutate elements which contain duplicates (like 00112) This would give only 30 distinct permutations i.s.o. 120. Of course, I could run the script and replace all the 1s with 0s, all the 2's with 1's, etc. and then delete the duplicates. But if I could delete duplicates much earlier on, it would be much faster. I think I know where to delete the duplicates in the script, but cannot get yet your script running by inputting a list like "0,0,1,1,2" ( or 00112 ) and use the trick Kay suggested. It works if I rework N to a list like "01234". I will sleep over it :-) Thanks a lot Geoff, Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re : Speed
Geoff Canyon wrote: > On Mon, Aug 25, 2014 at 6:21 AM, Beat Cornaz wrote: > >> But I think it quite a pity (to put it mildly) that LC 6.xx is so much >> slower thank 5.5. > > > Could it be the unicode implementation? Agreed, that would be unfortunate. > It would be nice to have a text setting for fields. Richard wrote : Not likely, as the "just works" Unicode implementation is only in v7. Has anyone filed a bug report against this? The speed difference is enough that it if fixed may help offset performance degradation as a part of the Unicode implementation. And since it predates the Unicode rollout, I'd wager it can indeed be fixed back to something closer to the v5.5.3 levels. And if not, would at least be nice to know why. -- I hadn't read your post before answering. So unicode should not be it. I hope it can be fixed. I cannot file a bug report myself at the moment, as I am experiencing very strange time issues with My LC 6.6.2 version (just opening a menu from the main menu sometimes takes like 8 seconds). So I need to sort that out before coming with a serious bug report. All the best, Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re : Speed
> But I think it quite a pity (to put it mildly) that LC 6.xx is so much > slower thank 5.5. Geoff wrote : Could it be the unicode implementation? Agreed, that would be unfortunate. It would be nice to have a text setting for fields. I talked about this just a couple of hours ago with my brother Claudi. he suspected also the unicode implementation. Nice idea to have a text setting for fields. Cheers, Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re : Speed
James wrote : There are significant differences in speed between 5.5 and 6.6. Not so much in deriving the permutations as in displaying the results in a field. I guess that's true. The values in millisecs that I have posted are taken without putting the result into a field. Just the plain calculation of the permutations. But I think it quite a pity (to put it mildly) that LC 6.xx is so much slower thank 5.5. Cheers, Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re : Speed
All right, the permutations. Thanks for the responses. My findings so far : Mark wrote : -- In addition, you're losing much of the speed of the "repeat for each" loops by embedding a "repeat with" loop at the deepest level (and in addition you're making an unneccsary extra copy of tLine each time through the slowest loop): repeat for each line tLine in TempPerms1 repeat with y = Index down to 1 put tLine into Temp put newElement & comma before item y of temp put Temp & cr after TempPerms5 end repeat end repeat Something like this should be faster (do this for both upper and lower halves): repeat for each line tLine in TempPerms1 repeat for each item tItem in tLine put tItem & comma after TempPerms5 end repeat put cr into char -1 of TempPerms5 end repeat -- Mark, I cannot get your improvement to work. I think there is something missing or maybe I am overseeing something. The inner loop in your script is equivalent to : put tLine into TempPerms5. The total result from the inner & outer loop is the same as : put TempPerms1 into TempPerms1 As a total result of the complete script I always get (no matter what the input is) : 1,2 cr 2,1 In my script, I need to ' put tLine into Temp' in every time I pass the inner loop, to renew Temp with tLine. Otherwise I change tLine all the time in the inner loop. In every round in the outer loop, I step the new element (e.g. 3) through all possible positions in tLine (e.g. tLine = 1,2 >1,2,3 1,3,23,1,2 ) . Then I go on and do the same with the next element (4 in this case) for each newly formed line (1,2,3 etc). Dick wrote : The Wikipedia entry for "permutation" says the fastest algorithm for generating permutations is Heap's algorithm. Quite interesting. I still have to understand what's happening completely, but I implemented you LC translation of the Heap algo. And it runs on my system a bit over 2 minutes (165732 millisecs) for 10 elements. To my surprise, my old algo does it in 7515 millisecs. I could improve on that by using chars instead of items (7465 millisecs). Another improvement I could make was by only calculating the upper half of the permutations (all the ones that start with 1,2,) and then copy them and swap the 1's and 2's. This gave as result only 5597 millisecs for 10 elements. I am a bit at a loss, as I would be surprised if my way would be like 25 times faster than the fastest known algorithm. Did I make a mistake in implementing Dicks code (although Dick also reports 2 minutes to do the job, as my way does it in 5.6 secs). What is happening here. I even suspect, that I can improve more on my improved way (by only calculating half of the perms and swapping the 1's and 2's. I might apply that principle more (like only calculating 1/4 of the perms and do some swapping, or even better). I will look into that later. --- Kay wrote : I obtained a 10% speed increase by changing this: repeat with n = 3 to 10 to this: put "3,4,5,6,7,8,9,10" into nList repeat for each item n in nList I haven't been able to try this, but it is very interesting in general. That even such short lists produce such a difference in speed in repeat with or repeat for. I thought that only counted for longer lists. very enlightening though. Thanks. --- Geoff : looks promising. It is in the ballpark where my alto seems to be. I will get back to you letter when I have had a good look and test at your script. New idea : I was hinting at a way of producing permutations in the case that there are duplicate elements in the input. F.i. 1,1,2,3 only gives 12 permutations instead of 24 for 1,2,3,4 as input. Before I calculated all the possible permutations and deleted the duplicates afterwards. I found that if I move the removing of duplicates to an early stage (as early as possible), the speedup is enormous. Thanks for all the input, Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Speed
Thanks Richard, So it depends on a number of factors, which makes it a bit harder. I had hoped for some general rules, like always use repeat for if possible or words are generally slower that items. But I understand, it depends on more things. I have some hundred fitness functions, which need to be recalculated many times. But I think the problem of making Permutations might be illuminating for me, as this one takes quite long to run (with 10 or more elements to Permutate). So a good example would be how to make all possible permutations of say 10 different elements (0-9). This gives 3628800 different permutations. The resulting permutations will be in lines I guess, but what would be the best way to do this. Using lines, items, chars or any other way as Input? So the start would be f.i. a list with 10 lines with the ten elements, one in each line - That is what I am using now. OR items "0,1,2,3,4,5,6,7,8,9" or chars "0123456789" or another way to represent 10 elements to make it possible to run the script in minutes, not hours. the code I have now for this is follows - lines as input (one line per element) : function BC4_PermMech_Lines ToPermutate -- ** ToPermutate : all the elements to permutate, one per line put the number of lines of ToPermutate into NumInput put empty into TempPerms5 -- *** First calc the upper half. put line 1 of ToPermutate & comma & line 2 of ToPermutate & comma into TempPerms1 put line 3 to -1 of ToPermutate into tInput3 put 3 into Index repeat for each line newElement in tInput3 set the cursor to busy repeat for each line tLine in TempPerms1 repeat with y = Index down to 1 -- repeat with y = x down to 1 put tLine into Temp put newElement & comma before item y of temp put Temp & cr after TempPerms5 end repeat end repeat delete char -1 of TempPerms5 -- ** last cr put TempPerms5 into TempPerms1 put empty into TempPerms5 add 1 to Index end repeat -- *** Now the second half -- *** First calc the upper half. Later copy and inverse all (alternative idea) put line 2 of ToPermutate & comma & line 1 of ToPermutate & comma into TempPerms2 put 3 into Index repeat for each line newElement in tInput3 set the cursor to busy repeat for each line tLine in TempPerms2 repeat with y = Index down to 1 put tLine into Temp put newElement & comma before item y of temp put Temp & cr after TempPerms5 end repeat end repeat delete char -1 of TempPerms5 -- last cr put TempPerms5 into TempPerms2 put empty into TempPerms5 add 1 to Index end repeat put cr & TempPerms2 after TempPerms1 choose browse tool Return TempPerms1 end BC4_PermMech_Lines - Another example I am struggling with is to delete exact duplicate lines in a long, long list. Do I best use chars, items or words in the lines of the list? As example can be thought the deletion of duplicate permutations if you start with 10 elements, but there are duplicate elements in the start, e.g. 0011123456 . This would give 'only' 302400 permutations, so there are 60480 duplicate perms to be deleted. There might be an algorithm, which makes the correct permutations right away (in the case of duplicate elements), without first making all the general permutations and then deleting the duplicates. That would be really great and I'd love to hear it if someone knows an algorithm for those permutations But even so, I am also interested in de fastest way to delete duplicate lines anyway for other parts of my program. At the moment I use : -- function BC2_RemoveDuplicate_Lines pData repeat for each line rLine in pData add 1 to TestArray[rLine] end repeat return the keys of TestArray end BC2_RemoveDuplicate_Lines -- I hope someone knows a faster way :-) Thanks a lot, Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
speed
A while ago I did a test for speed with 'repeat for'. It turned out that with items it worked the fasted. Chars were slower and words even more so. Now I redid the test with 'LineOffset'. To my surprise: with chars was considerably faster. A long list with lines like 'aabcbcax' (chars) OR "a,a,b,c,b,ca,x," (items) and finding a specific line gave the following time results in ticks (depending on how deep down the wanted line was in the list ) : items chars 57 42 45302871 29082087 24 15 I did the lineOffset for 1 specific string and repeated the lineOffset 10 times. The variation with the chars was about 1.35 to 1.6 times as fast as the variation with items. Can anybody confirm this from experience and maybe explain why the LineOffset works faster with strings of chars, while the repeat for works faster with items? I would also appreciate any other insights in how to speed up routines, as I am working a a program with Evolutionary Algorithms and I need to do hundred of thousands of calculations in each run, so speed is quite important. Cheers, Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Compatability Livecode projects on OSX and Windows
Real good feedback, thanks a lot Richmond & Scott. ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Compatability Livecode projects on OSX and Windows
Are there any issues with starting a Livecode project on OSX, then copy it to a Windows laptop , continue working on it and then going back to the OSX again. The Windows is only during the time that I am travelling and want to continue programming my project. At home I'll switch to my Mac again. OSX on a Mac Mini and Windows on a still to buy windows laptop. If that works without hassles, then I am much cheaper off :-) Thanks for sharing any experiences in this area. greetings, Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Pitch shifting Audio
>William Prothero wrote : >Midi would be a very different setup than digital audio. In midi, only >"events" need to be sent, while digital audio, especially independent tempo >and pitch translation require >some fancy signal processing. Yep, I know. Much easier than digital audio, but still it would be nice to have Midi functions in LiveCode. Especially some connection, so you could play midi files through your favourite sequencer software, like Ableton live or Logic. Maybe the SunnYmidi that René suggests might do the trick. That would be great. But on the whole, I would love to see that LC incorporates functionality on the audio/music front. Greetings, Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Pitch shifting Audio
Thanks for all your input. It seems clear to me that I have to take another road. But at least now I know. I agree that LiveCode is really excellent in many, many areas, but in audio & midi it is a bit of a handicapped child. I think that's a real pity, but those areas have never had the pleasure of much attention in the last 10 years or so. I think it's a pity, as there is, in my humble opinion quite a market for good music & audio software and apps. I hope the 'open source' will bring some change. Thanks & greetings, Beat ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Pitch shifting Audio
Hello to everyone, Is there a way to pitch-shift audio without changing the speed (playback rate) in real time in LC? And is there a way to get the audio of a movie player to be pitch-shifted without changing the speed (playback rate) in real time? If this is not possible, is there an external that can do the job? Thanks a lot, Beat Cornaz ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode