Functioning

This commit is contained in:
amazing-username
2017-04-09 19:10:28 -05:00
parent fabcff4e05
commit 2b3718f5fd
9 changed files with 90 additions and 11 deletions
+22
View File
@@ -0,0 +1,22 @@
#ifndef AUDIODUMP_H
#define AUDIODUMP_H
#include"stdio.h"
#include"stdlib.h"
class AudioDump
{
public:
AudioDump()
{
}
void dump()
{
system("amixer -c 1 get DAC0 > audio.txt");
}
};
#endif
+3 -3
View File
@@ -4,9 +4,12 @@
#include <string> #include <string>
#include"AudioInformation.h" #include"AudioInformation.h"
#include"AudioDump.h"
AudioInformation::AudioInformation() AudioInformation::AudioInformation()
{ {
AudioDump ad;
ad.dump();
stripInformation(); stripInformation();
} }
@@ -15,7 +18,6 @@ void AudioInformation::stripInformation()
{ {
std::fstream readAudio; std::fstream readAudio;
readAudio.open("audio.txt", std::ios::in); readAudio.open("audio.txt", std::ios::in);
//std::cout << "In here" << std::endl;
while (!readAudio.eof()) while (!readAudio.eof())
{ {
@@ -30,12 +32,10 @@ void AudioInformation::stripInformation()
if (count == 3) if (count == 3)
{ {
readAudio >> data; readAudio >> data;
std::cout << data << " volume" << std::endl;
volume = atoi(data.c_str()); volume = atoi(data.c_str());
break; break;
} }
} }
//std::cout << std::endl;
readAudio.close(); readAudio.close();
readAudio.open("currentVolume.txt", std::ios::out); readAudio.open("currentVolume.txt", std::ios::out);
+17
View File
@@ -1,11 +1,28 @@
#include"stdio.h"
#include"stdlib.h"
#include"AudioInformation.h"
#include"DecreaseVolume.h" #include"DecreaseVolume.h"
DecreaseVolume::DecreaseVolume() DecreaseVolume::DecreaseVolume()
{ {
AudioInformation vol;
volume = vol.getVolume();
newVolume();
updateVolume();
updateTheCurrentVolume();
} }
void DecreaseVolume::newVolume()
{
volume = volume - AFFECTAMOUNT;
}
void DecreaseVolume::updateVolume() void DecreaseVolume::updateVolume()
{ {
std::string command = "amixer -c 1 set DAC0 ";
command.append(std::to_string(volume));
system(command.c_str());
} }
+1
View File
@@ -8,6 +8,7 @@ class DecreaseVolume : public Volume
public: public:
DecreaseVolume(); DecreaseVolume();
void newVolume();
void updateVolume(); void updateVolume();
}; };
-4
View File
@@ -1,4 +0,0 @@
#Volume Dump
amixer -c 1 get DAC0 > audio.txt
+28
View File
@@ -0,0 +1,28 @@
#include"stdio.h"
#include"stdlib.h"
#include"IncreaseVolume.h"
#include"AudioInformation.h"
IncreaseVolume::IncreaseVolume()
{
AudioInformation vol;
volume = vol.getVolume();
newVolume();
updateVolume();
updateTheCurrentVolume();
}
void IncreaseVolume::newVolume()
{
volume = volume + AFFECTAMOUNT;
}
void IncreaseVolume::updateVolume()
{
std::string command = "amixer -c 1 set DAC0 ";
command.append(std::to_string(volume));
system(command.c_str());
}
+16
View File
@@ -0,0 +1,16 @@
#ifndef INCREASEVOLUME_H
#define INCREASEVOLUME_H
#include"Volume.h"
class IncreaseVolume : public Volume
{
public:
IncreaseVolume();
void newVolume();
void updateVolume();
};
#endif
+2 -4
View File
@@ -14,15 +14,13 @@ int main(int argc, char* argv[])
if (action.compare("up") == 0) if (action.compare("up") == 0)
{ {
IncreaseVolume iv; IncreaseVolume iv;
//iv.setVolume(30);
std::cout << "Volume test: " << iv.getVolume() << std::endl; //std::cout << "Volume test: " << iv.getVolume() << std::endl;
} }
else if (action.compare("down") == 0) else if (action.compare("down") == 0)
{ {
DecreaseVolume dv; DecreaseVolume dv;
//dv.setVolume(70); //std::cout << "Volume test: " << dv.getVolume() << std::endl;
std::cout << "Volume test: " << dv.getVolume() << std::endl;
} }
else else
{ {
+1
View File
@@ -22,6 +22,7 @@ public:
} }
void updateTheCurrentVolume(); void updateTheCurrentVolume();
virtual void updateVolume() = 0; virtual void updateVolume() = 0;
virtual void newVolume() = 0;
protected: protected: