Voice memory keyer

Bug fix
Working for compatibility with QT5
main
PianetaRadio 2024-12-03 20:40:21 +01:00 zatwierdzone przez GitHub
rodzic 095beba8fc
commit 9f33ab3c40
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
3 zmienionych plików z 12 dodań i 13 usunięć

Wyświetl plik

@ -48,7 +48,7 @@ DialogVoiceKeyer::DialogVoiceKeyer(QWidget *parent)
#endif #endif
connect(ui->horizontalSlider_audioLevel, &QAbstractSlider::valueChanged, ui->label_audioLevel, QOverload<int>::of(&QLabel::setNum)); connect(ui->horizontalSlider_audioLevel, &QAbstractSlider::valueChanged, ui->label_audioLevel, QOverload<int>::of(&QLabel::setNum));
ui->horizontalSlider_audioLevel->setValue(voiceKConf.audioOutputVolume*10); ui->horizontalSlider_audioLevel->setValue(voiceKConf.audioOutputVolume);
} }
DialogVoiceKeyer::~DialogVoiceKeyer() DialogVoiceKeyer::~DialogVoiceKeyer()
@ -111,6 +111,6 @@ void DialogVoiceKeyer::on_buttonBox_accepted()
configFile.setValue("VoiceKeyer/audioOutput", QVariant::fromValue(audioDevice.description())); configFile.setValue("VoiceKeyer/audioOutput", QVariant::fromValue(audioDevice.description()));
#endif #endif
voiceKConf.audioOutputVolume = (float)(ui->horizontalSlider_audioLevel->value())/10; voiceKConf.audioOutputVolume = ui->horizontalSlider_audioLevel->value();
configFile.setValue("VoiceKeyer/audioOutputVolume", voiceKConf.audioOutputVolume); configFile.setValue("VoiceKeyer/audioOutputVolume", voiceKConf.audioOutputVolume);
} }

Wyświetl plik

