Add microphone combobox using SDL (#1709)
This commit is contained in:
parent
4b32fb802c
commit
52d6265b58
|
@ -133,7 +133,12 @@ void MicOpen()
|
||||||
whatIwant.channels = 1;
|
whatIwant.channels = 1;
|
||||||
whatIwant.samples = 1024;
|
whatIwant.samples = 1024;
|
||||||
whatIwant.callback = MicCallback;
|
whatIwant.callback = MicCallback;
|
||||||
micDevice = SDL_OpenAudioDevice(NULL, 1, &whatIwant, &whatIget, 0);
|
const char* mic = NULL;
|
||||||
|
if (Config::MicDevice != "")
|
||||||
|
{
|
||||||
|
mic = Config::MicDevice.c_str();
|
||||||
|
}
|
||||||
|
micDevice = SDL_OpenAudioDevice(mic, 1, &whatIwant, &whatIget, 0);
|
||||||
if (!micDevice)
|
if (!micDevice)
|
||||||
{
|
{
|
||||||
Platform::Log(Platform::LogLevel::Error, "Mic init failed: %s\n", SDL_GetError());
|
Platform::Log(Platform::LogLevel::Error, "Mic init failed: %s\n", SDL_GetError());
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
@ -70,6 +71,20 @@ AudioSettingsDialog::AudioSettingsDialog(QWidget* parent, bool emuActive) : QDia
|
||||||
{
|
{
|
||||||
ui->chkSyncDSiVolume->setEnabled(false);
|
ui->chkSyncDSiVolume->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
bool isext = (Config::MicInputType == 1);
|
||||||
|
ui->cbMic->setEnabled(isext);
|
||||||
|
|
||||||
|
const int count = SDL_GetNumAudioDevices(true);
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
ui->cbMic->addItem(SDL_GetAudioDeviceName(i, true));
|
||||||
|
}
|
||||||
|
if (Config::MicDevice == "" && count > 0)
|
||||||
|
{
|
||||||
|
Config::MicDevice = SDL_GetAudioDeviceName(0, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->cbMic->setCurrentText(QString::fromStdString(Config::MicDevice));
|
||||||
|
|
||||||
grpMicMode = new QButtonGroup(this);
|
grpMicMode = new QButtonGroup(this);
|
||||||
grpMicMode->addButton(ui->rbMicNone, micInputType_Silence);
|
grpMicMode->addButton(ui->rbMicNone, micInputType_Silence);
|
||||||
|
@ -95,6 +110,7 @@ AudioSettingsDialog::AudioSettingsDialog(QWidget* parent, bool emuActive) : QDia
|
||||||
btn->setEnabled(false);
|
btn->setEnabled(false);
|
||||||
ui->txtMicWavPath->setEnabled(false);
|
ui->txtMicWavPath->setEnabled(false);
|
||||||
ui->btnMicWavBrowse->setEnabled(false);
|
ui->btnMicWavBrowse->setEnabled(false);
|
||||||
|
ui->cbMic->setEnabled(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ui->lblInstanceNum->hide();
|
ui->lblInstanceNum->hide();
|
||||||
|
@ -123,6 +139,7 @@ void AudioSettingsDialog::onConsoleReset()
|
||||||
|
|
||||||
void AudioSettingsDialog::on_AudioSettingsDialog_accepted()
|
void AudioSettingsDialog::on_AudioSettingsDialog_accepted()
|
||||||
{
|
{
|
||||||
|
Config::MicDevice = ui->cbMic->currentText().toStdString();
|
||||||
Config::MicInputType = grpMicMode->checkedId();
|
Config::MicInputType = grpMicMode->checkedId();
|
||||||
Config::MicWavPath = ui->txtMicWavPath->text().toStdString();
|
Config::MicWavPath = ui->txtMicWavPath->text().toStdString();
|
||||||
Config::Save();
|
Config::Save();
|
||||||
|
@ -197,8 +214,10 @@ void AudioSettingsDialog::on_chkSyncDSiVolume_clicked(bool checked)
|
||||||
void AudioSettingsDialog::onChangeMicMode(int mode)
|
void AudioSettingsDialog::onChangeMicMode(int mode)
|
||||||
{
|
{
|
||||||
bool iswav = (mode == 3);
|
bool iswav = (mode == 3);
|
||||||
|
bool isext = (mode == 1);
|
||||||
ui->txtMicWavPath->setEnabled(iswav);
|
ui->txtMicWavPath->setEnabled(iswav);
|
||||||
ui->btnMicWavBrowse->setEnabled(iswav);
|
ui->btnMicWavBrowse->setEnabled(iswav);
|
||||||
|
ui->cbMic->setEnabled(isext);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioSettingsDialog::on_btnMicWavBrowse_clicked()
|
void AudioSettingsDialog::on_btnMicWavBrowse_clicked()
|
||||||
|
|
|
@ -136,7 +136,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0" colspan="3">
|
<item row="1" column="0">
|
||||||
<widget class="QRadioButton" name="rbMicExternal">
|
<widget class="QRadioButton" name="rbMicExternal">
|
||||||
<property name="whatsThis">
|
<property name="whatsThis">
|
||||||
<string><html><head/><body><p>Input from an external microphone, if available, will be forwarded to the emulated microphone.</p></body></html></string>
|
<string><html><head/><body><p>Input from an external microphone, if available, will be forwarded to the emulated microphone.</p></body></html></string>
|
||||||
|
@ -146,6 +146,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="1" colspan="2">
|
||||||
|
<widget class="QComboBox" name="cbMic">
|
||||||
|
<property name="whatsThis">
|
||||||
|
<string><html><head/><body><p>The selected microphone to be used.</p></body></html></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="2" column="0" colspan="3">
|
<item row="2" column="0" colspan="3">
|
||||||
<widget class="QRadioButton" name="rbMicNoise">
|
<widget class="QRadioButton" name="rbMicNoise">
|
||||||
<property name="whatsThis">
|
<property name="whatsThis">
|
||||||
|
|
|
@ -120,6 +120,7 @@ int AudioBitDepth;
|
||||||
int AudioVolume;
|
int AudioVolume;
|
||||||
bool DSiVolumeSync;
|
bool DSiVolumeSync;
|
||||||
int MicInputType;
|
int MicInputType;
|
||||||
|
std::string MicDevice;
|
||||||
std::string MicWavPath;
|
std::string MicWavPath;
|
||||||
|
|
||||||
std::string LastROMFolder;
|
std::string LastROMFolder;
|
||||||
|
@ -300,6 +301,7 @@ ConfigEntry ConfigFile[] =
|
||||||
{"AudioVolume", 0, &AudioVolume, 256, true},
|
{"AudioVolume", 0, &AudioVolume, 256, true},
|
||||||
{"DSiVolumeSync", 0, &DSiVolumeSync, 0, true},
|
{"DSiVolumeSync", 0, &DSiVolumeSync, 0, true},
|
||||||
{"MicInputType", 0, &MicInputType, 1, false},
|
{"MicInputType", 0, &MicInputType, 1, false},
|
||||||
|
{"MicDevice", 2, &MicDevice, (std::string)"", false},
|
||||||
{"MicWavPath", 2, &MicWavPath, (std::string)"", false},
|
{"MicWavPath", 2, &MicWavPath, (std::string)"", false},
|
||||||
|
|
||||||
{"LastROMFolder", 2, &LastROMFolder, (std::string)"", true},
|
{"LastROMFolder", 2, &LastROMFolder, (std::string)"", true},
|
||||||
|
|
|
@ -177,6 +177,7 @@ extern int AudioBitDepth;
|
||||||
extern int AudioVolume;
|
extern int AudioVolume;
|
||||||
extern bool DSiVolumeSync;
|
extern bool DSiVolumeSync;
|
||||||
extern int MicInputType;
|
extern int MicInputType;
|
||||||
|
extern std::string MicDevice;
|
||||||
extern std::string MicWavPath;
|
extern std::string MicWavPath;
|
||||||
|
|
||||||
extern std::string LastROMFolder;
|
extern std::string LastROMFolder;
|
||||||
|
|
Loading…
Reference in New Issue