virtual Harmony* GenerateRandomHarmony() const {
     Harmony* newHarmony = new Harmony();
     for (unsigned i = 0; i < HarmonyFactory::m_vCount; ++i)
         newHarmony->push_back(HarmonyFactory::m_vCount-m_gen);
     ++m_gen;
     return newHarmony;
 }
Exemple #2
0
Palette* MuseScore::newTextPalette()
{
    Palette* sp = new Palette;
    sp->setName(QT_TRANSLATE_NOOP("Palette", "Text"));
    sp->setMag(0.65);
    sp->setGrid(84, 28);
    sp->setDrawGrid(true);

    StaffText* st = new StaffText(gscore);
    st->setTextStyleType(TEXT_STYLE_STAFF);
    st->setText(tr("staff-text"));
    sp->append(st, tr("Staff Text"));

    st = new StaffText(gscore);
    st->setTextStyleType(TEXT_STYLE_SYSTEM);
    st->setText(tr("system-text"));
    sp->append(st, tr("System Text"));

    RehearsalMark* rhm = new RehearsalMark(gscore);
    rhm->setTrack(0);
    rhm->setText("B1");
    sp->append(rhm, tr("Rehearsal Mark"));

    InstrumentChange* is = new InstrumentChange(gscore);
    is->setText(tr("Instrument"));
    sp->append(is, tr("Instrument Change"));

    Text* text = new Text(gscore);
    text->setTrack(0);
    text->setTextStyleType(TEXT_STYLE_LYRICS_VERSE_NUMBER);
    text->setText(tr("1."));
    sp->append(text, tr("Lyrics Verse Number"));

    static const TempoPattern tp[] = {
        TempoPattern(QString("%1%2 = 80").    arg(QChar(0xd834)).arg(QChar(0xdd5f)), 80.0/60.0),      // 1/4
        TempoPattern(QString("%1%2 = 80").    arg(QChar(0xd834)).arg(QChar(0xdd5e)), 80.0/30.0),      // 1/2
        TempoPattern(QString("%1%2 = 80").    arg(QChar(0xd834)).arg(QChar(0xdd60)), 80.0/120.0),     // 1/8
        TempoPattern(QString("%1%2%3%4 = 80").arg(QChar(0xd834)).arg(QChar(0xdd5f)).arg(QChar(0xd834)).arg(QChar(0xdd6d)), 120.0/60.0),  // dotted 1/4
        TempoPattern(QString("%1%2%3%4 = 80").arg(QChar(0xd834)).arg(QChar(0xdd5e)).arg(QChar(0xd834)).arg(QChar(0xdd6d)), 120/30.0),    // dotted 1/2
        TempoPattern(QString("%1%2%3%4 = 80").arg(QChar(0xd834)).arg(QChar(0xdd60)).arg(QChar(0xd834)).arg(QChar(0xdd6d)), 120/120.0)    // dotted 1/8
    };
    for (unsigned i = 0; i < sizeof(tp)/sizeof(*tp); ++i) {
        TempoText* tt = new TempoText(gscore);
        tt->setFollowText(true);
        tt->setTrack(0);
        tt->setTempo(tp[i].f);
        tt->setText(tp[i].pattern);
        sp->append(tt, tr("Tempo Text"), QString(), 1.5);
    }

    Harmony* harmony = new Harmony(gscore);
    harmony->setText("C7");
    sp->append(harmony, tr("Chord Name"));
    return sp;
}
void TestChordSymbol::testAddPart()
      {
      MasterScore* score = test_pre("add-part");
      Segment* seg = score->firstSegment(Segment::Type::ChordRest);
      ChordRest* cr = seg->cr(0);
      Harmony* harmony = new Harmony(score);
      harmony->setHarmony("C7");
      harmony->setTrack(cr->track());
      harmony->setParent(cr->segment());
      score->undoAddElement(harmony);
      score->doLayout();
      test_post(score, "add-part");
      }
