Initialize to 0.
*/
Rational ();
- Rational (int, int);
- Rational (double);
+ Rational (int);
+ explicit Rational (int, int);
+ explicit Rational (double);
Rational (Rational const &r) { copy (r);}
Rational &operator = (Rational const &r)
{
operator << (ostream &, Rational);
#endif
-const Rational infinity_rat = INT_MAX;
+const Rational infinity_rat (INT_MAX);
#endif // RATIONAL_HH
normalize ();
}
+Rational::Rational (int n)
+{
+ sign_ = ::sign (n);
+ num_ = ::abs (n);
+ den_ = 1;
+}
+
+
+/*
+ We can actually do a little better. See Knuth 4.5.2
+ */
static inline
int gcd (int a, int b)
{
depth = ..
-SUBDIRS = test regression tutorial no-notation mutopia manual
+SUBDIRS = test regression tutorial midi no-notation mutopia manual
examples = typography-demo les-nereides wilhelmus proportional bach-schenker cary
--- /dev/null
+depth = ../..
+
+STEPMAKE_TEMPLATES=documentation texinfo tex
+LOCALSTEPMAKE_TEMPLATES=lilypond ly lysdoc
+
+include $(depth)/make/stepmake.make
+TITLE=LilyPond MIDI Tests
+
--- /dev/null
+
+\version "2.10.0"
+
+\version "2.10.1"
+
+\score {
+ \new DrumStaff <<
+ \drummode {
+ bd4 sn4 bd4 sn4
+ <<
+ {\voiceOne \repeat unfold 16 hh16 }
+ \new DrumVoice { \voiceTwo bd4 sn4 bd4 sn4 }
+ >> \oneVoice
+ }
+ >>
+ \layout {}
+ \midi {}
+}
--- /dev/null
+\version "2.10.0"
+\header{ texidoc = "Tests MIDI output with grace notes. " }
+
+\score {
+ \context Voice \relative c {
+ \new Voice = VoiceOne
+ \grace {
+ \override Stem #'stroke-style = #"grace"
+ c8
+ \revert Stem #'stroke-style }
+ d4 d d d d
+ \grace {
+ \override Stem #'stroke-style = #"grace"
+ e16 f e f
+ \revert Stem #'stroke-style }
+ d4 d d d d
+
+ }
+ \layout { }
+ \midi { }
+}
+
--- /dev/null
+\version "2.10.0"
+\header {
+
+ texidoc = "Lyrics in MIDI are aligned to ties and beams:
+this examples causes no bar checks in MIDI.
+"
+
+
+ }
+\score {
+
+ <<\relative c'' \new Voice = A {
+ \autoBeamOff
+ c8[ c] c2.
+ c1~c4 c2.
+ c4 ( d e) d
+ c1
+
+ }
+ \lyricsto "A" \lyrics { bla bla | bla bla | bla bla | bla }
+ >>
+ \layout {}
+ \midi {}
+ }
--- /dev/null
+
+\version "2.10.0"
+% candidate for regression. -gp
+\header {
+ texidoc="Converting LilyPond input to MIDI and then again back with
+ @code{midi2ly.py} is a reversible procedure in some simple cases,
+ which mean that the original @code{.ly} -file and the one converted
+ back from the generated @code{.midi} -file do not differ.
+ Here are produced some scales.
+
+ "
+}
+
+%{
+ This means, doing:
+
+ lilypond input/test/midi-scales.ly
+ midi2ly midi-scales.midi
+ diff -u input/test/midi-scales.ly midi-scales-midi.ly
+
+ should show no differences at all in \key commands or notes.
+
+ Therefore, do not reformat this file unless midi2ly changes.
+
+ 1.7.30 reformatted, because
+ midi2ly now outpts 1 bar per line and adds bar checks and numbers.
+
+%}
+
+scales = \relative c {
+
+ % [INSTRUMENT_NAME] bright acoustic
+ \key c \major % sharp-major
+ c'4 d e f |
+ g a b c |
+
+ \key g \major
+ g a b c |
+ d e fis g |
+
+ \key d \major
+ d, e fis g |
+ a b cis d |
+
+ \key a \major
+ a b cis d |
+ e fis gis a |
+
+ \key e \major
+ e, fis gis a |
+ b cis dis e |
+
+ \key b \major
+ b cis dis e |
+ fis gis ais b |
+
+ \key fis \major
+ fis, gis ais b |
+ cis dis eis fis |
+
+ \key cis \major
+ cis, dis eis fis |
+ gis ais bis cis |
+
+ \key a \minor % sharp-minor
+ a b c d |
+ e f gis a |
+
+ \key e \minor
+ e, fis g a |
+ b c dis e |
+
+ \key b \minor
+ b cis d e |
+ fis g ais b |
+
+ \key fis \minor
+ fis, gis a b |
+ cis d eis fis |
+
+ \key cis \minor
+ cis, dis e fis |
+ gis a bis cis |
+
+ \key gis \minor
+ gis ais b cis |
+ dis e fisis gis |
+
+ \key dis \minor
+ dis, eis fis gis |
+ ais b cisis dis |
+
+ \key ais \minor
+ ais bis cis dis |
+ eis fis gisis ais |
+
+ \key f \major % flat-major
+ f, g a bes |
+ c d e f |
+
+ \key bes \major
+ bes c d ees |
+ f g a bes |
+
+ \key ees \major
+ ees,, f g aes |
+ bes c d ees |
+
+ \key aes \major
+ aes, bes c des |
+ ees f g aes |
+
+ \key des \major
+ des,, ees f ges |
+ aes bes c des |
+
+ \key ges \major
+ ges, aes bes ces |
+ des ees f ges |
+
+ \key ces \major
+ ces,, des ees fes |
+ ges aes bes ces |
+
+ \key d \minor % flat-minor
+ d, e f g |
+ a bes cis d |
+
+ \key g \minor
+ g, a bes c |
+ d ees fis g |
+
+ \key c \minor
+ c,, d ees f |
+ g aes b c |
+
+ \key f \minor
+ f, g aes bes |
+ c des e f |
+
+ \key bes \minor
+ bes,, c des ees |
+ f ges a bes |
+
+ \key ees \minor
+ ees, f ges aes |
+ bes ces d ees |
+
+ \key aes \minor
+ aes, bes ces des |
+ ees fes g aes |
+}
+
+\score {
+ \context Voice \scales
+ \layout { }
+ \midi { }
+}
+
--- /dev/null
+\version "2.10.0"
+\header {
+texidoc = "
+
+Midi2ly tuplet test.
+
+@example
+ python scripts/midi2ly.py --duration-quant=32 \
+ --allow-tuplet=4*2/3 \
+ --allow-tuplet=8*2/3 \
+ --allow-tuplet=4*3/5 \
+ --allow-tuplet=8*3/5 \
+ tu.midi
+@end example
+"
+}
+
+
+\score {
+ \context Voice \relative c' {
+
+ a1 a2 a2. a4 a4. a8 a8. a16 a16. a32 a32. a64
+
+ \times 2/3 { b4 b4 b4 }
+ \times 3/5 { b4 b4 b4 b4 b4 }
+
+ \times 2/3 { c8 c8 c8 }
+ \times 3/5 { c8 c8 c8 c8 c8 }
+
+ }
+ \layout { }
+ \midi { }
+}
+
+
--- /dev/null
+\version "2.10.0"
+\header {
+ texidoc = "@cindex Midi Volume Equaliser
+The full orchestra plays a notes, where groups stop one after
+another. Use this to tune equalizer settings. "
+}
+
+#(set-global-staff-size 16)
+
+%{
+
+Override, see scm/midi.scm:
+
+#(set! instrument-equalizer-alist
+ (append
+ '(
+ ("flute" . (0 . 0.7))
+ )
+ instrument-equalizer-alist))
+
+%}
+
+flauti = \relative c' {
+ \set Staff.midiInstrument = #"flute"
+ \set Staff.instrumentName = #"2 Flauti"
+ \set Staff.shortInstrumentName = #"Fl."
+
+ c1\f R1*10
+}
+
+oboi = \relative c' {
+ \set Staff.midiInstrument = #"oboe"
+ \set Staff.instrumentName = #"2 Oboi"
+ \set Staff.shortInstrumentName = #"Ob."
+
+ R1*1 c1\f R1*9
+}
+
+clarinetti = \relative c' {
+ \set Staff.midiInstrument = #"clarinet"
+ \set Staff.instrumentName = #"Clarinetti"
+ \set Staff.shortInstrumentName = #"Cl"
+
+ R1*2 c1\f R1*8
+}
+
+fagotti = \relative c' {
+ \set Staff.midiInstrument = #"bassoon"
+ \set Staff.instrumentName = #"2 Fagotti"
+ \set Staff.shortInstrumentName = #"Fg."
+
+ \clef bass
+ R1*3 c1\f R1*7
+}
+
+corni = \relative c' {
+ \set Staff.midiInstrument = #"french horn"
+ \set Staff.instrumentName = #"Corni"
+ \set Staff.shortInstrumentName = #"Cor"
+
+ R1*4 c1\f R1*6
+}
+
+trombe = \relative c' {
+ \set Staff.midiInstrument = #"trumpet"
+ \set Staff.instrumentName = #"Trombe"
+ \set Staff.shortInstrumentName = #"Tp."
+
+ \clef bass
+ R1*5 c1\f R1*5
+}
+
+timpani = \relative c' {
+ \set Staff.midiInstrument = #"timpani"
+ \set Staff.instrumentName = #"Timpani"
+ \set Staff.shortInstrumentName = #"Timp."
+
+ R1*6 c1\f R1*4
+}
+
+violinoI = \relative c' {
+ \set Staff.midiInstrument = #"violin"
+ \set Staff.instrumentName = #"Violino I "
+ \set Staff.shortInstrumentName = #"Vl. I "
+
+ R1*7 c1\f R1*3
+}
+
+violinoII = \relative c' {
+ \set Staff.midiInstrument = #"violin"
+ \set Staff.instrumentName = #"Violino II "
+ \set Staff.shortInstrumentName = #"Vl. II "
+
+ R1*8 c1\f R1*2
+}
+
+viola = \relative c' {
+ \set Staff.midiInstrument = #"viola"
+ \set Staff.instrumentName = #"Viola"
+ \set Staff.shortInstrumentName = #"Vla."
+
+ \clef alto
+ R1*9 c1\f R1*1
+}
+
+violoncello = \relative c' {
+ \set Staff.midiInstrument = #"cello"
+ %\set Staff.midiInstrument = #"contrabass"
+ \set Staff.instrumentName = #"Violoncello"
+ \set Staff.shortInstrumentName = #"Vc."
+
+ \clef bass
+ R1*10 c1\f
+}
+
+
+\score {
+ <<
+ \new StaffGroup = "legni" <<
+ \new Staff = "flauti" \flauti
+ \new Staff = "oboi" \oboi
+ \new Staff = "clarinetti" \clarinetti
+ \new Staff = "fagotti" \fagotti
+ >>
+ \new StaffGroup = "ottoni" <<
+ \new Staff = "corni" \corni
+ \new Staff = "trombe" \trombe
+ >>
+ \new StaffGroup = "timpani" <<
+ \new Staff = "timpani" \timpani
+ {
+ \skip 1
+ %% Hmm: this forces a staff-bracket, that's good!
+ %% However, I can't find where is decided on staff-bracket yes/no
+ }
+ >>
+ \new StaffGroup = "archi" <<
+ \new GrandStaff = "violini" <<
+ \new Staff = "violino1" \violinoI
+ \new Staff = "violino2" \violinoII
+ >>
+ \new Staff = "viola" \viola
+ \new Staff = "violoncello" \violoncello
+ >>
+ >>
+
+ \layout {
+ \context {
+ \RemoveEmptyStaffContext
+ }
+ }
+
+ \midi {
+ \context {
+ \Score
+ tempoWholesPerMinute = #(ly:make-moment 60 1)
+ }
+ }
+}
+
+
+++ /dev/null
-
-\version "2.10.0"
-
-\version "2.10.1"
-
-\score {
- \new DrumStaff <<
- \drummode {
- bd4 sn4 bd4 sn4
- <<
- {\voiceOne \repeat unfold 16 hh16 }
- \new DrumVoice { \voiceTwo bd4 sn4 bd4 sn4 }
- >> \oneVoice
- }
- >>
- \layout {}
- \midi {}
-}
+++ /dev/null
-#(ly:set-option 'old-relative)
-\version "2.10.0"
-\header{ texidoc = "Tests MIDI output with grace notes. " }
-
-\score {
- \context Voice \relative c {
- \new Voice = VoiceOne
- \grace {
- \override Stem #'stroke-style = #"grace"
- c8
- \revert Stem #'stroke-style }
- d4 d d d d
- \grace {
- \override Stem #'stroke-style = #"grace"
- e16 f e f
- \revert Stem #'stroke-style }
- d4 d d d d
-
- }
- \layout { }
- \midi { }
-}
-
+++ /dev/null
-\version "2.10.0"
-\header {
-
- texidoc = "Lyrics in MIDI are aligned to ties and beams:
-this examples causes no bar checks in MIDI.
-"
-
-
- }
-\score {
-
- <<\relative c'' \new Voice = A {
- \autoBeamOff
- c8[ c] c2.
- c1~c4 c2.
- c4 ( d e) d
- c1
-
- }
- \lyricsto "A" \lyricmode\new Lyrics { bla bla | bla bla | bla bla | bla }
- >>
- \layout {}
- \midi {}
- }
+++ /dev/null
-
-\version "2.10.0"
-% candidate for regression. -gp
-\header {
- texidoc="Converting LilyPond input to MIDI and then again back with
- @code{midi2ly.py} is a reversible procedure in some simple cases,
- which mean that the original @code{.ly} -file and the one converted
- back from the generated @code{.midi} -file do not differ.
- Here are produced some scales.
-
- "
-}
-
-%{
- This means, doing:
-
- lilypond input/test/midi-scales.ly
- midi2ly midi-scales.midi
- diff -u input/test/midi-scales.ly midi-scales-midi.ly
-
- should show no differences at all in \key commands or notes.
-
- Therefore, do not reformat this file unless midi2ly changes.
-
- 1.7.30 reformatted, because
- midi2ly now outpts 1 bar per line and adds bar checks and numbers.
-
-%}
-
-scales = \relative c {
-
- % [INSTRUMENT_NAME] bright acoustic
- \key c \major % sharp-major
- c'4 d e f |
- g a b c |
-
- \key g \major
- g a b c |
- d e fis g |
-
- \key d \major
- d, e fis g |
- a b cis d |
-
- \key a \major
- a b cis d |
- e fis gis a |
-
- \key e \major
- e, fis gis a |
- b cis dis e |
-
- \key b \major
- b cis dis e |
- fis gis ais b |
-
- \key fis \major
- fis, gis ais b |
- cis dis eis fis |
-
- \key cis \major
- cis, dis eis fis |
- gis ais bis cis |
-
- \key a \minor % sharp-minor
- a b c d |
- e f gis a |
-
- \key e \minor
- e, fis g a |
- b c dis e |
-
- \key b \minor
- b cis d e |
- fis g ais b |
-
- \key fis \minor
- fis, gis a b |
- cis d eis fis |
-
- \key cis \minor
- cis, dis e fis |
- gis a bis cis |
-
- \key gis \minor
- gis ais b cis |
- dis e fisis gis |
-
- \key dis \minor
- dis, eis fis gis |
- ais b cisis dis |
-
- \key ais \minor
- ais bis cis dis |
- eis fis gisis ais |
-
- \key f \major % flat-major
- f, g a bes |
- c d e f |
-
- \key bes \major
- bes c d ees |
- f g a bes |
-
- \key ees \major
- ees,, f g aes |
- bes c d ees |
-
- \key aes \major
- aes, bes c des |
- ees f g aes |
-
- \key des \major
- des,, ees f ges |
- aes bes c des |
-
- \key ges \major
- ges, aes bes ces |
- des ees f ges |
-
- \key ces \major
- ces,, des ees fes |
- ges aes bes ces |
-
- \key d \minor % flat-minor
- d, e f g |
- a bes cis d |
-
- \key g \minor
- g, a bes c |
- d ees fis g |
-
- \key c \minor
- c,, d ees f |
- g aes b c |
-
- \key f \minor
- f, g aes bes |
- c des e f |
-
- \key bes \minor
- bes,, c des ees |
- f ges a bes |
-
- \key ees \minor
- ees, f ges aes |
- bes ces d ees |
-
- \key aes \minor
- aes, bes ces des |
- ees fes g aes |
-}
-
-\score {
- \context Voice \scales
- \layout { }
- \midi { }
-}
-
+++ /dev/null
-#(ly:set-option 'old-relative)
-\version "2.10.0"
-
-\header { texidoc = "@cindex Transposing
-The transposing property leaves output invariant, but has effect on MIDI. "
-}
-
-\score {
- \context Voice \relative c {
- % btw: this is not how transposing is done in lilypond
- % this is a transposing performer, i.e. for midi-output only
- \set Staff.transposing = #0 c
- \set Staff.transposing = #2 c
- \set Staff.transposing = #4 c
- \set Staff.transposing = #5 c
- \set Staff.transposing = #7 c
- \set Staff.transposing = #9 c
- \set Staff.transposing = #11 c
- \set Staff.transposing = #12 c
-
- }
- \layout { ragged-right = ##t }
- \midi { }
-}
-
+++ /dev/null
-#(ly:set-option 'old-relative)
-\version "2.10.0"
-\header {
-texidoc = "
-
-Midi2ly tuplet test.
-
-@example
- python scripts/midi2ly.py --duration-quant=32 \
- --allow-tuplet=4*2/3 \
- --allow-tuplet=8*2/3 \
- --allow-tuplet=4*3/5 \
- --allow-tuplet=8*3/5 \
- tu.midi
-@end example
-"
-}
-
-
-\score {
- \context Voice \relative c' {
-
- a1 a2 a2. a4 a4. a8 a8. a16 a16. a32 a32. a64
-
- \times 2/3 { b4 b4 b4 }
- \times 3/5 { b4 b4 b4 b4 b4 }
-
- \times 2/3 { c8 c8 c8 }
- \times 3/5 { c8 c8 c8 c8 c8 }
-
- }
- \layout { }
- \midi { }
-}
-
-
+++ /dev/null
-#(ly:set-option 'old-relative)
-\version "2.10.0"
-\header {
-texidoc = "@cindex Midi Volume Equaliser
-The full orchestra plays a notes, where groups stop one after
-another. Use this to tune equalizer settings. "
-}
-
-#(set-global-staff-size 16)
-
-%{
-
-Override, see scm/midi.scm:
-
-#(set! instrument-equalizer-alist
- (append
- '(
- ("flute" . (0 . 0.7))
- )
- instrument-equalizer-alist))
-
-%}
-
-flauti = \relative c' {
- \set Staff.midiInstrument = #"flute"
- \set Staff.instrumentName = #"2 Flauti"
- \set Staff.shortInstrumentName = #"Fl."
-
- c1\f R1*10
-}
-
-oboi = \relative c' {
- \set Staff.midiInstrument = #"oboe"
- \set Staff.instrumentName = #"2 Oboi"
- \set Staff.shortInstrumentName = #"Ob."
-
- R1*1 c1\f R1*9
-}
-
-clarinetti = \relative c' {
- \set Staff.midiInstrument = #"clarinet"
- \set Staff.instrumentName = #"Clarinetti"
- \set Staff.shortInstrumentName = #"Cl"
-
- R1*2 c1\f R1*8
-}
-
-fagotti = \relative c' {
- \set Staff.midiInstrument = #"bassoon"
- \set Staff.instrumentName = #"2 Fagotti"
- \set Staff.shortInstrumentName = #"Fg."
-
- \clef bass
- R1*3 c1\f R1*7
-}
-
-corni = \relative c' {
- \set Staff.midiInstrument = #"french horn"
- \set Staff.instrumentName = #"Corni"
- \set Staff.shortInstrumentName = #"Cor"
-
- R1*4 c1\f R1*6
-}
-
-trombe = \relative c' {
- \set Staff.midiInstrument = #"trumpet"
- \set Staff.instrumentName = #"Trombe"
- \set Staff.shortInstrumentName = #"Tp."
-
- \clef bass
- R1*5 c1\f R1*5
-}
-
-timpani = \relative c' {
- \set Staff.midiInstrument = #"timpani"
- \set Staff.instrumentName = #"Timpani"
- \set Staff.shortInstrumentName = #"Timp."
-
- R1*6 c1\f R1*4
-}
-
-violinoI = \relative c' {
- \set Staff.midiInstrument = #"violin"
- \set Staff.instrumentName = #"Violino I "
- \set Staff.shortInstrumentName = #"Vl. I "
-
- R1*7 c1\f R1*3
-}
-
-violinoII = \relative c' {
- \set Staff.midiInstrument = #"violin"
- \set Staff.instrumentName = #"Violino II "
- \set Staff.shortInstrumentName = #"Vl. II "
-
- R1*8 c1\f R1*2
-}
-
-viola = \relative c' {
- \set Staff.midiInstrument = #"viola"
- \set Staff.instrumentName = #"Viola"
- \set Staff.shortInstrumentName = #"Vla."
-
- \clef alto
- R1*9 c1\f R1*1
-}
-
-violoncello = \relative c' {
- \set Staff.midiInstrument = #"cello"
- %\set Staff.midiInstrument = #"contrabass"
- \set Staff.instrumentName = #"Violoncello"
- \set Staff.shortInstrumentName = #"Vc."
-
- \clef bass
- R1*10 c1\f
-}
-
-
-\score {
- <<
- \new StaffGroup = "legni" <<
- \new Staff = "flauti" \flauti
- \new Staff = "oboi" \oboi
- \new Staff = "clarinetti" \clarinetti
- \new Staff = "fagotti" \fagotti
- >>
- \new StaffGroup = "ottoni" <<
- \new Staff = "corni" \corni
- \new Staff = "trombe" \trombe
- >>
- \new StaffGroup = "timpani" <<
- \new Staff = "timpani" \timpani
- {
- \skip 1
- % Hmm: this forces a staff-bracket, that's good!
- % However, I can't find where is decided on staff-bracket yes/no
- }
- >>
- \new StaffGroup = "archi" <<
- \new GrandStaff = "violini" <<
- \new Staff = "violino1" \violinoI
- \new Staff = "violino2" \violinoII
- >>
- \new Staff = "viola" \viola
- \new Staff = "violoncello" \violoncello
- >>
- >>
-
- \layout {
- \layoutSixteen
- indent=100.0\mm
- line-width=150.0\mm
- \context {
- \RemoveEmptyStaffContext
- }
- }
-
- \midi {
- \context {
- \Score
- tempoWholesPerMinute = #(ly:make-moment 60 1)
- }
- }
-
-
-}
-
-
else if (scm_is_pair (alteration_def))
return ly_scm2rational (scm_car (alteration_def));
else if (alteration_def == SCM_BOOL_F)
- return 0;
+ return Rational (0);
else
assert (0);
- return 0;
+ return Rational (0);
}
bool
audio_column_ = 0;
}
-Audio_note::Audio_note (Pitch p, Moment m, bool tie_event, int transposing_i)
+Audio_note::Audio_note (Pitch p, Moment m, bool tie_event, Pitch transposing)
{
pitch_ = p;
length_mom_ = m;
tied_ = 0;
- transposing_ = transposing_i;
+ transposing_ = transposing;
tie_event_ = tie_event;
}
volume_ = volume;
}
-Audio_tempo::Audio_tempo (int per_minute_4_i)
+Audio_tempo::Audio_tempo (int per_minute_4)
{
- per_minute_4_ = per_minute_4_i;
+ per_minute_4_ = per_minute_4;
}
Audio_time_signature::Audio_time_signature (int beats, int one_beat)
{
if (start_moment_.grace_part_)
{
- start_moment_.main_part_ =
- start_moment_.grace_part_;
+ start_moment_.main_part_ = start_moment_.grace_part_;
start_moment_.grace_part_ = 0;
}
}
SCM_ASSERT_TYPE (l, list, SCM_ARG1, __FUNCTION__, "listener");
SCM_ASSERT_TYPE (d, disp, SCM_ARG2, __FUNCTION__, "dispatcher");
- for (int arg=SCM_ARG3; scm_is_pair (cl); cl = scm_cdr (cl), arg++)
+ for (int arg = SCM_ARG3; scm_is_pair (cl); cl = scm_cdr (cl), arg++)
{
- SCM_ASSERT_TYPE (scm_symbol_p (cl), cl, arg, __FUNCTION__, "symbol");
- d->add_listener (*l, scm_car (cl));
+ SCM sym = scm_car (cl);
+ SCM_ASSERT_TYPE (scm_is_symbol (sym), sym, arg, __FUNCTION__, "symbol");
+ d->add_listener (*l, sym);
}
return SCM_UNDEFINED;
}
Audio_note *p = new Audio_note (*pit, get_event_length (n),
- tie_event, 0);
+ tie_event, Pitch (0, 0, 0));
Audio_element_info info (p, n);
announce_element (info);
notes_.push_back (p);
"(whole, half, quarter, etc.) and a number of augmentation\n"
"dots. \n")
{
- SCM_ASSERT_TYPE (scm_integer_p (length) == SCM_BOOL_T,
+ SCM_ASSERT_TYPE (scm_is_integer (length),
length, SCM_ARG1, __FUNCTION__, "integer");
int dots = 0;
if (dotcount != SCM_UNDEFINED)
{
- SCM_ASSERT_TYPE (scm_integer_p (dotcount) == SCM_BOOL_T,
+ SCM_ASSERT_TYPE (scm_is_integer (dotcount),
dotcount, SCM_ARG2, __FUNCTION__, "integer");
dots = scm_to_int (dotcount);
}
1, 1, 0, (SCM file_name, SCM mode),
"Redirect stderr to FILE-NAME, opened with MODE.")
{
- SCM_ASSERT_TYPE (scm_string_p (file_name), file_name, SCM_ARG1,
+ SCM_ASSERT_TYPE (scm_is_string (file_name), file_name, SCM_ARG1,
__FUNCTION__, "file_name");
char const *m = "w";
if (mode != SCM_UNDEFINED && scm_string_p (mode))
class Audio_note : public Audio_item
{
public:
- Audio_note (Pitch p, Moment m, bool tie_event, int transposing);
+ Audio_note (Pitch p, Moment m, bool tie_event, Pitch transposition);
void tie_to (Audio_note *);
Pitch pitch_;
Moment length_mom_;
- int transposing_;
+ Pitch transposing_;
+
Audio_note *tied_;
bool tie_event_;
};
Rational tone_pitch () const;
int rounded_semitone_pitch () const;
int rounded_quartertone_pitch () const;
-
+ Pitch negated () const;
string to_string () const;
DECLARE_SCHEME_CALLBACK (less_p, (SCM a, SCM b));
DECLARE_UNSMOB (Score, score);
-void default_rendering (SCM, SCM, SCM, SCM, SCM, SCM);
SCM ly_render_output (SCM, SCM);
SCM ly_run_translator (SCM, SCM, SCM);
public:
Stream_event ();
VIRTUAL_COPY_CONSTRUCTOR (Stream_event, Stream_event);
- // todo: remove unneeded constructors
+
Stream_event (SCM event_class, SCM mutable_props=SCM_EOL);
Stream_event (SCM class_name, Input *);
- Stream_event (Stream_event *ev);
Input *origin () const;
void set_spot (Input *i);
bool internal_in_event_class (SCM class_name);
+ virtual SCM copy_mutable_properties () const;
+
DECLARE_SCHEME_CALLBACK (undump, (SCM));
DECLARE_SCHEME_CALLBACK (dump, (SCM));
Stream_event *unsmob_stream_event (SCM);
DECLARE_TYPE_P (Stream_event);
+SCM ly_event_deep_copy (SCM);
#endif /* STREAM_EVENT_HH */
if (scm_is_pair (alist))
{
- r->origin ()->warning ("No ordering for key signature alterations");
+ bool warn = false;
for (SCM s = alist; scm_is_pair (s); s = scm_cdr (s))
if (ly_scm2rational (scm_cdar (s)))
- accs = scm_cons (scm_car (s), accs);
+ {
+ warn = true;
+ accs = scm_cons (scm_car (s), accs);
+ }
+
+ if (warn)
+ r->origin ()->warning ("No ordering for key signature alterations");
}
context ()->set_property ("keySignature", accs);
Pitch key_do (0,
scm_to_int (scm_caar (pitchlist)),
- scm_to_int (scm_cdar (pitchlist)));
+ ly_scm2rational (scm_cdar (pitchlist)));
Pitch c_do (0, 0, 0);
int
Midi_note::get_fine_tuning () const
{
- Rational tune = audio_->pitch_.tone_pitch () * Rational (2);
+ Rational tune = (audio_->pitch_.tone_pitch ()
+ + audio_->transposing_.tone_pitch ()) * Rational (2);
tune -= Rational (get_semitone_pitch ());
tune *= 100;
int
Midi_note::get_semitone_pitch () const
{
- return int (rint (double (audio_->pitch_.tone_pitch () * Rational (2, 1))))
- + audio_->transposing_;
+ return int (double ((audio_->pitch_.tone_pitch ()
+ + audio_->transposing_.tone_pitch ()) * Rational (2)));
}
string
}
/*
-TODO: make transposition non-destructive
+ This mutates alist. Hence, make sure that it is not changed
*/
SCM
transpose_mutable (SCM alist, Pitch delta)
{
if (note_evs_.size ())
{
- int transposing = 0;
-
+ Pitch transposing;
SCM prop = get_property ("instrumentTransposition");
if (unsmob_pitch (prop))
- transposing = unsmob_pitch (prop)->rounded_semitone_pitch ();
+ transposing = *unsmob_pitch (prop);
while (note_evs_.size ())
{
}
Audio_note *p = new Audio_note (*pitp, get_event_length (n),
- tie_event, - transposing);
+ tie_event, transposing.negated ());
Audio_element_info info (p, n);
announce_element (info);
notes_.push_back (p);
return ell;
}
-LY_DEFINE (ly_layout_def_p, "ly:layout-def?",
+LY_DEFINE (ly_output_def_p, "ly:output-def?",
1, 0, 0, (SCM def),
"Is @var{def} a layout definition?")
{
{
if (scm_is_pair (performances_))
{
- SCM proc = ly_lily_module_constant ("paper-book-write-midis");
-
- scm_call_2 (proc, self_scm (), output_channel);
+ SCM proc = ly_lily_module_constant ("write-performances-midis");
+
+ scm_call_2 (proc, performances (), output_channel);
}
if (scores_ == SCM_EOL)
return p.smobbed_copy ();
}
+LY_DEFINE (ly_pitch_negate, "ly:pitch-negate", 1, 0, 0,
+ (SCM p),
+ "Negate @var{p}.")
+{
+ Pitch *pp = unsmob_pitch (p);
+ SCM_ASSERT_TYPE (pp, p, SCM_ARG1, __FUNCTION__, "Pitch");
+ return pp->negated ().smobbed_copy ();
+}
+
LY_DEFINE (ly_pitch_steps, "ly:pitch-steps", 1, 0, 0,
(SCM p),
"Number of steps counted from middle C of the pitch @var{p}.")
Rational FLAT_ALTERATION (-1, 2);
Rational SHARP_ALTERATION (1, 2);
+
+Pitch
+Pitch::negated () const
+{
+ return pitch_interval (*this, Pitch ());
+}
mp = *me_pitch;
Pitch diff = pitch_interval (qp, mp);
-
+ ev = ev->clone ();
+
SCM props = transpose_mutable (ev->get_property_alist (true), diff);
ev = new Stream_event (ev->get_property ("class"), props);
transposed_musics_ = scm_cons (ev->unprotect (), transposed_musics_);
"\n"
" @var{callback} should take exactly one argument." )
{
- SCM_ASSERT_TYPE (scm_procedure_p (callback), callback, SCM_ARG1, __FUNCTION__, "procedure");
+ SCM_ASSERT_TYPE (ly_is_procedure (callback), callback, SCM_ARG1, __FUNCTION__, "procedure");
Scheme_listener *l = new Scheme_listener (callback);
SCM listener = GET_LISTENER (l->call).smobbed_copy ();
l->unprotect ();
#include "output-def.hh"
#include "global-context.hh"
#include "lilypond-key.hh"
+#include "music-output.hh"
+#include "paper-score.hh"
+#include "paper-book.hh"
LY_DEFINE (ly_make_score, "ly:make-score",
1, 0, 0,
return score->unprotect ();
}
+LY_DEFINE (ly_score_output_defs, "ly:score-output-defs",
+ 1, 0, 0, (SCM score),
+ "All output defs in a score.")
+{
+ Score *sc = unsmob_score (score);
+ SCM_ASSERT_TYPE (sc, score, SCM_ARG1, __FUNCTION__, "score");
+
+ SCM l = SCM_EOL;
+ for (vsize i = 0; i < sc->defs_.size (); i++)
+ l = scm_cons (sc->defs_[i]->self_scm(), l);
+ return scm_reverse_x (l, SCM_EOL);
+}
+
+
+
+LY_DEFINE (ly_score_header, "ly:score-header",
+ 1, 0, 0, (SCM score),
+ "return score header.")
+{
+ Score *sc = unsmob_score (score);
+ SCM_ASSERT_TYPE (sc, score, SCM_ARG1, __FUNCTION__, "score");
+ return sc->header_;
+}
+
+
+LY_DEFINE (ly_score_music, "ly:score-music",
+ 1, 0, 0, (SCM score),
+ "return score music.")
+{
+ Score *sc = unsmob_score (score);
+ SCM_ASSERT_TYPE (sc, score, SCM_ARG1, __FUNCTION__, "score");
+ return sc->get_music ();
+}
+
+LY_DEFINE (ly_score_error_p, "ly:score-error?",
+ 1, 0, 0, (SCM score),
+ "Was there an error in the score?")
+{
+ Score *sc = unsmob_score (score);
+ SCM_ASSERT_TYPE (sc, score, SCM_ARG1, __FUNCTION__, "score");
+ return scm_from_bool (sc->error_found_);
+}
+
LY_DEFINE (ly_score_embedded_format, "ly:score-embedded-format",
2, 1, 0, (SCM score, SCM layout, SCM key),
"Run @var{score} through @var{layout}, an output definition, "
return output;
}
-LY_DEFINE (ly_score_process, "ly:score-process",
- 5, 0, 0,
- (SCM score_smob,
- SCM default_header,
- SCM default_paper,
- SCM default_layout,
- SCM basename),
- "Print score without page-layout: just print the systems.")
+LY_DEFINE (ly_score_process, "ly:render-music-as-systems",
+ 5, 0, 0, (SCM music,
+ SCM outdef,
+ SCM book_outputdef,
+ SCM header,
+ SCM outname),
+ "Create output using a default \\book block. ")
{
- Score *score = unsmob_score (score_smob);
+ SCM_ASSERT_TYPE(unsmob_music(music), music,
+ SCM_ARG1, __FUNCTION__, "music");
+ SCM_ASSERT_TYPE(unsmob_output_def (outdef), outdef,
+ SCM_ARG2, __FUNCTION__, "output def");
+ SCM_ASSERT_TYPE(unsmob_output_def (book_outputdef), book_outputdef,
+ SCM_ARG3, __FUNCTION__, "output def");
+ SCM_ASSERT_TYPE(scm_is_string (outname), outname,
+ SCM_ARG5, __FUNCTION__, "string");
+
+
+ SCM scaled_def = outdef;
+ SCM scaled_bookdef = book_outputdef;
+
+ Output_def *bpd = unsmob_output_def (book_outputdef);
+
+ /* ugh . */
+ assert (bpd->c_variable ("is-paper") == SCM_BOOL_T);
+
+ Real scale = scm_to_double (bpd->c_variable ("output-scale"));
+
+ Output_def *def = scale_output_def (unsmob_output_def (outdef), scale);
+ Output_def *bdef = scale_output_def (bpd, scale);
+ def->parent_ = bdef;
+
+ scaled_def = def->self_scm ();
+ scaled_bookdef = bdef->self_scm ();
- SCM_ASSERT_TYPE (score, score_smob, SCM_ARG1, __FUNCTION__, "score");
+ def->unprotect ();
+ bdef->unprotect ();
- // allow header to be undefined.
- SCM_ASSERT_TYPE (unsmob_output_def (default_paper),
- default_header, SCM_ARG3, __FUNCTION__, "\\paper block");
- SCM_ASSERT_TYPE (unsmob_output_def (default_layout),
- default_header, SCM_ARG4, __FUNCTION__, "\\layout block");
+ SCM context = ly_run_translator (music, scaled_def, SCM_BOOL_F);
+ SCM output_as_scm = ly_format_output (context);
+ Music_output *output = unsmob_music_output (output_as_scm);
- Object_key *key = new Lilypond_general_key (0, score->user_key_, 0);
+ Paper_score *pscore = dynamic_cast<Paper_score *> (output);
+ assert (pscore);
- if (score->error_found_)
- return SCM_UNSPECIFIED;
+ /* ugh, this is strange, Paper_book without a Book object. */
+ Paper_book *paper_book = new Paper_book ();
+ paper_book->header_ = header;
+ paper_book->paper_ = unsmob_output_def (scaled_bookdef);
- SCM header = ly_is_module (score->header_)
- ? score->header_
- : default_header;
+ if (ly_is_module (header))
+ paper_book->add_score (header);
- for (vsize i = 0; i < score->defs_.size (); i++)
- default_rendering (score->get_music (), score->defs_[i]->self_scm (),
- default_paper, header, basename, key->self_scm ());
+ paper_book->add_score (pscore->self_scm ());
+ paper_book->classic_output (outname);
+ paper_book->unprotect ();
- if (score->defs_.empty ())
- {
- default_rendering (score->get_music (),
- default_layout,
- default_paper,
- header, basename, key->self_scm ());
- }
+ scm_remember_upto_here_1 (scaled_def);
+ scm_remember_upto_here_1 (scaled_bookdef);
- key->unprotect ();
return SCM_UNSPECIFIED;
}
ly_module_copy (header_, s.header_);
}
-void
-default_rendering (SCM music, SCM outdef,
- SCM book_outputdef,
- SCM header,
- SCM outname,
- SCM key)
-{
- SCM scaled_def = outdef;
- SCM scaled_bookdef = book_outputdef;
-
- Output_def *bpd = unsmob_output_def (book_outputdef);
-
- /* ugh. */
- if (bpd->c_variable ("is-paper") == SCM_BOOL_T)
- {
- Real scale = scm_to_double (bpd->c_variable ("output-scale"));
-
- Output_def *def = scale_output_def (unsmob_output_def (outdef), scale);
- Output_def *bdef = scale_output_def (bpd, scale);
- def->parent_ = bdef;
-
- scaled_def = def->self_scm ();
- scaled_bookdef = bdef->self_scm ();
-
- def->unprotect ();
- bdef->unprotect ();
- }
-
- SCM context = ly_run_translator (music, scaled_def, key);
-
- SCM output_as_scm = ly_format_output (context);
- Music_output *output = unsmob_music_output (output_as_scm);
-
- if (Paper_score *pscore = dynamic_cast<Paper_score *> (output))
- {
- /* ugh, this is strange, Paper_book without a Book object. */
- Paper_book *paper_book = new Paper_book ();
- paper_book->header_ = header;
- paper_book->paper_ = unsmob_output_def (scaled_bookdef);
-
- if (ly_is_module (header))
- paper_book->add_score (header);
-
- paper_book->add_score (pscore->self_scm ());
- paper_book->classic_output (outname);
- paper_book->unprotect ();
- }
-
- scm_remember_upto_here_1 (scaled_def);
- scm_remember_upto_here_1 (output_as_scm);
- scm_remember_upto_here_1 (scaled_bookdef);
-}
/*
Format score, return list of Music_output objects.
"Creates a stream event of class @var{cl} with the given mutable property list.\n" )
{
SCM_ASSERT_TYPE (scm_is_symbol (cl), cl, SCM_ARG1, __FUNCTION__, "symbol");
- if (proplist != SCM_UNDEFINED)
- {
- SCM_ASSERT_TYPE (scm_list_p (proplist), proplist, SCM_ARG2, __FUNCTION__, "association list");
- }
- else
+
+ /* should be scm_list_p, but scm_list_p is expensive. */
+ SCM_ASSERT_TYPE (scm_is_pair (proplist), proplist, SCM_ARG2, __FUNCTION__, "association list");
+
+ if (proplist == SCM_UNDEFINED)
proplist = SCM_EOL;
+
Stream_event *e = new Stream_event (cl, proplist);
return e->unprotect ();
}
SCM_ASSERT_TYPE (sc, ev, SCM_ARG1, __FUNCTION__, "event");
return ly_prob_set_property_x (ev, sym, val);
}
+
+LY_DEFINE (ly_event_deep_copy, "ly:event-deep-copy",
+ 1, 0, 0, (SCM m),
+ "Copy @var{m} and all sub expressions of @var{m}")
+{
+ SCM copy = m;
+ if (Stream_event *ev = unsmob_stream_event (m))
+ {
+ ev = ev->clone ();
+ copy = ev->unprotect ();
+ }
+ else if (scm_is_pair (m))
+ copy = scm_cons (ly_event_deep_copy (scm_car (m)),
+ ly_event_deep_copy (scm_cdr (m)));
+
+ return copy;
+}
set_spot (origin);
}
-Stream_event::Stream_event (Stream_event *ev)
- : Prob (ly_symbol2scm ("Stream_event"), SCM_EOL)
+SCM
+Stream_event::copy_mutable_properties () const
{
- mutable_property_alist_ = scm_copy_tree (ev->mutable_property_alist_);
- immutable_property_alist_ = ev->immutable_property_alist_;
+ return ly_event_deep_copy (mutable_property_alist_);
}
Input *
"dash-period "
"details "
"direction "
+ "head-direction "
"line-thickness "
"quant-score "
"staff-position "
(context-spec-music
(make-property-set 'instrumentTransposition
- (ly:pitch-diff (ly:make-pitch 0 0 0) (pitch-of-note pitch-note)))
- 'Staff
-))
+ (ly:pitch-negate (pitch-of-note pitch-note)))
+ 'Staff))
tweak = #(define-music-function (parser location sym val arg)
(symbol? scheme? ly:music?)
(instrumentEqualizer ,procedure? "
Function taking a string (instrument name), and returning a (@var{min} . @var{max}) pair of numbers for the loudness range of the instrument.
")
+
+ ;; the definition is reversed wrt traditional transposition
+ ;; this because \transpose { \transposition .. } won't work
+ ;; otherwise.
(instrumentTransposition ,ly:pitch? "Defines the transposition of
the instrument. Its value is the pitch that sounds like middle C. This
is used to transpose the MIDI output, and @code{\\quote}s.")
"A ligature"
'())
+(ly:add-interface
+ 'key-cancellation-interface
+ "A key cancellation"
+ '())
+
(ly:add-interface
'ligature-bracket-interface
"A bracket indicating a ligature in the original edition"
(define-public default-script-alist '())
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; parser <-> output hooks.
+
;; parser stuff.
(define-public (print-music-as-book parser music)
(let* ((head (ly:parser-lookup parser '$defaultheader))
parser 'toplevel-scores
(cons score (ly:parser-lookup parser 'toplevel-scores))))
-
(define-public (scorify-music music parser)
(for-each (lambda (func)
(define-public (print-score-with-defaults parser score)
(let*
((paper (ly:parser-lookup parser '$defaultpaper))
- (layout (ly:parser-lookup parser '$defaultlayout))
- (header (ly:parser-lookup parser '$defaultheader))
(count (ly:parser-lookup parser 'output-count))
(base (ly:parser-output-name parser)))
(set! base (format #f "~a-~a" base count)))
(ly:parser-define! parser 'output-count (1+ count))
- (ly:score-process score header paper layout base)
- ))
+
+ (if (not (ly:score-error? score))
+ (let*
+ ((header (ly:score-header score))
+ (output-defs (ly:score-output-defs score))
+ (layout-defs (filter (lambda (d) (eq? #t (ly:output-def-lookup d 'is-layout)))
+ output-defs))
+ (midi-defs (filter (lambda (d) (eq? #t (ly:output-def-lookup d 'is-midi)))
+ output-defs))
+ (music (ly:score-music score))
+ (layout-def (if (null? layout-defs)
+ (ly:parser-lookup parser '$defaultlayout)
+ (car layout-defs))))
+
+ (if (not (module? header))
+ (set! header (ly:parser-lookup parser '$defaultheader)))
+
+ (ly:render-music-as-systems
+ music layout-def paper header base)
+
+ (if (pair? midi-defs)
+ (ly:performance-write (ly:format-output (ly:run-translator music (car midi-defs)))
+ (format #f "~a.midi" base)
+ ))
+
+ ))))
+
+
+
;;;;;;;;;;;;;;;;
(define-public (alterations-in-key pitch-list)
"Count number of sharps minus number of flats"
- (/ (apply + (map cdr pitch-list)) 2))
+
+ (* (apply + (map cdr pitch-list)) 2))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
-(define-public (paper-book-write-midis paper-book basename)
+(define-public (write-performances-midis performances basename)
(let
loop
- ((perfs (ly:paper-book-performances paper-book))
+ ((perfs performances)
(count 0))
ly:output-description
ly:paper-book?
ly:prob-property
- ly:layout-def?
+ ly:output-def?
ly:paper-get-font
ly:paper-get-number
ly:paper-system?