Exemple #1
0
void split(int *dataIN, int dataSize){
    auto firstHalfSize = (dataSize + 1) / 2;
    std::vector<int> firstHalf(dataIN, dataIN + firstHalfSize); 
    std::vector<int> secondHalf(dataIN + firstHalfSize, dataIN + dataSize);

    std::cout << "firstHalf: ";
    print(firstHalf);
    std::cout << "seconHalf: ";      
    print(secondHalf);
}
Exemple #2
0
//***************************************************************************
Kwave::CurveWidget::CurveWidget(QWidget *parent)
    :QWidget(parent), m_width(0), m_height(0), m_curve(), m_menu(0),
     m_preset_menu(0), m_current(Kwave::Curve::NoPoint),
     m_last(Kwave::Curve::NoPoint),
     m_down(false), m_knob(), m_selected_knob()
{
    KIconLoader icon_loader;

    // set the default curve
    m_curve.fromCommand(_("curve(linear,0,0,1,1)"));

    QPalette pal = palette();
    pal.setColor(QPalette::Window, Qt::black);
    setPalette(pal);

    // create the pixmaps for the selected and non-selected knob
    m_knob = icon_loader.loadIcon(_("knob.xpm"), KIconLoader::Small);
    m_selected_knob = icon_loader.loadIcon(_("selectedknob.xpm"),
                                           KIconLoader::Small);

    // set up the context menu for the right mouse button
    m_menu = new QMenu(this);
    Q_ASSERT(m_menu);
    if (!m_menu) return;

    QMenu *interpolation = m_menu->addMenu(i18n("Interpolation"));
    Q_ASSERT(interpolation);
    if (!interpolation) return;

    m_menu->addSeparator();
    QMenu *transform = m_menu->addMenu(i18n("Transform"));
    Q_ASSERT(transform);
    if (!transform) return;
    transform->addAction(i18n("Flip horizontal"),
	                 this, SLOT(HFlip()));
    transform->addAction(i18n("Flip vertical"),
                         this, SLOT(VFlip()));
    transform->addSeparator();
    transform->addAction(i18n("Into first half"),
                         this, SLOT(firstHalf()));
    transform->addAction(i18n("Into second half"),
                         this, SLOT(secondHalf()));

    QMenu *del = m_menu->addMenu(i18n("Delete"));
    Q_ASSERT(del);
    if (!del) return;

    m_menu->addAction(i18n("Fit In"), this, SLOT(scaleFit()));
    m_menu->addSeparator();

    /* list of presets */
    m_preset_menu = m_menu->addMenu(i18n("Presets"));
    Q_ASSERT(m_preset_menu);
    if (!m_preset_menu) return;
    loadPresetList();
    connect(m_preset_menu, SIGNAL(triggered(QAction*)),
            this, SLOT(loadPreset(QAction*)));

    m_menu->addAction(
	icon_loader.loadIcon(_("document-export"), KIconLoader::Small),
	i18n("Save Preset"),
	this, SLOT(savePreset()));

    del->addAction(
	icon_loader.loadIcon(_("edit-delete"), KIconLoader::Small),
	i18n("Currently Selected Point"),
	this, SLOT(deleteLast()),
	QKeySequence::Delete);
    del->addAction(i18n("Every Second Point"),
	           this, SLOT(deleteSecond()));

    QStringList types = Kwave::Interpolation::descriptions(true);
    int id = 0;
    foreach (const QString &text, types) {
	QAction *action = new QAction(interpolation);
	action->setText(text);
	action->setData(id++);
	interpolation->addAction(action);
    }