mirror of
https://gitee.com/drabel/LibQQt.git
synced 2025-01-04 10:18:44 +08:00
更新QQt 音频控制模块的用例 voicetest
This commit is contained in:
parent
6b816fa843
commit
a487f2fc7d
@ -112,8 +112,6 @@ void MainWindow::on_pushButton_2_clicked()
|
|||||||
ui->inputListWidget->addItem ( adInfo.deviceName() );
|
ui->inputListWidget->addItem ( adInfo.deviceName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->inputListWidget->setCurrentRow ( 0 );
|
|
||||||
|
|
||||||
|
|
||||||
ui->outputListWidget->clear();
|
ui->outputListWidget->clear();
|
||||||
|
|
||||||
@ -128,8 +126,6 @@ void MainWindow::on_pushButton_2_clicked()
|
|||||||
ui->outputListWidget->addItem ( adInfo.deviceName() );
|
ui->outputListWidget->addItem ( adInfo.deviceName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->outputListWidget->setCurrentRow ( 0 );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::currentInputRowChanged ( QModelIndex cur, QModelIndex )
|
void MainWindow::currentInputRowChanged ( QModelIndex cur, QModelIndex )
|
||||||
@ -214,18 +210,43 @@ void MainWindow::currentOutputRowChanged ( QModelIndex cur, QModelIndex )
|
|||||||
|
|
||||||
void MainWindow::on_pushButton_clicked()
|
void MainWindow::on_pushButton_clicked()
|
||||||
{
|
{
|
||||||
|
/*这里是自定义输入、输出设备*/
|
||||||
QString name = ui->inputListWidget->currentIndex().data().toString();
|
QString name = ui->inputListWidget->currentIndex().data().toString();
|
||||||
QAudioDeviceInfo dev = findInputAudioDeviceInfoByName ( name );
|
QAudioDeviceInfo dev = findInputAudioDeviceInfoByName ( name );
|
||||||
|
|
||||||
name = ui->outputListWidget->currentIndex().data().toString();
|
name = ui->outputListWidget->currentIndex().data().toString();
|
||||||
QAudioDeviceInfo devOut = findOutputAudioDeviceInfoByName ( name );
|
QAudioDeviceInfo devOut = findOutputAudioDeviceInfoByName ( name );
|
||||||
|
|
||||||
manager.inputAudioFormat() = dev.preferredFormat();
|
/*使用默认输入、输出设备*/
|
||||||
manager.outputAudioFormat() = devOut.preferredFormat();
|
//如果开启这段代码,页面上的输入、输出设备选择,就仅仅是个显示了,不具备操作能力。
|
||||||
|
/*
|
||||||
|
dev = QQtAudioManager::defaultInputDevice();
|
||||||
|
devOut = QQtAudioManager::defaultOutputDevice();
|
||||||
|
*/
|
||||||
|
|
||||||
|
//把设备设进manager去
|
||||||
manager.inputDeviceInfo() = dev;
|
manager.inputDeviceInfo() = dev;
|
||||||
manager.outputDeviceInfo() = devOut;
|
manager.outputDeviceInfo() = devOut;
|
||||||
|
|
||||||
|
//这里保证输入、输出使用格式相等 或者 不同
|
||||||
|
//如果格式不同,在mac电脑上本地输入输出设备是可以使用的,但是对于连接的语音蓝牙话筒,却是不可以使用的,原因未知。
|
||||||
|
//格式相同的时候,实在是太好用啦。
|
||||||
|
//这个建议默认就相同,但是,在QQtAudioManager当中,并没有直接将其相等处理,如果用户在readyRead槽函数里,可以更改采样率进行某些特殊处理。一般不需要差异处理的,相等就行了。
|
||||||
|
manager.inputAudioFormat() = manager.outputDeviceInfo().preferredFormat();
|
||||||
|
manager.outputAudioFormat() = manager.outputDeviceInfo().preferredFormat();
|
||||||
|
|
||||||
|
pline() << "in prefer" << dev.preferredFormat().channelCount() << dev.preferredFormat().sampleRate() <<
|
||||||
|
dev.preferredFormat().sampleSize();
|
||||||
|
|
||||||
|
pline() << "out prefer" << devOut.preferredFormat().channelCount() << devOut.preferredFormat().sampleRate() <<
|
||||||
|
devOut.preferredFormat().sampleSize();
|
||||||
|
|
||||||
|
pline() << "in" << manager.inputAudioFormat().channelCount() << manager.inputAudioFormat().sampleRate() <<
|
||||||
|
manager.inputAudioFormat().sampleSize();
|
||||||
|
|
||||||
|
pline() << "out" << manager.outputAudioFormat().channelCount() << manager.outputAudioFormat().sampleRate() <<
|
||||||
|
manager.outputAudioFormat().sampleSize();
|
||||||
|
|
||||||
manager.startInput();
|
manager.startInput();
|
||||||
manager.startOutput();
|
manager.startOutput();
|
||||||
}
|
}
|
||||||
@ -235,3 +256,9 @@ void MainWindow::readyRead()
|
|||||||
QByteArray bytes = manager.readStreamBytes();
|
QByteArray bytes = manager.readStreamBytes();
|
||||||
manager.writeStreamBytes ( bytes );
|
manager.writeStreamBytes ( bytes );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_pushButton_3_clicked()
|
||||||
|
{
|
||||||
|
manager.stopOutput();
|
||||||
|
manager.stopInput();
|
||||||
|
}
|
||||||
|
@ -26,6 +26,8 @@ private slots:
|
|||||||
void currentOutputRowChanged ( QModelIndex, QModelIndex );
|
void currentOutputRowChanged ( QModelIndex, QModelIndex );
|
||||||
void on_pushButton_clicked();
|
void on_pushButton_clicked();
|
||||||
void readyRead();
|
void readyRead();
|
||||||
|
void on_pushButton_3_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow* ui;
|
Ui::MainWindow* ui;
|
||||||
QQtAudioManager manager;
|
QQtAudioManager manager;
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>610</x>
|
<x>610</x>
|
||||||
<y>100</y>
|
<y>200</y>
|
||||||
<width>181</width>
|
<width>181</width>
|
||||||
<height>32</height>
|
<height>32</height>
|
||||||
</rect>
|
</rect>
|
||||||
@ -78,6 +78,19 @@
|
|||||||
<string>refresh device list</string>
|
<string>refresh device list</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QPushButton" name="pushButton_3">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>610</x>
|
||||||
|
<y>90</y>
|
||||||
|
<width>181</width>
|
||||||
|
<height>32</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>stop (optional)</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
<widget class="QWidget" name="">
|
<widget class="QWidget" name="">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user