From: fred Date: Wed, 27 Mar 2002 00:33:13 +0000 (+0000) Subject: lilypond-1.3.108 X-Git-Tag: release/1.5.59~1112 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=c7d278638a85b695c051e393dbb17ad58ac52028;p=lilypond.git lilypond-1.3.108 --- diff --git a/lily/audio-item.cc b/lily/audio-item.cc index b4d358c7f7..05b101eabd 100644 --- a/lily/audio-item.cc +++ b/lily/audio-item.cc @@ -20,7 +20,7 @@ Audio_item::Audio_item () audio_column_l_ = 0; } -Audio_note::Audio_note (Musical_pitch p, Moment m, int transposing_i) +Audio_note::Audio_note (Pitch p, Moment m, int transposing_i) { pitch_ = p; length_mom_ = m; diff --git a/lily/auto-change-iterator.cc b/lily/auto-change-iterator.cc index 183c5fece4..5db9f69033 100644 --- a/lily/auto-change-iterator.cc +++ b/lily/auto-change-iterator.cc @@ -77,11 +77,11 @@ Auto_change_iterator::change_to (Music_iterator *it, String to_type, PRECONDITION: this->ok() holds. */ -Array +Array Auto_change_iterator::pending_pitch (Moment m) const { Music_iterator * iter = child_iter_p_ ->clone (); - Array ps; + Array ps; while (1) { SCM muses = iter->get_music (m); @@ -112,12 +112,12 @@ Auto_change_iterator::process (Moment m) first we get the pitches, then we do the real work. Music_wrapper_iterator::process() might process (and throw away) pitches we need. */ - Array ps = pending_pitch (m); + Array ps = pending_pitch (m); Music_wrapper_iterator::process (m); if (ps.size ()) { - Musical_pitch p = ps[0]; + Pitch p = ps[0]; Direction s = Direction (sign(p.steps ())); if (s != where_dir_) { diff --git a/lily/chord-name-engraver.cc b/lily/chord-name-engraver.cc index 50ece53329..877d7c988c 100644 --- a/lily/chord-name-engraver.cc +++ b/lily/chord-name-engraver.cc @@ -16,7 +16,8 @@ #include "main.hh" #include "dimensions.hh" #include "item.hh" -#include "musical-pitch.hh" +#include "pitch.hh" +#include "protected-scm.hh" class Chord_name_engraver : public Engraver { @@ -32,14 +33,16 @@ protected: private: void create_chord_name (); - - Array pitch_arr_; + Item* chord_name_p_; - Chord* chord_p_; - Chord* last_chord_p_; - Tonic_req* tonic_req_; - Inversion_req* inversion_req_; - Bass_req* bass_req_; + Protected_scm pitches_; + + Protected_scm chord_; + Protected_scm last_chord_; + + Protected_scm tonic_req_; + Protected_scm inversion_req_; + Protected_scm bass_req_; }; ADD_THIS_TRANSLATOR (Chord_name_engraver); @@ -47,18 +50,19 @@ ADD_THIS_TRANSLATOR (Chord_name_engraver); Chord_name_engraver::Chord_name_engraver () { chord_name_p_ = 0; - tonic_req_ = 0; - inversion_req_ = 0; - bass_req_ = 0; - chord_p_ = 0; - last_chord_p_ = 0; + pitches_ = SCM_EOL; + tonic_req_ = SCM_EOL; + inversion_req_ = SCM_EOL; + bass_req_ = SCM_EOL; + chord_ = SCM_EOL; + last_chord_ = SCM_EOL; } void Chord_name_engraver::acknowledge_element (Score_element_info i) { if (Note_req* n = dynamic_cast (i.req_l_)) - pitch_arr_.push (* unsmob_pitch (n->get_mus_property ("pitch"))); + pitches_ = gh_cons (n->get_mus_property ("pitch"), pitches_); } bool @@ -66,22 +70,22 @@ Chord_name_engraver::do_try_music (Music* m) { if (Note_req* n = dynamic_cast (m)) { - pitch_arr_.push (* unsmob_pitch (n->get_mus_property ("pitch"))); + pitches_ = gh_cons (n->get_mus_property ("pitch"), pitches_); return true; } if (Tonic_req* t = dynamic_cast (m)) { - tonic_req_ = t; + tonic_req_ = t->get_mus_property ("pitch"); return true; } if (Inversion_req* i = dynamic_cast (m)) { - inversion_req_ = i; + inversion_req_ = i->get_mus_property ("pitch"); return true; } if (Bass_req* b = dynamic_cast (m)) { - bass_req_ = b; + bass_req_ = b->get_mus_property ("pitch"); return true; } return false; @@ -90,47 +94,41 @@ Chord_name_engraver::do_try_music (Music* m) void Chord_name_engraver::do_process_music () { - if (chord_name_p_) - return; - - if (!pitch_arr_.size ()) - return; - - bool find_inversion_b = false; - SCM chord_inversion = get_property ("chordInversion"); - if (gh_boolean_p (chord_inversion)) - find_inversion_b = gh_scm2bool (chord_inversion); - - chord_p_ = new Chord (to_chord (pitch_arr_, - tonic_req_, inversion_req_, bass_req_, - find_inversion_b)); - - create_chord_name (); - announce_element (chord_name_p_, 0); - SCM s = get_property ("drarnChords"); //FIXME! - if (to_boolean (s) && last_chord_p_ && !compare (chord_p_, last_chord_p_)) - chord_name_p_->set_elt_property ("begin-of-line-visible", SCM_BOOL_T); + if (!chord_name_p_ && pitches_ != SCM_EOL) + { + bool find_inversion_b = false; + SCM chord_inversion = get_property ("chordInversion"); + if (gh_boolean_p (chord_inversion)) + find_inversion_b = gh_scm2bool (chord_inversion); + + chord_ = Chord::pitches_and_requests_to_chord (pitches_, + tonic_req_, + inversion_req_, + bass_req_, + find_inversion_b); + + create_chord_name (); + announce_element (chord_name_p_, 0); + SCM s = get_property ("drarnChords"); //FIXME! + if (to_boolean (s) && last_chord_ != SCM_EOL && + gh_equal_p (chord_, last_chord_)) + chord_name_p_->set_elt_property ("begin-of-line-visible", SCM_BOOL_T); + } } void Chord_name_engraver::create_chord_name () { - assert (chord_p_); chord_name_p_ = new Item (get_property ("ChordName")); - /* - Hmm, why not represent complete chord as list? - ((tonic third fifth) (inversion bass)) - */ - SCM plist = SCM_EOL; - for (int i= chord_p_->pitch_arr_.size (); i--; ) - plist = gh_cons (chord_p_->pitch_arr_[i].smobbed_copy (), plist); - - chord_name_p_->set_elt_property ("pitches", plist); - if (chord_p_->inversion_b_) - chord_name_p_->set_elt_property ("inversion", - chord_p_->inversion_pitch_.smobbed_copy ()); - if (chord_p_->bass_b_) - chord_name_p_->set_elt_property ("bass", chord_p_->bass_pitch_.smobbed_copy ()); + + SCM pitches = gh_car (chord_); + SCM modifiers = gh_cdr (chord_); + SCM inversion = gh_car (modifiers); + SCM bass = gh_cdr (modifiers); + /* Hmm, maybe chord-name should use (pitches (inversion . base)) too? */ + chord_name_p_->set_elt_property ("pitches", pitches); + chord_name_p_->set_elt_property ("inversion", inversion); + chord_name_p_->set_elt_property ("inversion", bass); } void @@ -140,13 +138,13 @@ Chord_name_engraver::do_pre_move_processing () { typeset_element (chord_name_p_); } - pitch_arr_.clear (); chord_name_p_ = 0; - tonic_req_ = 0; - inversion_req_ = 0; - bass_req_ = 0; - delete last_chord_p_; - last_chord_p_ = chord_p_; - chord_p_ = 0; + + pitches_ = SCM_EOL; + tonic_req_ = SCM_EOL; + inversion_req_ = SCM_EOL; + bass_req_ = SCM_EOL; + last_chord_ = chord_; + chord_ = SCM_EOL; } diff --git a/lily/command-request.cc b/lily/command-request.cc index aef049e980..0b615681a4 100644 --- a/lily/command-request.cc +++ b/lily/command-request.cc @@ -49,7 +49,7 @@ Key_change_req::do_equal_b (Request const * req) const void -Key_change_req::transpose (Musical_pitch p) +Key_change_req::transpose (Pitch p) { SCM newlist = SCM_EOL; SCM pa = get_mus_property ("pitch-alist"); @@ -59,7 +59,7 @@ Key_change_req::transpose (Musical_pitch p) SCM alter = gh_cdar (s); if (gh_pair_p (key)) { - Musical_pitch orig (gh_scm2int (gh_car (key)), + Pitch orig (gh_scm2int (gh_car (key)), gh_scm2int (gh_cdr (key)), gh_scm2int (alter)); @@ -73,7 +73,7 @@ Key_change_req::transpose (Musical_pitch p) } else if (gh_number_p (key)) { - Musical_pitch orig (0, gh_scm2int (key), gh_scm2int (alter)); + Pitch orig (0, gh_scm2int (key), gh_scm2int (alter)); orig.transpose (p); key =gh_int2scm (orig.notename_i_); diff --git a/lily/custos-engraver.cc b/lily/custos-engraver.cc index 77e354d632..02ffd1f46d 100644 --- a/lily/custos-engraver.cc +++ b/lily/custos-engraver.cc @@ -36,7 +36,7 @@ private: Item * create_custos(); bool custos_permitted; Link_array custos_arr_; - Array pitches_; + Array pitches_; }; Custos_engraver::Custos_engraver () diff --git a/lily/include/audio-item.hh b/lily/include/audio-item.hh index e8ced6a64b..72281b52da 100644 --- a/lily/include/audio-item.hh +++ b/lily/include/audio-item.hh @@ -12,7 +12,7 @@ #include "string.hh" #include "audio-element.hh" -#include "musical-pitch.hh" +#include "pitch.hh" #include "moment.hh" #include "drul-array.hh" @@ -61,11 +61,11 @@ public: class Audio_note : public Audio_item { public: - Audio_note (Musical_pitch p, Moment m, int transposing_i = 0); + Audio_note (Pitch p, Moment m, int transposing_i = 0); void tie_to (Audio_note*); - Musical_pitch pitch_; + Pitch pitch_; Moment length_mom_; Moment delayed_mom_; Moment delayed_until_mom_; diff --git a/lily/include/auto-change-iterator.hh b/lily/include/auto-change-iterator.hh index aba977192f..74558ab4df 100644 --- a/lily/include/auto-change-iterator.hh +++ b/lily/include/auto-change-iterator.hh @@ -25,7 +25,7 @@ protected: virtual void process (Moment); - Array pending_pitch (Moment)const; + Array pending_pitch (Moment)const; private: diff --git a/lily/include/chord.hh b/lily/include/chord.hh index 98290e29c2..c062efb6ac 100644 --- a/lily/include/chord.hh +++ b/lily/include/chord.hh @@ -9,56 +9,37 @@ #ifndef CHORD_HH #define CHORD_HH -#include "array.hh" -#include "musical-pitch.hh" -#include "lily-proto.hh" - - +#include "pitch.hh" /* - Slightly on the hairy side? In any case COMMENTME. + ``chord'' is encoded: + (PITCHES . (INVERSION . BASS)) + + Chord:: namespace... */ class Chord { public: - static Array base_arr (Musical_pitch p); - static int find_tonic_i (Array const*); - static int find_pitch_i (Array const*, Musical_pitch p); - static int find_notename_i (Array const*, Musical_pitch p); - static Array missing_thirds_pitch_arr (Array const* pitch_arr_p); - static void rebuild_from_base (Array*, int base_i); - static void rebuild_insert_inversion (Array*, int tonic_i); - static void rebuild_transpose (Array*, Musical_pitch tonic, bool fix7_b); - static void rebuild_with_bass (Array*, int bass_i); - static int step_i (Musical_pitch tonic, Musical_pitch p); - - - Chord (); - Chord (Array pitch_arr, Musical_pitch* inversion_p, Musical_pitch* bass_p); - Chord (Chord const&); - - Array to_pitch_arr () const; - - Array pitch_arr_; - bool inversion_b_; - Musical_pitch inversion_pitch_; - bool bass_b_; - Musical_pitch bass_pitch_; + static SCM pitches_and_requests_to_chord (SCM pitches, + SCM tonic_req, + SCM inversion_req, + SCM bass_req, + bool find_inversion_b); + static SCM base_pitches (SCM tonic); + static SCM transpose_pitches (SCM tonic, SCM pitches); + static SCM lower_step (SCM tonic, SCM pitches, SCM step); + static SCM member_notename (SCM p, SCM pitches); + static int step_i (Pitch tonic, Pitch p); + static SCM step_scm (SCM tonic, SCM p); + static SCM missing_thirds (SCM pitches); + static SCM to_pitches (SCM chord); + static SCM guess_tonic (SCM pitches); + static SCM rebuild_from_base (SCM pitches, SCM base); + static SCM rebuild_insert_inversion (SCM pitches); //, SCM tonic); + static SCM rebuild_with_bass (SCM pitches, SCM bass); + static SCM tonic_add_sub_inversion_bass_to_scm (SCM tonic, SCM add, SCM sub, + SCM inversion, SCM bass); + static Simultaneous_music *get_chord (SCM tonic, SCM add, SCM sub, SCM inversion, SCM bass, SCM dur); }; -Chord to_chord (Musical_pitch tonic, Array* add_arr_p, Array* sub_arr_p, Musical_pitch* inversion_p, Musical_pitch* bass_p); - -Chord to_chord (Array pitch_arr, Tonic_req* tonic_req, Inversion_req* inversion_req, Bass_req* bass_req, bool find_inversion_b); - -int compare (Chord*, Chord*); - -Simultaneous_music *get_chord (SCM tonic, - SCM add_arr_p, - SCM sub_arr_p, - SCM inversion_p, - SCM bass_p, - SCM d); - - - -#endif // CHORD_HH +#endif /* CHORD_HH */ diff --git a/lily/include/command-request.hh b/lily/include/command-request.hh index 2acf5d4ba1..5415808e58 100644 --- a/lily/include/command-request.hh +++ b/lily/include/command-request.hh @@ -13,7 +13,7 @@ #include "request.hh" #include "array.hh" #include "duration.hh" -#include "musical-pitch.hh" +#include "pitch.hh" #include "protected-scm.hh" class Break_req : public Request { @@ -68,7 +68,7 @@ public: protected: VIRTUAL_COPY_CONS(Music); - void transpose (Musical_pitch d); + void transpose (Pitch d); bool do_equal_b (Request const * )const; }; diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh index 5dea72d5b5..b1fba08ddd 100644 --- a/lily/include/lily-proto.hh +++ b/lily/include/lily-proto.hh @@ -116,7 +116,7 @@ class Music_output_def; class Music_sequence; class Music_wrapper; class Music_wrapper_iterator; -class Musical_pitch; +class Pitch; class Musical_req; class My_lily_lexer; class Note_performer; diff --git a/lily/include/local-key-item.hh b/lily/include/local-key-item.hh index 88b76d7b46..9eb8c92b9f 100644 --- a/lily/include/local-key-item.hh +++ b/lily/include/local-key-item.hh @@ -9,14 +9,14 @@ #include "array.hh" -#include "musical-pitch.hh" +#include "pitch.hh" class Local_key_item { static Molecule parenthesize (Score_element*me, Molecule) ; public: DECLARE_SCHEME_CALLBACK(brew_molecule, (SCM )); - static void add_pitch (Score_element*me, Musical_pitch, bool cautionary, bool natural); + static void add_pitch (Score_element*me, Pitch, bool cautionary, bool natural); static bool has_interface (Score_element*); static void set_interface (Score_element*); }; diff --git a/lily/include/lyric-combine-music.hh b/lily/include/lyric-combine-music.hh index 9b121ff0d7..d28a8c5fe3 100644 --- a/lily/include/lyric-combine-music.hh +++ b/lily/include/lyric-combine-music.hh @@ -19,11 +19,11 @@ public: Music * lyrics_l () const; Lyric_combine_music (Music*, Music*); - virtual void transpose (Musical_pitch); + virtual void transpose (Pitch); VIRTUAL_COPY_CONS(Music); virtual Moment length_mom () const; - virtual Musical_pitch to_relative_octave (Musical_pitch); + virtual Pitch to_relative_octave (Pitch); virtual void compress (Moment); }; #endif /* LYRIC_COMBINE_MUSIC_HH */ diff --git a/lily/include/music-list.hh b/lily/include/music-list.hh index 63d39edc37..b0a0017a15 100644 --- a/lily/include/music-list.hh +++ b/lily/include/music-list.hh @@ -21,7 +21,7 @@ class Simultaneous_music : public Music_sequence public: VIRTUAL_COPY_CONS(Music); Simultaneous_music(SCM); - virtual Musical_pitch to_relative_octave (Musical_pitch); + virtual Pitch to_relative_octave (Pitch); virtual Moment length_mom () const; }; @@ -33,7 +33,7 @@ class Request_chord : public Simultaneous_music { public: VIRTUAL_COPY_CONS(Music); - virtual Musical_pitch to_relative_octave (Musical_pitch); + virtual Pitch to_relative_octave (Pitch); Request_chord(SCM list); }; diff --git a/lily/include/music-sequence.hh b/lily/include/music-sequence.hh index 6e88236e33..67ce044dee 100644 --- a/lily/include/music-sequence.hh +++ b/lily/include/music-sequence.hh @@ -24,8 +24,8 @@ public: void append_music (Music *); VIRTUAL_COPY_CONS(Music); - Musical_pitch do_relative_octave (Musical_pitch p, bool b); - virtual void transpose (Musical_pitch ); + Pitch do_relative_octave (Pitch p, bool b); + virtual void transpose (Pitch ); void truncate (int k); virtual void compress (Moment); int length_i () const; @@ -33,7 +33,7 @@ public: Moment maximum_length () const; protected: - virtual Musical_pitch to_relative_octave (Musical_pitch); + virtual Pitch to_relative_octave (Pitch); }; diff --git a/lily/include/music-wrapper.hh b/lily/include/music-wrapper.hh index d5227830a7..4f6546c405 100644 --- a/lily/include/music-wrapper.hh +++ b/lily/include/music-wrapper.hh @@ -11,7 +11,7 @@ #define MUSIC_WRAPPER_HH #include "music.hh" -#include "musical-pitch.hh" +#include "pitch.hh" /** A Music that modifies an existing Music. This data structure corresponds to a production that takes a single Music argument, @@ -24,12 +24,12 @@ class Music_wrapper : public Music public: Music_wrapper (Music*); Music * element () const; - virtual void transpose (Musical_pitch); + virtual void transpose (Pitch); VIRTUAL_COPY_CONS(Music); virtual Moment length_mom () const; - virtual Musical_pitch to_relative_octave (Musical_pitch); + virtual Pitch to_relative_octave (Pitch); virtual void compress (Moment); }; diff --git a/lily/include/music.hh b/lily/include/music.hh index dbcfccf687..a139ae28d4 100644 --- a/lily/include/music.hh +++ b/lily/include/music.hh @@ -44,14 +44,14 @@ public: void set_mus_pointer (const char*, SCM val); SCM remove_mus_property (const char* nm); - virtual Musical_pitch to_relative_octave (Musical_pitch); + virtual Pitch to_relative_octave (Pitch); /// The duration of this piece of music virtual Moment length_mom () const; void print() const; /// Transpose, with the interval central C to #p# - virtual void transpose (Musical_pitch p); + virtual void transpose (Pitch p); /// Scale the music in time by #factor#. virtual void compress (Moment factor); diff --git a/lily/include/musical-pitch.hh b/lily/include/musical-pitch.hh index a78973b563..e69de29bb2 100644 --- a/lily/include/musical-pitch.hh +++ b/lily/include/musical-pitch.hh @@ -1,73 +0,0 @@ -/* - musical-pitch.hh -- declare Musical_pitch - - source file of the GNU LilyPond music typesetter - - (c) 1998--2000 Han-Wen Nienhuys - - */ - -#ifndef MUSICAL_PITCH_HH -#define MUSICAL_PITCH_HH - -#include "lily-proto.hh" -#include "smobs.hh" - -/** A "tonal" pitch. This is a pitch as it figures in diatonal western - music (12 semitones in an octave), as opposed to a frequence in Hz - or a integer number of semitones. - - - - -*/ -class Musical_pitch -{ -public: // fixme - - /// 0 is c, 6 is b - int notename_i_; - - /// 0 natural, 1 sharp, etc - int alteration_i_; - - /// 0 is central c - int octave_i_; -public: - - int octave_i () const; - int notename_i () const; - int alteration_i () const; - - /* - Musical_pitch is lexicographically ordered by (octave, notename, - alteration). - */ - Musical_pitch (int octave, int notename,int accidental); - Musical_pitch (); - - Musical_pitch to_relative_octave (Musical_pitch); - void transpose (Musical_pitch); - static int compare (Musical_pitch const&,Musical_pitch const&); - /// return large part of interval from central c - int steps() const; - /// return pitch from central c (in halfnotes) - int semitone_pitch() const; - void up_to (int); - void down_to (int); - String str () const; - - SCM smobbed_copy () const; - DECLARE_SCHEME_CALLBACK(less_p, (SCM a, SCM b)); - DECLARE_SIMPLE_SMOBS(Musical_pitch,); -}; - -Musical_pitch* unsmob_pitch (SCM); - -#include "compare.hh" -INSTANTIATE_COMPARE(Musical_pitch, Musical_pitch::compare); - -int compare (Array*, Array*); - -#endif /* MUSICAL_PITCH_HH */ - diff --git a/lily/include/musical-request.hh b/lily/include/musical-request.hh index f98b1bee86..f3d1adcbb1 100644 --- a/lily/include/musical-request.hh +++ b/lily/include/musical-request.hh @@ -13,7 +13,7 @@ #include "lily-proto.hh" #include "request.hh" #include "duration.hh" -#include "musical-pitch.hh" +#include "pitch.hh" #include "array.hh" /** a request with a duration. @@ -75,7 +75,7 @@ struct Melodic_req :virtual Request { protected: /// transpose. #delta# is relative to central c. - virtual void transpose (Musical_pitch delta); + virtual void transpose (Pitch delta); virtual bool do_equal_b (Request const*) const; VIRTUAL_COPY_CONS(Music); diff --git a/lily/include/my-lily-lexer.hh b/lily/include/my-lily-lexer.hh index a76957edf6..dbe59c6ccd 100644 --- a/lily/include/my-lily-lexer.hh +++ b/lily/include/my-lily-lexer.hh @@ -18,7 +18,7 @@ #include "string.hh" #include "includable-lexer.hh" #include "duration.hh" -#include "musical-pitch.hh" +#include "pitch.hh" #include "protected-scm.hh" bool busy_parsing(); diff --git a/lily/include/my-lily-parser.hh b/lily/include/my-lily-parser.hh index 7832bb3c07..bd5b82159b 100644 --- a/lily/include/my-lily-parser.hh +++ b/lily/include/my-lily-parser.hh @@ -16,7 +16,7 @@ #include "lily-proto.hh" #include "lily-proto.hh" #include "duration.hh" -#include "musical-pitch.hh" +#include "pitch.hh" #include "string.hh" #include "array.hh" #include "input.hh" @@ -66,13 +66,13 @@ private: char const* here_ch_C() const; - Simultaneous_music * get_chord (Musical_pitch tonic, Array* add_arr_p, - Array* sub_arr_p, Musical_pitch* inversion_p, - Musical_pitch* bass_p, Duration d); + Simultaneous_music * get_chord (Pitch tonic, Array* add_arr_p, + Array* sub_arr_p, Pitch* inversion_p, + Pitch* bass_p, Duration d); void set_chord_tremolo (int type_i); void set_last_duration (Duration const *); - void set_last_pitch (Musical_pitch const *); + void set_last_pitch (Pitch const *); friend int yyparse (void*); }; diff --git a/lily/include/part-combine-music.hh b/lily/include/part-combine-music.hh index cccfaaa1d3..ed0b560a9f 100644 --- a/lily/include/part-combine-music.hh +++ b/lily/include/part-combine-music.hh @@ -22,10 +22,10 @@ public: Music * first_l () const; Music * second_l () const; - virtual void transpose (Musical_pitch); + virtual void transpose (Pitch); virtual Moment length_mom () const; - virtual Musical_pitch to_relative_octave (Musical_pitch); + virtual Pitch to_relative_octave (Pitch); virtual void compress (Moment); }; diff --git a/lily/include/relative-music.hh b/lily/include/relative-music.hh index a861d451bc..071b34152b 100644 --- a/lily/include/relative-music.hh +++ b/lily/include/relative-music.hh @@ -15,13 +15,13 @@ class Relative_octave_music : public Music_wrapper { public: - Musical_pitch last_pitch_; + Pitch last_pitch_; - Relative_octave_music (Music*, Musical_pitch); + Relative_octave_music (Music*, Pitch); VIRTUAL_COPY_CONS(Music); - virtual Musical_pitch to_relative_octave (Musical_pitch); + virtual Pitch to_relative_octave (Pitch); }; diff --git a/lily/include/repeated-music.hh b/lily/include/repeated-music.hh index b222111fe4..b2deaee08f 100644 --- a/lily/include/repeated-music.hh +++ b/lily/include/repeated-music.hh @@ -54,7 +54,7 @@ public: /// how often do we repeat? int repeat_count( ) const; - virtual Musical_pitch to_relative_octave (Musical_pitch); + virtual Pitch to_relative_octave (Pitch); Moment body_length_mom () const; Moment alternatives_length_mom (bool fold) const; @@ -64,7 +64,7 @@ public: DECLARE_SCHEME_CALLBACK(folded_music_length, (SCM)); /// Transpose, with the interval central C to #p# - virtual void transpose (Musical_pitch p); + virtual void transpose (Pitch p); /// Scale the music in time by #factor#. virtual void compress (Moment factor); diff --git a/lily/include/transposed-music.hh b/lily/include/transposed-music.hh index a559feb2bb..1c3defee06 100644 --- a/lily/include/transposed-music.hh +++ b/lily/include/transposed-music.hh @@ -16,13 +16,13 @@ class Transposed_music : public Music_wrapper { public: - Musical_pitch transpose_to_pitch_; + Pitch transpose_to_pitch_; - Transposed_music (Music*, Musical_pitch); + Transposed_music (Music*, Pitch); VIRTUAL_COPY_CONS(Music); - virtual Musical_pitch to_relative_octave (Musical_pitch); + virtual Pitch to_relative_octave (Pitch); }; #endif /* TRANSPOSED_MUSIC_HH */ diff --git a/lily/key-engraver.cc b/lily/key-engraver.cc index 5546180906..4b1e204a83 100644 --- a/lily/key-engraver.cc +++ b/lily/key-engraver.cc @@ -15,7 +15,7 @@ #include "staff-symbol-referencer.hh" #include "translator-group.hh" #include "engraver.hh" -#include "musical-pitch.hh" +#include "pitch.hh" #include "protected-scm.hh" #include "clef.hh" diff --git a/lily/local-key-item.cc b/lily/local-key-item.cc index 5caf337451..47e3c4180e 100644 --- a/lily/local-key-item.cc +++ b/lily/local-key-item.cc @@ -1,5 +1,5 @@ /* - local-key-item.cc -- implement Local_key_item, Musical_pitch + local-key-item.cc -- implement Local_key_item, Pitch source file of the GNU LilyPond music typesetter @@ -18,7 +18,7 @@ static SCM pitch_less (SCM p1, SCM p2) { - return Musical_pitch::less_p (gh_car (p1), gh_car (p2)); + return Pitch::less_p (gh_car (p1), gh_car (p2)); } static SCM pitch_less_proc; @@ -33,7 +33,7 @@ ADD_SCM_INIT_FUNC(lkpitch,init_pitch_funcs); void -Local_key_item::add_pitch (Score_element*me, Musical_pitch p, bool cautionary, bool natural) +Local_key_item::add_pitch (Score_element*me, Pitch p, bool cautionary, bool natural) { SCM acs = me->get_elt_property ("accidentals"); SCM pitch = p.smobbed_copy (); @@ -82,7 +82,7 @@ Local_key_item::brew_molecule (SCM smob) for (SCM s = accs; gh_pair_p (s); s = gh_cdr (s)) { - Musical_pitch p (*unsmob_pitch (gh_caar (s))); + Pitch p (*unsmob_pitch (gh_caar (s))); SCM opts = gh_cdar (s); // do one octave diff --git a/lily/lyric-combine-music.cc b/lily/lyric-combine-music.cc index f474443bca..4b9ca36048 100644 --- a/lily/lyric-combine-music.cc +++ b/lily/lyric-combine-music.cc @@ -9,7 +9,7 @@ #include "lyric-combine-music.hh" #include "lyric-combine-music-iterator.hh" -#include "musical-pitch.hh" +#include "pitch.hh" Lyric_combine_music::Lyric_combine_music (Music * m, Music * l) { @@ -22,7 +22,7 @@ Lyric_combine_music::Lyric_combine_music (Music * m, Music * l) void -Lyric_combine_music::transpose (Musical_pitch p) +Lyric_combine_music::transpose (Pitch p) { music_l ()->transpose (p); lyrics_l () ->transpose (p); @@ -35,8 +35,8 @@ Lyric_combine_music::length_mom () const return music_l ()->length_mom (); } -Musical_pitch -Lyric_combine_music::to_relative_octave ( Musical_pitch p ) +Pitch +Lyric_combine_music::to_relative_octave ( Pitch p ) { p = music_l ()->to_relative_octave (p); return lyrics_l () ->to_relative_octave (p); diff --git a/lily/music-list.cc b/lily/music-list.cc index 1a1847783e..a2a82aeccc 100644 --- a/lily/music-list.cc +++ b/lily/music-list.cc @@ -8,7 +8,7 @@ #include "music-list.hh" #include "music-wrapper.hh" -#include "musical-pitch.hh" +#include "pitch.hh" #include "request.hh" #include "musical-request.hh" #include "music-iterator.hh" @@ -45,8 +45,8 @@ Sequential_music::length_mom () const return cumulative_length (); } -Musical_pitch -Simultaneous_music::to_relative_octave (Musical_pitch p) +Pitch +Simultaneous_music::to_relative_octave (Pitch p) { return do_relative_octave (p, true); } @@ -58,15 +58,15 @@ Request_chord::Request_chord(SCM s) Request_chord_iterator::constructor_cxx_function); } -Musical_pitch -Request_chord::to_relative_octave (Musical_pitch last) +Pitch +Request_chord::to_relative_octave (Pitch last) { for (SCM s = music_list (); gh_pair_p (s); s = gh_cdr (s)) { Music * mus = unsmob_music (gh_car (s)); if (Melodic_req *m= dynamic_cast (mus)) { - Musical_pitch pit = *unsmob_pitch (m->get_mus_property ("pitch")); + Pitch pit = *unsmob_pitch (m->get_mus_property ("pitch")); pit.to_relative_octave (last); m->set_mus_property ("pitch", pit.smobbed_copy()); diff --git a/lily/music-sequence.cc b/lily/music-sequence.cc index d8089ad74d..5fd6206da3 100644 --- a/lily/music-sequence.cc +++ b/lily/music-sequence.cc @@ -8,7 +8,7 @@ */ #include "music-list.hh" #include "debug.hh" -#include "musical-pitch.hh" +#include "pitch.hh" void @@ -57,7 +57,7 @@ Music_sequence::Music_sequence(SCM h) } void -Music_sequence::transpose (Musical_pitch rq) +Music_sequence::transpose (Pitch rq) { for (SCM s = music_list (); gh_pair_p (s); s = gh_cdr (s)) unsmob_music (gh_car (s))->transpose (rq); @@ -75,8 +75,8 @@ Music_sequence::cumulative_length () const return last; } -Musical_pitch -Music_sequence::to_relative_octave (Musical_pitch p) +Pitch +Music_sequence::to_relative_octave (Pitch p) { return do_relative_octave (p, false); } @@ -97,13 +97,13 @@ Music_sequence::length_i () const return scm_ilength (music_list ()); } -Musical_pitch -Music_sequence::do_relative_octave (Musical_pitch p, bool ret_first) +Pitch +Music_sequence::do_relative_octave (Pitch p, bool ret_first) { - Musical_pitch retval; + Pitch retval; int count=0; - Musical_pitch last = p; + Pitch last = p; for (SCM s = music_list (); gh_pair_p (s); s = gh_cdr (s)) { last = unsmob_music (gh_car (s))->to_relative_octave (last); diff --git a/lily/music-wrapper.cc b/lily/music-wrapper.cc index ffcba96336..801af5b8e9 100644 --- a/lily/music-wrapper.cc +++ b/lily/music-wrapper.cc @@ -14,7 +14,7 @@ void -Music_wrapper::transpose (Musical_pitch p) +Music_wrapper::transpose (Pitch p) { if (element ()) element ()-> transpose (p); @@ -33,8 +33,8 @@ Music_wrapper::length_mom () const return element ()->length_mom (); } -Musical_pitch -Music_wrapper::to_relative_octave (Musical_pitch p) +Pitch +Music_wrapper::to_relative_octave (Pitch p) { return element ()->to_relative_octave (p); } diff --git a/lily/music.cc b/lily/music.cc index e12ea41ea5..b807dec07e 100644 --- a/lily/music.cc +++ b/lily/music.cc @@ -10,7 +10,7 @@ #include "music.hh" #include "music-list.hh" #include "debug.hh" -#include "musical-pitch.hh" +#include "pitch.hh" #include "ly-smobs.icc" SCM @@ -90,15 +90,15 @@ Music::print_smob(SCM s, SCM p, scm_print_state*) return 1; } -Musical_pitch -Music::to_relative_octave (Musical_pitch m) +Pitch +Music::to_relative_octave (Pitch m) { return m; } void -Music::transpose (Musical_pitch ) +Music::transpose (Pitch ) { } diff --git a/lily/musical-request.cc b/lily/musical-request.cc index 15c881df04..ef2b193979 100644 --- a/lily/musical-request.cc +++ b/lily/musical-request.cc @@ -18,9 +18,9 @@ Tremolo_req::Tremolo_req () void -Melodic_req::transpose (Musical_pitch delta) +Melodic_req::transpose (Pitch delta) { - Musical_pitch p = *unsmob_pitch (get_mus_property ("pitch")); + Pitch p = *unsmob_pitch (get_mus_property ("pitch")); p.transpose (delta); diff --git a/lily/note-performer.cc b/lily/note-performer.cc index 946b604c00..d452ae5e87 100644 --- a/lily/note-performer.cc +++ b/lily/note-performer.cc @@ -36,7 +36,7 @@ Note_performer::do_process_music () while (note_req_l_arr_.size ()) { Note_req* n = note_req_l_arr_.pop (); - Musical_pitch pit = * unsmob_pitch (n->get_mus_property ("pitch")); + Pitch pit = * unsmob_pitch (n->get_mus_property ("pitch")); Audio_note* p = new Audio_note (pit, n->length_mom (), transposing_i); Audio_element_info info (p, n); announce_element (info); diff --git a/lily/part-combine-music-iterator.cc b/lily/part-combine-music-iterator.cc index 1f813a7445..235b64452e 100644 --- a/lily/part-combine-music-iterator.cc +++ b/lily/part-combine-music-iterator.cc @@ -11,32 +11,9 @@ #include "translator-group.hh" #include "musical-request.hh" #include "music-sequence.hh" +#include "lily-guile.hh" #include "warn.hh" - -/* - DOCUMENTME - */ -int -compare (Array const * left, Array const * right) -{ - assert (left); - assert (right); - - if (left->size () == right->size ()) - { - for (int i = 0; i < left->size (); i++) - { - int r = Duration::compare ((*left)[i], (*right)[i]); - if (r) - return r; - } - } - else - return 1; - return 0; -} - Part_combine_music_iterator::Part_combine_music_iterator () { first_iter_p_ = 0; @@ -131,8 +108,9 @@ Part_combine_music_iterator::change_to (Music_iterator *it, String to_type, } +// SCM*, moet / kan dat niet met set_x ofzo? static void -get_music_info (Moment m, Music_iterator* iter, Array *pitches, Array *durations) +get_music_info (Moment m, Music_iterator* iter, SCM *pitches, SCM *durations) { if (iter->ok ()) { @@ -140,9 +118,9 @@ get_music_info (Moment m, Music_iterator* iter, Array *pitches, A { Music *m = unsmob_music (gh_car (i)); if (Melodic_req *r = dynamic_cast (m)) - pitches->push (*unsmob_pitch (r->get_mus_property("pitch"))); + *pitches = gh_cons (r->get_mus_property("pitch"), *pitches); if (Rhythmic_req *r = dynamic_cast (m)) - durations->push (*unsmob_duration (r->get_mus_property("duration"))); + *durations = gh_cons (r->get_mus_property("duration"), *durations); } } } @@ -199,35 +177,46 @@ Part_combine_music_iterator::get_state (Moment) pending = first_iter->pending_moment () pending_moment (); last_pending = pending; - Array first_pitches; - Array first_durations; - get_music_info (pending, first_iter, &first_pitches, &first_durations); + SCM first_pitches = SCM_EOL; + SCM first_durations = SCM_EOL; + get_music_info (pending, first_iter, + &first_pitches, &first_durations); - Array second_pitches; - Array second_durations; - get_music_info (pending, second_iter, &second_pitches, &second_durations); + SCM second_pitches = SCM_EOL; + SCM second_durations = SCM_EOL; + get_music_info (pending, second_iter, + &second_pitches, &second_durations); - if (first_pitches.size () && second_pitches.size ()) + if (first_pitches != SCM_EOL && second_pitches != SCM_EOL) { - first_pitches.sort (Musical_pitch::compare); - second_pitches.sort (Musical_pitch::compare); - interval = gh_int2scm (first_pitches.top ().steps () - - second_pitches[0].steps ()); + scm_sort_list_x (first_pitches, + scm_eval2 (ly_str02scm ("Pitch::less_p"), + SCM_EOL)); + scm_sort_list_x (second_pitches, + scm_eval2 (ly_str02scm ("Pitch::less_p"), + SCM_EOL)); + interval = gh_int2scm (unsmob_pitch (gh_car (first_pitches))->steps () + - unsmob_pitch (gh_car (scm_last_pair (second_pitches)))->steps ()); } - if (first_durations.size ()) + + if (first_durations != SCM_EOL) { - first_durations.sort (Duration::compare); - first_mom += first_durations.top ().length_mom (); + scm_sort_list_x (first_durations, + scm_eval2 (ly_str02scm ("Duration::less_p"), + SCM_EOL)); + first_mom += unsmob_duration (gh_car (first_durations))->length_mom (); } - - if (second_durations.size ()) + + if (second_durations != SCM_EOL) { - second_durations.sort (Duration::compare); - second_mom += second_durations.top ().length_mom (); + scm_sort_list_x (second_durations, + scm_eval2 (ly_str02scm ("Duration::less_p"), + SCM_EOL)); + second_mom += unsmob_duration (gh_car (second_durations))->length_mom (); } - - if (!first_pitches.empty () && second_pitches.empty () - && !(second_until_ > now)) + + if (first_pitches != SCM_EOL && second_pitches == SCM_EOL + && !(second_until_ > now)) { state |= UNRELATED; state &= ~UNISILENCE; @@ -237,7 +226,7 @@ Part_combine_music_iterator::get_state (Moment) else state &= ~SOLO1; - if (first_pitches.empty () && !second_pitches.empty () + if (first_pitches == SCM_EOL && second_pitches != SCM_EOL && !(first_until_ > now)) { state |= UNRELATED; @@ -248,7 +237,7 @@ Part_combine_music_iterator::get_state (Moment) else state &= ~SOLO2; - if (!compare (&first_durations, &second_durations)) + if (gh_equal_p (first_durations, second_durations)) { state &= ~UNISILENCE; if (!(state & ~(UNIRHYTHM | UNISON))) @@ -257,8 +246,8 @@ Part_combine_music_iterator::get_state (Moment) else state &= ~(UNIRHYTHM | UNISILENCE); - if (!first_pitches.empty () - &&!compare (&first_pitches, &second_pitches)) + if (first_pitches != SCM_EOL + && gh_equal_p (first_pitches, second_pitches)) { state &= ~UNISILENCE; if (!(state & ~(UNIRHYTHM | UNISON))) @@ -267,7 +256,7 @@ Part_combine_music_iterator::get_state (Moment) else state &= ~(UNISON); - if (first_pitches.empty () && second_pitches.empty ()) + if (first_pitches == SCM_EOL && second_pitches == SCM_EOL) { if (!(state & ~(UNIRHYTHM | UNISILENCE))) state |= UNISILENCE; @@ -294,9 +283,9 @@ Part_combine_music_iterator::get_state (Moment) state &= ~(SPLIT_INTERVAL); } - if (first && !first_pitches.empty ()) + if (first && first_pitches != SCM_EOL) first_until_ = first_mom; - if (first && !second_pitches.empty ()) + if (first && second_pitches != SCM_EOL) second_until_ = second_mom; first = false; @@ -374,13 +363,17 @@ Part_combine_music_iterator::process (Moment m) if (combine_b != previously_combined_b) change_to (second_iter_p_, w, (combine_b ? "one" : "two") + suffix_); - + Translator_group *first_translator = first_iter_p_->report_to_l ()->find_create_translator_l (w, "one" + suffix_); Translator_group *second_translator = second_iter_p_->report_to_l ()->find_create_translator_l (w, "two" + suffix_); + - /* - hmm - */ + /* Hmm */ + first_translator->set_property ("combineParts", SCM_BOOL_T); + second_translator ->set_property ("combineParts", SCM_BOOL_T); + + + /* hmm */ SCM b = (state & UNIRHYTHM) ? SCM_BOOL_T : SCM_BOOL_F; first_translator->set_property ("unirhythm", b); second_translator->set_property ("unirhythm", b); diff --git a/lily/part-combine-music.cc b/lily/part-combine-music.cc index 91c351fc02..ea53d706b5 100644 --- a/lily/part-combine-music.cc +++ b/lily/part-combine-music.cc @@ -9,7 +9,7 @@ #include "part-combine-music.hh" #include "part-combine-music-iterator.hh" -#include "musical-pitch.hh" +#include "pitch.hh" Part_combine_music::Part_combine_music (SCM what, Music * f, Music * s) { @@ -26,7 +26,7 @@ Part_combine_music::Part_combine_music (SCM what, Music * f, Music * s) } void -Part_combine_music::transpose (Musical_pitch p) +Part_combine_music::transpose (Pitch p) { first_l ()->transpose (p); second_l () ->transpose (p); @@ -40,8 +40,8 @@ Part_combine_music::length_mom () const return first_l ()->length_mom (); } -Musical_pitch -Part_combine_music::to_relative_octave (Musical_pitch p) +Pitch +Part_combine_music::to_relative_octave (Pitch p) { p = first_l ()->to_relative_octave (p); return second_l ()->to_relative_octave (p); diff --git a/lily/pitch.cc b/lily/pitch.cc new file mode 100644 index 0000000000..a6447b5f26 --- /dev/null +++ b/lily/pitch.cc @@ -0,0 +1,352 @@ +/* + musical-pitch.cc -- implement Pitch + + source file of the GNU LilyPond music typesetter + + (c) 1998--2000 Han-Wen Nienhuys + + */ +#include "pitch.hh" +#include "debug.hh" +#include "main.hh" +#include "ly-smobs.icc" + + + +Pitch::Pitch (int o, int n, int a) +{ + notename_i_ = n; + alteration_i_ = a; + octave_i_ = o; + + if (n < 0 || n >= 7 || + a < -2 || a > 2) + { + String s = _("Pitch arguments out of range"); + s += ": alteration = " + to_str (a); + s += ", notename = " + to_str (n); + warning (s); + } +} + +Pitch::Pitch () +{ + notename_i_ = 0; + alteration_i_ = 0; + octave_i_ = 0; +} + +int +Pitch::compare (Pitch const &m1, Pitch const &m2) +{ + int o= m1.octave_i_ - m2.octave_i_; + int n = m1.notename_i_ - m2.notename_i_; + int a = m1.alteration_i_ - m2.alteration_i_; + + if (o) + return o; + if (n) + return n; + if (a) + return a; + return 0; +} + +int +Pitch::steps () const +{ + return notename_i_ + octave_i_*7; +} + +/* + should be settable from input? + */ +static Byte pitch_byte_a[ ] = { 0, 2, 4, 5, 7, 9, 11 }; + +int +Pitch::semitone_pitch () const +{ + return pitch_byte_a[ notename_i_ % 7 ] + alteration_i_ + octave_i_ * 12; +} + +/* WHugh, wat een intervaas */ +void +Pitch::transpose (Pitch delta) +{ + int old_pitch = semitone_pitch (); + int delta_pitch = delta.semitone_pitch (); + octave_i_ += delta.octave_i_; + notename_i_ += delta.notename_i_; + + + while (notename_i_ >= 7) + { + notename_i_ -= 7; + octave_i_ ++; + } + + int new_pitch = semitone_pitch (); + int delta_acc = new_pitch - old_pitch - delta_pitch; + alteration_i_ -= delta_acc; +} + + + + +/* FIXME */ +#if 0 +// nice test for internationalisation strings +char const *accname[] = {"double flat", "flat", "natural", + "sharp" , "double sharp"}; +#else +char const *accname[] = {"eses", "es", "", "is" , "isis"}; +#endif + +String +Pitch::str () const +{ + int n = (notename_i_ + 2) % 7; + String s = to_str (char(n + 'a')); + if (alteration_i_) + s += String (accname[alteration_i_ + 2]); + + if (octave_i_ > 0) + { + int o = octave_i_ + 1; + while (o--) + s += "'"; + } + else if (octave_i_ <0) + { + int o = (-octave_i_) - 1; + while (o--) + s += to_str (','); + } + + + return s; +} + +/* + change me to relative, counting from last pitch p + return copy of resulting pitch + */ +Pitch +Pitch::to_relative_octave (Pitch p) +{ + int oct_mod = octave_i_ + 1; // account for c' = octave 1 iso. 0 4 + Pitch up_pitch (p); + Pitch down_pitch (p); + + up_pitch.alteration_i_ = alteration_i_; + down_pitch.alteration_i_ = alteration_i_; + + Pitch n = *this; + up_pitch.up_to (notename_i_); + down_pitch.down_to (notename_i_); + + int h = p.steps (); + if (abs (up_pitch.steps () - h) < abs (down_pitch.steps () - h)) + n = up_pitch; + else + n = down_pitch; + + n.octave_i_ += oct_mod; + + *this = n; + return *this; +} + +void +Pitch::up_to (int notename) +{ + if (notename_i_ > notename) + { + octave_i_ ++; + } + notename_i_ = notename; +} + +void +Pitch::down_to (int notename) +{ + if (notename_i_ < notename) + { + octave_i_ --; + } + notename_i_ = notename; +} + +///MAKE_SCHEME_CALLBACK (Pitch, transpose, 2); +///transpose_proc? +SCM +Pitch::transpose (SCM p, SCM delta) +{ + Pitch t = *unsmob_pitch (p); + t.transpose (*unsmob_pitch (delta)); + return t.smobbed_copy (); +} + +static SCM +pitch_transpose (SCM p, SCM delta) +{ + return Pitch::transpose (p, delta); +} + +/****************************************************************/ + + +IMPLEMENT_TYPE_P(Pitch, "pitch?"); +IMPLEMENT_UNSMOB(Pitch, pitch); +SCM +Pitch::mark_smob (SCM ) +{ + return SCM_EOL; +} + +IMPLEMENT_SIMPLE_SMOBS(Pitch); + + +int +Pitch::print_smob (SCM s, SCM port, scm_print_state *) +{ + Pitch *r = (Pitch *) gh_cdr (s); + + scm_puts ("#str().ch_C()), port); + scm_puts (" >", port); + + return 1; +} + +SCM +Pitch::equal_p (SCM a , SCM b) +{ + Pitch *p = (Pitch *) gh_cdr (a); + Pitch *q = (Pitch *) gh_cdr (b); + + bool eq = p->notename_i_ == q->notename_i_ + && p->octave_i_ == q->octave_i_ + && p->alteration_i_ == q->alteration_i_; + + return eq ? SCM_BOOL_T : SCM_BOOL_F; +} + +MAKE_SCHEME_CALLBACK(Pitch, less_p, 2); +SCM +Pitch::less_p (SCM p1, SCM p2) +{ + Pitch *a = unsmob_pitch (p1); + Pitch *b = unsmob_pitch (p2); + + if (compare(*a, *b) < 0 ) + return SCM_BOOL_T; + else + return SCM_BOOL_F; +} + +/* + should add optional args + */ + +static SCM +make_pitch (SCM o, SCM n, SCM a) +{ + Pitch p; + p.octave_i_ = gh_scm2int (o); + p.notename_i_ = gh_scm2int (n); + p.alteration_i_ = gh_scm2int (a); + return p.smobbed_copy (); +} + +static SCM +pitch_octave (SCM pp) +{ + Pitch *p = unsmob_pitch (pp); + int q = 0; + if (!p) + warning ("Not a pitch"); + else + q = p->octave_i(); + + return gh_int2scm (q); +} + +static SCM +pitch_alteration (SCM pp) +{ + Pitch *p = unsmob_pitch (pp); + int q = 0; + if (!p) + warning ("Not a pitch"); + else + q = p->alteration_i(); + + return gh_int2scm (q); +} + +static SCM +pitch_notename (SCM pp) +{ + Pitch *p = unsmob_pitch (pp); + int q = 0; + if (!p) + warning ("Not a pitch"); + else + q = p->notename_i(); + + return gh_int2scm (q); +} + +static SCM +pitch_semitones (SCM pp) +{ + Pitch *p = unsmob_pitch (pp); + int q = 0; + if (!p) + warning ("Not a pitch"); + else + q = p->steps(); + + return gh_int2scm (q); +} + +static void +add_funcs() +{ + // should take list?: (make-pitch '(octave name accidental)) + scm_make_gsubr ("make-pitch", 3, 0, 0, (Scheme_function_unknown)make_pitch); + + scm_make_gsubr ("pitch-octave", 1, 0, 0, (Scheme_function_unknown)pitch_octave); + scm_make_gsubr ("pitch-notename", 1, 0, 0, (Scheme_function_unknown)pitch_notename); + scm_make_gsubr ("pitch-alteration", 1, 0, 0, (Scheme_function_unknown)pitch_alteration); + scm_make_gsubr ("pitch-semitones", 1, 0, 0, (Scheme_function_unknown)pitch_semitones); + scm_make_gsubr ("Pitch::transpose", 2, 0, 0, (Scheme_function_unknown) pitch_transpose); +} + +ADD_SCM_INIT_FUNC(pitch, add_funcs); + +SCM +Pitch::smobbed_copy ()const +{ + Pitch * p = new Pitch (*this); + return p->smobbed_self (); +} + +int +Pitch::octave_i ()const +{ + return octave_i_; +} + +int +Pitch::notename_i () const +{ + return notename_i_; +} + +int +Pitch::alteration_i () const +{ + return alteration_i_; +} diff --git a/lily/relative-octave-music.cc b/lily/relative-octave-music.cc index f339aa92ca..2c7480bdc9 100644 --- a/lily/relative-octave-music.cc +++ b/lily/relative-octave-music.cc @@ -10,14 +10,14 @@ #include "relative-music.hh" #include "debug.hh" -Musical_pitch -Relative_octave_music::to_relative_octave (Musical_pitch) +Pitch +Relative_octave_music::to_relative_octave (Pitch) { return last_pitch_; } -Relative_octave_music::Relative_octave_music(Music*p,Musical_pitch def) +Relative_octave_music::Relative_octave_music(Music*p,Pitch def) : Music_wrapper (p) { last_pitch_ = element ()->to_relative_octave (def); diff --git a/lily/repeated-music.cc b/lily/repeated-music.cc index 6f2a0913be..fec8d7be73 100644 --- a/lily/repeated-music.cc +++ b/lily/repeated-music.cc @@ -9,7 +9,7 @@ #include "repeated-music.hh" #include "music-list.hh" -#include "musical-pitch.hh" +#include "pitch.hh" #include "debug.hh" Music * @@ -48,13 +48,13 @@ Repeated_music::Repeated_music (Repeated_music const &s) } -Musical_pitch -Repeated_music::to_relative_octave (Musical_pitch p) +Pitch +Repeated_music::to_relative_octave (Pitch p) { if (body ()) p = body ()->to_relative_octave (p); - Musical_pitch last = p ; + Pitch last = p ; if (alternatives ()) for (SCM s = alternatives ()->music_list (); gh_pair_p (s); s = gh_cdr (s)) unsmob_music (gh_car (s))->to_relative_octave (p); @@ -64,7 +64,7 @@ Repeated_music::to_relative_octave (Musical_pitch p) } void -Repeated_music::transpose (Musical_pitch p) +Repeated_music::transpose (Pitch p) { if (body ()) body ()->transpose (p); diff --git a/lily/tie-engraver.cc b/lily/tie-engraver.cc index 277a4206e2..576e465317 100644 --- a/lily/tie-engraver.cc +++ b/lily/tie-engraver.cc @@ -146,7 +146,7 @@ Tie_engraver::process_acknowledged () while (i >= 0 && j >=0) { int comp - = Musical_pitch::compare (*unsmob_pitch (now_heads_[i].req_l_->get_mus_property ("pitch") ), + = Pitch::compare (*unsmob_pitch (now_heads_[i].req_l_->get_mus_property ("pitch") ), *unsmob_pitch (stopped_heads_[j].req_l_->get_mus_property ("pitch"))); if (comp) @@ -294,7 +294,7 @@ CHead_melodic_tuple::pitch_compare (CHead_melodic_tuple const&h1, SCM p1 = h1.req_l_->get_mus_property ("pitch"); SCM p2 = h2.req_l_->get_mus_property ("pitch"); - return Musical_pitch::equal_p (p1,p2) == SCM_BOOL_T; + return Pitch::equal_p (p1,p2) == SCM_BOOL_T; } int diff --git a/lily/tie-performer.cc b/lily/tie-performer.cc index feb335d6e8..521ac201c4 100644 --- a/lily/tie-performer.cc +++ b/lily/tie-performer.cc @@ -74,7 +74,7 @@ Tie_performer::process_acknowledged () while ( i < now_notes_.size () && j < stopped_notes_.size ()) { int comp - = Musical_pitch::compare (*unsmob_pitch (now_notes_[i].req_l_->get_mus_property ("pitch") ), + = Pitch::compare (*unsmob_pitch (now_notes_[i].req_l_->get_mus_property ("pitch") ), *unsmob_pitch (stopped_notes_[j].req_l_->get_mus_property ("pitch"))); if (comp) @@ -159,7 +159,7 @@ CNote_melodic_tuple::pitch_compare (CNote_melodic_tuple const&h1, { SCM p1 = h1.req_l_->get_mus_property ("pitch"); SCM p2 = h2.req_l_->get_mus_property ("pitch"); - return Musical_pitch::compare (*unsmob_pitch (p1), + return Pitch::compare (*unsmob_pitch (p1), *unsmob_pitch (p2)); } diff --git a/lily/transposed-music.cc b/lily/transposed-music.cc index e22f19f8f2..74aa3006ec 100644 --- a/lily/transposed-music.cc +++ b/lily/transposed-music.cc @@ -10,7 +10,7 @@ #include "transposed-music.hh" #include "debug.hh" -Transposed_music::Transposed_music (Music *p, Musical_pitch pit) +Transposed_music::Transposed_music (Music *p, Pitch pit) : Music_wrapper (p) { transpose_to_pitch_ = pit; @@ -19,8 +19,8 @@ Transposed_music::Transposed_music (Music *p, Musical_pitch pit) } -Musical_pitch -Transposed_music::to_relative_octave (Musical_pitch p) +Pitch +Transposed_music::to_relative_octave (Pitch p) { return p; }