[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Use of ly:set-default-scale
From: |
Han-Wen Nienhuys |
Subject: |
Re: Use of ly:set-default-scale |
Date: |
Mon, 20 Dec 2010 12:19:32 -0200 |
2010/12/20 Felipe Gonçalves Assis <address@hidden>:
> Hi,
>
> In the attached snippet, the call to ly:set-default-scale has no
> effect on the midi result, both in the stable and development
> versions.
>
> I believe that this is due to Pitches being constructed before
> the new default_global_scale is set (see files lily/pitch.cc and
> lily/scale.cc), so that they keep a pointer to the old Scale,
> created in scm/lily.scm:387.
>
> This looks bad, because as ly:set-default-scale is called, the
> old object gets unprotected.
>
> In fact, by applying the change described in the attached file
> diff.txt, I obtained the results I expected (set-scale-test-mine.midi),
> which only confirms my suspicions. (The last c is 6 tones higher,
> because an octave is hard-coded as 6 tones, but that is another
> issue).
>
> This leads me to the following questions:
>
> 1. Is the current behaviour the desired one?
Yes. After setting the scale, you have to redefine the pitches for
them to pick up the new scale.
> 2. Is it a bug?
> 3. Do we really have a problem with garbage collection?
> (I observe no consequences)
No. Since old pitches still have references to the old scale, it is
not flushed.
> By the way, there is actually an alternative solution, which would be
> to make Pitch objects use default_global_scale directly, instead of
> storing its value as an internal field during initialisation. This leads
> me to the related question:
>
> 4. What is the purpose of the non-static scale_ field in the Pitch class?
>
> I look forward to and would very much appreciate any thoughts on
> these from anybody acquainted with this code.
In general, I tried to avoid creating global variables (such as
scale), as a matter of habit.
--
Han-Wen Nienhuys - address@hidden - http://www.xs4all.nl/~hanwen