Пример #1
0
void do_fft_test()
{
    int i, scale;
    unsigned diff;
    short x[N], fx[N];

    printf("Samples: \n");

    for (i=0; i<N; i++) {
        /*
        x[i] = AMPLITUDE*cos(i*FREQUENCY*(2*3.1415926535)/N);
        if (i & 0x01)
        	fx[(N+i)>>1] = x[i];
        else
        	fx[i>>1] = x[i];
        */
#if DEBUG
        show_amp(i,x[i], AMPLITUDE);
#endif
    }

    fix_fftr(fx, log2N, 0);
    printf("----------------------------------------------\n");
    printf("-  Frequencies                               -\n");
    printf("----------------------------------------------\n");
    for (i=0; i<N/2; i++) show_amp(i, fx[i], AMPLITUDE);


#if SPECTRUM
    for (i=0; i<N/2; i++) show_amp(i, fx[i], AMPLITUDE);
    return;
#endif
    printf("----------------------------------------------\n");
    printf("-  Scaled                                    -\n");
    printf("----------------------------------------------\n");
    scale = fix_fftr(fx, log2N, 1);
//fprintf(stderr, "scale = %d\n", scale);

    for (i=0,diff=0; i<N; i++) {
        int sample;
        if (i & 0x01)
            sample = fx[(N+i)>>1] << scale;
        else
            sample = fx[i>>1] << scale;
#if DEBUG
        show_amp(i, sample, AMPLITUDE);
#endif
        diff += abs(x[i]-sample);
    }
Пример #2
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    memset(names, 0x00, 100*32);

    // load window size
    QSettings settings;
    restoreGeometry(settings.value("Windows/mainWindowGeometry").toByteArray());
    restoreState(settings.value("Windows/mainWindowState").toByteArray());

    // setting default values if there was none
    if(!settings.contains("Settings/checkForUpdates"))
        settings.setValue("Settings/checkForUpdates", true);
    if(!settings.contains("Settings/connectOnStartup"))
        settings.setValue("Settings/connectOnStartup", true);
    if(!settings.contains("Settings/oneSetToSetThemAll"))
        settings.setValue("Settings/oneSetToSetThemAll", false);
    if(!settings.contains("Settings/keepWindowsOpen"))
        settings.setValue("Settings/keepWindowsOpen", false);
    if(!settings.contains("Settings/popupChangedWindows"))
        settings.setValue("Settings/popupChangedWindows", true);
    if(!settings.contains("Settings/defaultEffectValues"))
        settings.setValue("Settings/defaultEffectValues", true);

    // create child objects
    amp_ops = new Mustang();
    amp = new Amplifier(this);
    effect1 = new Effect(this, 0);
    effect2 = new Effect(this, 1);
    effect3 = new Effect(this, 2);
    effect4 = new Effect(this, 3);

    about_window = new About(this);
    save = new SaveOnAmp(this);
    load = new LoadFromAmp(this);
    seffects = new SaveEffects(this);
    settings_win = new Settings(this);
    saver = new SaveToFile(this);
    quickpres = new QuickPresets(this);

    connected = false;

    // connect buttons to slots
    //
    connect(ui->Amplifier, SIGNAL(clicked()), amp, SLOT(show()));
    connect(ui->EffectButton1, SIGNAL(clicked()), effect1, SLOT(show()));
    connect(ui->EffectButton2, SIGNAL(clicked()), effect2, SLOT(show()));
    connect(ui->EffectButton3, SIGNAL(clicked()), effect3, SLOT(show()));
    connect(ui->EffectButton4, SIGNAL(clicked()), effect4, SLOT(show()));
    connect(ui->actionConnect, SIGNAL(triggered()), this, SLOT(start_amp()));
    connect(ui->actionDisconnect, SIGNAL(triggered()), this, SLOT(stop_amp()));
    connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(close()));
    connect(ui->actionAbout, SIGNAL(triggered()), about_window, SLOT(open()));
    connect(ui->actionSave_to_amplifier, SIGNAL(triggered()), save, SLOT(show()));
    connect(ui->action_Load_from_amplifier, SIGNAL(triggered()), load, SLOT(show()));
    connect(ui->actionSave_effects, SIGNAL(triggered()), seffects, SLOT(open()));
    connect(ui->actionCheck_for_Updates, SIGNAL(triggered()), this, SLOT(check_for_updates()));
    connect(ui->action_Options, SIGNAL(triggered()), settings_win, SLOT(show()));
    connect(ui->actionL_oad_from_file, SIGNAL(triggered()), this, SLOT(loadfile()));
    connect(ui->actionS_ave_to_file, SIGNAL(triggered()), saver, SLOT(show()));
    connect(ui->action_Library_view, SIGNAL(triggered()), this, SLOT(show_library()));
    connect(ui->action_Update_firmware, SIGNAL(triggered()), this, SLOT(update_firmware()));
    connect(ui->action_Default_effects, SIGNAL(triggered()), this, SLOT(show_default_effects()));
    connect(ui->action_Quick_presets, SIGNAL(triggered()), quickpres, SLOT(show()));



    // shortcuts to activate effect windows
    QShortcut *showfx1 = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_1), this, 0, 0, Qt::ApplicationShortcut);
    QShortcut *showfx2 = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_2), this, 0, 0, Qt::ApplicationShortcut);
    QShortcut *showfx3 = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_3), this, 0, 0, Qt::ApplicationShortcut);
    QShortcut *showfx4 = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_4), this, 0, 0, Qt::ApplicationShortcut);
    QShortcut *showamp = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_5), this, 0, 0, Qt::ApplicationShortcut);
    connect(showfx1, SIGNAL(activated()), this, SLOT(show_fx1()));
    connect(showfx2, SIGNAL(activated()), this, SLOT(show_fx2()));
    connect(showfx3, SIGNAL(activated()), this, SLOT(show_fx3()));
    connect(showfx4, SIGNAL(activated()), this, SLOT(show_fx4()));
    connect(showamp, SIGNAL(activated()), this, SLOT(show_amp()));

    // shortcuts for quick loading presets
    QShortcut *loadpres0 = new QShortcut(QKeySequence(Qt::Key_0), this, 0, 0, Qt::ApplicationShortcut);
    QShortcut *loadpres1 = new QShortcut(QKeySequence(Qt::Key_1), this, 0, 0, Qt::ApplicationShortcut);
    QShortcut *loadpres2 = new QShortcut(QKeySequence(Qt::Key_2), this, 0, 0, Qt::ApplicationShortcut);
    QShortcut *loadpres3 = new QShortcut(QKeySequence(Qt::Key_3), this, 0, 0, Qt::ApplicationShortcut);
    QShortcut *loadpres4 = new QShortcut(QKeySequence(Qt::Key_4), this, 0, 0, Qt::ApplicationShortcut);
    QShortcut *loadpres5 = new QShortcut(QKeySequence(Qt::Key_5), this, 0, 0, Qt::ApplicationShortcut);
    QShortcut *loadpres6 = new QShortcut(QKeySequence(Qt::Key_6), this, 0, 0, Qt::ApplicationShortcut);
    QShortcut *loadpres7 = new QShortcut(QKeySequence(Qt::Key_7), this, 0, 0, Qt::ApplicationShortcut);
    QShortcut *loadpres8 = new QShortcut(QKeySequence(Qt::Key_8), this, 0, 0, Qt::ApplicationShortcut);
    QShortcut *loadpres9 = new QShortcut(QKeySequence(Qt::Key_9), this, 0, 0, Qt::ApplicationShortcut);
    connect(loadpres0, SIGNAL(activated()), this, SLOT(load_presets0()));
    connect(loadpres1, SIGNAL(activated()), this, SLOT(load_presets1()));
    connect(loadpres2, SIGNAL(activated()), this, SLOT(load_presets2()));
    connect(loadpres3, SIGNAL(activated()), this, SLOT(load_presets3()));
    connect(loadpres4, SIGNAL(activated()), this, SLOT(load_presets4()));
    connect(loadpres5, SIGNAL(activated()), this, SLOT(load_presets5()));
    connect(loadpres6, SIGNAL(activated()), this, SLOT(load_presets6()));
    connect(loadpres7, SIGNAL(activated()), this, SLOT(load_presets7()));
    connect(loadpres8, SIGNAL(activated()), this, SLOT(load_presets8()));
    connect(loadpres9, SIGNAL(activated()), this, SLOT(load_presets9()));

    // shortcut to activate buttons
    QShortcut *shortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_A), this);
    connect(shortcut, SIGNAL(activated()), this, SLOT(enable_buttons()));

    // connect the functions if needed
    if(settings.value("Settings/checkForUpdates").toBool())
        connect(this, SIGNAL(started()), this, SLOT(check_for_updates()));
    if(settings.value("Settings/connectOnStartup").toBool())
        connect(this, SIGNAL(started()), this, SLOT(start_amp()));

    this->show();
    this->repaint();

    emit started();
}