Re: [frogs] chord_name_engraver - help with c++ ...

[ Thread Index | Date Index | More lilynet.net/frogs Archives ]


On 7/4/11 5:25 PM, "Wols Lists" <antlists@xxxxxxxxxxxxxxx> wrote:

> This frog is back ... I said I'd wait until 2.14 which has finally
> arrived :-) But I've revamped my code a bit and am having problems...
> 
>       SCM capopitch = get_property ( "capoPitch" );
>       bool capo = false;
>       Pitch *c_p = unsmob_pitch (capopitch);
>       if ( c_p != NULL )
>       {
>         if ( &c_p::get_notename != 0 || &c_p::get_alteration != NATURAL )
>         {
>           capo = true;
>         }
>       }
> 
> I assume the simplest test to tell if capoPitch has been set is to
> unsmob it? Presumably if the property hasn't been set, the pointer will
> be returned as NULL?

I'm going out on a limb here, because I haven't tested this, but I think I'd
check for capopitch ==  SCM_EOL to see if it hasn't been set.

> 
> Then, a pure c++ problem, when I'm testing for notename and alteration,
> I'm getting compile errors:
> 
> chord-name-engraver.cc: In member function Ovoid
> Chord_name_engraver::process_music()¹:
> chord-name-engraver.cc:108: error: Oc_p¹ is not a class or namespace
> chord-name-engraver.cc:108: error: Oc_p¹ is not a class or namespace
> 
> Given that Pitch is declared as a class in pitch.hh, and when I tried
> "c_p->get_notename" it blew up with a different error, this implies my
> c++-fu is wanting :-( Can you help me with the correct syntax?

Please don't use c_p; we want to use full words, rather than abbreviations.

I'd try

c_p->get_notename ()

And I'd recommend the code be something like

       SCM capo_pitch = get_property ("capoPitch");
       bool capo = false;
       if !(capo_pitch == SCM_EOL)
         capo = (Pitch::compare (unsmob_pitch (capo_pitch), Pitch()) != 0)

Note -- I haven't tested this code.  But I think it follows the general
trend.

HTH,

Carl


---
----
Join the Frogs!


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/