Scheme in LilyPond

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Scheme in LilyPond

Charles Winston
Hi,

I’m fooling around with using Scheme in lilypond files, making some way on my GSoC chords project. I’m trying to call the make-note-ev procedure found in scm/chord-entry.scm on line 196. I’ve written something simple:

#(begin
        (define root (ly:make-pitch 0 0 0))
        (display (make-note-ev root))
)

And I get an error saying that make-note-ev is an unbound variable. I thought that we could call Scheme procedures from the source in lilypond files. What am I missing here?

Thanks,
Charles
_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Scheme in LilyPond

David Kastrup
Charles Winston <[hidden email]> writes:

> Hi,
>
> I’m fooling around with using Scheme in lilypond files, making some
> way on my GSoC chords project. I’m trying to call the make-note-ev
> procedure found in scm/chord-entry.scm on line 196. I’ve written
> something simple:
>
> #(begin
> (define root (ly:make-pitch 0 0 0))
> (display (make-note-ev root))
> )
>
> And I get an error saying that make-note-ev is an unbound variable. I
> thought that we could call Scheme procedures from the source in
> lilypond files. What am I missing here?

You can only access exported definitions (defined using define-public or
explicitly exported using (export ...)) outside of the module itself.
But even then, only entities defined at top level are part of the module
interface and can be exported: all other definitions are local to the
enclosing definition and not known outside.

--
David Kastrup

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Scheme in LilyPond

Jan-Peter Voigt
In reply to this post by Charles Winston
Hi Charles,

the make-note-ev function is hidden inside a closure and therefore not
publicly visible. It depends on the duration defined in that closure. To
create NoteEvents you should create them like this:

(make-music 'NoteEvent 'pitch root 'duration some-duration)

where 'some-duration' is defined with a duration: (ly:make-duration 2)
for a quarter note.

The begin-define-sequence implies using 'let':

#(let ((root (ly:make-pitch 0 0 0))
        (dur (ly:make-duration 2)))
    (display (make-music 'NoteEvent 'pitch root 'duration dur)))

If there is a duration reachable in the scope you are acting, then you
can use that one like you found in the mentioned file and probably copy
the definition of make-note-ev.

HTH
Jan-Peter

Am 01.06.2017 um 17:03 schrieb Charles Winston:

> Hi,
>
> I’m fooling around with using Scheme in lilypond files, making some way on my GSoC chords project. I’m trying to call the make-note-ev procedure found in scm/chord-entry.scm on line 196. I’ve written something simple:
>
> #(begin
> (define root (ly:make-pitch 0 0 0))
> (display (make-note-ev root))
> )
>
> And I get an error saying that make-note-ev is an unbound variable. I thought that we could call Scheme procedures from the source in lilypond files. What am I missing here?
>
> Thanks,
> Charles
> _______________________________________________
> lilypond-devel mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/lilypond-devel
>


_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Scheme in LilyPond

Winston, Charles R.
Totally makes sense. Thanks for the help!

Charles

> On Jun 1, 2017, at 11:29 AM, Jan-Peter Voigt <[hidden email]> wrote:
>
> Hi Charles,
>
> the make-note-ev function is hidden inside a closure and therefore not publicly visible. It depends on the duration defined in that closure. To create NoteEvents you should create them like this:
>
> (make-music 'NoteEvent 'pitch root 'duration some-duration)
>
> where 'some-duration' is defined with a duration: (ly:make-duration 2) for a quarter note.
>
> The begin-define-sequence implies using 'let':
>
> #(let ((root (ly:make-pitch 0 0 0))
>       (dur (ly:make-duration 2)))
>   (display (make-music 'NoteEvent 'pitch root 'duration dur)))
>
> If there is a duration reachable in the scope you are acting, then you can use that one like you found in the mentioned file and probably copy the definition of make-note-ev.
>
> HTH
> Jan-Peter
>
> Am 01.06.2017 um 17:03 schrieb Charles Winston:
>> Hi,
>> I’m fooling around with using Scheme in lilypond files, making some way on my GSoC chords project. I’m trying to call the make-note-ev procedure found in scm/chord-entry.scm on line 196. I’ve written something simple:
>> #(begin
>> (define root (ly:make-pitch 0 0 0))
>> (display (make-note-ev root))
>> )
>> And I get an error saying that make-note-ev is an unbound variable. I thought that we could call Scheme procedures from the source in lilypond files. What am I missing here?
>> Thanks,
>> Charles
>> _______________________________________________
>> lilypond-devel mailing list
>> [hidden email]
>> https://lists.gnu.org/mailman/listinfo/lilypond-devel
>
>
> _______________________________________________
> lilypond-devel mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/lilypond-devel

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Scheme in LilyPond

Paul Morris
In reply to this post by Charles Winston
On 06/01/2017 11:03 AM, Charles Winston wrote:

> And I get an error saying that make-note-ev is an unbound variable. I thought that we could call Scheme procedures from the source in lilypond files. What am I missing here?

I'll just add that generally you can call scheme procedures defined in
source files when they are defined with 'define-public'.  If they are
defined with 'define' then they probably won't be callable.  In the
latter case you can often just copy/paste them into your .ly file
(adding # at the beginning of the opening paren(s)) and use them that way.

Cheers,
-Paul

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Scheme in LilyPond

Urs Liska


Am 01.06.2017 um 17:41 schrieb Paul:

> On 06/01/2017 11:03 AM, Charles Winston wrote:
>
>> And I get an error saying that make-note-ev is an unbound variable. I
>> thought that we could call Scheme procedures from the source in
>> lilypond files. What am I missing here?
>
> I'll just add that generally you can call scheme procedures defined in
> source files when they are defined with 'define-public'.  If they are
> defined with 'define' then they probably won't be callable.  In the
> latter case you can often just copy/paste them into your .ly file
> (adding # at the beginning of the opening paren(s)) and use them that
> way.

One more addition: This limitation to define-public is only true for
Scheme files (.scm) that are included with use-modules. All definitions
within LilyPond files are public automatically. So when you write

#(define my-variable "something")

in an included LilyPond file you can always access it directly.

HTH
Urs

>
> Cheers,
> -Paul
>
> _______________________________________________
> lilypond-devel mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/lilypond-devel

--
[hidden email]
https://openlilylib.org
http://lilypondblog.org


_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Loading...