Using less bash scripting
This commit is contained in:
@@ -1,7 +0,0 @@
|
|||||||
#decrease Audio
|
|
||||||
|
|
||||||
currentVolume=`cat currentVolume.txt`
|
|
||||||
|
|
||||||
newVolume=`./decreaseVolume.out $currentVolume`
|
|
||||||
|
|
||||||
amixer -c 1 set DAC0 $newVolume > /dev/null
|
|
||||||
@@ -3,35 +3,39 @@
|
|||||||
#include <ios>
|
#include <ios>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
#include"AudioInformation.h"
|
||||||
|
|
||||||
|
AudioInformation::AudioInformation()
|
||||||
|
{
|
||||||
|
stripInformation();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AudioInformation::stripInformation()
|
||||||
{
|
{
|
||||||
std::fstream readAudio;
|
std::fstream readAudio;
|
||||||
unsigned short count;
|
|
||||||
unsigned short volume;
|
|
||||||
|
|
||||||
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())
|
||||||
{
|
{
|
||||||
std::string data;
|
std::string data;
|
||||||
readAudio >> data;
|
readAudio >> data;
|
||||||
|
|
||||||
//std::cout << data << " ";
|
|
||||||
|
|
||||||
if (data.compare("Playback") == 0)
|
if (data.compare("Playback") == 0)
|
||||||
{
|
{
|
||||||
++count;
|
++count;
|
||||||
std::cout << "Count incremented" << std::endl;
|
|
||||||
}
|
}
|
||||||
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());
|
||||||
std::cout << volume << " value of audio" << std::endl;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::cout << std::endl;
|
//std::cout << std::endl;
|
||||||
|
|
||||||
readAudio.close();
|
readAudio.close();
|
||||||
readAudio.open("currentVolume.txt", std::ios::out);
|
readAudio.open("currentVolume.txt", std::ios::out);
|
||||||
@@ -39,6 +43,10 @@ int main(int argc, char* argv[])
|
|||||||
readAudio << volume;
|
readAudio << volume;
|
||||||
|
|
||||||
readAudio.close();
|
readAudio.close();
|
||||||
|
}
|
||||||
return 0;
|
|
||||||
|
|
||||||
|
unsigned short AudioInformation::getVolume() const
|
||||||
|
{
|
||||||
|
return volume;
|
||||||
}
|
}
|
||||||
@@ -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
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#raiseAudio
|
|
||||||
|
|
||||||
currentVolume=`cat currentVolume.txt`
|
|
||||||
|
|
||||||
newVolume=`./increaseVolume.out $currentVolume`
|
|
||||||
|
|
||||||
amixer -c 1 set DAC0 $newVolume > /dev/null
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#include"DecreaseVolume.h"
|
||||||
|
|
||||||
|
DecreaseVolume::DecreaseVolume()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DecreaseVolume::updateVolume()
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef DECREASEVOLUME_H
|
||||||
|
#define DECREASEVOLUME_H
|
||||||
|
|
||||||
|
#include"Volume.h"
|
||||||
|
|
||||||
|
class DecreaseVolume : public Volume
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DecreaseVolume();
|
||||||
|
|
||||||
|
void updateVolume();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
#include <iostream>
|
|
||||||
#include <fstream>
|
|
||||||
#include <ios>
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
#include<iostream>
|
||||||
|
#include<string>
|
||||||
|
|
||||||
|
#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;
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -1,19 +0,0 @@
|
|||||||
#include <iostream>
|
|
||||||
#include <fstream>
|
|
||||||
#include <ios>
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
#include<iostream>
|
||||||
|
#include<fstream>
|
||||||
|
#include<string>
|
||||||
|
|
||||||
|
#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();
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
#ifndef VOLUME_H
|
||||||
|
#define VOLUME_H
|
||||||
|
|
||||||
|
#include<string>
|
||||||
|
|
||||||
|
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
|
||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user