HeadsetControl icon indicating copy to clipboard operation
HeadsetControl copied to clipboard

Add Eqalizer info to json output

Open nicola02nb opened this issue 1 year ago • 9 comments

Description

Add for devices that supports the equalizer -e --equalizer argument some info when calling -o json like EQUALIZER_BANDS_SIZE, EQUALIZER_BAND_MIN, EQUALIZER_BAND_MAX. It can be a sectionlike this:

{
  "name": "HeadsetControl",
  "devices": [
    {
      "status": "success",
      "device": "HeadsetControl Test device",
      "vendor": "HeadsetControl",
      "product": "Test device",
      "id_vendor": "0xf00b",
      "id_product": "0xa00c",
      "capabilities": [
        "CAP_EQUALIZER",
      ],
      "capabilities_str": [
        "equalizer"
      ],
      "equalizer": {
        "band_size": 10
        "min": -10,
        "max": 10
      },
    }
  ]
}

nicola02nb avatar Jun 06 '24 11:06 nicola02nb

It would be also cool a section equalizer_preset that returns the presets of the headpones:

euqalizer_preset[
   flat: [0,....0,],
   bass: [....],
   ....
]

nicola02nb avatar Jun 08 '24 07:06 nicola02nb

Yeah that is quite easy to do.

However I do not fully understand your preset example. So basically what I see what we can return is something like this:

euqalizer_preset[
   flat,
   bass,
   smiley,
   focus
]

Where are the numbers in your example come from? (can you also link me the device file when you reference a specific one)

Sapd avatar Jun 09 '24 10:06 Sapd

Yeah, sorrry I missed some information... I was thinking something like this:

"euqalizer_preset":[
   "flat":[0,0,0,0,0,0,0],
   "bass":[0,0,0,0,0,0,0],
   "smiley":[0,0,0,0,0,0,0],
   "focus":[0,0,0,0,0,0,0]
]

I'm writing a GUI for HeadsetControl, and having those informations would be useful. Those values should come from the specific device... Take as example the Steelseries Artic Nova 7: image

nicola02nb avatar Jun 09 '24 10:06 nicola02nb

Ah yes now I get it, I saw the code before didn't realize that the command actually simply contains equalizer-payload.

Probably needs some code cleanup with more data-driven approach (defining the equalizer as struct and also using it to directly pass it to hid_write), but otherwise easily doable.

I think it can be implemented as a device function, which simply returns that information somewhere here - similar to other request functions (but that it instead returns the data from variables instead of from HID): https://github.com/Sapd/HeadsetControl/blob/f64ac48384cbb7df3878749cbe9635adefdae84c/src/device.h#L235

Can do so in the near future

Sapd avatar Jun 09 '24 11:06 Sapd

Yeah, it could be an idea... it seems also quite simply to implement... Tell me if you need anithing else

nicola02nb avatar Jun 09 '24 11:06 nicola02nb

@Sapd I done a commit on my fork where I added the feature for json output... It needs some refactor of some comments on device.h added function firms, and it also needs to get implemented all missing functions for compatible devices... can you give a look at it?

nicola02nb avatar Jun 16 '24 14:06 nicola02nb

Some suggestions:

  • Maybe it would be easier to be a device information in device.h in the device struct instead of a "feature"
    • As when you request json output without any options you will get all information anyway. And this information is static in any case
    • EqualizerInfo would have to be a pointer then inside the device struct, which is simply NULL when there is no EQ info. When it is null no output is needed
    • You would also then do not need the functions like request_equalizer

Sapd avatar Jun 17 '24 10:06 Sapd

Did a rollback and a new commit following your idea.

nicola02nb avatar Jun 17 '24 13:06 nicola02nb

Looks fine to me on first looks, in any case you can create a PR from your fork

Sapd avatar Jun 19 '24 09:06 Sapd