diff --git a/AudioDown.sh b/AudioDown.sh deleted file mode 100755 index 18f0f46..0000000 --- a/AudioDown.sh +++ /dev/null @@ -1,7 +0,0 @@ -#decrease Audio - -currentVolume=`cat currentVolume.txt` - -newVolume=`./decreaseVolume.out $currentVolume` - -amixer -c 1 set DAC0 $newVolume > /dev/null diff --git a/PrintAudioInfo.cpp b/AudioInformation.cpp similarity index 60% rename from PrintAudioInfo.cpp rename to AudioInformation.cpp index b9a2686..79f515b 100644 --- a/PrintAudioInfo.cpp +++ b/AudioInformation.cpp @@ -3,35 +3,39 @@ #include #include -int main(int argc, char* argv[]) +#include"AudioInformation.h" + +AudioInformation::AudioInformation() +{ + stripInformation(); +} + + +void AudioInformation::stripInformation() { std::fstream readAudio; - unsigned short count; - unsigned short volume; - readAudio.open("audio.txt", std::ios::in); - + //std::cout << "In here" << std::endl; + while (!readAudio.eof()) { std::string data; readAudio >> data; - //std::cout << data << " "; if (data.compare("Playback") == 0) { ++count; - std::cout << "Count incremented" << std::endl; } if (count == 3) { readAudio >> data; + std::cout << data << " volume" << std::endl; volume = atoi(data.c_str()); - std::cout << volume << " value of audio" << std::endl; break; } } - std::cout << std::endl; + //std::cout << std::endl; readAudio.close(); readAudio.open("currentVolume.txt", std::ios::out); @@ -39,6 +43,10 @@ int main(int argc, char* argv[]) readAudio << volume; readAudio.close(); - - return 0; +} + + +unsigned short AudioInformation::getVolume() const +{ + return volume; } diff --git a/AudioInformation.h b/AudioInformation.h new file mode 100644 index 0000000..cfe625d --- /dev/null +++ b/AudioInformation.h @@ -0,0 +1,19 @@ +#ifndef AUDIOINFORMATION_H +#define AUDIOINFORMATION_H + +class AudioInformation +{ +public: + AudioInformation(); + + unsigned short getVolume() const; + +private: + void stripInformation(); + + unsigned short volume = 0; + unsigned short count = 0; + const unsigned short MAXCOUNTS = 3; +}; + +#endif diff --git a/AudioUp.sh b/AudioUp.sh deleted file mode 100755 index 87cf127..0000000 --- a/AudioUp.sh +++ /dev/null @@ -1,7 +0,0 @@ -#raiseAudio - -currentVolume=`cat currentVolume.txt` - -newVolume=`./increaseVolume.out $currentVolume` - -amixer -c 1 set DAC0 $newVolume > /dev/null diff --git a/DecreaseVolume.cpp b/DecreaseVolume.cpp new file mode 100644 index 0000000..131b0c7 --- /dev/null +++ b/DecreaseVolume.cpp @@ -0,0 +1,11 @@ +#include"DecreaseVolume.h" + +DecreaseVolume::DecreaseVolume() +{ + +} + + +void DecreaseVolume::updateVolume() +{ +} diff --git a/DecreaseVolume.h b/DecreaseVolume.h new file mode 100644 index 0000000..ba0e134 --- /dev/null +++ b/DecreaseVolume.h @@ -0,0 +1,14 @@ +#ifndef DECREASEVOLUME_H +#define DECREASEVOLUME_H + +#include"Volume.h" + +class DecreaseVolume : public Volume +{ +public: + DecreaseVolume(); + + void updateVolume(); +}; + +#endif diff --git a/DownVolume.cpp b/DownVolume.cpp deleted file mode 100644 index 71a08c2..0000000 --- a/DownVolume.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include -#include - -int main(int argc, char* argv[]) -{ - std::fstream sssssssssliper; - sssssssssliper.open("currentVolume.txt", std::ios::out); - - const unsigned short DECREMENT = 15; - unsigned short currentVolume = atoi(*(argv + 1)); - unsigned short newVolume = currentVolume - DECREMENT; - - sssssssssliper << newVolume; - sssssssssliper.close(); - - std::cout << newVolume << std::endl; - - - return 0; -} diff --git a/MainVolumeControl.cpp b/MainVolumeControl.cpp new file mode 100644 index 0000000..b33ef69 --- /dev/null +++ b/MainVolumeControl.cpp @@ -0,0 +1,33 @@ +#include +#include + +#include"stdio.h" +#include"stdlib.h" + +#include"IncreaseVolume.h" +#include"DecreaseVolume.h" + +int main(int argc, char* argv[]) +{ + std::string action = *(argv + 1); + + if (action.compare("up") == 0) + { + IncreaseVolume iv; + //iv.setVolume(30); + + std::cout << "Volume test: " << iv.getVolume() << std::endl; + } + else if (action.compare("down") == 0) + { + DecreaseVolume dv; + //dv.setVolume(70); + std::cout << "Volume test: " << dv.getVolume() << std::endl; + } + else + { + std::cout << "Not the same" << std::endl; + } + + return 0; +} diff --git a/StripVolume.out b/StripVolume.out deleted file mode 100755 index 1fe74d6..0000000 Binary files a/StripVolume.out and /dev/null differ diff --git a/UpVolume.cpp b/UpVolume.cpp deleted file mode 100644 index b5602cc..0000000 --- a/UpVolume.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include -#include - -int main(int argc, char* argv[]) -{ - std::fstream cv; - cv.open("currentVolume.txt", std::ios::out); - const unsigned short INCREMENT = 15; - unsigned short currentVolume = atoi(*(argv + 1)); - unsigned short newVolume = currentVolume + INCREMENT; - - cv << newVolume; - std::cout << newVolume << std::endl; - - cv.close(); - - return 0; -} diff --git a/Volume.cpp b/Volume.cpp new file mode 100644 index 0000000..d829b5f --- /dev/null +++ b/Volume.cpp @@ -0,0 +1,19 @@ +#include +#include +#include + +#include"stdio.h" +#include"stdlib.h" + +#include"Volume.h" + +void Volume::updateTheCurrentVolume() +{ + std::fstream updateFile; + + updateFile.open("currentVolume.txt", std::ios::out); + + updateFile << volume; + + updateFile.close(); +} diff --git a/Volume.h b/Volume.h new file mode 100644 index 0000000..b321693 --- /dev/null +++ b/Volume.h @@ -0,0 +1,34 @@ +#ifndef VOLUME_H +#define VOLUME_H + +#include + +class Volume +{ +public: + + Volume() + { + + } + void setVolume(const unsigned short& volume) + { + this->volume = volume; + } + + unsigned short getVolume() const + { + return volume; + } + void updateTheCurrentVolume(); + virtual void updateVolume() = 0; + +protected: + + unsigned short volume; + const unsigned short AFFECTAMOUNT = 20; + +private: +}; + +#endif diff --git a/decreaseVolume.out b/decreaseVolume.out deleted file mode 100755 index cf2eb72..0000000 Binary files a/decreaseVolume.out and /dev/null differ diff --git a/increaseVolume.out b/increaseVolume.out deleted file mode 100755 index 0c1c0a4..0000000 Binary files a/increaseVolume.out and /dev/null differ