mirror of
https://github.com/kavishdevar/librepods.git
synced 2026-01-31 23:29:10 +00:00
Merge pull request #85 from tim-gromeyer/linux-adaptive-noise-level
[Linux] Implement adaptive audio noise
This commit is contained in:
@@ -18,6 +18,8 @@ class AirPodsTrayApp : public QObject {
|
||||
Q_PROPERTY(QString earDetectionStatus READ earDetectionStatus NOTIFY earDetectionStatusChanged)
|
||||
Q_PROPERTY(int noiseControlMode READ noiseControlMode WRITE setNoiseControlMode NOTIFY noiseControlModeChanged)
|
||||
Q_PROPERTY(bool conversationalAwareness READ conversationalAwareness WRITE setConversationalAwareness NOTIFY conversationalAwarenessChanged)
|
||||
Q_PROPERTY(int adaptiveNoiseLevel READ adaptiveNoiseLevel WRITE setAdaptiveNoiseLevel NOTIFY adaptiveNoiseLevelChanged)
|
||||
Q_PROPERTY(bool adaptiveModeActive READ adaptiveModeActive NOTIFY noiseControlModeChanged)
|
||||
|
||||
public:
|
||||
AirPodsTrayApp(bool debugMode) : debugMode(debugMode) {
|
||||
@@ -96,6 +98,8 @@ public:
|
||||
QString earDetectionStatus() const { return m_earDetectionStatus; }
|
||||
int noiseControlMode() const { return static_cast<int>(m_noiseControlMode); }
|
||||
bool conversationalAwareness() const { return m_conversationalAwareness; }
|
||||
bool adaptiveModeActive() const { return m_noiseControlMode == NoiseControlMode::Adaptive; }
|
||||
int adaptiveNoiseLevel() const { return m_adaptiveNoiseLevel; }
|
||||
|
||||
private:
|
||||
bool debugMode;
|
||||
@@ -256,6 +260,18 @@ public slots:
|
||||
saveConversationalAwarenessState();
|
||||
}
|
||||
|
||||
void setAdaptiveNoiseLevel(int level)
|
||||
{
|
||||
level = qBound(0, level, 100);
|
||||
if (m_adaptiveNoiseLevel != level && adaptiveModeActive())
|
||||
{
|
||||
m_adaptiveNoiseLevel = level;
|
||||
QByteArray packet = AirPodsPackets::AdaptiveNoise::getPacket(level);
|
||||
writePacketToSocket(packet, "Adaptive noise level packet written: ");
|
||||
emit adaptiveNoiseLevelChanged(level);
|
||||
}
|
||||
}
|
||||
|
||||
bool writePacketToSocket(const QByteArray &packet, const QString &logMessage)
|
||||
{
|
||||
if (socket && socket->isOpen())
|
||||
@@ -697,6 +713,7 @@ signals:
|
||||
void earDetectionStatusChanged(const QString &status);
|
||||
void batteryStatusChanged(const QString &status);
|
||||
void conversationalAwarenessChanged(bool enabled);
|
||||
void adaptiveNoiseLevelChanged(int level);
|
||||
|
||||
private:
|
||||
QSystemTrayIcon *trayIcon;
|
||||
@@ -715,6 +732,7 @@ private:
|
||||
QString m_earDetectionStatus;
|
||||
NoiseControlMode m_noiseControlMode = NoiseControlMode::Off;
|
||||
bool m_conversationalAwareness = false;
|
||||
int m_adaptiveNoiseLevel = 50;
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
Reference in New Issue
Block a user