Example #1
0
static U8 handle_dec_entry(U8 key)
{
    U8 status;
    switch (CUR_COL_CHAIN)
    {
        case PHRASE_COL:
            status = get_hex_from_keyboard(key, PHRASE_COUNT - 1);
            switch (status)
            {
                case HEXGET_DONE:
                    last_input_phrase[EDIT_CH] = g_hexget_value;
                    alloc_phrase(g_hexget_value);
                    // Fall through!
                    
                case HEXGET_ACTIVE:
                    set_phrase(g_hexget_value);
            }
            break;

        case TRANSPOSE_COL:
            status = get_hex_from_keyboard(key, 0xffu);
            if (status != HEXGET_IDLE)
            {
                set_transpose(g_hexget_value);
                last_input_transpose[EDIT_CH] = g_hexget_value;
            }
            break;
    }
    return status == HEXGET_ACTIVE;
}
Example #2
0
static void handle_space()
{
    switch (CUR_COL_CHAIN)
    {
        case PHRASE_COL:
            handle_phrase_space();
            break;

        case TRANSPOSE_COL:
            {
                U8 tsp = get_transpose();
                if (!tsp)
                    set_transpose(last_input_transpose[EDIT_CH]);
                else
                    last_input_transpose[EDIT_CH] = tsp;
            }
    }
}
Example #3
0
void
perfedit::transpose_button_callback (int transpose)
{
    if (perf().get_transpose() != transpose)
        set_transpose(transpose);
}
Example #4
0
perfedit::perfedit
(
    perform & p,
    bool second_perfedit,
    int ppqn
) :
    gui_window_gtk2     (p, 750, 500),
    m_peer_perfedit     (nullptr),
    m_table             (manage(new Gtk::Table(6, 3, false))),
    m_vadjust           (manage(new Gtk::Adjustment(0, 0, 1, 1, 1, 1))),
    m_hadjust           (manage(new Gtk::Adjustment(0, 0, 1, 1, 1, 1))),
    m_vscroll           (manage(new Gtk::VScrollbar(*m_vadjust))),
    m_hscroll           (manage(new Gtk::HScrollbar(*m_hadjust))),
    m_perfnames         (manage(new perfnames(perf(), *this, *m_vadjust))),
    m_perfroll
    (
        manage(new perfroll(perf(), *this, *m_hadjust, *m_vadjust, ppqn))
    ),
    m_perftime          (manage(new perftime(perf(), *this, *m_hadjust))),
    m_menu_snap         (manage(new Gtk::Menu())),
#ifdef SEQ64_STAZED_TRANSPOSE
    m_menu_xpose        (manage(new Gtk::Menu())),
    m_button_xpose      (manage(new Gtk::Button())),
    m_entry_xpose       (manage(new Gtk::Entry())),
#endif
    m_image_play        (manage(new PIXBUF_IMAGE(play2_xpm))),
    m_button_snap       (manage(new Gtk::Button())),
    m_entry_snap        (manage(new Gtk::Entry())),
    m_button_stop       (manage(new Gtk::Button())),
    m_button_play       (manage(new Gtk::Button())),
    m_button_loop       (manage(new Gtk::ToggleButton())),
    m_button_expand     (manage(new Gtk::Button())),
    m_button_collapse   (manage(new Gtk::Button())),
    m_button_copy       (manage(new Gtk::Button())),
    m_button_grow       (manage(new Gtk::Button())),
    m_button_undo       (manage(new Gtk::Button())),
    m_button_redo       (manage(new Gtk::Button())),    // stazed
#ifdef SEQ64_STAZED_JACK_SUPPORT
    m_button_jack       (manage(new Gtk::ToggleButton())),
    m_button_follow     (manage(new Gtk::ToggleButton())),
#endif
    m_button_bpm        (manage(new Gtk::Button())),
    m_entry_bpm         (manage(new Gtk::Entry())),
    m_button_bw         (manage(new Gtk::Button())),
    m_entry_bw          (manage(new Gtk::Entry())),
    m_hbox              (manage(new Gtk::HBox(false, 2))),
    m_hlbox             (manage(new Gtk::HBox(false, 2))),
    m_tooltips          (manage(new Gtk::Tooltips())),  // valgrind complains!
    m_menu_bpm          (manage(new Gtk::Menu())),
    m_menu_bw           (manage(new Gtk::Menu())),
    m_snap              (0),
    m_bpm               (0),
    m_bw                (0),
    m_ppqn              (0),
