From b2bbb891206392489f112612a00d5d0748a0fd0b Mon Sep 17 00:00:00 2001 From: hanwen Date: Thu, 5 Feb 2004 19:05:25 +0000 Subject: [PATCH] new file: perform drum notes. --- ChangeLog | 2 + input/mutopia/F.Schubert/morgenlied.ly | 5 +- lily/accidental-engraver.cc | 4 -- lily/note-performer.cc | 6 +- lily/parser.yy | 2 +- lily/staff-performer.cc | 2 - ly/drumpitch-init.ly | 77 ++++++++++++++++++++++++++ ly/performer-init.ly | 6 +- scm/lily.scm | 22 ++++++-- scm/midi.scm | 4 +- 10 files changed, 109 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6fa94cc7d1..a3c4d5debd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2004-02-05 Han-Wen Nienhuys + * lily/drum-note-performer.cc: new file: perform drum notes. + * VERSION (PACKAGE_NAME): release 2.1.19. 2004-02-05 Jan Nieuwenhuizen diff --git a/input/mutopia/F.Schubert/morgenlied.ly b/input/mutopia/F.Schubert/morgenlied.ly index 91cafca72d..a8e1f08550 100644 --- a/input/mutopia/F.Schubert/morgenlied.ly +++ b/input/mutopia/F.Schubert/morgenlied.ly @@ -152,10 +152,8 @@ pianoLH = \notes \relative c'' \repeat volta 2 { \new Staff << \context Staff \modernAccidentals \melody >> - \new LyricsVoice << \lyricsto "singer" \new LyricsVoice \firstVerse \lyricsto "singer" \new LyricsVoice \secondVerse - >> \new PianoStaff << \property PianoStaff.instrument = \markup { \bold @@ -185,4 +183,7 @@ pianoLH = \notes \relative c'' \repeat volta 2 { minimumVerticalExtent = #'(-3. . 6) } } + \midi { + \tempo 4 = 70 + } } diff --git a/lily/accidental-engraver.cc b/lily/accidental-engraver.cc index f41260d6b6..c6f1f4ed54 100644 --- a/lily/accidental-engraver.cc +++ b/lily/accidental-engraver.cc @@ -21,10 +21,6 @@ /** - -FIXME: should not compute vertical positioning of accidentals, but -get them from the noteheads - The algorithm for accidentals should be documented, and made tweakable. diff --git a/lily/note-performer.cc b/lily/note-performer.cc index 02b0baceff..22df5b0fb8 100644 --- a/lily/note-performer.cc +++ b/lily/note-performer.cc @@ -47,11 +47,11 @@ Note_performer::create_audio_elements () while (note_evs_.size ()) { Music* n = note_evs_.pop (); - Pitch *pit = unsmob_pitch (n->get_mus_property ("pitch")); + SCM pit = n->get_mus_property ("pitch"); - if (pit) + if (Pitch * pitp = unsmob_pitch (pit)) { - Audio_note* p = new Audio_note (*pit, n->get_length (), transposing_i); + Audio_note* p = new Audio_note (*pitp, n->get_length (), transposing_i); Audio_element_info info (p, n); announce_element (info); notes_.push (p); diff --git a/lily/parser.yy b/lily/parser.yy index 91e83eed8d..e9024a2e7e 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -893,7 +893,7 @@ Composite_music: scm_gc_unprotect_object ($2->self_scm ()); $$ = unsmob_music (res); scm_gc_protect_object (res); - $$->set_spot (THIS->here_input()) + $$->set_spot (THIS->here_input()); } | PARTCOMBINE Music Music { static SCM proc; diff --git a/lily/staff-performer.cc b/lily/staff-performer.cc index 859a9945bb..1c5e99f066 100644 --- a/lily/staff-performer.cc +++ b/lily/staff-performer.cc @@ -93,9 +93,7 @@ Staff_performer::stop_translation_timestep () /* UGH. -> don't use eval. */ - static SCM proc; - if (!proc) proc = scm_primitive_eval (ly_symbol2scm ("percussion?")); diff --git a/ly/drumpitch-init.ly b/ly/drumpitch-init.ly index cc4ad8e7ef..bf6bca0744 100644 --- a/ly/drumpitch-init.ly +++ b/ly/drumpitch-init.ly @@ -148,6 +148,83 @@ drumPitchNames = (de . fivedown) ) +midiDrumPitches = #`( + (acousticbassdrum . ,(ly:make-pitch -3 6 NATURAL)) + (bassdrum . ,(ly:make-pitch -2 0 NATURAL)) + (hisidestick . ,(ly:make-pitch -3 6 DOUBLE-SHARP)) + (sidestick . ,(ly:make-pitch -2 0 SHARP)) + (losidestick . ,(ly:make-pitch -2 1 FLAT)) + (acousticsnare . ,(ly:make-pitch -2 1 NATURAL)) + (snare . ,(ly:make-pitch -2 2 DOUBLE-FLAT)) + (handclap . ,(ly:make-pitch -2 1 SHARP)) + (electricsnare . ,(ly:make-pitch -2 2 NATURAL)) + (lowfloortom . ,(ly:make-pitch -2 3 NATURAL)) + (closedhihat . ,(ly:make-pitch -2 3 SHARP)) + (hihat . ,(ly:make-pitch -2 4 FLAT)) + (highfloortom . ,(ly:make-pitch -2 4 NATURAL)) + (pedalhihat . ,(ly:make-pitch -2 4 SHARP)) + (lowtom . ,(ly:make-pitch -2 5 NATURAL)) + (openhihat . ,(ly:make-pitch -2 5 SHARP)) + (halfopenhihat . ,(ly:make-pitch -2 5 SHARP)) + (lowmidtom . ,(ly:make-pitch -2 6 NATURAL)) + (himidtom . ,(ly:make-pitch -1 0 NATURAL)) + (crashcymbala . ,(ly:make-pitch -1 0 SHARP)) + (crashcymbal . ,(ly:make-pitch -1 1 FLAT)) + (hightom . ,(ly:make-pitch -1 1 NATURAL)) + (ridecymbala . ,(ly:make-pitch -1 1 SHARP)) + (ridecymbal . ,(ly:make-pitch -1 2 FLAT)) + (chinesecymbal . ,(ly:make-pitch -1 2 NATURAL)) + (ridebell . ,(ly:make-pitch -1 3 NATURAL)) + (tambourine . ,(ly:make-pitch -1 3 SHARP)) + (splashcymbal . ,(ly:make-pitch -1 4 NATURAL)) + (cowbell . ,(ly:make-pitch -1 4 SHARP)) + (crashcymbalb . ,(ly:make-pitch -1 5 NATURAL)) + (vibraslap . ,(ly:make-pitch -1 5 SHARP)) + (ridecymbalb . ,(ly:make-pitch -1 6 NATURAL)) + (mutehibongo . ,(ly:make-pitch -1 6 SHARP)) + (hibongo . ,(ly:make-pitch 0 0 NATURAL)) + (openhibongo . ,(ly:make-pitch 0 1 DOUBLE-FLAT)) + (mutelobongo . ,(ly:make-pitch -1 6 DOUBLE-SHARP)) + (lobongo . ,(ly:make-pitch 0 0 SHARP)) + (openlobongo . ,(ly:make-pitch 0 1 FLAT)) + (mutehiconga . ,(ly:make-pitch 0 1 NATURAL)) + (muteloconga . ,(ly:make-pitch 0 2 DOUBLE-FLAT)) + (openhiconga . ,(ly:make-pitch 0 1 SHARP)) + (hiconga . ,(ly:make-pitch 0 2 FLAT)) + (openloconga . ,(ly:make-pitch 0 1 DOUBLE-SHARP)) + (loconga . ,(ly:make-pitch 0 2 NATURAL)) + (hitimbale . ,(ly:make-pitch 0 3 NATURAL)) + (lotimbale . ,(ly:make-pitch 0 3 SHARP)) + (hiagogo . ,(ly:make-pitch 0 4 NATURAL)) + (loagogo . ,(ly:make-pitch 0 4 SHARP)) + (cabasa . ,(ly:make-pitch 0 5 NATURAL)) + (maracas . ,(ly:make-pitch 0 5 SHARP)) + (shortwhistle . ,(ly:make-pitch 0 6 NATURAL)) + (longwhistle . ,(ly:make-pitch 1 0 NATURAL)) + (shortguiro . ,(ly:make-pitch 1 0 SHARP)) + (longguiro . ,(ly:make-pitch 1 1 NATURAL)) + (guiro . ,(ly:make-pitch 1 0 DOUBLE-SHARP)) + (claves . ,(ly:make-pitch 1 1 SHARP)) + (hiwoodblock . ,(ly:make-pitch 1 2 NATURAL)) + (lowoodblock . ,(ly:make-pitch 1 3 NATURAL)) + (mutecuica . ,(ly:make-pitch 1 3 SHARP)) + (opencuica . ,(ly:make-pitch 1 4 NATURAL)) + (mutetriangle . ,(ly:make-pitch 1 4 SHARP)) + (triangle . ,(ly:make-pitch 1 4 DOUBLE-SHARP)) + (opentriangle . ,(ly:make-pitch 1 5 NATURAL)) + + ;; "transposing" pitches: + (oneup . ,(ly:make-pitch 0 1 NATURAL)) + (twoup . ,(ly:make-pitch 0 2 NATURAL)) + (threeup . ,(ly:make-pitch 0 3 NATURAL)) + (fourup . ,(ly:make-pitch 0 4 NATURAL)) + (fiveup . ,(ly:make-pitch 0 5 NATURAL)) + (onedown . ,(ly:make-pitch -1 6 NATURAL)) + (twodown . ,(ly:make-pitch -1 5 NATURAL)) + (threedown . ,(ly:make-pitch -1 4 NATURAL)) + (fourdown . ,(ly:make-pitch -1 3 NATURAL)) + (fivedown . ,(ly:make-pitch -1 2 NATURAL)) +) #(map diff --git a/ly/performer-init.ly b/ly/performer-init.ly index 244f0eb5e4..9255018689 100644 --- a/ly/performer-init.ly +++ b/ly/performer-init.ly @@ -16,6 +16,7 @@ \translator { \StaffContext \name DrumStaff + midiInstrument = #"drums" \accepts DrumVoice } @@ -30,6 +31,8 @@ \translator { \VoiceContext + \remove "Note_performer" + \consists "Drum_note_performer" \name DrumVoice } @@ -94,13 +97,14 @@ \accepts RhythmicStaff \accepts ChordNames \accepts FiguredBass - + \accepts LyricsVoice \alias "Timing" \consists "Timing_translator" \consists "Swallow_performer" dynamicAbsoluteVolumeFunction = #default-dynamic-absolute-volume instrumentEqualizer = #default-instrument-equalizer + drumPitchTable = #(alist->hash-table midiDrumPitches) } diff --git a/scm/lily.scm b/scm/lily.scm index c10fe8241c..5a73f51553 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -168,13 +168,23 @@ (if (not (defined? 'hash-table?)) ; guile 1.6 compat - (define hash-table? vector?)) + (begin + (define hash-table? vector?) -(define-public (hash-table->alist t) - "Convert table t to list" - (apply append - (vector->list t) - )) + (define-public (hash-table->alist t) + "Convert table t to list" + (apply append + (vector->list t) + ))) + + ;; native hashtabs. + (begin + (define-public (hash-table->alist t) + + (hash-fold (lambda (k v acc) (acons k v acc)) + '() t) + ) + )) ;; todo: code dup with C++. (define-public (alist->hash-table l) diff --git a/scm/midi.scm b/scm/midi.scm index b1b10fd05c..63da9d1a4f 100644 --- a/scm/midi.scm +++ b/scm/midi.scm @@ -266,8 +266,8 @@ returns whether the instrument should use midi channel 9 (entry (assoc inst instrument-names-alist)) ) (and entry (>= (cdr entry) 32768)) - ) -) + )) + (define-public (midi-program instrument) " returns the program of the instrument -- 2.39.2