Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have lights respond to music #43

Open
5 tasks
dan47bennett opened this issue Aug 21, 2019 · 3 comments
Open
5 tasks

Have lights respond to music #43

dan47bennett opened this issue Aug 21, 2019 · 3 comments
Assignees
Labels
area: home-api Affects the home-api type: feature New feature or request

Comments

@dan47bennett
Copy link
Contributor

dan47bennett commented Aug 21, 2019

This is a long term goal for the HO, creating functionality to have lights respond to the beat of music. There are several issues to overcome before the final production:

  • Access the audio being produced by the PC.
  • Extract the frequency content from the audio.
  • Work on changing the state of the lights as quickly as possibly.
  • Choose how to have the lights respond e.g. brightness, on/off, colour changes etc.
  • Reduce latency as much as possible to give instantaneous response.

Latency is obviously hugely important for real-time response from the lights. There is a possibility to produce the audio and introduce a small delay in playback to give synchronous response from the lights, however this is not ideal. The Home API should allow us to avoid this by hosting the network locally.

There are several libraries that can be used to extract the frequency spectrum of audio such as p5.js https://p5js.org/examples/sound-frequency-spectrum.html.

My initial thought is that taking the average amplitude of frequencies below around 100-150Hz should give the beat of the song. Electronically produced music tends to have fairly sparse sounds at this level, usually just a kick which keeps the tempo. Experimentation with what parts of the spectrum to use and how to use multiple lights will be interesting and allow for a lot of customisation.

@dan47bennett dan47bennett self-assigned this Aug 21, 2019
@fitzhavey
Copy link
Member

This is awesome, as we expand into new areas of research - perhaps we are interested in using the wiki section to create a sharedm re-usable knowledgehub

@dan47bennett dan47bennett mentioned this issue Aug 27, 2019
@dan47bennett
Copy link
Contributor Author

dan47bennett commented Aug 27, 2019

Currently an issue with the home api:
Sending the following request to the localhost server allows the user to change the on and brightness variables, however changing the colour has no effect.

{
    "light": {
        "meta": {
            "hueId": "1"
        },
        "state": {
            "on": true,
            "colour": "rgb(0,220,0)",
            "brightness": "100"
        },
        "name": "danlamp",
        "type": "hue",
        "_id": "ehlg6A207F1uuRhECtlw"
    },
    "network": {
        "ownerId": "zf8aPHxxyffb6v1Ma1OGDynXNhZ2",
        "settings": {
            "lights": {
                "hue": {
                    "username": "pZZSkYfviBrTH4qxNq36Vsur5lYiABEFCsrBLjjs",
                    "ipAddress": "192.168.0.156",
                    "usingLocalAPI": false,
                    "useIFTTT": false
                }
            },
            "IFTTT": {
                "key": "i52Xme7UTQLy7liEykqeF5bwHWcf7Ji3jJKVC7nSzhY"
            },
            "localUrl": "http://localhost:4000",
            "usingLocalAPI": true
        },
        "name": "Dan's Room",
        "_id": "18InBMu296ZOs819j5mu"
    }
}

Clearly the request is being passed to the lights but it is not accepting the rgb values.

@dan47bennett
Copy link
Contributor Author

dan47bennett commented Sep 4, 2019

After some difficulties it seems that any node packages we attempt to use for this cannot be used within the home API as they are designed for use within a browser. If we used a web browser for sound we would lose the super fast connection the API gives us. Some decisions therefore must be made regarding whether we develop our own way of processing sound or if we decide to integrate the sound processing with the orchestrator site.

@fitzhavey fitzhavey added area: home-api Affects the home-api type: feature New feature or request labels Sep 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: home-api Affects the home-api type: feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants