c++ - 需要帮助弄清楚如何使用 Qdial 更改我的 main 中的变量
问题描述
我一直试图弄清楚 QT 有一段时间了,所以我想我只是问这个问题。我一直在尝试让一系列六个 Qdial 基本上在其更改时返回它们的值,并使用它来指示我的 main 值中的变量。
这是main.cpp
#include <QApplication>
#include <iostream>
#include "audioOut.h"
#include "ADSR.h"
#include "Oscillators.h"
#include "mainwindow.h"
using namespace std;
atomic<double> frequencyOutput{0.0};
ADSREnvelope envelope;
double octaveBaseFrequency = 110.0;
const double twelfthRootOfTwo = 1.05946309436;
int osc1 = 0;
int osc2 = 0;
double lfoHertz = 5.0;
double lfoAmp = 0.5;
double bias1 = 1.0;
double bias2 = 1.0;
double MakeNoise(double dTime)
{
// Mixed sine and square waves
double dOutput = envelope.GetAmplitude(dTime) *
(+bias1 * osc(frequencyOutput * 0.5, dTime, osc1, lfoHertz, lfoAmp) + bias2 * osc(frequencyOutput, dTime, osc2, lfoHertz, lfoAmp));
return dOutput * 0.4; // Master Volume
}
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
MainWindow w;
w.show();
vector<wstring> devices = audioOut<short>::Enumerate(); //find output device
for (auto d : devices) wcout << "found output device: " << d << endl;
audioOut<short> sound(devices[0], 44100, 1, 8, 512); //creates an object of the AudioOut Class
sound.SetUserFunction(MakeNoise);
cout << "_____________________________________________________________\n"
"| | | | | | | | | | | | | | | | |\n"
"| | | | | | | | | | | | | | | | |\n"
"| |S| | |F| |G| | |J| |K| |L| | |\n"
"| - | - - | - - - | |\n"
"| Z | X | C | V | B | N | M | , | . | / |\n"
"-------------------------------------------------------------";
int currentKey = -1;
bool keyPressed = false;
while(w.isVisible())
{
a.processEvents();
keyPressed = false;
for (int k = 0; k < 16; k++)
{
if (GetAsyncKeyState((unsigned char)("ZSXCFVGBNJMK\xbcL\xbe\xbf"[k])) & 0x8000)
{
if (currentKey != k)
{
frequencyOutput = octaveBaseFrequency * pow(twelfthRootOfTwo, k);
envelope.KeyPress(sound.GetTime());
wcout << "\rNote On : " << sound.GetTime() << "s " << frequencyOutput << "Hz";
currentKey = k;
}
keyPressed = true;
}
}
if (!keyPressed)
{
if (currentKey != -1)
{
wcout << "\rNote Off: " << sound.GetTime() << "s ";
envelope.KeyDepress(sound.GetTime());
currentKey = -1;
}
}
}
return 0;
}
这是我的 mainWindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_OSC1Select_valueChanged(int value)
{
}
基本上我希望 OSC1Select 的值主要更改 int osc1,我假设这是使用 on_OSC1Select_valueChanged 方法完成的,但我真的不知道如何。任何帮助将不胜感激
解决方案
推荐阅读
- python - Scipy 最小化不执行迭代
- python - 记录 python - 带颜色的自定义格式化程序
- facebook - iOS - 如何在不硬编码 info.plist 文件中的值的情况下启用 Facebook 登录
- hadoop - 在缓存中找不到 Hdfs 委托令牌 - Spark 应用程序中的错误
- regex - Notepad++ 正则表达式第二场比赛
- c++ - MIPS 上 pthread 中的段错误
- bash - 为重复出现的线条模式创建输出文件
- ruby - 定义最小和最大长度
- bloom-filter - 为什么布隆过滤器不能处理范围查询?
- amazon-web-services - 是否可以向 ELB 后面的特定实例发送消息?