Search in sources :

Example 1 with EqualizerCustomBands

use of nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerCustomBands in project Gadgetbridge by Freeyourgadget.

the class SonyProtocolImplV1 method handleEqualizer.

public List<? extends GBDeviceEvent> handleEqualizer(final byte[] payload) {
    if (payload.length != 10) {
        LOG.warn("Unexpected payload length {}", payload.length);
        return Collections.emptyList();
    }
    EqualizerPreset mode = null;
    for (EqualizerPreset value : EqualizerPreset.values()) {
        if (value.getCode() == payload[2]) {
            mode = value;
            break;
        }
    }
    if (mode == null) {
        LOG.warn("Unknown equalizer preset code {}", String.format("%02x", payload[2]));
        return Collections.emptyList();
    }
    LOG.debug("Equalizer Preset: {}", mode);
    final int clearBass = payload[4] - 10;
    final List<Integer> bands = new ArrayList<>(5);
    for (int i = 0; i < 5; i++) {
        bands.add(payload[5 + i] - 10);
    }
    final EqualizerCustomBands customBands = new EqualizerCustomBands(bands, clearBass);
    LOG.info("Equalizer Custom Bands: {}", customBands);
    final GBDeviceEventUpdatePreferences event = new GBDeviceEventUpdatePreferences().withPreferences(mode.toPreferences()).withPreferences(customBands.toPreferences());
    return Collections.singletonList(event);
}
Also used : EqualizerCustomBands(nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerCustomBands) EqualizerPreset(nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerPreset) ArrayList(java.util.ArrayList) GBDeviceEventUpdatePreferences(nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences)

Aggregations

ArrayList (java.util.ArrayList)1 GBDeviceEventUpdatePreferences (nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences)1 EqualizerCustomBands (nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerCustomBands)1 EqualizerPreset (nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerPreset)1