Exemple #4
0
Palette* MuseScore::newTextPalette()
      {
      Palette* sp = new Palette;
      sp->setName(QT_TRANSLATE_NOOP("Palette", "Text"));
      sp->setMag(0.65);
      sp->setGrid(84, 28);
      sp->setDrawGrid(true);

      StaffText* st = new StaffText(gscore);
      st->setTextStyleType(TextStyleType::STAFF);
      st->setText(tr("staff-text"));
      sp->append(st, tr("Staff Text"));

      st = new StaffText(gscore);
      st->setTextStyleType(TextStyleType::SYSTEM);
      st->setText(tr("system-text"));
      sp->append(st, tr("System Text"));

      RehearsalMark* rhm = new RehearsalMark(gscore);
      rhm->setTrack(0);
      rhm->setText("B1");
      sp->append(rhm, tr("Rehearsal Mark"));

      InstrumentChange* is = new InstrumentChange(gscore);
      is->setText(tr("Instrument"));
      sp->append(is, tr("Instrument Change"));

      Text* text = new Text(gscore);
      text->setTrack(0);
      text->setTextStyleType(TextStyleType::LYRICS_VERSE_NUMBER);
      text->setText(tr("1."));
      sp->append(text, tr("Lyrics Verse Number"));

      Harmony* harmony = new Harmony(gscore);
      harmony->setText("C7");
      sp->append(harmony, tr("Chord Symbol"));
      return sp;
      }
 float operator() (Harmony const& h) const {
     float result = 0.0;
     for (unsigned i = 0; i < h.size(); ++i)
         result += h.at(i);
     return result;
 }
