%% Generated by lilypond-book
%% Options: [exampleindent=10.16\mm,indent=0\mm,line-width=160\mm,paper-height=845.047\pt,paper-width=597.508\pt,papersize='(cons (* 597.508 pt) (* 845.047 pt))]
\include "lilypond-book-preamble.ly"


% ****************************************************************
% Start cut-&-pastable-section
% ****************************************************************

#(ly:set-option 'eps-box-padding 3.000000)



\paper {
  #(set-paper-size '(cons (* 597.508 pt) (* 845.047 pt)))
  indent = 0\mm
  line-width = 160\mm
  % offset the left padding, also add 1mm as lilypond creates cropped
  % images with a little space on the right
  line-width = #(- line-width (* mm  3.000000) (* mm 1))
}

\layout {
  
}




% ****************************************************************
% ly snippet:
% ****************************************************************
\sourcefilename "snippets/generating-random-notes.ly"
\sourcefileline 0
%% DO NOT EDIT this file manually; it was automatically
%% generated from the LilyPond Wiki
%% (https://wiki.lilypond.community).
%%
%% Make any changes in the Wiki itself, or in
%% `Documentation/snippets/new/`, then run
%% `scripts/auxiliar/makelsr.pl`.
%%
%% This file is in the public domain.

\version "2.24.0"

\header {
%% Translation of GIT committish: a8a85e19654e46d725563e6deba44083ef137a2c
  texidocja = "
この Scheme ベースのスニペットは、24 の (あるいは必要な分の) ランダムな@c
音符を、現在の時間から (あるいは毎回同じ結果を得るために指定した数から)
生成します。別の音符列を生成したい場合は、数字を変更します。
"
  doctitleja = "ランダムな音符を生成する"

%% Translation of GIT committish: 304f8be3cd1ecbbc37f30191b4b49dcdc85bf3d5
  texidocfr = "
Le fragment de code Scheme ci-dessous génère aléatoirement des notes.
Il s'utilise ainsi :

@example
\\randomNotes @var{n} @var{de} @var{à} @var{dur}
@end example

@noindent
pour générer @emph{n} notes dont la hauteur varie entre @emph{de} et
@emph{à} sur une durée de @emph{dur}.
"

  doctitlefr = "Génération de notes aléatoires"

%% Translation of GIT committish: 6d96d9c7a40e4be6472937c5e1dd84aa01e39463
  texidoces = "
Este fragmento de código basado en Scheme genera notas aleatorias.
Úselo como

@example
\\randomNotes @var{n} @var{desde} @var{hasta} @var{duración}
@end example

para generar @emph{n} notas aleatorias entre las alturas
@emph{desde} y @emph{hasta}, con una longitud de @emph{duración}.
"
  doctitlees = "Generación de notas aleatorias"

%% Translation of GIT committish: 8ffecf6be17c6ec2ff87cf31873121a8cce29b09
  texidocca = "
Aquest fragment de codi basat en l'Scheme genera 24 notes aleatòries
(o tantes com calguin), basant-se en l'hora actual (o en qualsevol
nombre pseudo-aleatori que s'especifiqui en el seu lloc, per obtenir
les mateixes notes aleatòries cada cop): és a dir, per obtenir
diferents patrons de notes, sols ha de modificar aquest número.
"
  doctitleca = "Generació de notes aleatòries"

  categories = "Pitches, Really cool, Scheme"

  texidoc = "
This Scheme-based snippet generates random notes. Use as

@example
\\randomNotes @var{n} @var{from} @var{to} @var{dur}
@end example

to generate @emph{n} random notes between pitches @emph{from} and
@emph{to}, with duration @emph{dur}.
"

  doctitle = "Generating random notes"
} % begin verbatim


randomNotes =
#(define-music-function (n from to dur)
   (integer? ly:pitch? ly:pitch? ly:duration?)
   (let ((from-step (ly:pitch-steps from))
         (to-step (ly:pitch-steps to)))
     (make-sequential-music
      (map (lambda (_)
             (let* ((step (+ from-step
                             (random (- to-step from-step))))
                    (pitch (ly:make-pitch 0 step 0)))
               #{ $pitch $dur #}))
           (iota n)))))

\randomNotes 24 c' g'' 8



% ****************************************************************
% end ly snippet
% ****************************************************************
