From squarewave at elisanet.fi Fri Mar 11 08:41:34 2022 From: squarewave at elisanet.fi (Matti Koskinen) Date: Fri, 11 Mar 2022 18:41:34 +0200 Subject: [CM] Simple example Message-ID: <02A3271C-7900-496A-9878-94A5D1524D67@elisanet.fi> Hi all, I got Grace compiled and it works, but since I?ve used it many years ago, can?t remember anything at all. If someone could post a simple example how to read midi from keyboard and save it to a midi file, I?d be more than happy. Thanks -m From bil at ccrma.Stanford.EDU Fri Mar 11 13:53:38 2022 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Fri, 11 Mar 2022 13:53:38 -0800 Subject: [CM] Snd 22.2 Message-ID: Snd 22.2: moved s7_apply_* from s7.h to xen.h if DISABLE_DEPRECATED. checked: sbcl 2.2.1|2, notcurses 3.0.6|7 Thanks!: Mike Scholz From treegestalt at gmail.com Fri Mar 11 17:48:32 2022 From: treegestalt at gmail.com (Forrest Curo) Date: Fri, 11 Mar 2022 17:48:32 -0800 Subject: [CM] Simple example In-Reply-To: <02A3271C-7900-496A-9878-94A5D1524D67@elisanet.fi> References: <02A3271C-7900-496A-9878-94A5D1524D67@elisanet.fi> Message-ID: If you run Grace and check the Help menu, you will find several examples listed, explaining how to do most of what a user is likely to want to know. On Fri, Mar 11, 2022 at 8:42 AM Matti Koskinen wrote: > Hi all, > > I got Grace compiled and it works, but since I?ve used it many years ago, > can?t remember anything at all. > If someone could post a simple example how to read midi from keyboard and > save it to a midi file, I?d be more than happy. > > Thanks > > -m > > > _______________________________________________ > Cmdist mailing list > Cmdist at ccrma.stanford.edu > https://cm-mail.stanford.edu/mailman/listinfo/cmdist > -------------- next part -------------- An HTML attachment was scrubbed... URL: From squarewave at elisanet.fi Fri Mar 11 19:16:48 2022 From: squarewave at elisanet.fi (Matti Koskinen) Date: Sat, 12 Mar 2022 05:16:48 +0200 Subject: [CM] Simple example In-Reply-To: References: <02A3271C-7900-496A-9878-94A5D1524D67@elisanet.fi> Message-ID: <8E8CC349-F824-4008-B881-306EED451D66@elisanet.fi> Hi, Thanks, but none of the examples show what I want. I thought that (with-midi(?test.mid?) (mp:receive myplayer)) would do the trick. It doesn?t give any errors, nor does it write the midi file either. Tnx -m > On 12. Mar 2022, at 3.48, Forrest Curo wrote: > > If you run Grace and check the Help menu, you will find several examples listed, explaining how to do most of what a user is likely to want to know. > > On Fri, Mar 11, 2022 at 8:42 AM Matti Koskinen > wrote: > Hi all, > > I got Grace compiled and it works, but since I?ve used it many years ago, can?t remember anything at all. > If someone could post a simple example how to read midi from keyboard and save it to a midi file, I?d be more than happy. > > Thanks > > -m > > > _______________________________________________ > Cmdist mailing list > Cmdist at ccrma.stanford.edu > https://cm-mail.stanford.edu/mailman/listinfo/cmdist -------------- next part -------------- An HTML attachment was scrubbed... URL: From squarewave at elisanet.fi Sat Mar 12 13:30:48 2022 From: squarewave at elisanet.fi (Matti Koskinen) Date: Sat, 12 Mar 2022 23:30:48 +0200 Subject: [CM] Simple example In-Reply-To: <8E8CC349-F824-4008-B881-306EED451D66@elisanet.fi> References: <02A3271C-7900-496A-9878-94A5D1524D67@elisanet.fi> <8E8CC349-F824-4008-B881-306EED451D66@elisanet.fi> Message-ID: <9BDE7780-D0AC-480B-9996-7141B1071597@elisanet.fi> Hi, Now I remember, how I created the midi file. The player wrote a text file, that could be converted to a midi file with txt2midi programme. The txt2midi and midi2txt can?t be compiled with newer c-compilers, but this link https://grfia.dlsi.ua.es/gen.php?id=resources has newer version, that compiled nicely one Bg Sur. Now if I?d only had any idea of what was done, except how hard it was getting the timing right. It?s so long a ago, that the sources have long been in the heaven of bits:-) -m > On 12. Mar 2022, at 5.16, Matti Koskinen wrote: > > Hi, > > Thanks, but none of the examples show what I want. > I thought that > > (with-midi(?test.mid?) > (mp:receive myplayer)) > > would do the trick. It doesn?t give any errors, nor does it write the midi file either. > > Tnx > > -m > > >> On 12. Mar 2022, at 3.48, Forrest Curo > wrote: >> >> If you run Grace and check the Help menu, you will find several examples listed, explaining how to do most of what a user is likely to want to know. >> >> On Fri, Mar 11, 2022 at 8:42 AM Matti Koskinen > wrote: >> Hi all, >> >> I got Grace compiled and it works, but since I?ve used it many years ago, can?t remember anything at all. >> If someone could post a simple example how to read midi from keyboard and save it to a midi file, I?d be more than happy. >> >> Thanks >> >> -m >> >> >> _______________________________________________ >> Cmdist mailing list >> Cmdist at ccrma.stanford.edu >> https://cm-mail.stanford.edu/mailman/listinfo/cmdist > > _______________________________________________ > Cmdist mailing list > Cmdist at ccrma.stanford.edu > https://cm-mail.stanford.edu/mailman/listinfo/cmdist -------------- next part -------------- An HTML attachment was scrubbed... URL: From squarewave at elisanet.fi Sat Mar 12 22:05:19 2022 From: squarewave at elisanet.fi (Matti Koskinen) Date: Sun, 13 Mar 2022 08:05:19 +0200 Subject: [CM] Simple example In-Reply-To: <02A3271C-7900-496A-9878-94A5D1524D67@elisanet.fi> References: <02A3271C-7900-496A-9878-94A5D1524D67@elisanet.fi> Message-ID: <78ED4242-687D-4729-9F87-7E77FD2C9EED@elisanet.fi> Found a solution, surely not the most elegant one, but seems to work: ; ;; Receiving MIDI Input ; ; Here is the definition of a MIDI receiver that routes midi on and ; off messages to the output port and as alist to *m* global variable (define *m* (list (now))) (define (myplayer data) (let* ((opcode (first data)) (channel (second data)) (keyn (third data)) (velocity (fourth data))) (set! *m* (append *m* (list (list data (now))))) (if (= opcode mm:on) (mp:on :time (now) :key keyn :vel velocity :chan channel) (if (= opcode mm:off) (mp:off :key keyn :chan channel))))) ; Set receiver, then play your midi keyboard (mp:receive myplayer) ; When you are done clear it... (mp:receive #f) ;save the *m* to a file (define (play-it-again-sam file) (sprout (let* ((notes (rest *m*)) (wasnow (first *m*))) (process for d in notes do (print d) (let* ((data (first d)) (op (first data)) (ch (second data)) (keyn (third data)) (veloc(fourth data))) (if (= op mm:on) (mp:on :time (- wasnow (last d)) :chan ch :key keyn :vel veloc)) (if (= op mm:off) (mp:off :time (- wasnow (last d)) :chan ch :key keyn))))) file)) ;test it (play-it-again-sam "ts3.mid") > On 11. Mar 2022, at 18.41, Matti Koskinen wrote: > > Hi all, > > I got Grace compiled and it works, but since I?ve used it many years ago, can?t remember anything at all. > If someone could post a simple example how to read midi from keyboard and save it to a midi file, I?d be more than happy. > > Thanks > > -m > > > _______________________________________________ > Cmdist mailing list > Cmdist at ccrma.stanford.edu > https://cm-mail.stanford.edu/mailman/listinfo/cmdist From juanig at ccrma.Stanford.EDU Mon Mar 14 14:31:04 2022 From: juanig at ccrma.Stanford.EDU (Juan Reyes) Date: Mon, 14 Mar 2022 14:31:04 -0700 Subject: [CM] Simple example In-Reply-To: <02A3271C-7900-496A-9878-94A5D1524D67@elisanet.fi> References: <02A3271C-7900-496A-9878-94A5D1524D67@elisanet.fi> Message-ID: <8c32f8f1-42e9-e216-16ba-ac9cc25f8fac@ccrma.stanford.edu> -On the subject-matter of compiling Grace-. I take it Matti compiled Grace for Mac OSX using Juce. Been trying to compile Grace for Linux Fedora 34 with no luck so far. Even Juce doesn't seem to work fine, and thus gave up. Don't know if anyone has a recent binary running on Linux or at least pointers for compiling it. Grace is S7!, making things still appealing. Regards, --* Juan Reyes > > I got Grace compiled and it works, but since I?ve used it many years > ago, can?t remember anything at all. If someone could post a simple > example how to read midi from keyboard and save it to a midi file, > I?d be more than happy. > From juanig at ccrma.Stanford.EDU Tue Mar 15 15:31:28 2022 From: juanig at ccrma.Stanford.EDU (Juan Reyes) Date: Tue, 15 Mar 2022 15:31:28 -0700 Subject: [CM] Grace on Linux Fedora 34 In-Reply-To: <8c32f8f1-42e9-e216-16ba-ac9cc25f8fac@ccrma.stanford.edu> References: <02A3271C-7900-496A-9878-94A5D1524D67@elisanet.fi> <8c32f8f1-42e9-e216-16ba-ac9cc25f8fac@ccrma.stanford.edu> Message-ID: <96a87590-fb17-e35c-db3d-1d856a47edbc@ccrma.stanford.edu> Hi, Was able to compile Grace 3.10.3 with Juce on Linux Fedora 34. Lot's of warnings and a tweak(*). Perhaps some of the Juce code needs to be updated to newer Juce versions to avoid warnings. --* Juan (*) Tweak is that 'JUCE_MODAL_LOOPS_PERMITTED=1' Should be added to Projucer's Preprocessor Definitions Steps below: # mkdir parent # cd parent # git clone https://github.com/juce-framework/JUCE.git # curl ftp://ccrma-ftp.stanford.edu/pub/Lisp/sndlib.tar.gz | tar -zx # git clone https://github.com/ricktaube/grace.git grace # cd sndlib # premake4 --with-g++ # make Now for Juce: Need to compile (make) Projucer App (binary) (make sure you have dependencies on "doc/Linux_dependencies.md Linux_dependencies.md") libasound2-dev libjack-jackd2-dev \ ladspa-sdk \ libcurl4-openssl-dev \ libfreetype6-dev \ libx11-dev libxcomposite-dev libxcursor-dev \ libxcursor-dev libxext-dev libxinerama-dev \ libxrandr-dev libxrender-dev \ libwebkit2gtk-4.0-dev \ libglu1-mesa-dev mesa-common-dev # cd ../ # cd JUCE/extras/Projucer/Builds/LinuxMakefile # make Once we have a binary and on the Builds directory: # cd build/ Run Projucer: # ./Projucer Now on Projucer's Window on the File Menu, OPEN ../parent/grace/Grace.jucer On the Exporters tab make sure Linux Makefile is yellowed or outlined. On Projucer's right side list scroll down on to "Preprocessors Definitions" Add the following definition: JUCE_MODAL_LOOPS_PERMITTED=1 Then Preprocessor Definitions should look like: JUCE_MODAL_LOOPS_PERMITTED=1 HAVE_SCHEME=1 On Projucer's File menu: select 'SAVE' This will create a new Makefile on '../parent/grace/Builds/LinuxMakefile' Now, # cd ../parent/grace/Builds/LinuxMakefile and, # make Grace binary should be on the Build directory # cd Build Run Grace ./Grace & > > ?-On the subject-matter of compiling Grace-. > > I take it Matti compiled Grace for Mac OSX using Juce. > > Been trying to compile Grace for Linux Fedora 34 with no luck so far. > > Even Juce doesn't seem to work fine, and thus gave up. > > Don't know if anyone has a recent binary running on Linux or at least > pointers for compiling it. > > Grace is S7!, making things still appealing. > From wdouglass at carnegierobotics.com Wed Mar 16 06:18:12 2022 From: wdouglass at carnegierobotics.com (Woody Douglass) Date: Wed, 16 Mar 2022 13:18:12 +0000 Subject: [CM] Lint suggests do Message-ID: Hi all, I've started running lint.scm against my (working) code, and i've understood and implemented a lot of the suggestions that it provides. One that I don't understand is the suggestion that i replace a lot of named lets with `do` loops Are do loops more efficient, or is this a stylistic choice? i've always found them to be sort of unlispy, and i'd love to learn more here. Thanks, Woody Douglass From bil at ccrma.Stanford.EDU Wed Mar 16 06:39:31 2022 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Wed, 16 Mar 2022 06:39:31 -0700 Subject: [CM] Lint suggests do In-Reply-To: References: Message-ID: It's mostly stylistic -- I hate named let. But I think a do-loop is nearly always faster in s7 due to its roots in Snd. I can add a flag to control that report if you like. Please let me know of any stupidities in lint -- I use it a lot, but I am set in my ways. From wdouglass at carnegierobotics.com Wed Mar 16 06:57:09 2022 From: wdouglass at carnegierobotics.com (Woody Douglass) Date: Wed, 16 Mar 2022 13:57:09 +0000 Subject: [CM] Lint suggests do In-Reply-To: References: Message-ID: Oh no problem, i don't mind lint being a bit opinionated! Honestly, since i started linting my code i've learned a lot of stylistic things that I wouldn't have thought of. My scheme code still has a "this was written by a C programmer" smell... Thanks a lot, Woody On Wed, 2022-03-16 at 06:39 -0700, bil at ccrma.Stanford.EDU wrote: > It's mostly stylistic -- I hate named let. But > I think a do-loop is nearly always faster in s7 > due to its roots in Snd. I can add a flag to control > that report if you like. Please let me know of any > stupidities in lint -- I use it a lot, but > I am set in my ways. > From wdouglass at carnegierobotics.com Mon Mar 21 09:21:26 2022 From: wdouglass at carnegierobotics.com (Woody Douglass) Date: Mon, 21 Mar 2022 16:21:26 +0000 Subject: [CM] pre-parsing scheme code Message-ID: All, I have a habit of creating a lot of s7 lists in C. this manifested in my C code being littered with nested `s7_list_nl` calls, and became unwieldy pretty quickly. So i wrote the attached script to "pre-parse" scheme s-expressions that i use in my C code, and generate C code -- it has done wonders for the maintainability of my codebase; also, it makes running the linter against the embedded scheme less finicky. Have any of you done something similar to this? is there a reason it's a bad idea? is there a better way? I guess this is just a request for comment; thanks for any insight you can provide. also, feel free to use/improve this script! -Woody Douglass -------------- next part -------------- A non-text attachment was scrubbed... Name: scheme_to_c.scm Type: text/x-scheme Size: 3451 bytes Desc: scheme_to_c.scm URL: From k.s.matheussen at gmail.com Mon Mar 21 10:29:11 2022 From: k.s.matheussen at gmail.com (Kjetil Matheussen) Date: Mon, 21 Mar 2022 18:29:11 +0100 Subject: [CM] pre-parsing scheme code In-Reply-To: References: Message-ID: Nice code. But isn't the result of doing: s7_eval_c_string("(list 1 2 3)"); the same as the result of doing: s7_list_nl(s, 3, s7_make_integer(s, 1),\ s7_make_integer(s, 2),\ s7_make_integer(s, 3),\ NULL); ? Except that the second version probably runs much faster... On Mon, Mar 21, 2022 at 5:25 PM Woody Douglass wrote: > > All, > > I have a habit of creating a lot of s7 lists in C. this manifested in > my C code being littered with nested `s7_list_nl` calls, and became > unwieldy pretty quickly. So i wrote the attached script to "pre-parse" > scheme s-expressions that i use in my C code, and generate C code -- it > has done wonders for the maintainability of my codebase; also, it makes > running the linter against the embedded scheme less finicky. > > Have any of you done something similar to this? is there a reason it's > a bad idea? is there a better way? > > I guess this is just a request for comment; thanks for any insight you > can provide. also, feel free to use/improve this script! > -Woody Douglass > _______________________________________________ > Cmdist mailing list > Cmdist at ccrma.stanford.edu > https://cm-mail.stanford.edu/mailman/listinfo/cmdist From wdouglass at carnegierobotics.com Mon Mar 21 10:31:46 2022 From: wdouglass at carnegierobotics.com (Woody Douglass) Date: Mon, 21 Mar 2022 17:31:46 +0000 Subject: [CM] pre-parsing scheme code In-Reply-To: References: Message-ID: <16c3a2e1ef634b6044297aa159a92a1c5ad45cf1.camel@carnegierobotics.com> The second version running much faster is the goal; so i'm mechanically transforming the first version to the second -Woody On Mon, 2022-03-21 at 18:29 +0100, Kjetil Matheussen wrote: > CAUTION: This email originated from outside of the organization. Do > not click links or open attachments unless you recognize the sender. > > > Nice code. But isn't the result of doing: > > s7_eval_c_string("(list 1 2 3)"); > > the same as the result of doing: > > s7_list_nl(s, 3, s7_make_integer(s, 1),\ > s7_make_integer(s, 2),\ > s7_make_integer(s, 3),\ > NULL); > > ? > > Except that the second version probably runs much faster... > > > On Mon, Mar 21, 2022 at 5:25 PM Woody Douglass > wrote: > > All, > > > > I have a habit of creating a lot of s7 lists in C. this manifested > > in > > my C code being littered with nested `s7_list_nl` calls, and became > > unwieldy pretty quickly. So i wrote the attached script to "pre- > > parse" > > scheme s-expressions that i use in my C code, and generate C code > > -- it > > has done wonders for the maintainability of my codebase; also, it > > makes > > running the linter against the embedded scheme less finicky. > > > > Have any of you done something similar to this? is there a reason > > it's > > a bad idea? is there a better way? > > > > I guess this is just a request for comment; thanks for any insight > > you > > can provide. also, feel free to use/improve this script! > > -Woody Douglass > > _______________________________________________ > > Cmdist mailing list > > Cmdist at ccrma.stanford.edu > > https://cm-mail.stanford.edu/mailman/listinfo/cmdist From bil at ccrma.Stanford.EDU Mon Mar 21 12:17:20 2022 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Mon, 21 Mar 2022 12:17:20 -0700 Subject: [CM] pre-parsing scheme code In-Reply-To: <16c3a2e1ef634b6044297aa159a92a1c5ad45cf1.camel@carnegierobotics.com> References: <16c3a2e1ef634b6044297aa159a92a1c5ad45cf1.camel@carnegierobotics.com> Message-ID: <2a4255f5abc17d7550c0d3c3345305a5@ccrma.stanford.edu> I didn't realize there was such a difference in speed: #include #include #include #include "s7.h" int main(int argc, char **argv) { s7_scheme *s; int i; s = s7_init(); #if 1 for (i = 0; i < 2000000; i++) s7_eval_c_string(s, "(list 1 2 3)"); #else for (i = 0; i < 2000000; i++) s7_list_nl(s, 4, s7_make_symbol(s, "list"), \ s7_make_integer(s, 1), \ s7_make_integer(s, 2), \ s7_make_integer(s, 3), \ NULL); #endif } /* gcc -o ex1 ex1.c s7.o -O2 -lm -I. -ldl */ /* 3045 vs 703 callgrind */ A factor of 4! From bil at ccrma.Stanford.EDU Mon Mar 21 12:25:52 2022 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Mon, 21 Mar 2022 12:25:52 -0700 Subject: [CM] pre-parsing scheme code In-Reply-To: <2a4255f5abc17d7550c0d3c3345305a5@ccrma.stanford.edu> References: <16c3a2e1ef634b6044297aa159a92a1c5ad45cf1.camel@carnegierobotics.com> <2a4255f5abc17d7550c0d3c3345305a5@ccrma.stanford.edu> Message-ID: <704b1ab9f2adf072aaee76426b37155e@ccrma.stanford.edu> Gah -- I forgot to eval the expression in the second case -- then it's 1600, which is more what I expected. for (i = 0; i < 2000000; i++) s7_eval(s, s7_list_nl(s, 4, s7_make_symbol(s, "list"), \ s7_make_integer(s, 1), \ s7_make_integer(s, 2), \ s7_make_integer(s, 3), \ NULL), s7_rootlet(s)); From bil at ccrma.Stanford.EDU Mon Mar 21 12:27:35 2022 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Mon, 21 Mar 2022 12:27:35 -0700 Subject: [CM] pre-parsing scheme code In-Reply-To: <704b1ab9f2adf072aaee76426b37155e@ccrma.stanford.edu> References: <16c3a2e1ef634b6044297aa159a92a1c5ad45cf1.camel@carnegierobotics.com> <2a4255f5abc17d7550c0d3c3345305a5@ccrma.stanford.edu> <704b1ab9f2adf072aaee76426b37155e@ccrma.stanford.edu> Message-ID: Sorry about that repetition -- I seem to have a flakey net connection today -- can't see any squirrels chewing on the cable. From wdouglass at carnegierobotics.com Mon Mar 21 12:31:20 2022 From: wdouglass at carnegierobotics.com (Woody Douglass) Date: Mon, 21 Mar 2022 19:31:20 +0000 Subject: [CM] pre-parsing scheme code In-Reply-To: <704b1ab9f2adf072aaee76426b37155e@ccrma.stanford.edu> References: <16c3a2e1ef634b6044297aa159a92a1c5ad45cf1.camel@carnegierobotics.com> <2a4255f5abc17d7550c0d3c3345305a5@ccrma.stanford.edu> <704b1ab9f2adf072aaee76426b37155e@ccrma.stanford.edu> Message-ID: <12fbf06c317728698c0150f51799bfa0f09a00c2.camel@carnegierobotics.com> Thanks for testing this! A factor of 2 is still nothing to sneeze at; I'm running s7 on a resource-constrained embeddded machine, so I'll take every cycle i can get at runtime! On Mon, 2022-03-21 at 12:25 -0700, bil at ccrma.Stanford.EDU wrote: > Gah -- I forgot to eval the expression in the second > case -- then it's 1600, which is more what I expected. > > for (i = 0; i < 2000000; i++) > s7_eval(s, s7_list_nl(s, 4, s7_make_symbol(s, "list"), \ > s7_make_integer(s, 1), \ > s7_make_integer(s, 2), \ > s7_make_integer(s, 3), \ > NULL), s7_rootlet(s)); > From bil at ccrma.Stanford.EDU Mon Mar 21 13:04:06 2022 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Mon, 21 Mar 2022 13:04:06 -0700 Subject: [CM] pre-parsing scheme code In-Reply-To: <12fbf06c317728698c0150f51799bfa0f09a00c2.camel@carnegierobotics.com> References: <16c3a2e1ef634b6044297aa159a92a1c5ad45cf1.camel@carnegierobotics.com> <2a4255f5abc17d7550c0d3c3345305a5@ccrma.stanford.edu> <704b1ab9f2adf072aaee76426b37155e@ccrma.stanford.edu> <12fbf06c317728698c0150f51799bfa0f09a00c2.camel@carnegierobotics.com> Message-ID: <5ee7f7478dae575edac4ec4a0ecbaeb6@ccrma.stanford.edu> If you're running the same code many times, it might be worth it to call s7_optimize, save the function it returns, then call that function rather than eval+expression-writing code. There's an example in snd-sig.c. The idea there is that you're running a function over every sample of some sound, so you first optimize it, then apply that to each sample. snd-sig.c uses s7_set_slot and so on to change the (user-level) function's argument to be each new sample. I should write a simpler example... (It's faster because you don't rebuild the code each time you use it, and the optimized evaluation is usually at least twice as fast.) From bil at ccrma.Stanford.EDU Mon Mar 21 13:32:19 2022 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Mon, 21 Mar 2022 13:32:19 -0700 Subject: [CM] pre-parsing scheme code In-Reply-To: <12fbf06c317728698c0150f51799bfa0f09a00c2.camel@carnegierobotics.com> References: <16c3a2e1ef634b6044297aa159a92a1c5ad45cf1.camel@carnegierobotics.com> <2a4255f5abc17d7550c0d3c3345305a5@ccrma.stanford.edu> <704b1ab9f2adf072aaee76426b37155e@ccrma.stanford.edu> <12fbf06c317728698c0150f51799bfa0f09a00c2.camel@carnegierobotics.com> Message-ID: <9afbd5da5c6c813aa5d33ea27d2ccbbb@ccrma.stanford.edu> Here's an example: #include #include #include #include "s7.h" int main(int argc, char **argv) { s7_scheme *s; s7_pfunc f; s7_pointer body; int i; s = s7_init(); body = s7_list_nl(s, 4, s7_make_symbol(s, "list"), \ s7_make_integer(s, 1), \ s7_make_integer(s, 2), \ s7_make_integer(s, 3), \ NULL); f = s7_optimize(s, s7_list(s, 1, body)); if (!f) fprintf(stderr, "oops\n"); else for (i = 0; i < 2000000; i++) f(s); } /* 130 in callgrind */ From wdouglass at carnegierobotics.com Tue Mar 22 04:39:36 2022 From: wdouglass at carnegierobotics.com (Woody Douglass) Date: Tue, 22 Mar 2022 11:39:36 +0000 Subject: [CM] pre-parsing scheme code In-Reply-To: <9afbd5da5c6c813aa5d33ea27d2ccbbb@ccrma.stanford.edu> References: <16c3a2e1ef634b6044297aa159a92a1c5ad45cf1.camel@carnegierobotics.com> <2a4255f5abc17d7550c0d3c3345305a5@ccrma.stanford.edu> <704b1ab9f2adf072aaee76426b37155e@ccrma.stanford.edu> <12fbf06c317728698c0150f51799bfa0f09a00c2.camel@carnegierobotics.com> <9afbd5da5c6c813aa5d33ea27d2ccbbb@ccrma.stanford.edu> Message-ID: <93818b3cebfbfae882d8c192ec3ae7b4d87bfdd0.camel@carnegierobotics.com> I didn't know about s7_optimize -- super cool! i'll start using it, thanks! -Woody Douglass On Mon, 2022-03-21 at 13:32 -0700, bil at ccrma.Stanford.EDU wrote: > Here's an example: > > #include > #include > #include > #include "s7.h" > > int main(int argc, char **argv) > { > s7_scheme *s; > s7_pfunc f; > s7_pointer body; > int i; > s = s7_init(); > body = s7_list_nl(s, 4, s7_make_symbol(s, "list"), \ > s7_make_integer(s, 1), \ > s7_make_integer(s, 2), \ > s7_make_integer(s, 3), \ > NULL); > f = s7_optimize(s, s7_list(s, 1, body)); > if (!f) fprintf(stderr, "oops\n"); > else > for (i = 0; i < 2000000; i++) > f(s); > } > > /* 130 in callgrind */ > From bil at ccrma.Stanford.EDU Tue Mar 22 05:50:26 2022 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Tue, 22 Mar 2022 05:50:26 -0700 Subject: [CM] pre-parsing scheme code In-Reply-To: <93818b3cebfbfae882d8c192ec3ae7b4d87bfdd0.camel@carnegierobotics.com> References: <16c3a2e1ef634b6044297aa159a92a1c5ad45cf1.camel@carnegierobotics.com> <2a4255f5abc17d7550c0d3c3345305a5@ccrma.stanford.edu> <704b1ab9f2adf072aaee76426b37155e@ccrma.stanford.edu> <12fbf06c317728698c0150f51799bfa0f09a00c2.camel@carnegierobotics.com> <9afbd5da5c6c813aa5d33ea27d2ccbbb@ccrma.stanford.edu> <93818b3cebfbfae882d8c192ec3ae7b4d87bfdd0.camel@carnegierobotics.com> Message-ID: <5a3eef5d94a3cef8ff507eeab92447b3@ccrma.stanford.edu> I added that example to s7.html, and added GC protection for "body". I didn't advertise s7_optimize in the past because I was fiddling with it for a long time. There is also s7_float_optimize which is probably not documented, and others like it in s7.c. If s7_optimize returns NULL, you can fall back on s7_eval (NULL just means the optimizer gave up for some reason). From wdouglass at carnegierobotics.com Tue Mar 22 11:38:38 2022 From: wdouglass at carnegierobotics.com (Woody Douglass) Date: Tue, 22 Mar 2022 18:38:38 +0000 Subject: [CM] s7_call_with_location Message-ID: All, What are the rules RE: s7_call_with_location? does it work with any applicable object? conversely, how difficult would it be to implement s7_eval_with_location? Thanks, Woody Douglass From bil at ccrma.Stanford.EDU Tue Mar 22 11:53:00 2022 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Tue, 22 Mar 2022 11:53:00 -0700 Subject: [CM] =?utf-8?q?s7=5Fcall=5Fwith=5Flocation?= In-Reply-To: References: Message-ID: <0ba72caeb2604fa7c901475c86860c5f@ccrma.stanford.edu> > What are the rules RE: s7_call_with_location? does it work with any > applicable object? conversely, how difficult would it be to implement > s7_eval_with_location? Yes, it should work with any applicable object. To implement s7_eval_with_location, use the location wrapper code in s7_call_with_location, substituting s7_eval for s7_call (and making the function arguments match s7_eval). From wdouglass at carnegierobotics.com Tue Mar 22 13:02:55 2022 From: wdouglass at carnegierobotics.com (Woody Douglass) Date: Tue, 22 Mar 2022 20:02:55 +0000 Subject: [CM] s7_call_with_location In-Reply-To: <0ba72caeb2604fa7c901475c86860c5f@ccrma.stanford.edu> References: <0ba72caeb2604fa7c901475c86860c5f@ccrma.stanford.edu> Message-ID: Thanks -- I'm applying the attached patch to my local s7 copy seems to work so far Woody Douglass On Tue, 2022-03-22 at 11:53 -0700, bil at ccrma.Stanford.EDU wrote: > > What are the rules RE: s7_call_with_location? does it work with any > > applicable object? conversely, how difficult would it be to > > implement > > s7_eval_with_location? > > Yes, it should work with any applicable object. To > implement s7_eval_with_location, use the location wrapper > code in s7_call_with_location, substituting s7_eval for > s7_call (and making the function arguments match s7_eval). > > -------------- next part -------------- A non-text attachment was scrubbed... Name: 0003-eval-with-location.patch Type: text/x-patch Size: 1434 bytes Desc: 0003-eval-with-location.patch URL: From bil at ccrma.Stanford.EDU Tue Mar 22 13:19:22 2022 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Tue, 22 Mar 2022 13:19:22 -0700 Subject: [CM] =?utf-8?q?s7=5Fcall=5Fwith=5Flocation?= In-Reply-To: References: <0ba72caeb2604fa7c901475c86860c5f@ccrma.stanford.edu> Message-ID: <13983c421b32ce11ae330a5ff19d50cd@ccrma.stanford.edu> > seems to work so far good -- I'll add it to my version, but I think I'll include the environment argument. Thanks! From wdouglass at carnegierobotics.com Wed Mar 23 12:09:43 2022 From: wdouglass at carnegierobotics.com (Woody Douglass) Date: Wed, 23 Mar 2022 19:09:43 +0000 Subject: [CM] Identify binary plugins Message-ID: All, S7 identifies plugins by file extension -- ".so" files are considered binary, and anything else is assumed to be scheme The attached patch identifies by ELF header, so there doesn't need to be any rules about plugin naming. Just thought i'd share Thanks, Woody Douglass -------------- next part -------------- A non-text attachment was scrubbed... Name: 0004-identify-elf.patch Type: text/x-patch Size: 1522 bytes Desc: 0004-identify-elf.patch URL: From bil at ccrma.Stanford.EDU Wed Mar 23 14:57:33 2022 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Wed, 23 Mar 2022 14:57:33 -0700 Subject: [CM] Identify binary plugins In-Reply-To: References: Message-ID: <3470ba06a7a017ef23611b03355f8b72@ccrma.stanford.edu> Thanks, but isn't ELF format specific to Linux? My *.so files on a Mac appear to be something else. Also, can't an ELF file be an executable? From elronnd at elronnd.net Wed Mar 23 15:00:14 2022 From: elronnd at elronnd.net (Elijah Stone) Date: Wed, 23 Mar 2022 15:00:14 -0700 (PDT) Subject: [CM] Identify binary plugins In-Reply-To: <3470ba06a7a017ef23611b03355f8b72@ccrma.stanford.edu> References: <3470ba06a7a017ef23611b03355f8b72@ccrma.stanford.edu> Message-ID: Afaik, by convention, the file extension for shared libraries is .dylib on macos and .dll on windows. On Wed, 23 Mar 2022, bil at ccrma.Stanford.EDU wrote: > Thanks, but isn't ELF format specific to Linux? > My *.so files on a Mac appear to be something else. > Also, can't an ELF file be an executable? > > _______________________________________________ > Cmdist mailing list > Cmdist at ccrma.stanford.edu > https://cm-mail.stanford.edu/mailman/listinfo/cmdist > From bil at ccrma.Stanford.EDU Wed Mar 23 15:16:16 2022 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Wed, 23 Mar 2022 15:16:16 -0700 Subject: [CM] Identify binary plugins In-Reply-To: References: <3470ba06a7a017ef23611b03355f8b72@ccrma.stanford.edu> Message-ID: <6ab9f8a2fd849647f2a3323dfe716425@ccrma.stanford.edu> I'll add dylib as an acceptable extension. From wdouglass at carnegierobotics.com Thu Mar 24 05:05:35 2022 From: wdouglass at carnegierobotics.com (Woody Douglass) Date: Thu, 24 Mar 2022 12:05:35 +0000 Subject: [CM] Identify binary plugins In-Reply-To: <6ab9f8a2fd849647f2a3323dfe716425@ccrma.stanford.edu> References: <3470ba06a7a017ef23611b03355f8b72@ccrma.stanford.edu> <6ab9f8a2fd849647f2a3323dfe716425@ccrma.stanford.edu> Message-ID: <8968e7ff586a05f8300909404489c311401c0ec8.camel@carnegierobotics.com> one more pass at this; dlopen uses the "magic numbers" at the beginning of a file to identify the executable format; i think it's safe for s7 to do the same. I've modified the patch to include MacOS and Windows exectuable file formats. as an aside, ELF files can be executable! and dlopen can load them just like a dll (as long as they have a dynamic symbol table). I can't see a reason for s7 to take advantage of this, but I also can't see a reason to prevent someone from loading an executable as an s7 extension either Take a look at the revised patch, attached. Thanks, Woody Douglass On Wed, 2022-03-23 at 15:16 -0700, bil at ccrma.Stanford.EDU wrote: > I'll add dylib as an acceptable extension. > > _______________________________________________ > Cmdist mailing list > Cmdist at ccrma.stanford.edu > https://cm-mail.stanford.edu/mailman/listinfo/cmdist -------------- next part -------------- A non-text attachment was scrubbed... Name: 0004-identify-elf.patch Type: text/x-patch Size: 2080 bytes Desc: 0004-identify-elf.patch URL: From bil at ccrma.Stanford.EDU Thu Mar 24 06:21:16 2022 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Thu, 24 Mar 2022 06:21:16 -0700 Subject: [CM] Identify binary plugins In-Reply-To: <8968e7ff586a05f8300909404489c311401c0ec8.camel@carnegierobotics.com> References: <3470ba06a7a017ef23611b03355f8b72@ccrma.stanford.edu> <6ab9f8a2fd849647f2a3323dfe716425@ccrma.stanford.edu> <8968e7ff586a05f8300909404489c311401c0ec8.camel@carnegierobotics.com> Message-ID: Thanks again, but I am not comfortable with this. It means building in magic numbers and assuming that everyone uses them, but I'd like s7 to work anywhere there's a C compiler and (in this context) dlopen, and be able to handle changes in the future without maintaining an ever-growing list of magic numbers. (And it means any file starting with "MZ" will be treated as an object file). From wdouglass at carnegierobotics.com Thu Mar 24 06:28:26 2022 From: wdouglass at carnegierobotics.com (Woody Douglass) Date: Thu, 24 Mar 2022 13:28:26 +0000 Subject: [CM] Identify binary plugins In-Reply-To: References: <3470ba06a7a017ef23611b03355f8b72@ccrma.stanford.edu> <6ab9f8a2fd849647f2a3323dfe716425@ccrma.stanford.edu> <8968e7ff586a05f8300909404489c311401c0ec8.camel@carnegierobotics.com> Message-ID: <65664ddf6a93304d026f2e7addfa7acb153e9da1.camel@carnegierobotics.com> That's fair, thanks for looking! -Woody Douglass On Thu, 2022-03-24 at 06:21 -0700, bil at ccrma.Stanford.EDU wrote: > Thanks again, but I am not comfortable with this. > It means building in magic numbers and assuming > that everyone uses them, but I'd like s7 to work > anywhere there's a C compiler and (in this context) > dlopen, and be able to handle changes in the future > without maintaining an ever-growing list of magic > numbers. (And it means any file starting with "MZ" > will be treated as an object file). >