Exemple #6
0
int main(int argc, char* argv[]) {
    srand(time(NULL));
    std::ifstream in;
    std::string outName;
    bool initHarmonies = false;
    if (argc == 3) {
        in.open(argv[1]);
        initHarmonies = in.is_open();
        outName = std::string(argv[2]);
    }

    int const varCount = GetVarCount();
    int const memorySize = 5;
    float const r_accept = 0.95;
    float const r_pa = 0.99;
    float const r_range = 0.1;

    std::vector<Harmony> init;
    if (initHarmonies) {
        for (int i = 0; i < memorySize; ++i) {
            Harmony h;
            in.ignore(1);
            for (int i = 0; i < varCount; ++i) {
                float weight = 0.0;    
                in >> weight;
                h.push_back(weight);
                in.ignore(1);
            }
            in.ignore(1);
            in.ignore(1);
            init.push_back(h);
        }
    }
    in.close();

    int const gameLength = 1000;
    int const iterationCount = 1000;

    HarmonyRanges const* ranges = GetRanges();
    HarmonyFactory const factory (varCount, *ranges);
    GeneratedGame generator (gameLength);
    TetrisPointsEarned f (generator);
    HarmonyCompareMax maxComp (f);
    HarmonyCompareWrapper comp (maxComp);
    HarmonySearch search (comp, factory, varCount, memorySize,
                            r_accept, r_pa, r_range);
    if (initHarmonies)
        search.InitializeHarmonies(init);

    for (int i = 0; i < iterationCount; ++i) {
        search.Iterate();
        generator.GenerateNewGame();
        search.EraseHarmonyCaches();
        std::cout << "COMPLETED ITERATION " << i << std::endl;
    }
    delete ranges;

    std::vector<Harmony const*> memory;
    for (int i = 0; i < memorySize; ++i)
        memory.push_back(search.GetRanked(i));

    std::stringstream ss;
    std::ofstream out (outName.c_str(), std::ios::app);
    for (int i = 0; i < memorySize; ++i)
        ss << *(memory.at(i)) << std::endl << std::endl;

    ss << std::endl;
    out << ss.str();
    out.close();

    for (int i = 0; i < memorySize; ++i)
        delete memory.at(i);

    std::cout << "Completed!" << std::endl;

    return 0;
}
Exemple #7
0
void MuseScore::populatePalette()
      {
      //-----------------------------------
      //    notes
      //-----------------------------------

      Palette* notePalette = new Palette;
      notePalette->setName(tr("Grace Notes"));
      notePalette->setGrid(32, 40);
      notePalette->setDrawGrid(true);

      static const IconAction gna[] = {
            { ICON_ACCIACCATURA, "acciaccatura" },
            { ICON_APPOGGIATURA, "appoggiatura" },
            { ICON_GRACE4,       "grace4" },
            { ICON_GRACE16,      "grace16" },
            { ICON_GRACE32,      "grace32" },
            { -1, "" }
            };
      populateIconPalette(notePalette, gna);

      paletteBox->addPalette(notePalette);

      //-----------------------------------
      //    clefs
      //-----------------------------------

      Palette* sp = new Palette;
      sp->setName(tr("Clefs"));
      sp->setMag(0.8);
      sp->setGrid(33, 60);
      sp->setYOffset(1.0);
      static const ClefType clefs[21] = {
            CLEF_G, CLEF_G1, CLEF_G2, CLEF_G3, CLEF_G4,
            CLEF_C1, CLEF_C2, CLEF_C3, CLEF_C4, CLEF_C5,
            CLEF_F, CLEF_F_8VA, CLEF_F_15MA, CLEF_F8, CLEF_F15, CLEF_F_B, CLEF_F_C,
            CLEF_PERC, CLEF_TAB, CLEF_TAB2, CLEF_PERC2
            };
      for (int i = 0; i < 20; ++i) {
            ClefType j = clefs[i];
            Clef* k = new ::Clef(gscore);
            k->setClefType(ClefTypeList(j, j));
            sp->append(k, qApp->translate("clefTable", clefTable[j].name));
            }
      paletteBox->addPalette(sp);

      //-----------------------------------
      //    key signatures
      //-----------------------------------

      sp = newKeySigPalette();
      paletteBox->addPalette(sp);

      //-----------------------------------
      //    Time
      //-----------------------------------

      sp = new Palette;
      sp->setName(tr("Time Signatures"));
      sp->setMag(.8);
      sp->setGrid(42, 38);

      TimeSig* ts;
      ts = new TimeSig(gscore);
      ts->setSig(2, 2);
      sp->append(ts, "2/2");

      sp->append(new TimeSig(gscore,  2, 4), "2/4");
      sp->append(new TimeSig(gscore,  3, 4), "3/4");
      sp->append(new TimeSig(gscore,  4, 4), "4/4");
      sp->append(new TimeSig(gscore,  5, 4), "5/4");
      sp->append(new TimeSig(gscore,  6, 4), "6/4");
      sp->append(new TimeSig(gscore,  3, 8), "3/8");
      sp->append(new TimeSig(gscore,  6, 8), "6/8");
      sp->append(new TimeSig(gscore,  9, 8), "9/8");
      sp->append(new TimeSig(gscore, 12, 8), "12/8");

      sp->append(new TimeSig(gscore, TSIG_FOUR_FOUR),  tr("4/4 common time"));
      sp->append(new TimeSig(gscore, TSIG_ALLA_BREVE), tr("2/2 alla breve"));
      paletteBox->addPalette(sp);

      //-----------------------------------
      //    Bar Lines
      //-----------------------------------

      sp = new Palette;
      sp->setName(tr("Barlines"));
      sp->setMag(0.8);
      sp->setGrid(42, 38);

      struct {
            BarLineType type;
            const char* name;
            } t[] = {
            { NORMAL_BAR,       QT_TR_NOOP("Normal") },
            { BROKEN_BAR,       QT_TR_NOOP("Dashed") },
            { END_BAR,          QT_TR_NOOP("End Bar") },
            { DOUBLE_BAR,       QT_TR_NOOP("Double Bar") },
            { START_REPEAT,     QT_TR_NOOP("Start Repeat") },
            { END_REPEAT,       QT_TR_NOOP("End Repeat") },
            { END_START_REPEAT, QT_TR_NOOP("End-Start Repeat") },
            };
      for (unsigned i = 0; i < sizeof(t)/sizeof(*t); ++i) {
            BarLine* b  = new BarLine(gscore);
            b->setSubtype(t[i].type);
            sp->append(b, tr(t[i].name));
            }
      paletteBox->addPalette(sp);

      //-----------------------------------
      //    Lines
      //-----------------------------------

      sp = new Palette;
      sp->setName(tr("Lines"));
      sp->setMag(.8);
      sp->setGrid(82, 23);

      Slur* slur = new Slur(gscore);
      slur->setId(0);
      sp->append(slur, tr("Slur"));

      Hairpin* gabel0 = new Hairpin(gscore);
      gabel0->setSubtype(0);
      sp->append(gabel0, tr("Crescendo"));

      Hairpin* gabel1 = new Hairpin(gscore);
      gabel1->setSubtype(1);
      sp->append(gabel1, tr("Diminuendo"));

      Volta* volta = new Volta(gscore);
      volta->setSubtype(VOLTA_CLOSED);
      volta->setText("1.");
      QList<int> il;
      il.append(1);
      volta->setEndings(il);
      sp->append(volta, tr("Prima volta"));

      volta = new Volta(gscore);
      volta->setSubtype(VOLTA_CLOSED);
      volta->setText("2.");
      il.clear();
      il.append(2);
      volta->setEndings(il);
      sp->append(volta, tr("Seconda volta"));

      volta = new Volta(gscore);
      volta->setSubtype(VOLTA_CLOSED);
      volta->setText("3.");
      il.clear();
      il.append(3);
      volta->setEndings(il);
      sp->append(volta, tr("Terza volta"));

      volta = new Volta(gscore);
      volta->setSubtype(VOLTA_OPEN);
      volta->setText("2.");
      il.clear();
      il.append(2);
      volta->setEndings(il);
      sp->append(volta, tr("Seconda volta 2"));

      Ottava* ottava = new Ottava(gscore);
      ottava->setSubtype(0);
      sp->append(ottava, tr("8va"));

      ottava = new Ottava(gscore);
      ottava->setSubtype(1);
      sp->append(ottava, tr("15ma"));

      ottava = new Ottava(gscore);
      ottava->setSubtype(2);
      sp->append(ottava, tr("8vb"));

      ottava = new Ottava(gscore);
      ottava->setSubtype(3);
      sp->append(ottava, tr("15mb"));

      Pedal* pedal = new Pedal(gscore);
      //pedal->setLen(l);
      sp->append(pedal, tr("Pedal"));

      pedal = new Pedal(gscore);
      //pedal->setLen(l);
      pedal->setEndHookType(HOOK_45);
      sp->append(pedal, tr("Pedal"));

      pedal = new Pedal(gscore);
      //pedal->setLen(l);
      pedal->setBeginSymbol(-1);
      pedal->setBeginHook(true);
      pedal->setBeginHookType(HOOK_45);
      pedal->setEndHookType(HOOK_45);
      sp->append(pedal, tr("Pedal"));

      pedal = new Pedal(gscore);
      //pedal->setLen(l);
      pedal->setBeginSymbol(-1);
      pedal->setBeginHook(true);
      pedal->setBeginHookType(HOOK_45);
      sp->append(pedal, tr("Pedal"));

      Trill* trill = new Trill(gscore);
      sp->append(trill, tr("Trill line"));

      trill = new Trill(gscore);
      trill->setSubtype("upprall");
      sp->append(trill, tr("Upprall line"));

      trill = new Trill(gscore);
      trill->setSubtype("downprall");
      sp->append(trill, tr("Downprall line"));

      trill = new Trill(gscore);
      trill->setSubtype("prallprall");
      sp->append(trill, tr("Prallprall line"));

      TextLine* textLine = new TextLine(gscore);
      textLine->setBeginText("VII");
      textLine->setEndHook(true);
      sp->append(textLine, tr("Text line"));

      TextLine* line = new TextLine(gscore);
      line->setDiagonal(true);
      sp->append(line, tr("Line"));

      paletteBox->addPalette(sp);

      //-----------------------------------
      //    Arpeggio && Glissando
      //-----------------------------------

      sp = new Palette();
      sp->setName(tr("Arpeggio && Glissando"));
      sp->setGrid(27, 60);

      for (int i = 0; i < 4; ++i) {
            Arpeggio* a = new Arpeggio(gscore);
            a->setSubtype(ArpeggioType(i));
            sp->append(a, tr("Arpeggio"));
            }
      for (int i = 0; i < 2; ++i) {
            Glissando* a = new Glissando(gscore);
            a->setSubtype(i);
            sp->append(a, tr("Glissando"));
            }
      paletteBox->addPalette(sp);

      //-----------------------------------
      //    Symbols: Breath
      //-----------------------------------

      sp = new Palette();
      sp->setName(tr("Breath && Pauses"));
      sp->setGrid(42, 40);

      for (int i = 0; i < 4; ++i) {
            Breath* a = new Breath(gscore);
            a->setSubtype(i);
            if (i < 2)
                  sp->append(a, tr("Breath"));
            else
                  sp->append(a, tr("Caesura"));
            }

      paletteBox->addPalette(sp);

      //-----------------------------------
      //    Brackets
      //-----------------------------------

      sp = new Palette;
      sp->setName(tr("Brackets"));
      sp->setMag(0.7);
      sp->setGrid(42, 60);

      Bracket* b1 = new Bracket(gscore);
      b1->setSubtype(BRACKET_NORMAL);
      Bracket* b2 = new Bracket(gscore);
      b2->setSubtype(BRACKET_AKKOLADE);
      // b1->setHeight(_spatium * 7);
      // b2->setHeight(_spatium * 7);

      sp->append(b1, tr("Square bracket"));
      sp->append(b2, tr("Curly bracket"));

      paletteBox->addPalette(sp);

      //-----------------------------------
      //    Attributes, Ornaments
      //-----------------------------------

      sp = new Palette;
      sp->setName(tr("Articulations && Ornaments"));
      sp->setGrid(42, 25);

      for (int i = 0; i < ARTICULATIONS; ++i) {
            Articulation* s = new Articulation(gscore);
            s->setSubtype(ArticulationType(i));
            sp->append(s, qApp->translate("articulation", qPrintable(s->subtypeUserName())));
            }
      Bend* bend = new Bend(gscore);
      bend->points().append(PitchValue(0,    0, false));
      bend->points().append(PitchValue(15, 100, false));
      bend->points().append(PitchValue(60, 100, false));
      sp->append(bend, qApp->translate("articulation", "Bend"));

      TremoloBar* tb = new TremoloBar(gscore);
      tb->points().append(PitchValue(0,     0, false));     // "Dip"
      tb->points().append(PitchValue(30, -100, false));
      tb->points().append(PitchValue(60,    0, false));
      sp->append(tb, qApp->translate("articulation", "Tremolo Bar"));

      paletteBox->addPalette(sp);

      //-----------------------------------
      //    Accidentals
      //-----------------------------------

      sp = newAccidentalsPalette();
      paletteBox->addPalette(sp);

      //-----------------------------------
      //    Dynamics
      //-----------------------------------

      sp = new Palette;
      sp->setName(tr("Dynamics"));
      sp->setMag(.8);
      sp->setGrid(42, 28);

      static const char* dynS[] = {
            "ppp", "pp", "p", "mp", "mf", "f", "ff", "fff"
            };
      for (unsigned i = 0; i < sizeof(dynS)/sizeof(*dynS); ++i) {
            Dynamic* dynamic = new Dynamic(gscore);
            dynamic->setSubtype(dynS[i]);
            sp->append(dynamic, dynamic->subtypeName());
            }
      paletteBox->addPalette(sp);

      //-----------------------------------
      //    Fingering
      //-----------------------------------

      sp = new Palette;
      sp->setName(tr("Fingering"));
      sp->setMag(1.5);
      sp->setGrid(28, 30);
      sp->setDrawGrid(true);

      const char finger[] = "012345pimac";
      for (unsigned i = 0; i < strlen(finger); ++i) {
            Fingering* f = new Fingering(gscore);
            f->setText(QString(finger[i]));
            sp->append(f, tr("Fingering %1").arg(finger[i]));
            }
      const char stringnumber[] = "0123456";
      for (unsigned i = 0; i < strlen(stringnumber); ++i) {
            Fingering* f = new Fingering(gscore);
            f->setTextStyle(TEXT_STYLE_STRING_NUMBER);
            f->setText(QString(stringnumber[i]));
            sp->append(f, tr("String number %1").arg(stringnumber[i]));
            }
      Symbol* symbol = new Symbol(gscore, thumbSym);
      sp->append(symbol, tr("Thumb"));

      paletteBox->addPalette(sp);

      //-----------------------------------
      //    Noteheads
      //-----------------------------------

      sp = new Palette;
      sp->setName(tr("Note Heads"));
      sp->setMag(1.3);
      sp->setGrid(33, 36);
      sp->setDrawGrid(true);

      for (int i = 0; i < HEAD_GROUPS; ++i) {
            int sym = noteHeads[0][i][1];
            if (i == HEAD_BREVIS_ALT)
                  sym = noteHeads[0][i][3];
            NoteHead* nh = new NoteHead(gscore);
            nh->setSym(sym);
            sp->append(nh, qApp->translate("symbol", symbols[0][sym].name()));
            }
      paletteBox->addPalette(sp);

      //-----------------------------------
      //    Tremolo
      //-----------------------------------

      sp = new Palette;
      sp->setName(tr("Tremolo"));
      sp->setGrid(27, 40);
      sp->setDrawGrid(true);
      const char* tremoloName[] = {
            QT_TR_NOOP("1/8 through stem"),
            QT_TR_NOOP("1/16 through stem"),
            QT_TR_NOOP("1/32 through stem"),
            QT_TR_NOOP("1/64 through stem"),
            QT_TR_NOOP("1/8 between notes"),
            QT_TR_NOOP("1/16 between notes"),
            QT_TR_NOOP("1/32 between notes"),
            QT_TR_NOOP("1/64 between notes")
            };

      for (int i = TREMOLO_R8; i <= TREMOLO_C64; ++i) {
            Tremolo* tremolo = new Tremolo(gscore);
            tremolo->setSubtype(TremoloType(i));
            sp->append(tremolo, tr(tremoloName[i - TREMOLO_R8]));
            }
      paletteBox->addPalette(sp);

      //-----------------------------------
      //    Fall, Doit
      //-----------------------------------

      sp = new Palette;
      sp->setName(tr("Fall/Doit"));
      sp->setGrid(27, 40);
      sp->setDrawGrid(true);
      const char* scorelineNames[] = {
            QT_TR_NOOP("fall"),
            QT_TR_NOOP("doit"),
            };

      ChordLine* cl = new ChordLine(gscore);
      cl->setSubtype(1);
      sp->append(cl, tr(scorelineNames[0]));

      cl = new ChordLine(gscore);
      cl->setSubtype(2);
      sp->append(cl, tr(scorelineNames[1]));

      paletteBox->addPalette(sp);

      //-----------------------------------
      //    Repeats
      //-----------------------------------

      sp = new Palette;
      sp->setName(tr("Repeats"));
      sp->setMag(0.65);
      sp->setGrid(84, 28);
      sp->setDrawGrid(true);

      RepeatMeasure* rm = new RepeatMeasure(gscore);
      sp->append(rm, tr("Repeat measure sign"));

      Marker* mk = new Marker(gscore);
      mk->setMarkerType(MARKER_SEGNO);
      sp->append(mk, tr("Segno"));

      mk = new Marker(gscore);
      mk->setMarkerType(MARKER_VARSEGNO);
      sp->append(mk, tr("Segno Variation"));

      mk = new Marker(gscore);
      mk->setMarkerType(MARKER_CODA);
      sp->append(mk, tr("Coda"));

      mk = new Marker(gscore);
      mk->setMarkerType(MARKER_VARCODA);
      sp->append(mk, tr("Varied coda"));

      mk = new Marker(gscore);
      mk->setMarkerType(MARKER_CODETTA);
      sp->append(mk, tr("Codetta"));

      mk = new Marker(gscore);
      mk->setMarkerType(MARKER_FINE);
      sp->append(mk, tr("Fine"));

      Jump* jp = new Jump(gscore);
      jp->setJumpType(JUMP_DC);
      sp->append(jp, tr("Da Capo"));

      jp = new Jump(gscore);
      jp->setJumpType(JUMP_DC_AL_FINE);
      sp->append(jp, tr("Da Capo al Fine"));

      jp = new Jump(gscore);
      jp->setJumpType(JUMP_DC_AL_CODA);
      sp->append(jp, tr("Da Capo al Coda"));

      jp = new Jump(gscore);
      jp->setJumpType(JUMP_DS_AL_CODA);
      sp->append(jp, tr("D.S al Coda"));

      jp = new Jump(gscore);
      jp->setJumpType(JUMP_DS_AL_FINE);
      sp->append(jp, tr("D.S al Fine"));

      jp = new Jump(gscore);
      jp->setJumpType(JUMP_DS);
      sp->append(jp, tr("D.S"));

      mk = new Marker(gscore);
      mk->setMarkerType(MARKER_TOCODA);
      sp->append(mk, tr("To Coda"));

      paletteBox->addPalette(sp);

      //-----------------------------------
      //    Text
      //-----------------------------------

      sp = new Palette;
      sp->setName(tr("Text"));
      sp->setMag(0.65);
      sp->setGrid(84, 28);
      sp->setDrawGrid(true);

      StaffText* st = new StaffText(gscore);
      st->setSystemFlag(false);
      st->setTextStyle(TEXT_STYLE_STAFF);
//TODO      st->setSubtype(TEXT_STAFF);
      st->setText(tr("staff-text"));
      sp->append(st, tr("Staff Text"));

      st = new StaffText(gscore);
      st->setSystemFlag(true);
      st->setTextStyle(TEXT_STYLE_SYSTEM);
//      st->setSubtype(TEXT_SYSTEM);
      st->setText(tr("system-text"));
      sp->append(st, tr("System Text"));

      RehearsalMark* rhm = new RehearsalMark(gscore);
      rhm->setTrack(0);
      rhm->setText("B1");
      sp->append(rhm, tr("RRehearsal Mark"));

      InstrumentChange* is = new InstrumentChange(gscore);
      is->setText(tr("Instrument"));
      sp->append(is, tr("Instrument Change"));

      Text* text = new Text(gscore);
      text->setTrack(0);
      text->setTextStyle(TEXT_STYLE_LYRICS_VERSE_NUMBER);
      text->setText(tr("1."));
      text->setSystemFlag(true);
      sp->append(text, tr("Lyrics Verse Number"));

      static const TempoPattern tp[] = {
            TempoPattern(QString("%1%2 = 80").    arg(QChar(0xd834)).arg(QChar(0xdd5f)), 80.0/60.0),      // 1/4
            TempoPattern(QString("%1%2 = 80").    arg(QChar(0xd834)).arg(QChar(0xdd5e)), 80.0/30.0),      // 1/2
            TempoPattern(QString("%1%2 = 80").    arg(QChar(0xd834)).arg(QChar(0xdd60)), 80.0/120.0),     // 1/8
            TempoPattern(QString("%1%2%3%4 = 80").arg(QChar(0xd834)).arg(QChar(0xdd5f)).arg(QChar(0xd834)).arg(QChar(0xdd6d)), 120.0/60.0),  // dotted 1/4
            TempoPattern(QString("%1%2%3%4 = 80").arg(QChar(0xd834)).arg(QChar(0xdd5e)).arg(QChar(0xd834)).arg(QChar(0xdd6d)), 120/30.0),    // dotted 1/2
            TempoPattern(QString("%1%2%3%4 = 80").arg(QChar(0xd834)).arg(QChar(0xdd60)).arg(QChar(0xd834)).arg(QChar(0xdd6d)), 120/120.0)    // dotted 1/8
            };
      for (unsigned i = 0; i < sizeof(tp)/sizeof(*tp); ++i) {
            TempoText* tt = new TempoText(gscore);
            tt->setFollowText(true);
            tt->setTrack(0);
            tt->setTempo(tp[i].f);
            tt->setText(tp[i].pattern);
            sp->append(tt, tr("Tempo Text"), QString(), 1.5);
            }

      Harmony* harmony = new Harmony(gscore);
      harmony->setText("c7");
      sp->append(harmony, tr("Chord Name"));

      paletteBox->addPalette(sp);

      //-----------------------------------
      //    breaks
      //-----------------------------------

      qreal _spatium = gscore->spatium();
      sp = new Palette;
      sp->setName(tr("Breaks && Spacer"));
      sp->setMag(.7);
      sp->setGrid(42, 36);
      sp->setDrawGrid(true);

      LayoutBreak* lb = new LayoutBreak(gscore);
      lb->setSubtype(LAYOUT_BREAK_LINE);
      sp->append(lb, tr("Line break"));

      lb = new LayoutBreak(gscore);
      lb->setSubtype(LAYOUT_BREAK_PAGE);
      sp->append(lb, tr("Page break"));

      lb = new LayoutBreak(gscore);
      lb->setSubtype(LAYOUT_BREAK_SECTION);
      sp->append(lb, tr("Section break"));

      Spacer* spacer = new Spacer(gscore);
      spacer->setGap(3 * _spatium);
      spacer->setSubtype(SPACER_DOWN);
      sp->append(spacer, tr("Staff spacer down"));

      spacer = new Spacer(gscore);
      spacer->setGap(3 * _spatium);
      spacer->setSubtype(SPACER_UP);
      sp->append(spacer, tr("Staff spacer up"));

      paletteBox->addPalette(sp);

      //-----------------------------------
      //    staff state changes
      //-----------------------------------

#if 0
      sp = new Palette;
      sp->setName(tr("Staff Changes"));
      sp->setMag(.7);
      sp->setGrid(42, 36);
      sp->setDrawGrid(true);

      StaffState* st = new StaffState(gscore);
      st->setSubtype(STAFF_STATE_VISIBLE);
      sp->append(st, tr("set visible"));

      st = new StaffState(gscore);
      st->setSubtype(STAFF_STATE_INVISIBLE);
      sp->append(st, tr("set invisible"));

      st = new StaffState(gscore);
      st->setSubtype(STAFF_STATE_TYPE);
      sp->append(st, tr("change staff type"));

      st = new StaffState(gscore);
      st->setSubtype(STAFF_STATE_INSTRUMENT);
      sp->append(st, tr("change instrument"));

      paletteBox->addPalette(sp);
#endif

      //-----------------------------------
      //    beam properties
      //-----------------------------------

      sp = new Palette;
      sp->setName(tr("Beam Properties"));
      sp->setGrid(27, 40);
      sp->setDrawGrid(true);

      static const IconAction bpa[] = {
            { ICON_SBEAM,    "beam-start" },
            { ICON_MBEAM,    "beam-mid" },
            { ICON_NBEAM,    "no-beam" },
            { ICON_BEAM32,   "beam32" },
            { ICON_BEAM64,   "beam64" },
            { ICON_AUTOBEAM, "auto-beam" },
            { ICON_FBEAM1,   "fbeam1" },
            { ICON_FBEAM2,   "fbeam2" },
            { -1, ""}
            };

      populateIconPalette(sp, bpa);
      paletteBox->addPalette(sp);

      //-----------------------------------
      //    Symbols
      //-----------------------------------

      sp = new Palette;
      sp->setName(tr("Symbols"));
      sp->setGrid(42, 45);
      sp->setDrawGrid(true);

      sp->append(accDiscantSym);
      sp->append(accDotSym);
      sp->append(accFreebaseSym);
      sp->append(accStdbaseSym);
      sp->append(accBayanbaseSym);
      sp->append(accOldEESym);
      sp->append(accpushSym);
      sp->append(accpullSym);

      FretDiagram* fret = new FretDiagram(gscore);
      fret->setDot(5, 1);
      fret->setDot(2, 2);
      fret->setDot(1, 3);
      fret->setMarker(0, 'X');
      fret->setMarker(3, 'O');
      fret->setMarker(4, 'O');
      sp->append(fret, tr("Fret Diagram"));

      paletteBox->addPalette(sp);
      }
 float operator() (Harmony const& h) const {
     float x = h.at(0);
     float y = h.at(1);
     float result = (1-x)*(1-x) + 100*(y-x*x)*(y-x*x);
     return result;
 }