#ifdef SEQ64_PAUSE_SUPPORT
    m_is_running        (false),
#endif
    m_standard_bpm      (SEQ64_DEFAULT_LINES_PER_MEASURE)   /* 4            */
{
    std::string title = "Sequencer64 - Song Editor";
    if (second_perfedit)
        title += " 2";

    m_ppqn = choose_ppqn(ppqn);
    set_icon(Gdk::Pixbuf::create_from_xpm_data(perfedit_xpm));
    set_title(title);                                       /* caption bar  */
    m_table->set_border_width(2);
    m_hlbox->set_border_width(2);
    m_button_grow->add
    (
        *manage(new Gtk::Arrow(Gtk::ARROW_RIGHT, Gtk::SHADOW_OUT))
    );
    m_button_grow->signal_clicked().connect(mem_fun(*this, &perfedit::grow));
    add_tooltip(m_button_grow, "Increase size of grid.");

    /*
     * Fill the table
     */

    m_table->attach(*m_hlbox, 0, 3, 0, 1,  Gtk::FILL, Gtk::SHRINK, 2, 0);
    m_table->attach(*m_perfnames, 0, 1, 2, 3, Gtk::SHRINK, Gtk::FILL);
    m_table->attach(*m_perftime, 1, 2, 1, 2, Gtk::FILL, Gtk::SHRINK);
    m_table->attach
    (
        *m_perfroll, 1, 2, 2, 3, Gtk::FILL | Gtk::SHRINK, Gtk::FILL | Gtk::SHRINK
    );
    m_table->attach(*m_vscroll, 2, 3, 2, 3, Gtk::SHRINK, Gtk::FILL | Gtk::EXPAND);
    m_table->attach(*m_hbox,  0, 1, 3, 4,  Gtk::FILL, Gtk::SHRINK, 0, 2);
    m_table->attach(*m_hscroll, 1, 2, 3, 4, Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK);
    m_table->attach(*m_button_grow, 2, 3, 3, 4, Gtk::SHRINK, Gtk::SHRINK);

    /*
     * To reduce the amount of written code, we now use a static array to
     * initialize some of the menu entries.  We use the same list for the snap
     * menu and for the beat-width menu.  This adds a beat-width of 32 to the
     * beat-width menu.  A new feature!  :-D
     */

#define SET_SNAP    mem_fun(*this, &perfedit::set_snap)
#define SET_BW      mem_fun(*this, &perfedit::set_beat_width)

    static const int s_width_items [] =
    {
        1, 2, 4, 8, 16, 32,
        0,
        3, 6, 12, 24,
#ifdef USE_STAZED_EXTRA_SNAPS
        0,
        5, 10, 20, 40,
        0,
        7, 9, 11, 13, 14, 15
#endif
    };
    static const int s_width_count = sizeof(s_width_items) / sizeof(int);
    for (int si = 0; si < s_width_count; ++si)
    {
        int item = s_width_items[si];
        char fmt[8];
        bool use_separator = false;
        if (item > 1)
            snprintf(fmt, sizeof fmt, "1/%d", item);
        else if (item == 0)
            use_separator = true;
        else
            snprintf(fmt, sizeof fmt, "%d", item);

        if (use_separator)
        {
            m_menu_snap->items().push_back(SeparatorElem());
        }
        else
        {
            m_menu_snap->items().push_back
            (
                MenuElem(fmt, sigc::bind(SET_SNAP, item))
            );
            snprintf(fmt, sizeof fmt, "%d", item);
            m_menu_bw->items().push_back(MenuElem(fmt, sigc::bind(SET_BW, item)));
        }
    }

#define SET_POPUP   mem_fun(*this, &perfedit::popup_menu)

    m_button_snap->add(*manage(new PIXBUF_IMAGE(snap_xpm)));
    m_button_snap->signal_clicked().connect
    (
        sigc::bind<Gtk::Menu *>(SET_POPUP, m_menu_snap)
    );
    add_tooltip(m_button_snap, "Grid snap (fraction of measure length).");
    m_entry_snap->set_size_request(40, -1);
    m_entry_snap->set_editable(false);

#ifdef SEQ64_STAZED_TRANSPOSE

    char num[12];
    for (int i = -SEQ64_OCTAVE_SIZE; i <= SEQ64_OCTAVE_SIZE; ++i)
    {
        if (i != 0)
            snprintf(num, sizeof num, "%+d [%s]", i, c_interval_text[abs(i)]);
        else
            snprintf(num, sizeof num, "0 [normal]");

        m_menu_xpose->items().push_front
        (
            MenuElem
            (
                num,
                sigc::bind
                (
                    mem_fun(*this, &perfedit::transpose_button_callback), i
                )
            )
        );
    }
    m_button_xpose->add
    (
        *manage(new Gtk::Image(Gdk::Pixbuf::create_from_xpm_data(transpose_xpm)))
    );
    m_button_xpose->signal_clicked().connect
    (
        sigc::bind<Gtk::Menu *>
        (
            mem_fun(*this, &perfedit::popup_menu), m_menu_xpose
        )
    );
    add_tooltip(m_button_xpose, "Song-transpose all transposable sequences.");
    m_entry_xpose->set_size_request(30, -1);
    m_entry_xpose->set_editable(false);

#endif  // SEQ64_STAZED_TRANSPOSE

#define SET_BPB     mem_fun(*this, &perfedit::set_beats_per_bar)

    char b[4];
    for (int i = 0; i < 16; ++i)
    {
        snprintf(b, sizeof b, "%d", i + 1);
        m_menu_bpm->items().push_back(MenuElem(b, sigc::bind(SET_BPB, i + 1)));
    }
    m_button_bpm->add(*manage(new PIXBUF_IMAGE(down_xpm)));
    m_button_bpm->signal_clicked().connect
    (
        sigc::bind<Gtk::Menu *>(SET_POPUP, m_menu_bpm)
    );
    add_tooltip
    (
        m_button_bpm, "Time signature: beats per measure or bar."
    );
    m_entry_bpm->set_width_chars(2);
    m_entry_bpm->set_editable(false);

    m_button_bw->add(*manage(new PIXBUF_IMAGE(down_xpm)));  /* beat width */
    m_button_bw->signal_clicked().connect
    (
        sigc::bind<Gtk::Menu *>(SET_POPUP, m_menu_bw)
    );
    add_tooltip(m_button_bw, "Time signature: length of measure or bar.");
    m_entry_bw->set_width_chars(2);
    m_entry_bw->set_editable(false);

    m_button_undo->add(*manage(new PIXBUF_IMAGE(undo_xpm)));
    m_button_undo->signal_clicked().connect(mem_fun(*this, &perfedit::undo));
    add_tooltip(m_button_undo, "Undo the last action (Ctrl-Z).");

    m_button_redo->add(*manage(new PIXBUF_IMAGE(redo_xpm)));
    m_button_redo->signal_clicked().connect(mem_fun(*this, &perfedit::redo));
    add_tooltip(m_button_redo, "Redo the last undone action (Ctrl-R).");

    m_button_expand->add(*manage(new PIXBUF_IMAGE(expand_xpm)));
    m_button_expand->signal_clicked().connect(mem_fun(*this, &perfedit::expand));
    add_tooltip(m_button_expand, "Expand space between L and R markers.");

    m_button_collapse->add(*manage(new PIXBUF_IMAGE(collapse_xpm)));
    m_button_collapse->signal_clicked().connect
    (
        mem_fun(*this, &perfedit::collapse)
    );
    add_tooltip(m_button_collapse, "Collapse pattern between L and R markers.");

    m_button_copy->add(*manage(new PIXBUF_IMAGE(copy_xpm))); /* expand+copy */
    m_button_copy->signal_clicked().connect(mem_fun(*this, &perfedit::copy));
    add_tooltip(m_button_copy, "Expand and copy between the L and R markers.");

    m_button_loop->add(*manage(new PIXBUF_IMAGE(loop_xpm)));
    m_button_loop->signal_toggled().connect
    (
        mem_fun(*this, &perfedit::set_looped)
    );
    add_tooltip(m_button_loop, "Playback looped between the L and R markers.");

    m_button_stop->set_focus_on_click(false);
    m_button_stop->add(*manage(new PIXBUF_IMAGE(stop_xpm)));
    m_button_stop->signal_clicked().connect
    (
        mem_fun(*this, &perfedit::stop_playing)
    );
    add_tooltip(m_button_stop, "Stop playback.");
    m_button_stop->set_sensitive(true);

    m_button_play->set_focus_on_click(false);
    m_button_play->set_image(*m_image_play);
    m_button_play->signal_clicked().connect
    (
        mem_fun(*this, &perfedit::start_playing)
    );
    add_tooltip(m_button_play, "Begin playback at the L marker.");
    m_button_play->set_sensitive(true);

#ifdef SEQ64_STAZED_JACK_SUPPORT
    m_button_jack->add(*manage(new PIXBUF_IMAGE(jack_black_xpm)));
    m_button_jack->signal_clicked().connect
    (
        mem_fun(*this, &perfedit::set_jack_mode)
    );
    add_tooltip(m_button_jack, "Toggle JACK sync connection.");
    if (rc().with_jack_transport())
        m_button_jack->set_active(true);

    m_button_follow->add(*manage(new PIXBUF_IMAGE(transport_follow_xpm)));
    m_button_follow->signal_clicked().connect
    (
        mem_fun(*this, &perfedit::set_follow_transport)
    );
    add_tooltip(m_button_follow, "Toggle the following of JACK transport.");
    m_button_follow->set_active(true);
#endif

    m_hlbox->pack_end(*m_button_copy , false, false);
    m_hlbox->pack_end(*m_button_expand , false, false);
    m_hlbox->pack_end(*m_button_collapse , false, false);
    m_hlbox->pack_end(*m_button_undo , false, false);
    m_hlbox->pack_end(*m_button_redo , false, false);       // stazed
    m_hlbox->pack_start(*m_button_stop , false, false);
    m_hlbox->pack_start(*m_button_play , false, false);
    m_hlbox->pack_start(*m_button_loop , false, false);
    m_hlbox->pack_start(*m_button_bpm , false, false);
    m_hlbox->pack_start(*m_entry_bpm , false, false);
    m_hlbox->pack_start(*(manage(new Gtk::Label("/"))), false, false, 4);
    m_hlbox->pack_start(*m_button_bw , false, false);
    m_hlbox->pack_start(*m_entry_bw , false, false);
    m_hlbox->pack_start(*(manage(new Gtk::Label("x"))), false, false, 4);
    m_hlbox->pack_start(*m_button_snap , false, false);
    m_hlbox->pack_start(*m_entry_snap , false, false);

#ifdef SEQ64_STAZED_TRANSPOSE
    m_hlbox->pack_start(*m_button_xpose , false, false);
    m_hlbox->pack_start(*m_entry_xpose , false, false);
#endif

#ifdef SEQ64_STAZED_JACK_SUPPORT
    m_hlbox->pack_start(*m_button_jack, false, false);
    m_hlbox->pack_start(*m_button_follow, false, false);
#endif

    add(*m_table);

    /*
     * Here, the set_snap call depends on the others being done first.  These
     * calls also depend upon the values being set to bogus (0) values in the
     * initializer list, otherwise no change will occur, and the items won't
     * be displayed.
     */

    set_beats_per_bar(SEQ64_DEFAULT_BEATS_PER_MEASURE); /* time-sig numerator   */
    set_beat_width(SEQ64_DEFAULT_BEAT_WIDTH);           /* time-sig denominator */
    set_snap(SEQ64_DEFAULT_PERFEDIT_SNAP);

#ifdef SEQ64_STAZED_TRANSPOSE
    set_transpose(0);
#endif

    /*
     * Log the pointer to the appropriate perfedit object, if not already
     * done.
     */

    if (second_perfedit)
    {
        if (is_nullptr(gs_perfedit_pointer_1))
            gs_perfedit_pointer_1 = this;
    }
    else
    {
        if (is_nullptr(gs_perfedit_pointer_0))
            gs_perfedit_pointer_0 = this;
    }
}