Esempio n. 1
0
void GrooveDialog::ApplySelectedGroove()
{
    int index = (int)SendDlgItemMessage(m_hwnd, IDC_GROOVELIST, LB_GETCURSEL, 0, 0);
    std::string grooveName = __LOCALIZE("** User Groove **","sws_DLG_157");
    GrooveTemplateMemento memento = GrooveTemplateHandler::GetMemento();

    if(index > 0) {
        std::string itemLocation;
        char itemText[MAX_PATH];
        SendDlgItemMessage(m_hwnd, IDC_GROOVELIST, LB_GETTEXT, index, (LPARAM)itemText);
        grooveName = itemText;
        itemLocation = currentDir;
        itemLocation += PATH_SEP;
        itemLocation += grooveName;
        itemLocation += ".rgt";


        GrooveTemplateHandler *me = GrooveTemplateHandler::Instance();

        std::string errMessage;
        if(!me->LoadGroove(itemLocation, errMessage))
            MessageBox(GetMainHwnd(), errMessage.c_str(), __LOCALIZE("FNG - Error","sws_DLG_157"), 0);
    }
    if(index >= 0) {

        GrooveTemplateHandler *me = GrooveTemplateHandler::Instance();
        int beatDivider = me->GetGrooveTolerance();

        bool midiEditorTarget = SendDlgItemMessage(m_hwnd, IDC_TARG_NOTES, BM_GETCHECK, 0, 0) == BST_CHECKED;

        HWND editControl = GetDlgItem(m_hwnd, IDC_STRENGTH);
        char percentage[16];
        GetWindowText(editControl, percentage, 16);
        double posStrength = (double)atoi(percentage) / 100.0;
        editControl = GetDlgItem(m_hwnd, IDC_VELSTRENGTH);
        GetWindowText(editControl, percentage, 16);
        double velStrength = (double)atoi(percentage) / 100.0;
        std::string undoMessage = __LOCALIZE("FNG: load and apply groove - ","sws_DLG_157") + grooveName;

        try {
            if(midiEditorTarget)
                me->ApplyGrooveToMidiEditor(beatDivider, posStrength, velStrength);
            else
                me->ApplyGroove(beatDivider, posStrength, velStrength);
            Undo_OnStateChange2(0, undoMessage.c_str());
        } catch(RprLibException &e) {
            if(e.notify()) {
                MessageBox(GetMainHwnd(), e.what(), __LOCALIZE("FNG - Error","sws_DLG_157"), 0);
            }
        }
    }
    GrooveTemplateHandler::SetMemento(memento);
}
Esempio n. 2
0
static void ApplyGrooveInMidiEditor(int flags, void *data)
{
    int *beatDivider = (int *)data;
    GrooveTemplateHandler *me = GrooveTemplateHandler::Instance();
    me->ApplyGrooveToMidiEditor(*beatDivider, 1.0, 1.0);
}