From 1767b5913fb409e94be9b442f2f94acde5dba651 Mon Sep 17 00:00:00 2001 From: carlou Date: Fri, 9 Sep 2016 10:44:56 +0200 Subject: [PATCH] Refactoring --- src/PlayThread.cpp | 118 +++++++++++++-------------- src/PlayThread.h | 16 ++-- src/SerialManager.cpp | 6 +- src/SerialManager.h | 4 +- src/Server.cpp | 182 +++++++++++++++++++++--------------------- src/Server.h | 24 +++--- src/Track.cpp | 14 ++-- src/Track.h | 2 +- 8 files changed, 183 insertions(+), 183 deletions(-) diff --git a/src/PlayThread.cpp b/src/PlayThread.cpp index 3f73e80..182c281 100644 --- a/src/PlayThread.cpp +++ b/src/PlayThread.cpp @@ -13,25 +13,25 @@ #include PlayThread::PlayThread(QSettings* c) : - QThread(0), options(c) { + QThread(0), m_options(c) { - options->beginGroup("default"); - setThreshold(options->value("threshold").toInt()); - options->endGroup(); + m_options->beginGroup("default"); + setThreshold(m_options->value("threshold").toInt()); + m_options->endGroup(); } unsigned int PlayThread::getTracksCount() const { - return tracks.size(); + return m_tracks.size(); } Track* PlayThread::getTrack(const unsigned int track){ - return (isValidTrack(track) ? tracks[track] : NULL); + return (isValidTrack(track) ? m_tracks[track] : NULL); } int PlayThread::getActivatedTracks() const{ int res = 0; - for(int i= 0; iisActivated() ? pow(2,i) : 0); + for(int i= 0; iisActivated() ? pow(2,i) : 0); return res; } @@ -41,88 +41,88 @@ int PlayThread::getThreshold() const { } void PlayThread::run() { - manager->input()->reset(); - bufferCount = 0; - isPlaying = true; - manager->execute(); + m_manager->input()->reset(); + m_bufferCount = 0; + m_isPlaying = true; + m_manager->execute(); } void PlayThread::setMasterVolume(const unsigned int vol) { - masterVolume->setGain(vol / 10.0); + m_masterVolume->setGain(vol / 10.0); } void PlayThread::setVolume(const unsigned int track, const unsigned int vol) { if(isValidTrack(track)) - tracks[track]->setVolume(vol); + m_tracks[track]->setVolume(vol); } void PlayThread::setPan(const unsigned int track, const int pan) { if(isValidTrack(track)) - tracks[track]->setPan(pan); + m_tracks[track]->setPan(pan); } void PlayThread::setMute(const unsigned int track, const bool doMute) { if(isValidTrack(track)) - tracks[track]->setMute(doMute); + m_tracks[track]->setMute(doMute); } void PlayThread::timeHandle() { - if(++bufferCount > maxBufferCount) - bufferCount = 0; + if(++m_bufferCount > m_maxBufferCount) + m_bufferCount = 0; - emit actualBeatChanged(bufferCount * conf.bufferSize / double(conf.samplingRate)); + emit actualBeatChanged(m_bufferCount * m_conf.bufferSize / double(m_conf.samplingRate)); } void PlayThread::stop() { if(this->isRunning()){ - manager->stop(); - manager->input()->reset(); - bufferCount = 0; - isPlaying = false; + m_manager->stop(); + m_manager->input()->reset(); + m_bufferCount = 0; + m_isPlaying = false; } } bool PlayThread::isStopped() const { - return !isPlaying; + return !m_isPlaying; } void PlayThread::reset() { - options->beginGroup("default"); - setMasterVolume(options->value("master").toInt()); - options->endGroup(); + m_options->beginGroup("default"); + setMasterVolume(m_options->value("master").toInt()); + m_options->endGroup(); - for(int i=0; ireset(); + for(int i=0; ireset(); } void PlayThread::solo(const unsigned int track, const bool state) { if(isValidTrack(track)) { - tracks[track]->setSolo(state); + m_tracks[track]->setSolo(state); if(state) { - tracks[track]->setMute(false); + m_tracks[track]->setMute(false); - for(int i=0; iisSolo()) - tracks[i]->setMute(true); + for(int i=0; iisSolo()) + m_tracks[i]->setMute(true); } else { bool noMoreSolo = true; - for(int i=0; iisSolo()) + for(int i=0; iisSolo()) noMoreSolo = false; if(noMoreSolo) - for(int i=0; isetMute( !tracks[i]->isActivated() ); + for(int i=0; isetMute( !m_tracks[i]->isActivated() ); else - tracks[track]->setMute( true ); + m_tracks[track]->setMute( true ); } } } void PlayThread::switchBox(const unsigned int track) { if(isValidTrack(track)) - tracks[track]->setActivated(!tracks[track]->isActivated()); + m_tracks[track]->setActivated(!m_tracks[track]->isActivated()); } void PlayThread::setThreshold(const unsigned int threshold){ @@ -130,49 +130,49 @@ void PlayThread::setThreshold(const unsigned int threshold){ } void PlayThread::resetThreshold() { - options->beginGroup("default"); - setThreshold(options->value("threshold").toInt()); - options->endGroup(); + m_options->beginGroup("default"); + setThreshold(m_options->value("threshold").toInt()); + m_options->endGroup(); } void PlayThread::load(const SongData& s) { // Reset to 0 - bufferCount = 0; + m_bufferCount = 0; int track_count = s.tracks.size(); - for(int i=0; i chains(track_count); #pragma omp parallel for for(int i = 0; i < track_count; i++) { - Track* t = new Track(s.tracks[i], conf, options, i); + Track* t = new Track(s.tracks[i], m_conf, m_options, i); connect(t, &Track::onActivationSwitch, this, &PlayThread::onEnablementChanged); - tracks[i] = t; + m_tracks[i] = t; - auto file = new FFMPEGFileInput(tracks[i]->getFile(), conf); - maxBufferCount = file->v(0).size() / conf.bufferSize; - emit beatCountChanged(file->v(0).size() / double(conf.samplingRate)); + auto file = new FFMPEGFileInput(m_tracks[i]->getFile(), m_conf); + m_maxBufferCount = file->v(0).size() / m_conf.bufferSize; + emit beatCountChanged(file->v(0).size() / double(m_conf.samplingRate)); chains[i] = Input_p(new SfxInputProxy(new StereoAdapter(new LoopInputProxy(file)), - new Sequence(conf, tracks[i]->getVolumePtr(), tracks[i]->getPanPtr(), tracks[i]->getMutePtr() ))); + new Sequence(m_conf, m_tracks[i]->getVolumePtr(), m_tracks[i]->getPanPtr(), m_tracks[i]->getMutePtr() ))); emit songLoaded(i+1,track_count); } // Master - auto input = Input_p(new SfxInputProxy(new SummationProxy(new InputMultiplexer(conf, chains)), masterVolume)); + auto input = Input_p(new SfxInputProxy(new SummationProxy(new InputMultiplexer(m_conf, chains)), m_masterVolume)); // Manager - manager = std::make_shared>(std::move(input), - std::move(std::make_shared>(conf)), + m_manager = std::make_shared>(std::move(input), + std::move(std::make_shared>(m_conf)), std::bind(&PlayThread::timeHandle, this), - conf); + m_conf); } bool PlayThread::isValidTrack(unsigned int track) diff --git a/src/PlayThread.h b/src/PlayThread.h index bd53080..65314b0 100644 --- a/src/PlayThread.h +++ b/src/PlayThread.h @@ -175,17 +175,17 @@ public slots: void load(const SongData& s); private: - QSettings* options; - Parameters conf; /*< Configuration data */ - std::shared_ptr> masterVolume {new Amplify(conf)}; - std::shared_ptr> manager; + QSettings* m_options; + Parameters m_conf; /*< Configuration data */ + std::shared_ptr> m_masterVolume {new Amplify(m_conf)}; + std::shared_ptr> m_manager; - QVector tracks; /*< List of the current song's tracks */ + QVector m_tracks; /*< List of the current song's tracks */ - int bufferCount {}; /*< Buffer in which we are s*/ - int maxBufferCount {}; /*< Total buffer count in a loop */ + int m_bufferCount {}; /*< Buffer in which we are s*/ + int m_maxBufferCount {}; /*< Total buffer count in a loop */ - bool isPlaying {false}; + bool m_isPlaying {false}; int m_threshold; /** diff --git a/src/SerialManager.cpp b/src/SerialManager.cpp index 99e2c5e..f6e1f90 100644 --- a/src/SerialManager.cpp +++ b/src/SerialManager.cpp @@ -20,7 +20,7 @@ SerialManager::SerialManager(QObject *parent): } void SerialManager::stop() { - this->isRunning = false; + this->m_isRunning = false; } void SerialManager::run() { @@ -58,13 +58,13 @@ void SerialManager::run() { int pin = 0; int hitavg = 0; - this->isRunning = true; + this->m_isRunning = true; //wiringPiSetupSys (); mcp3004Setup(BASE,SPI_CHAN); - while (this->isRunning){ + while (this->m_isRunning){ for(pin=0; pin<8; pin++){ diff --git a/src/SerialManager.h b/src/SerialManager.h index fcc5faa..a3b48c4 100644 --- a/src/SerialManager.h +++ b/src/SerialManager.h @@ -51,8 +51,8 @@ public slots: virtual void run(); private: - bool isRunning {false}; /*< Status of the reading */ - std::shared_ptr port; /*< Port to open */ + bool m_isRunning {false}; /*< Status of the reading */ + std::shared_ptr m_port; /*< Port to open */ }; #endif // SERIALMANAGER_H diff --git a/src/Server.cpp b/src/Server.cpp index 8f996b0..5184da2 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -31,21 +31,21 @@ void Server::ledSetup(){ wiringPiSetupSys(); //pinMode(LED_VALUE, OUTPUT); - QString c = QStringLiteral("gpio mode %1 out").arg(options->value("gpio/led").toInt()); + QString c = QStringLiteral("gpio mode %1 out").arg(m_options->value("gpio/led").toInt()); std::system(c.toStdString().c_str()); } void Server::ledOn(){ //digitalWrite(LED_VALUE, HIGH); - QString c = QStringLiteral("gpio write %1 1").arg(options->value("gpio/led").toInt()); + QString c = QStringLiteral("gpio write %1 1").arg(m_options->value("gpio/led").toInt()); std::system(c.toStdString().c_str()); } void Server::ledOff(){ //digitalWrite(LED_VALUE, LOW); - QString c = QStringLiteral("gpio write %1 0").arg(options->value("gpio/led").toInt()); + QString c = QStringLiteral("gpio write %1 0").arg(m_options->value("gpio/led").toInt()); std::system(c.toStdString().c_str()); } @@ -58,122 +58,122 @@ void Server::ledBlink(){ } Server::Server(QSettings* opt): - options(opt){ + m_options(opt){ - initConf(options); - qDebug() << options->fileName(); + initConf(m_options); + qDebug() << m_options->fileName(); ledSetup(); ledOn(); - player = new PlayThread(options); + m_player = new PlayThread(m_options); - options->beginGroup("osc"); - receiver = new OscReceiver(options->value("receiver").toInt()); - sender = new OscSender(options->value("ip").toString().toStdString(), - options->value("sender").toInt()); + m_options->beginGroup("osc"); + m_receiver = new OscReceiver(m_options->value("receiver").toInt()); + m_sender = new OscSender(m_options->value("ip").toString().toStdString(), + m_options->value("sender").toInt()); - options->endGroup(); + m_options->endGroup(); - connect(player, &PlayThread::muteChanged, - player, &PlayThread::setMute); + connect(m_player, &PlayThread::muteChanged, + m_player, &PlayThread::setMute); connect(this, &Server::updateThreshold, - player, &PlayThread::setThreshold); + m_player, &PlayThread::setThreshold); connect(this, &Server::resetThreshold, - player, &PlayThread::resetThreshold); + m_player, &PlayThread::resetThreshold); - connect(player, &PlayThread::actualBeatChanged, + connect(m_player, &PlayThread::actualBeatChanged, this, &Server::updateBeat); - connect(player, &PlayThread::beatCountChanged, + connect(m_player, &PlayThread::beatCountChanged, this, &Server::updateBeatCount); - connect(player, &PlayThread::songLoaded, + connect(m_player, &PlayThread::songLoaded, this, &Server::onSongLoaded); - connect(&saveManager, &SaveManager::updatedTracksList, + connect(&m_saveManager, &SaveManager::updatedTracksList, this, &Server::updateTrackList); - connect(&serialManager, &SerialManager::boxActivated, + connect(&m_serialManager, &SerialManager::boxActivated, this, &Server::switchBox); - connect(&serialManager, &SerialManager::boxActivated, + connect(&m_serialManager, &SerialManager::boxActivated, this, &Server::sendBoxActivation); - serialManager.start(); + m_serialManager.start(); //Client events - receiver->addHandler("/box/update_threshold", + m_receiver->addHandler("/box/update_threshold", std::bind(&Server::handle__box_updateThreshold, this, std::placeholders::_1)); - receiver->addHandler("/box/reset_threshold", + m_receiver->addHandler("/box/reset_threshold", std::bind(&Server::handle__box_resetThreshold, this, std::placeholders::_1)); - receiver->addHandler("/box/enable", + m_receiver->addHandler("/box/enable", std::bind(&Server::handle__box_enable, this, std::placeholders::_1)); - receiver->addHandler("/box/volume", + m_receiver->addHandler("/box/volume", std::bind(&Server::handle__box_volume, this, std::placeholders::_1)); - receiver->addHandler("/box/pan", + m_receiver->addHandler("/box/pan", std::bind(&Server::handle__box_pan, this, std::placeholders::_1)); - receiver->addHandler("/box/mute", + m_receiver->addHandler("/box/mute", std::bind(&Server::handle__box_mute, this, std::placeholders::_1)); - receiver->addHandler("/box/solo", + m_receiver->addHandler("/box/solo", std::bind(&Server::handle__box_solo, this, std::placeholders::_1)); - receiver->addHandler("/box/master", + m_receiver->addHandler("/box/master", std::bind(&Server::handle__box_master, this, std::placeholders::_1)); - receiver->addHandler("/box/play", + m_receiver->addHandler("/box/play", std::bind(&Server::handle__box_play, this, std::placeholders::_1)); - receiver->addHandler("/box/stop", + m_receiver->addHandler("/box/stop", std::bind(&Server::handle__box_stop, this, std::placeholders::_1)); - receiver->addHandler("/box/reset", + m_receiver->addHandler("/box/reset", std::bind(&Server::handle__box_reset, this, std::placeholders::_1)); - receiver->addHandler("/box/refresh_song", + m_receiver->addHandler("/box/refresh_song", std::bind(&Server::handle__box_refreshSong, this, std::placeholders::_1)); - receiver->addHandler("/box/select_song", + m_receiver->addHandler("/box/select_song", std::bind(&Server::handle__box_selectSong, this, std::placeholders::_1)); - receiver->addHandler("/box/sync", + m_receiver->addHandler("/box/sync", std::bind(&Server::handle__box_sync, this, std::placeholders::_1)); - receiver->run(); + m_receiver->run(); } Server::~Server() { qDebug() << "Stopping server..."; stop(); - player->stop(); + m_player->stop(); qDebug() << "PlayThread stopping..."; - if(!player->wait(5000)) { + if(!m_player->wait(5000)) { qWarning("PlayThread : Potential deadlock detected !! Terminating..."); - player->terminate(); - player->wait(5000); - player->exit(1); + m_player->terminate(); + m_player->wait(5000); + m_player->exit(1); } qDebug() << "SerialManager stopping..."; - serialManager.stop(); - if(!serialManager.wait(5000)) { + m_serialManager.stop(); + if(!m_serialManager.wait(5000)) { qWarning("SerialManager : Potential deadlock detected !! Terminating..."); - serialManager.terminate(); - serialManager.wait(5000); - serialManager.exit(1); + m_serialManager.terminate(); + m_serialManager.wait(5000); + m_serialManager.exit(1); } qDebug() << "Deleting pointers..."; - delete player; + delete m_player; ledOff(); - delete options; + delete m_options; qDebug() << "Stopping CoreApp..."; QCoreApplication::exit(0); @@ -184,7 +184,7 @@ int Server::getTempo() const { } unsigned int Server::getThreshold() const { - return 99 - (player->getThreshold()-100)/4; + return 99 - (m_player->getThreshold()-100)/4; } bool Server::initConf(QSettings *c) { @@ -228,7 +228,7 @@ void Server::sendThreshold() { } void Server::sendActivatedTracks() { - sendMsgActivatedTracks(player->getActivatedTracks()); + sendMsgActivatedTracks(m_player->getActivatedTracks()); } void Server::sendPlay() @@ -237,11 +237,11 @@ void Server::sendPlay() } void Server::sendTracksCount() { - sendMsgTracksCount(player->getTracksCount()); + sendMsgTracksCount(m_player->getTracksCount()); } void Server::sendBoxActivation(unsigned int i, int val) { - if(val >= player->getThreshold()){ + if(val >= m_player->getThreshold()){ sendMsgBoxActivation(i); } } @@ -251,22 +251,22 @@ void Server::sendBeatCount(unsigned int i) { } void Server::sendSongsList() { - options->beginGroup("files"); - QDir exportFolder(options->value("folder").toString()); + m_options->beginGroup("files"); + QDir exportFolder(m_options->value("folder").toString()); - exportFolder.setNameFilters(QStringList()<value("extension").toString()); + exportFolder.setNameFilters(QStringList()<value("extension").toString()); QStringList fileList = exportFolder.entryList(); QString str = fileList.join("|"); QByteArray list = str.toLatin1(); const char *c_list = list.data(); - options->endGroup(); + m_options->endGroup(); sendMsgSongsList(c_list); } void Server::sendSongTitle() { - QString raw_title = QString::fromStdString(song.name); + QString raw_title = QString::fromStdString(m_song.name); QByteArray title = raw_title.toLatin1(); const char *c_title = title.data(); @@ -297,7 +297,7 @@ void Server::handle__box_enable(osc::ReceivedMessageArgumentStream args) { qDebug() << "received /box/enable" << box; ledBlink(); - switchBox(box, player->getThreshold()); + switchBox(box, m_player->getThreshold()); } void Server::handle__box_volume(osc::ReceivedMessageArgumentStream args) { @@ -307,7 +307,7 @@ void Server::handle__box_volume(osc::ReceivedMessageArgumentStream args) { qDebug() << "received /box/volume" << vol; ledBlink(); - player->setVolume(box, vol); + m_player->setVolume(box, vol); } void Server::handle__box_pan(osc::ReceivedMessageArgumentStream args) { @@ -317,7 +317,7 @@ void Server::handle__box_pan(osc::ReceivedMessageArgumentStream args) { qDebug() << "received /box/pan" << box << vol; ledBlink(); - player->setPan(box, vol); + m_player->setPan(box, vol); } void Server::handle__box_mute(osc::ReceivedMessageArgumentStream args) { @@ -327,7 +327,7 @@ void Server::handle__box_mute(osc::ReceivedMessageArgumentStream args) { qDebug() << "received /box/mute" << box << state; ledBlink(); - player->setMute(box, state); + m_player->setMute(box, state); } void Server::handle__box_solo(osc::ReceivedMessageArgumentStream args) { @@ -337,7 +337,7 @@ void Server::handle__box_solo(osc::ReceivedMessageArgumentStream args) { qDebug() << "received /box/solo" << box << state; ledBlink(); - player->solo(box, state); + m_player->solo(box, state); } void Server::handle__box_master(osc::ReceivedMessageArgumentStream args) { @@ -346,7 +346,7 @@ void Server::handle__box_master(osc::ReceivedMessageArgumentStream args) { qDebug() << "received /box/master" << vol; ledBlink(); - player->setMasterVolume(vol); + m_player->setMasterVolume(vol); } void Server::handle__box_play(osc::ReceivedMessageArgumentStream args) { @@ -377,7 +377,7 @@ void Server::handle__box_reset(osc::ReceivedMessageArgumentStream args) { if(state) stop(); - player->reset(); + m_player->reset(); } void Server::handle__box_refreshSong(osc::ReceivedMessageArgumentStream args) { @@ -398,7 +398,7 @@ void Server::handle__box_selectSong(osc::ReceivedMessageArgumentStream args) { QString so = QString(QLatin1String(receptSong)); if(!so.isEmpty()) - selSong = so; + m_selSong = so; connect(this, SIGNAL(actionLoad()), this, SLOT(load()) ); @@ -424,12 +424,12 @@ void Server::handle__box_sync(osc::ReceivedMessageArgumentStream args) void Server::reset() { stop(); - player->reset(); + m_player->reset(); } void Server::switchBox(unsigned int i, int val) { - if(val >= player->getThreshold()) { - player->switchBox(i); + if(val >= m_player->getThreshold()) { + m_player->switchBox(i); } } @@ -439,14 +439,14 @@ void Server::play() { } sendPlay(); - player->start(); + m_player->start(); m_playing = true; } void Server::stop() { if(!m_loaded || !m_playing) return; - player->stop(); + m_player->stop(); m_previousBeat = 0; m_playing = false; @@ -457,7 +457,7 @@ void Server::updateBeat(double t) { // in seconds int time = (int)(t * getTempo() / 60.0f) + 1; - if(time != m_previousBeat && time <= m_beatCount && !player->isStopped()) { + if(time != m_previousBeat && time <= m_beatCount && !m_player->isStopped()) { m_previousBeat = time; sendBeatCount(time); @@ -465,7 +465,7 @@ void Server::updateBeat(double t) { // in seconds sendActivatedTracks(); sendBeatCount(time); } - } else if(player->isStopped()) { + } else if(m_player->isStopped()) { m_previousBeat = 0; sendBeatCount(0); } @@ -493,52 +493,52 @@ void Server::setTempo(unsigned int arg) { } void Server::sendMsgThreshold(int t) { - sender->send(osc::MessageGenerator()("/box/sensor", t)); + m_sender->send(osc::MessageGenerator()("/box/sensor", t)); qDebug() << "sent /box/sensor" << t; } void Server::sendMsgBoxActivation(int chan) { - sender->send(osc::MessageGenerator()("/box/enable_out", chan)); + m_sender->send(osc::MessageGenerator()("/box/enable_out", chan)); qDebug() << "sent /box/enable_out" << chan; } void Server::sendMsgActivatedTracks(int tracks) { - sender->send(osc::MessageGenerator()("/box/enable_sync", tracks)); + m_sender->send(osc::MessageGenerator()("/box/enable_sync", tracks)); qDebug() << "sent /box/enable_sync" << tracks; } void Server::sendMsgBeatCount(int beat) { - sender->send(osc::MessageGenerator()("/box/beat", beat)); + m_sender->send(osc::MessageGenerator()("/box/beat", beat)); qDebug() << "sent /box/beat" << beat; } void Server::sendMsgPlay(int tempo) { - sender->send(osc::MessageGenerator()("/box/play", tempo)); + m_sender->send(osc::MessageGenerator()("/box/play", tempo)); qDebug() << "sent /box/play" << tempo; } void Server::sendMsgSongTitle(const char *title) { - sender->send(osc::MessageGenerator()("/box/title", title)); + m_sender->send(osc::MessageGenerator()("/box/title", title)); qDebug() << "sent /box/title" << title; } void Server::sendMsgSongsList(const char *list) { - sender->send(osc::MessageGenerator()("/box/songs_list", list)); + m_sender->send(osc::MessageGenerator()("/box/songs_list", list)); qDebug() << "sent /box/songs_list" << list; } void Server::sendMsgTracksCount(int num) { - sender->send(osc::MessageGenerator()("/box/tracks_count", num)); + m_sender->send(osc::MessageGenerator()("/box/tracks_count", num)); qDebug() << "sent /box/tracks_count" << num; } void Server::sendMsgTracksList(const char *list) { - sender->send(osc::MessageGenerator()("/box/tracks_list", list)); + m_sender->send(osc::MessageGenerator()("/box/tracks_list", list)); qDebug() << "sent /box/tracks_list" << list; } void Server::sendMsgReady(bool isReady) { - sender->send(osc::MessageGenerator()("/box/ready", isReady)); + m_sender->send(osc::MessageGenerator()("/box/ready", isReady)); qDebug() << "sent /box/ready" << isReady; } @@ -546,18 +546,18 @@ int Server::load() { sendSongsList(); sendThreshold(); - if (!selSong.isEmpty()) { + if (!m_selSong.isEmpty()) { try { stop(); - QString file = EXPORT_FOLDER + selSong; + QString file = EXPORT_FOLDER + m_selSong; if(!file.isEmpty()) { - currentFile = file; - song = saveManager.load(file); + m_currentFile = file; + m_song = m_saveManager.load(file); - setTempo(song.tempo); - player->load(song); + setTempo(m_song.tempo); + m_player->load(m_song); m_loaded = true; sendSongTitle(); @@ -578,7 +578,7 @@ int Server::load() { void Server::save() { try { if(m_loaded) - saveManager.save(currentFile, this); + m_saveManager.save(m_currentFile, this); } catch(std::exception& e) { qCritical() << tr("SAVING ERROR :") << e.what(); } diff --git a/src/Server.h b/src/Server.h index 7dae621..543dd72 100644 --- a/src/Server.h +++ b/src/Server.h @@ -41,17 +41,17 @@ class Server : public /*QCoreApplication*/ QObject { friend class SaveManager; private: - PlayThread* player; /*< Audio play manager */ - SaveManager saveManager; /*< File handling manager */ - SerialManager serialManager {this}; /*< Interface with serial port */ + PlayThread* m_player; /*< Audio play manager */ + SaveManager m_saveManager; /*< File handling manager */ + SerialManager m_serialManager {this}; /*< Interface with serial port */ - QSettings* options; /*< Config options */ + QSettings* m_options; /*< Config options */ - SongData song; /*< Actual song's data */ - QString selSong; /*< Selected song's name */ - int threshold; - int nbChannels; - QString currentFile; + SongData m_song; /*< Actual song's data */ + QString m_selSong; /*< Selected song's name */ + int m_threshold; + int m_nbChannels; + QString m_currentFile; bool m_loaded {false}; /*< Indicate if a song has been loaded */ bool m_playing {false}; /*< Indicate if a song is playing */ @@ -62,8 +62,8 @@ class Server : public /*QCoreApplication*/ QObject { int m_previousBeat {-1}; - OscReceiver* receiver; /*< Receiving interface with OSC protocol */ - OscSender* sender; /*< Sending interface with OSC protocol */ + OscReceiver* m_receiver; /*< Receiving interface with OSC protocol */ + OscSender* m_sender; /*< Sending interface with OSC protocol */ /** * @brief Setup WiringPi interface @@ -282,7 +282,7 @@ class Server : public /*QCoreApplication*/ QObject { * @brief Notify of a new threshold value * @param threshold New threshold value */ - void updateThreshold(int threshold); + void updateThreshold(int m_threshold); /** * @brief Notify the threshold reset */ diff --git a/src/Track.cpp b/src/Track.cpp index 888c997..f44b84a 100644 --- a/src/Track.cpp +++ b/src/Track.cpp @@ -7,11 +7,11 @@ Track::Track(): m_id(0), m_file(""), m_name(""), - m_soloState(false), m_activatedState(false), options(NULL) + m_soloState(false), m_activatedState(false), m_options(NULL) {} Track::Track(const TrackData& data, Parameters conf, QSettings* opt, int id): - m_id(id), m_file(data.file), m_name(data.name), options(opt), + m_id(id), m_file(data.file), m_name(data.name), m_options(opt), m_soloState(false), m_activatedState(false) { m_volumePtr = std::make_shared>(conf); @@ -88,11 +88,11 @@ void Track::notifyEnabled(bool enabled) { } void Track::reset() { - options->beginGroup("default"); + m_options->beginGroup("default"); - setVolume(options->value("volume").toInt()); - setPan(options->value("pan").toInt()); - setActivated(options->value("activation").toBool()); + setVolume(m_options->value("volume").toInt()); + setPan(m_options->value("pan").toInt()); + setActivated(m_options->value("activation").toBool()); - options->endGroup(); + m_options->endGroup(); } diff --git a/src/Track.h b/src/Track.h index 7f65068..d6a8d3a 100644 --- a/src/Track.h +++ b/src/Track.h @@ -33,7 +33,7 @@ class Track : public QObject bool m_soloState; bool m_activatedState; - QSettings* options; + QSettings* m_options; std::shared_ptr> m_volumePtr; /*< Volume in the audio engine */ std::shared_ptr> m_panPtr; /*< Pan in the audio engine */