On 14 November 2017 at 11:30, David Kastrup <d...@gnu.org> wrote:

> Gianmaria Lari <gianmarial...@gmail.com> writes:
>
> > On 13 November 2017 at 13:31, Caagr98 <caag...@gmail.com> wrote:
> >
> >> I was thinking of something like this:
> >>
> >> <<
> >>   { c'1 }
> >>   { s8 \set Voice.midiExpression=#0.5 s2.. Voice.midiExpression=#1 }
> >> >> c'1
> >>
> >> That is, simultaneously: a) play a note, b) wait a short while, reduce
> >> volume, wait until rest of the note is finished (2.. is 7/8 of a
> measure),
> >> then reset to normal.
> >>
> >
> > Thank you, perfect!!!!
> >
> > In case other people need it, here it is a complete example where c1 note
> > is played reducing volume from maximum to minimum in step of 1/32.
> >
> > \version "2.19.80"
> > right = \fixed c'' { c1 }
> >
> > dynamics = {
> > s32 \set Voice.midiExpression=#1
> > s32 \set Voice.midiExpression=#0.96774
> > s32 \set Voice.midiExpression=#0.93548
> > s32 \set Voice.midiExpression=#0.90323
> [...]
> > }
> >
> > \score {
> >   \new Staff \with { midiInstrument = "accordion"}
> >   \new Voice <<\right \dynamics>>
> >   \midi {}
> >   \layout {}
> > }
>
> Well, that calls for something programmatic I think.
>

Well, I was hoping that a nice guy pop up with your nice lily/scheme
code:)  Thanks !!!

P.S.
I didn't wrote the long list of "s32 \set Voice.midiExpression=#xxxxx" by
hand; I wrote some lines of code to generate them programmatically (much
less practical then your code but better than write them by hand). Here it
is the function I used:

        public string setVolume(float duration, int resolution, float
volumeStart, float volumeEnd)
        {
            int steps = (int)((1 / duration) / (1 / (float)resolution));
            float val = (volumeStart - volumeEnd) / (steps - 1);
            string s = "";
            for (int i = 1; i <= steps; i++)
            {
                s += "s" + resolution.ToString()+ " " + "\\set
Voice.midiExpression=#";
                s += Math.Round(volumeStart, 5).ToString() + "\n";
                volumeStart -= val;
            }
            return s;
        }
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to