question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

beat-match script improvments

See original GitHub issue

this is a cool use of code to change colors of light, but could be much more efficient if it all ran in node instead of python, and would show off how to use API better:

import Analyser from 'audio-analyser'
import Generator from 'audio-generator'
import TPLSmartDevice from 'tplink-lightbulb'

const fftSize = 1024
const bufferSize = 44100

const analyser = new Analyser({
    // Magnitude diapasone, in dB
    minDecibels: -100,
    maxDecibels: -30,
 
    // Number of time samples to transform to frequency
    fftSize,
 
    // Number of frequencies, twice less than fftSize
    frequencyBinCount: fftSize / 2,
 
    // Smoothing, or the priority of the old data over the new data
    smoothingTimeConstant: 0.2,
 
    // Number of channel to analyse
    channel: 0,
 
    // Size of time data to buffer
    bufferSize
})

// resolve promise after some seconds
const sleep = seconds => new Promise(resolve => {
  setTimeout(resolve, seconds * 1000)
})

const loop = async () => {
  const freqData = analyser.getFrequencyData(fftSize)
  // TODO: do analysis here, and do stuff to lights
  await sleep(1)
  return loop()
}

const lights = {}
lights.white = new TPLSmartDevice('192.168.86.154') // LB120
lights.color = new TPLSmartDevice('192.168.86.153') // LB130

// TODO: do setup here to get audio into analyser
loop()

Need to do some research to resolve TODO’s

Also, I should figure out Kyle Dixon’s github name (got code from an email they sent.)

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:34 (19 by maintainers)

github_iconTop GitHub Comments

2reactions
blakewenloecommented, Jul 9, 2019

This works! My only issue now is that the mic input is nowhere near as accurate as piping the audio straight to the analyzer.

mic
  .pipe(musicBeatDetector.getAnalyzer())
  .pipe(fs.createWriteStream("/dev/null"))
  .on("open", () => musicBeatScheduler.start());
1reaction
konsumercommented, Jul 31, 2021

One idea might be to use my new crossaudio to do some analysis. It currently doesn’t have native (non-browser) mic-input setup, but should be pretty easy to add, and if nothing else could be used in a browser (like via electron or similar) to send commands to the lights.

Pretty sure the spectrum/bargraph stuff I am doing could be used to make lights act in a cool way with sound, even if not used to detect beats. this could sort of directly translate to “make a bunch of colored lights show something cool to music”

Read more comments on GitHub >

github_iconTop Results From Across the Web

Auto-DJ extension for beatmatching and harmonic mixing
This script extends Auto-DJ with basic beatmatching and basic harmonic ... improved usage instructions; performance improvements; various minor things.
Read more >
Things you wish you learned *before* you really learned how ...
Once you learn to beatmatch, making a nice transition is extremely gratifying as well, like making a perfect shift in a manual car....
Read more >
esmevane/beatmatch: Get recommendations and ... - GitHub
Potential improvements to the matchmaker. Add signal strength support (multipliers which increase or decrease the efficacy of a given signal) ...
Read more >
BeatEdit 2 for Premiere Pro - aescripts.com
Beat Matching for better Audio Transitions ... Hoy platicamos acerca de un script llamado BeatEdit de MamoWorld, este script nos permite automatizar la ......
Read more >
Novation Circuit Rhythm 2.0 intros beat match, Grid FX ...
The new firmware 2.0 adds beat match that allows you to pitch your samples up or down to get drum breaks perfectly in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found