From 6339901099e88d979cc189cef5083348c545f69a Mon Sep 17 00:00:00 2001 From: jontio Date: Sun, 6 Nov 2016 15:01:00 +1300 Subject: [PATCH] Added defained group 5A. Data for group is read from files. --- JMPX/JMPX.pro | 6 +- JMPX/fileloader.cpp | 99 +++++++++++++++++ JMPX/fileloader.h | 48 +++++++++ JMPX/mainwindow.cpp | 30 ++++-- JMPX/mainwindow.h | 3 + JMPX/options.cpp | 145 ++++++++++++++++++++++++- JMPX/options.h | 21 +++- JMPX/options.ui | 234 +++++++++++++++++++++++++++++++++++++++- libJMPX/JMPXInterface.h | 12 +++ libJMPX/libJMPX.h | 10 ++ libJMPX/libJMPX.pro | 3 + libJMPX/rds.cpp | 24 ++++- libJMPX/rds.h | 119 +++++++++++++++++--- 13 files changed, 716 insertions(+), 38 deletions(-) create mode 100644 JMPX/fileloader.cpp create mode 100644 JMPX/fileloader.h diff --git a/JMPX/JMPX.pro b/JMPX/JMPX.pro index 1ac00fd..f2adfbb 100644 --- a/JMPX/JMPX.pro +++ b/JMPX/JMPX.pro @@ -35,13 +35,15 @@ HEADERS += \ mainwindow.h \ vol/volumemeter.h \ ../libJMPX/JMPXInterface.h \ - options.h + options.h \ + fileloader.h SOURCES += \ main.cpp \ mainwindow.cpp \ vol/volumemeter.cpp \ - options.cpp + options.cpp \ + fileloader.cpp unix { HEADERS += nowplaying_linux.h diff --git a/JMPX/fileloader.cpp b/JMPX/fileloader.cpp new file mode 100644 index 0000000..2479e47 --- /dev/null +++ b/JMPX/fileloader.cpp @@ -0,0 +1,99 @@ +#include "fileloader.h" +#include +#include + +FileLoader::FileLoader(QObject *parent) : QObject(parent) +{ + filewatcher = new QFileSystemWatcher(this); + connect(filewatcher, SIGNAL(fileChanged(const QString &)), this, SLOT(fileChanged(const QString &))); + ashextext=false; + loaderror=true; +} + +void FileLoader::fileLoadErrorTimeout() +{ + if(!hasloaderror())return; + qDebug()<<"fileLoadErrorTimeout"; + if(!reloadfile())QTimer::singleShot(5000, this, SLOT(fileLoadErrorTimeout())); + else if((filewatcher->files().isEmpty())&&(!filename.isEmpty())) + { + qDebug()<<"fileCreated:"<addPath(filename); + } +} + +void FileLoader::set_filename(QString filename, bool ashextext) +{ + //if we are already watching the file then just leave the watcher alone + if(filewatcher->files().contains(filename)) + { + //if we failed to load the file then try again later + if(!load_file(filename,ashextext))QTimer::singleShot(5000, this, SLOT(fileLoadErrorTimeout())); + return; + } + //remove the all files from the watcher, set the filename, load the file, add the file to the watcher + if(!filewatcher->files().isEmpty())filewatcher->removePaths(filewatcher->files()); + //if we failed to load the file then try again later + if(!load_file(filename,ashextext))QTimer::singleShot(5000, this, SLOT(fileLoadErrorTimeout())); + if(!filename.isEmpty())filewatcher->addPath(get_filename()); +} + +void FileLoader::fileChanged(const QString &path) +{ + if(!QFile(filename).exists())//if removed + { + qDebug()<<"fileRemoved:"< +#include +#include + +class FileLoader : public QObject +{ + Q_OBJECT +public: + explicit FileLoader(QObject *parent = 0); + + //just set the file name and this class will take care of the rest + void set_filename(QString filename, bool ashextext); + + //if you want to force a reload but i cant see why you would want to + bool reloadfile(){return load_file(filename,ashextext,true);} + + //was there an error the last time the file was loaded? + bool hasloaderror(){return loaderror;} + + //what is the file that is being monitored? + QString get_filename(){return filename;} + + //is it in hex text? + bool get_ashextext(){return ashextext;} + +signals: + + //emits when there is new data or the file has been reloaded + void dataLoadSignal(const QByteArray &data); + +private: + bool ashextext;// + bool loaderror;// + QString filename;// + QByteArray ba;// + QFileSystemWatcher *filewatcher; + + bool load_file(QString _filename,bool _ashextext){return load_file(_filename,_ashextext,false);} + bool load_file(QString _filename,bool _ashextext,bool invalidate); + +private slots: + void fileChanged(const QString &path); + void fileLoadErrorTimeout(); +}; + +#endif // FILELOADER_H diff --git a/JMPX/mainwindow.cpp b/JMPX/mainwindow.cpp index de82e3f..6e3c784 100644 --- a/JMPX/mainwindow.cpp +++ b/JMPX/mainwindow.cpp @@ -50,8 +50,16 @@ MainWindow::MainWindow(QWidget *parent) : } } + //song title checker (has no settings) + nowplaying=new NowPlaying(this); + connect(nowplaying,SIGNAL(songtitlechanged(QString)),this,SLOT(songtitlecheck(QString))); + + //Fileloader for group 5A (has settings) + fileloader=new FileLoader(this); + connect(fileloader,SIGNAL(dataLoadSignal(QByteArray)),this,SLOT(pushdatato5a(QByteArray))); + //load settings - if(pJMPX)options->loadsettings(pJMPX); + if(pJMPX)options->loadsettings(pJMPX,fileloader); //update low rate info updatelowrateinfo(); @@ -61,10 +69,6 @@ MainWindow::MainWindow(QWidget *parent) : ptimer->setInterval(20); connect(ptimer,SIGNAL(timeout()),this,SLOT(updatedisplay())); - //song title checker - nowplaying=new NowPlaying(this); - connect(nowplaying,SIGNAL(songtitlechanged(QString)),this,SLOT(songtitlecheck(QString))); - //restore modulate enable QSettings settings("JontiSoft", "JMPX"); ui->checkBox_modulate->setChecked(settings.value("checkBox_modulate",false).toBool()); @@ -74,7 +78,7 @@ MainWindow::MainWindow(QWidget *parent) : MainWindow::~MainWindow() { //save settings - if(pJMPX)options->savesettings(pJMPX); + if(pJMPX)options->savesettings(pJMPX,fileloader); QSettings settings("JontiSoft", "JMPX"); settings.setValue("checkBox_modulate",ui->checkBox_modulate->isChecked()); delete ui; @@ -104,10 +108,10 @@ void MainWindow::updatedisplay() void MainWindow::on_action_Options_triggered() { if(!pJMPX)return; - options->populatesettings(pJMPX); + options->populatesettings(pJMPX,fileloader); if(options->exec()==QDialog::Accepted) { - options->pushsetting(pJMPX); + options->pushsetting(pJMPX,fileloader); ui->checkBox_modulate->setChecked(pJMPX->IsActive()); songtitlecheck(nowplaying->rt_title); @@ -166,10 +170,10 @@ void MainWindow::on_action_About_triggered() { QMessageBox::about(this,"JMPX","" "

Stereo and RDS encoder for FM transmitters

" - "

v2.0.0

" + "

v2.0.1

" "

When connected to an FM transmitter via a soundcard this program allows you to transmit in stereo along with the ability to send information using RDS (Radio Data System) to the listeners. With RDS the listerners can see what your station is called and other usefull information.

" "

For more information about this application see http://jontio.zapto.org/hda1/paradise/jmpxencoder/jmpx.html.

" - "

Jonti 2015

" ); + "

Jonti 2016

" ); } void MainWindow::on_actionAbout_Qt_triggered() @@ -193,3 +197,9 @@ void MainWindow::songtitlecheck(const QString &title) //set RT with title pJMPX->RDS_SetRT(title); } + +void MainWindow::pushdatato5a(const QByteArray &data) +{ + if((!pJMPX)||!pJMPX.data()->IsActive())return; + pJMPX->RDS_Set_5A_data(data); +} diff --git a/JMPX/mainwindow.h b/JMPX/mainwindow.h index 6900685..50f18dc 100644 --- a/JMPX/mainwindow.h +++ b/JMPX/mainwindow.h @@ -21,6 +21,7 @@ #include "nowplaying_mac.h" #endif +#include "fileloader.h" namespace Ui { class MainWindow; @@ -40,6 +41,7 @@ class MainWindow : public QMainWindow { Options *options; void updatelowrateinfo(); NowPlaying *nowplaying; + FileLoader *fileloader; private slots: void volbarssetfixedequalwidth(); void updatedisplay(); @@ -48,6 +50,7 @@ private slots: void on_action_About_triggered(); void on_actionAbout_Qt_triggered(); void songtitlecheck(const QString &title); + void pushdatato5a(const QByteArray &data); }; #endif // MAINWINDOW_H diff --git a/JMPX/options.cpp b/JMPX/options.cpp index 5ae2fbb..80fadd1 100644 --- a/JMPX/options.cpp +++ b/JMPX/options.cpp @@ -3,6 +3,7 @@ #include #include #include +#include Options::Options(QWidget *parent) : QDialog(parent), @@ -25,7 +26,7 @@ Options::~Options() delete ui; } -void Options::savesettings(JMPXInterface *pJMPX) +void Options::savesettings(JMPXInterface *pJMPX,FileLoader *fileloader) { QSettings settings("JontiSoft", "JMPX"); @@ -115,9 +116,25 @@ void Options::savesettings(JMPXInterface *pJMPX) //update_rt_music_title settings.setValue("update_rt_music_title",update_rt_music_title); +//third tab + + //5a enable + settings.setValue("RDS_5A_Enable",pJMPX->RDS_Get_5A_Enable()); + + //5a filename ashextext + settings.setValue("5A_fileloader_ashextext",fileloader->get_ashextext()); + + //5a filename + settings.setValue("5A_fileloader_filename",fileloader->get_filename()); + + //group percentages + settings.setValue("RDS_grp0Awantedbandwidthusage",pJMPX->RDS_Get_grp0Awantedbandwidthusage()); + settings.setValue("RDS_grp2Awantedbandwidthusage",pJMPX->RDS_Get_grp2Awantedbandwidthusage()); + settings.setValue("RDS_grp5Awantedbandwidthusage",pJMPX->RDS_Get_grp5Awantedbandwidthusage()); + } -void Options::loadsettings(JMPXInterface *pJMPX) +void Options::loadsettings(JMPXInterface *pJMPX,FileLoader *fileloader) { QSettings settings("JontiSoft", "JMPX"); @@ -205,9 +222,21 @@ void Options::loadsettings(JMPXInterface *pJMPX) //update_rt_music_title update_rt_music_title=(settings.value("update_rt_music_title",true).toBool()); +//third tab + + //5a enable + pJMPX->RDS_Set_5A_Enable(settings.value("RDS_5A_Enable",false).toBool()); + + //5a filename and ashextext + fileloader->set_filename(settings.value("5A_fileloader_filename","").toString(),settings.value("5A_fileloader_ashextext",true).toBool()); + + //group percentages + pJMPX->RDS_Set_grouppercentages(settings.value("RDS_grp0Awantedbandwidthusage",0.8).toDouble(),settings.value("RDS_grp2Awantedbandwidthusage",0.2).toDouble(),settings.value("RDS_grp5Awantedbandwidthusage",0.0).toDouble()); + + } -void Options::populatesettings(JMPXInterface *pJMPX) +void Options::populatesettings(JMPXInterface *pJMPX, FileLoader *fileloader) { //first tab @@ -362,9 +391,25 @@ void Options::populatesettings(JMPXInterface *pJMPX) //update_rt_music_title ui->checkBox_update_rt_music_title->setChecked(update_rt_music_title); +//third tab + + //5a enable + ui->groupBox_5a->setChecked(pJMPX->RDS_Get_5A_Enable()); + + //5a filename ashextext + ui->checkBox_5a_file_is_hextext->setChecked(fileloader->get_ashextext()); + + //5a filename + ui->lineEdit_5a_filename->setText(fileloader->get_filename()); + + //group percentages + ui->spinBox_0A_percent->setValue(pJMPX->RDS_Get_grp0Awantedbandwidthusage()*100+0.5); + ui->spinBox_2A_percent->setValue(pJMPX->RDS_Get_grp2Awantedbandwidthusage()*100+0.5); + ui->spinBox_5A_percent->setValue(pJMPX->RDS_Get_grp5Awantedbandwidthusage()*100+0.5); + } -void Options::pushsetting(JMPXInterface *pJMPX) +void Options::pushsetting(JMPXInterface *pJMPX,FileLoader *fileloader) { //first tab @@ -480,6 +525,17 @@ void Options::pushsetting(JMPXInterface *pJMPX) //update_rt_music_title update_rt_music_title=ui->checkBox_update_rt_music_title->isChecked(); +//third tab + + //5a enable + pJMPX->RDS_Set_5A_Enable(ui->groupBox_5a->isChecked()); + + //5a filename and ashextext + fileloader->set_filename(ui->lineEdit_5a_filename->text(),ui->checkBox_5a_file_is_hextext->isChecked()); + + //group percentages + pJMPX->RDS_Set_grouppercentages(ui->spinBox_0A_percent->value(),ui->spinBox_2A_percent->value(),ui->spinBox_5A_percent->value()); + } void Options::on_checkBox_rbds_clicked(bool checked) @@ -584,3 +640,84 @@ void Options::on_horizontalSlider_rdslevel_valueChanged(int value) { ui->label_rdslevel->setText(((QString)"%1%").arg(((double)value)/10.0,0,'f',1,'0')); } + +void Options::on_toolButton_5a_filename_clicked() +{ + + QFileDialog dlg( NULL,tr("Select 5A file"),ui->lineEdit_5a_filename->text(), tr("Any Files (*.*)")); + dlg.setAcceptMode( QFileDialog::AcceptOpen ); + if(dlg.exec() != QDialog::Accepted)return; + QString filename = dlg.selectedFiles().at(0);//QFileDialog::getOpenFileName(this,tr("Select 5A file"),lastdirectorytheuserlookedat, tr("Any Files (*.*)")); + ui->lineEdit_5a_filename->setText(filename); +} + +void Options::on_checkBox_rt_enable_clicked() +{ + on_groupBox_5a_clicked(); +} + +void Options::on_groupBox_5a_clicked() +{ + if(ui->checkBox_rt_enable->isChecked()>0) + { + if(ui->groupBox_5a->isChecked()) + { + ui->spinBox_0A_percent->setValue(40); + ui->spinBox_2A_percent->setValue(20); + ui->spinBox_5A_percent->setValue(40); + } + else + { + ui->spinBox_0A_percent->setValue(80); + ui->spinBox_2A_percent->setValue(20); + ui->spinBox_5A_percent->setValue(00); + } + } + else + { + if(ui->groupBox_5a->isChecked()) + { + ui->spinBox_0A_percent->setValue(50); + ui->spinBox_2A_percent->setValue(00); + ui->spinBox_5A_percent->setValue(50); + } + else + { + ui->spinBox_0A_percent->setValue(100); + ui->spinBox_2A_percent->setValue(00); + ui->spinBox_5A_percent->setValue(00); + } + } +} + +//not used but it could if you really want to +void Options::validatepercentagespinboxes() +{ + double grp0Awantedbandwidthusage=ui->spinBox_0A_percent->value(); + double grp2Awantedbandwidthusage=ui->spinBox_2A_percent->value(); + double grp5Awantedbandwidthusage=ui->spinBox_5A_percent->value(); + double scalling=1.0/(grp0Awantedbandwidthusage+grp2Awantedbandwidthusage+grp5Awantedbandwidthusage); + grp0Awantedbandwidthusage*=scalling; + grp2Awantedbandwidthusage*=scalling; + grp5Awantedbandwidthusage*=scalling; + + ui->spinBox_0A_percent->setValue(grp0Awantedbandwidthusage*100+0.5); + ui->spinBox_2A_percent->setValue(grp2Awantedbandwidthusage*100+0.5); + ui->spinBox_5A_percent->setValue(grp5Awantedbandwidthusage*100+0.5); +} + +void Options::on_spinBox_2A_percent_valueChanged(int arg1) +{ + if(arg1==0) + { + ui->checkBox_rt_enable->setChecked(false); + } else ui->checkBox_rt_enable->setChecked(true); +} + +void Options::on_spinBox_5A_percent_valueChanged(int arg1) +{ + if(arg1==0) + { + ui->groupBox_5a->setChecked(false); + } else ui->groupBox_5a->setChecked(true); +} diff --git a/JMPX/options.h b/JMPX/options.h index dc2678d..2df30a6 100644 --- a/JMPX/options.h +++ b/JMPX/options.h @@ -4,6 +4,7 @@ #include #include "../libJMPX/JMPXInterface.h" +#include "fileloader.h" namespace Ui { class Options; @@ -16,10 +17,10 @@ class Options : public QDialog public: explicit Options(QWidget *parent = 0); ~Options(); - void populatesettings(JMPXInterface *pJMPX); - void pushsetting(JMPXInterface *pJMPX); - void savesettings(JMPXInterface *pJMPX); - void loadsettings(JMPXInterface *pJMPX); + void populatesettings(JMPXInterface *pJMPX,FileLoader *fileloader); + void pushsetting(JMPXInterface *pJMPX,FileLoader *fileloader); + void savesettings(JMPXInterface *pJMPX,FileLoader *fileloader); + void loadsettings(JMPXInterface *pJMPX,FileLoader *fileloader); bool update_rt_music_title; bool quit_on_error; private slots: @@ -28,6 +29,18 @@ private slots: void on_horizontalSlider_38klevel_valueChanged(int value); void on_horizontalSlider_pilotlevel_valueChanged(int value); void on_horizontalSlider_rdslevel_valueChanged(int value); + void on_toolButton_5a_filename_clicked(); + + void on_checkBox_rt_enable_clicked(); + + void on_groupBox_5a_clicked(); + + void validatepercentagespinboxes(); + + void on_spinBox_2A_percent_valueChanged(int arg1); + + void on_spinBox_5A_percent_valueChanged(int arg1); + private: Ui::Options *ui; }; diff --git a/JMPX/options.ui b/JMPX/options.ui index b608a1d..af84a88 100644 --- a/JMPX/options.ui +++ b/JMPX/options.ui @@ -7,9 +7,21 @@ 0 0 505 - 458 + 465 + + + 505 + 465 + + + + + 505 + 465 + + Options @@ -700,7 +712,7 @@ 330 - 310 + 300 101 19 @@ -729,6 +741,224 @@ + + + RDS Advanced + + + + + 300 + 220 + 151 + 121 + + + + <html><head/><body><p>If you want to change the percentage of bandwidth given to each group. Note that group 4A (time) is excluded as is really doesn't use much bandwidth if it is used.</p></body></html> + + + Group bandwidth + + + + + 35 + 54 + 31 + 16 + + + + 2A: + + + + + + 35 + 84 + 31 + 16 + + + + 5A: + + + + + + 35 + 24 + 31 + 16 + + + + 0A: + + + + + + 65 + 24 + 46 + 22 + + + + false + + + Qt::AlignCenter + + + QAbstractSpinBox::NoButtons + + + % + + + 100 + + + + + + 65 + 84 + 46 + 22 + + + + false + + + Qt::AlignCenter + + + QAbstractSpinBox::NoButtons + + + % + + + 100 + + + + + + 65 + 54 + 46 + 22 + + + + false + + + Qt::AlignCenter + + + QAbstractSpinBox::NoButtons + + + % + + + 100 + + + + + + + 20 + 60 + 431 + 111 + + + + Eable sending user defined 5A groups + + + 5A group + + + true + + + true + + + + + 380 + 30 + 41 + 21 + + + + <html><head/><body><p>browse for file</p></body></html> + + + ... + + + + + + 50 + 30 + 321 + 21 + + + + <html><head/><body><p>Filename of data to send as group 5A. The file format is in blocks of 5 bytes, the first byte is the channel and the remaining 4 bytes are the data. The file can be in hex text or binary data.</p></body></html> + + + + + + + + + 10 + 30 + 31 + 16 + + + + File: + + + + + + 20 + 70 + 251 + 19 + + + + <html><head/><body><p>If enabled then the file is a text file and would look something like...</p><p>&quot;02FFFFFFF002636F6E7602657274&quot;</p><p>for example</p></body></html> + + + File is in hex text format + + + + diff --git a/libJMPX/JMPXInterface.h b/libJMPX/JMPXInterface.h index 85294be..f6fcd31 100644 --- a/libJMPX/JMPXInterface.h +++ b/libJMPX/JMPXInterface.h @@ -100,6 +100,11 @@ class JMPXInterface : public QObject virtual void RDS_Set_RT_Enable(bool enable)=0; virtual bool RDS_Get_RT_Enable()=0; + virtual void RDS_Set_5A_Enable(bool enable)=0; + virtual bool RDS_Get_5A_Enable()=0; + + virtual void RDS_Set_5A_data(const QByteArray &data)=0; + virtual void RDS_Set_clocktimeoffset(int offset_in_groups)=0; virtual int RDS_Get_clocktimeoffset()=0; @@ -108,6 +113,13 @@ class JMPXInterface : public QObject virtual double RDS_Get_altfreq2()=0; virtual void RDS_Set_altfreq2(double freq)=0; + virtual double RDS_Get_grp0Awantedbandwidthusage()=0; + virtual double RDS_Get_grp2Awantedbandwidthusage()=0; + virtual double RDS_Get_grp5Awantedbandwidthusage()=0; + virtual void RDS_Set_grouppercentages(double grp0Awantedbandwidthusage,double grp2Awantedbandwidthusage,double grp5Awantedbandwidthusage)=0; + + + //--RDS interface end signals: diff --git a/libJMPX/libJMPX.h b/libJMPX/libJMPX.h index 8f24f9b..f3942e3 100644 --- a/libJMPX/libJMPX.h +++ b/libJMPX/libJMPX.h @@ -218,6 +218,11 @@ class JMPXEncoder : public JMPXInterface void RDS_Set_RT_Enable(bool enable){rds->set_rt_enable(enable);} bool RDS_Get_RT_Enable(){return rds->get_rt_enable();} + void RDS_Set_5A_Enable(bool enable){rds->set_5a_enable(enable);} + bool RDS_Get_5A_Enable(){return rds->get_5a_enable();} + + void RDS_Set_5A_data(const QByteArray &data){rds->set_5a_data(data);} + void RDS_Set_clocktimeoffset(int offset_in_groups){rds->clocktimeoffset=offset_in_groups;} int RDS_Get_clocktimeoffset(){return rds->clocktimeoffset;} @@ -227,6 +232,11 @@ class JMPXEncoder : public JMPXInterface double RDS_Get_altfreq2(){return rds->get_altfreq2();} void RDS_Set_altfreq2(double freq){rds->set_altfreq2(freq);} + double RDS_Get_grp0Awantedbandwidthusage(){return rds->get_grp0Awantedbandwidthusage();} + double RDS_Get_grp2Awantedbandwidthusage(){return rds->get_grp2Awantedbandwidthusage();} + double RDS_Get_grp5Awantedbandwidthusage(){return rds->get_grp5Awantedbandwidthusage();} + void RDS_Set_grouppercentages(double grp0Awantedbandwidthusage,double grp2Awantedbandwidthusage,double grp5Awantedbandwidthusage){rds->set_grouppercentages(grp0Awantedbandwidthusage,grp2Awantedbandwidthusage,grp5Awantedbandwidthusage);} + //RDS interface to implimentation stop private slots: diff --git a/libJMPX/libJMPX.pro b/libJMPX/libJMPX.pro index 66cfdce..9ef84d1 100644 --- a/libJMPX/libJMPX.pro +++ b/libJMPX/libJMPX.pro @@ -16,6 +16,9 @@ DEFINES += JMPX_LIBRARY \ REAL_FASTFIR \ "kiss_fft_scalar=double" +#remove warnings about std::auto_ptr being deprescated. what should we replace them with. TODO +QMAKE_CXXFLAGS += -Wno-deprecated + #You dont need all these audio APIs. #Say if you want only jack then remove __LINUX_PULSE__ and __LINUX_ALSA__ leaving just DEFINES += __UNIX_JACK__ #I have never compiled on mac so if you have let me know if anything should be changed diff --git a/libJMPX/rds.cpp b/libJMPX/rds.cpp index 265b142..27b5919 100644 --- a/libJMPX/rds.cpp +++ b/libJMPX/rds.cpp @@ -2,6 +2,7 @@ #include #include +#include //----PHY layer things @@ -319,12 +320,16 @@ void RDSGroup::setBlock(quint16 message,offset_type offset) RDS::RDS(QObject *parent) : RDSDifferentialBiPhaseSymbolGenerator(parent) { + grp0Awantedbandwidthusage=-1; grp2Awantedbandwidthusage=-1; + grp5Awantedbandwidthusage=-1; + //default rates. no 5a groups //grp0Awantedbandwidthusage 80% //grp2Awantedbandwidthusage 20% - set_grouppercentages(0.8,0.2); + //grp5Awantedbandwidthusage 00% + set_grouppercentages(0.8,0.2,0.0); clocktimeoffset=0; @@ -333,20 +338,24 @@ RDS::RDS(QObject *parent) : RDSDifferentialBiPhaseSymbolGenerator(parent) rbds=false; connect(this,SIGNAL(wantmoregroups()),this,SLOT(wantmoregroups_slot()),Qt::QueuedConnection); + } -void RDS::set_grouppercentages(double _grp0Awantedbandwidthusage,double _grp2Awantedbandwidthusage) +void RDS::set_grouppercentages(double _grp0Awantedbandwidthusage, double _grp2Awantedbandwidthusage, double _grp5Awantedbandwidthusage) { - if((_grp0Awantedbandwidthusage==grp0Awantedbandwidthusage)&&(_grp2Awantedbandwidthusage==grp2Awantedbandwidthusage))return; + if((_grp0Awantedbandwidthusage==grp0Awantedbandwidthusage)&&(_grp2Awantedbandwidthusage==grp2Awantedbandwidthusage)&&(_grp5Awantedbandwidthusage==grp5Awantedbandwidthusage))return; grp0Awantedbandwidthusage=_grp0Awantedbandwidthusage; grp2Awantedbandwidthusage=_grp2Awantedbandwidthusage; + grp5Awantedbandwidthusage=_grp5Awantedbandwidthusage; - double scalling=1.0/(grp0Awantedbandwidthusage+grp2Awantedbandwidthusage); + double scalling=1.0/(grp0Awantedbandwidthusage+grp2Awantedbandwidthusage+grp5Awantedbandwidthusage); grp0Awantedbandwidthusage*=scalling; grp2Awantedbandwidthusage*=scalling; + grp5Awantedbandwidthusage*=scalling; txtrunccnt=0; grp0Atxsum=0; grp2Atxsum=0; + grp5Atxsum=0; } void RDS::reset() @@ -354,6 +363,7 @@ void RDS::reset() txtrunccnt=0; grp0Atxsum=0; grp2Atxsum=0; + grp5Atxsum=0; RDSDifferentialBiPhaseSymbolGenerator::reset(); } @@ -417,6 +427,7 @@ void RDS::wantmoregroups_slot() txtrunccnt+=1.0; if((grp0Atxsum/txtrunccnt)0)return true;return false;} + bool get_5a_enable(){if(grp5Awantedbandwidthusage>0)return true;return false;} - void set_pi(quint16 pi){grp0A.pi=pi;grp2A.pi=pi;grp4A.pi=pi;} + void set_pi(quint16 pi){grp0A.pi=pi;grp2A.pi=pi;grp4A.pi=pi;grp5A.pi=pi;} void set_ps(QString ps){grp0A.set_ps(ps);} void set_rt(QString rt){grp2A.set_rt(rt);} - void set_pty(pty_type pty){grp0A.pty=(quint8)pty;grp2A.pty=(quint8)pty;grp4A.pty=(quint8)pty;} + void set_pty(pty_type pty){grp0A.pty=(quint8)pty;grp2A.pty=(quint8)pty;grp4A.pty=(quint8)pty;grp5A.pty=(quint8)pty;} void set_altfreq1(double freq_mhz){grp0A.set_altfreq1(freq_mhz);} void set_altfreq2(double freq_mhz){grp0A.set_altfreq2(freq_mhz);} void set_stereo(bool set){grp0A.stereo=set;} void set_artificial_head(bool set){grp0A.artificial_head=set;} void set_compressed(bool set){grp0A.compressed=set;} void set_dynamic_pty(bool set){grp0A.dynamic_pty=set;} - void set_tp(bool set){grp0A.tp=set;grp2A.tp=set;grp4A.tp=set;} + void set_tp(bool set){grp0A.tp=set;grp2A.tp=set;grp4A.tp=set;grp5A.tp=set;} void set_ta(bool set){grp0A.ta=set;} void set_ms(bool set){grp0A.ms=set;} + void set_5a_data(const QByteArray &data){grp5A.loaddata(data);} void set_rt_enable(bool set) { - if(set)set_grouppercentages(0.8,0.2); - else set_grouppercentages(1.0,0.0); + if(grp5Awantedbandwidthusage>0) + { + if(set)set_grouppercentages(0.4,0.2,0.4); + else set_grouppercentages(0.5,0.0,0.5); + } + else + { + if(set)set_grouppercentages(0.8,0.2,0.0); + else set_grouppercentages(1,0.0,0.0); + } + } + void set_5a_enable(bool set) + { + if(grp2Awantedbandwidthusage>0) + { + if(set)set_grouppercentages(0.4,0.2,0.4); + else set_grouppercentages(0.8,0.2,0.0); + } + else + { + if(set)set_grouppercentages(0.5,0.0,0.5); + else set_grouppercentages(1,0.0,0.0); + } } - + double get_grp0Awantedbandwidthusage(){return grp0Awantedbandwidthusage;} + double get_grp2Awantedbandwidthusage(){return grp2Awantedbandwidthusage;} + double get_grp5Awantedbandwidthusage(){return grp5Awantedbandwidthusage;} //todo change these to getters and setters to match other things int clocktimeoffset;//to allow the user to adjust the delay caused by the soundcard buffer @@ -495,22 +589,23 @@ class RDS : public RDSDifferentialBiPhaseSymbolGenerator bool rbds; signals: - -public slots: private slots: void wantmoregroups_slot(); private: - typedef enum {SEL_0AGroup,SEL_2AGroup} selected_group_type; + typedef enum {SEL_0AGroup,SEL_2AGroup,SEL_5AGroup} selected_group_type; RDS0AGroup grp0A; RDS2AGroup grp2A; RDS4AGroup grp4A; + RDS5AGroup grp5A; double grp0Atxsum; double grp0Awantedbandwidthusage; double grp2Atxsum; double grp2Awantedbandwidthusage; + double grp5Atxsum; + double grp5Awantedbandwidthusage; double txtrunccnt; };