@ -47,5 +47,5 @@ typedef struct {
typedef struct { typedef struct {
QString memoryFile[5]; //Audio files QString memoryFile[5]; //Audio files
QString audioOutput; //Audio output device name QString audioOutput; //Audio output device name
float audioOutputVolume; //Audio output volume float 0..1 int audioOutputVolume; //Audio output volume integer 0..10
} voiceKeyerConfig; } voiceKeyerConfig;

Wyświetl plik

@ -470,13 +470,12 @@ void MainWindow::audioOutputInit(QString configFileName)
voiceKConf.memoryFile[3] = configFile.value("VoiceKeyer/voiceMemoryFile4", "").toString(); voiceKConf.memoryFile[3] = configFile.value("VoiceKeyer/voiceMemoryFile4", "").toString();
voiceKConf.memoryFile[4] = configFile.value("VoiceKeyer/voiceMemoryFile5", "").toString(); voiceKConf.memoryFile[4] = configFile.value("VoiceKeyer/voiceMemoryFile5", "").toString();
voiceKConf.audioOutput = configFile.value("VoiceKeyer/audioOutput").toString(); voiceKConf.audioOutput = configFile.value("VoiceKeyer/audioOutput").toString();
voiceKConf.audioOutputVolume = configFile.value("VoiceKeyer/audioOutputVolume", 1).toFloat(); voiceKConf.audioOutputVolume = configFile.value("VoiceKeyer/audioOutputVolume", 10).toInt();
audioPlayer = new QMediaPlayer(this); audioPlayer = new QMediaPlayer(this);
//Connect signal playback state change with slot on_voiceKeyerStateChanged function //Connect signal playback state change with slot on_voiceKeyerStateChanged function
connect(audioPlayer, &QMediaPlayer::mediaStatusChanged, this, &MainWindow::on_voiceKeyerStateChanged); connect(audioPlayer, &QMediaPlayer::mediaStatusChanged, this, &MainWindow::on_voiceKeyerStateChanged);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
audioOutput = new QAudioOutput(this); audioOutput = new QAudioOutput(this);
@ -492,9 +491,10 @@ void MainWindow::audioOutputInit(QString configFileName)
audioPlayer->setAudioOutput(audioOutput); audioPlayer->setAudioOutput(audioOutput);
//Set output volume //Set output volume
audioOutput->setVolume(voiceKConf.audioOutputVolume); //Float 0 min - 1 max audioOutput->setVolume((float)(voiceKConf.audioOutputVolume/10)); //Float 0 min - 1 max
#else #else
audioPlayer->setVolume((int)voiceKConf.audioOutputVolume*100); //Int 0 min - 100 max audioPlayer->setVolume((int)(voiceKConf.audioOutputVolume*10)); //Int 0 min - 100 max
qDebug() << audioPlayer->volume() << voiceKConf.audioOutputVolume;
#endif #endif
} }
@ -871,24 +871,25 @@ void MainWindow::setSubMeter()
void MainWindow::on_voiceKeyerStateChanged() void MainWindow::on_voiceKeyerStateChanged()
{ {
qDebug() << audioPlayer->mediaStatus() << rigCmd.voiceSend << rigGet.ptt;
if (rigCmd.voiceSend >= 1) if (rigCmd.voiceSend >= 1)
{ {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
if (audioPlayer->mediaStatus() == 2 && audioPlayer->source() == QUrl::fromLocalFile(voiceKConf.memoryFile[rigCmd.voiceSend - 1])) //LoadedMedia if (audioPlayer->mediaStatus() == QMediaPlayer::LoadedMedia && audioPlayer->source() == QUrl::fromLocalFile(voiceKConf.memoryFile[rigCmd.voiceSend - 1])) //LoadedMedia
#else #else
if (audioPlayer->mediaStatus() == 2 && audioPlayer->media() == QUrl::fromLocalFile(voiceKConf.memoryFile[rigCmd.voiceSend - 1])) if (audioPlayer->mediaStatus() == QMediaPlayer::LoadedMedia && audioPlayer->media() == QUrl::fromLocalFile(voiceKConf.memoryFile[rigCmd.voiceSend - 1]))
#endif #endif
{ {
ui->pushButton_PTT->toggle(); ui->pushButton_PTT->toggle();
ui->statusbar->showMessage("Playing audio..."); ui->statusbar->showMessage("Playing audio...");
} }
else if (audioPlayer->mediaStatus() == 0 || audioPlayer->mediaStatus() == 7) //NoMedia or InvalidMedia else if (audioPlayer->mediaStatus() == QMediaPlayer::NoMedia || audioPlayer->mediaStatus() == QMediaPlayer::InvalidMedia) //NoMedia or InvalidMedia
{ {
rigCmd.voiceSend = 0; rigCmd.voiceSend = 0;
ui->statusbar->showMessage("Audio file error!", 5000); ui->statusbar->showMessage("Audio file error!", 5000);
} }
else if (audioPlayer->mediaStatus() == 6 && rigGet.ptt) //EndOfMedia else if (audioPlayer->mediaStatus() == QMediaPlayer::EndOfMedia && rigGet.ptt) //EndOfMedia
{ {
rigCmd.voiceSend = 0; rigCmd.voiceSend = 0;
ui->pushButton_PTT->toggle(); ui->pushButton_PTT->toggle();
@ -1197,9 +1198,7 @@ void MainWindow::on_pushButton_VoiceK1_clicked()
{ {
rigCmd.voiceSend = 1; rigCmd.voiceSend = 1;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
qDebug() << audioPlayer->mediaStatus();
audioPlayer->setSource(QUrl::fromLocalFile(voiceKConf.memoryFile[0])); //Load audio file audioPlayer->setSource(QUrl::fromLocalFile(voiceKConf.memoryFile[0])); //Load audio file
qDebug() << audioPlayer->source() << audioPlayer->error() << audioPlayer->mediaStatus();
#else #else
audioPlayer->setMedia(QUrl::fromLocalFile(voiceKConf.memoryFile[0])); audioPlayer->setMedia(QUrl::fromLocalFile(voiceKConf.memoryFile[0]));
#endif #endif