]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/music.hh
83cc5ff4c3148a4add8d1c7b165bc46a0bfe8829
[lilypond.git] / lily / include / music.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1997--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef MUSIC_HH
21 #define MUSIC_HH
22
23 #include "smobs.hh"
24 #include "moment.hh"
25 #include "pitch.hh"
26 #include "prob.hh"
27
28 #define is_mus_type(x) internal_is_music_type (ly_symbol2scm (x))
29
30 class Music : public Prob
31 {
32 public:
33   Music (SCM init);
34   Music (Music const &m);
35   VIRTUAL_COPY_CONSTRUCTOR (Music, Music);
36
37   Input *origin () const;
38   void set_spot (Input);
39
40   bool internal_is_music_type (SCM) const;
41
42   Stream_event *to_event () const;
43
44   DECLARE_SCHEME_CALLBACK (relative_callback, (SCM, SCM));
45   Pitch to_relative_octave (Pitch);
46   Pitch generic_to_relative_octave (Pitch);
47   Moment get_length () const;
48   Moment start_mom () const;
49   void print () const;
50
51   /// Transpose, with the interval central C to #p#
52   void transpose (Pitch p);
53
54   /// Scale the music in time by #factor#.
55   void compress (Moment factor);
56
57   // Broadcast the event in a context's event-source.
58   void send_to_context (Context *c);
59
60   DECLARE_SCHEME_CALLBACK (duration_length_callback, (SCM));
61
62 protected:
63   virtual SCM copy_mutable_properties () const;
64   virtual void type_check_assignment (SCM, SCM) const;
65   virtual void derived_mark () const;
66 protected:
67   SCM length_callback_;
68   SCM start_callback_;
69   friend SCM ly_extended_make_music (SCM, SCM);
70 };
71
72 Music *unsmob_music (SCM);
73 Music *make_music_by_name (SCM sym);
74 SCM ly_music_deep_copy (SCM);
75 SCM ly_camel_case_2_lisp_identifier (SCM name_sym);
76
77 extern SCM ly_music_p_proc;
78
79 /* common transposition function for music and event */
80 void transpose_mutable (SCM alist, Pitch delta);
81
82 #endif /* MUSIC_HH */