Re: midi volume single note

2017-11-14 Thread Caagr98
You could also generate it dynamically at runtime, with something like this 
(please note that I haven't tested it):

gradual = #(define-music-function (f mus) (procedure? ly:music?)
  (make-simulaneous-music
(list mus (make-sequential-music
(let ((len (lambda (l) (ly:music-length (make-sequential-music 
l
  (l '()))
  (do () ((ly:moment On 14 November 2017 at 11:30, David Kastrup  > wrote:
> 
> Gianmaria Lari mailto:gianmarial...@gmail.com>> 
> writes:
> 
> > On 13 November 2017 at 13:31, Caagr98  > 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=#x" 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


Re: midi volume single note

2017-11-14 Thread Gianmaria Lari
On 14 November 2017 at 11:30, David Kastrup  wrote:

> Gianmaria Lari  writes:
>
> > On 13 November 2017 at 13:31, Caagr98  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=#x" 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


Re: midi volume single note

2017-11-14 Thread David Kastrup
Gianmaria Lari  writes:

> On 13 November 2017 at 13:31, Caagr98  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.

\version "2.19.80"

right = \fixed c'' { c1 }

withExpr =
#(define-music-function (steps start end music)
   (index? number? number? ly:music?)
   (let ((len (ly:make-duration 0 0
			(/ (ly:moment-main (ly:music-length music))
			   (1+ steps)
 #{ \context Bottom
	<< #music
	   { #@(append
  (map
	   (lambda (v)
		 #{ \set midiExpression = #v  \skip #len #})
	   (iota steps start (/ (- end start) (1+ steps
	  (list #{ \set midiExpression = #end #})) }
	>>
 #}))

\score {
  \new Staff \with { midiInstrument = "accordion"}
  \displayLilyMusic \new Voice { \withExpr 32 1 0 \right }
  \midi {}
  \layout {}
}


-- 
David Kastrup
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: midi volume single note

2017-11-14 Thread Gianmaria Lari
On 13 November 2017 at 13:31, Caagr98  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
s32 \set Voice.midiExpression=#0.87097
s32 \set Voice.midiExpression=#0.83871
s32 \set Voice.midiExpression=#0.80645
s32 \set Voice.midiExpression=#0.77419
s32 \set Voice.midiExpression=#0.74194
s32 \set Voice.midiExpression=#0.70968
s32 \set Voice.midiExpression=#0.67742
s32 \set Voice.midiExpression=#0.64516
s32 \set Voice.midiExpression=#0.6129
s32 \set Voice.midiExpression=#0.58065
s32 \set Voice.midiExpression=#0.54839
s32 \set Voice.midiExpression=#0.51613
s32 \set Voice.midiExpression=#0.48387
s32 \set Voice.midiExpression=#0.45161
s32 \set Voice.midiExpression=#0.41936
s32 \set Voice.midiExpression=#0.3871
s32 \set Voice.midiExpression=#0.35484
s32 \set Voice.midiExpression=#0.32258
s32 \set Voice.midiExpression=#0.29032
s32 \set Voice.midiExpression=#0.25806
s32 \set Voice.midiExpression=#0.22581
s32 \set Voice.midiExpression=#0.19355
s32 \set Voice.midiExpression=#0.16129
s32 \set Voice.midiExpression=#0.12903
s32 \set Voice.midiExpression=#0.09677
s32 \set Voice.midiExpression=#0.06452
s32 \set Voice.midiExpression=#0.03226
s32 \set Voice.midiExpression=#0
}

\score {
  \new Staff \with { midiInstrument = "accordion"}
  \new Voice <<\right \dynamics>>
  \midi {}
  \layout {}
}

Best regards, g.
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: midi volume single note

2017-11-13 Thread Caagr98
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.

On 11/13/17 13:25, Gianmaria Lari wrote:
> 
> On 13 November 2017 at 11:21, Caagr98  > wrote:
> 
> You can change `Voice.midiExpression` (0≤x≤1) in the middle of a note, 
> which changes dynamics/volume. I don't know whether you can do that to one 
> specific note without affecting other simultaneous ones, but you can just 
> create a new voice for that.
> 
> 
> I have no idea how to do that. Can you give more information or a small 
> example?

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: midi volume single note

2017-11-13 Thread Gianmaria Lari
On 13 November 2017 at 11:21, Caagr98  wrote:

> You can change `Voice.midiExpression` (0≤x≤1) in the middle of a note,
> which changes dynamics/volume. I don't know whether you can do that to one
> specific note without affecting other simultaneous ones, but you can just
> create a new voice for that.
>

I have no idea how to do that. Can you give more information or a small
example?
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: midi volume single note

2017-11-13 Thread Caagr98
You can change `Voice.midiExpression` (0≤x≤1) in the middle of a note, which 
changes dynamics/volume. I don't know whether you can do that to one specific 
note without affecting other simultaneous ones, but you can just create a new 
voice for that.

On 11/13/17 11:16, Gianmaria Lari wrote:
> 
> 
> On 13 November 2017 at 10:57, bb  > wrote:
> 
> Changes in the MIDI volume take place only on starting a note, so 
> crescendi and decrescendi cannot affect the volume of a single note.
> 
> http://lilypond.org/doc/v2.18/Documentation/notation/creating-midi-files.html 
> 
> 
> 
> That's why I also asked  about some existing escamotage. :)
> 
> Thank you,
> g.
> 
> 
> ___
> lilypond-user mailing list
> lilypond-user@gnu.org
> https://lists.gnu.org/mailman/listinfo/lilypond-user
> 

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: midi volume single note

2017-11-13 Thread Gianmaria Lari
On 13 November 2017 at 10:57, bb  wrote:

> Changes in the MIDI volume take place only on starting a note, so
> crescendi and decrescendi cannot affect the volume of a single note.
> http://lilypond.org/doc/v2.18/Documentation/notation/
> creating-midi-files.html
>
>
That's why I also asked  about some existing escamotage. :)

Thank you,
g.
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: midi volume single note

2017-11-13 Thread bb
Changes in the MIDI volume take place only on starting a note, so
crescendi and decrescendi cannot affect the volume of a single note.
http://lilypond.org/doc/v2.18/Documentation/notation/creating-midi-files.html

Regards

Am 13.11.2017 um 08:38 schrieb Gianmaria Lari:
>
> \version "2.19.80"
> right = \relative c'' { c1 ~ c1 }
> dynamics = { s4\f\> s4 s4 s4
>              s4 s4 s4 s4\! \p }
>
> \score {
>   \new Staff \with { midiInstrument = "accordion"} 
>     \new Voice <<\right \dynamics>>
>   \midi {}
>   \layout {}
> }
>

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user