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.

Realtime but not continuous analysis ?

See original GitHub issue

I try to use the nice package for a realtime BPM analysis with line / mic input using navigator.getUserMedia

BPM detection works fine, but I don’t understand why the value is not updated when input BPM changes.

Maybe I made a mistake in my code (or comprehension), but I think the analyzer does not update BPM continiously.

Starting from functionnal example edit app.js :

'use strict';

const RealTimeBPMAnalyzer = require('realtime-bpm-analyzer');

const App = {
  init() {

    var AudioContext = window.AudioContext || window.webkitAudioContext;
	
	navigator.getUserMedia = ( navigator.getUserMedia ||
                       navigator.webkitGetUserMedia ||
                       navigator.mozGetUserMedia ||
                       navigator.msGetUserMedia);
					   
	var context = new AudioContext();
	// Enable mic / line input watching
	navigator.getUserMedia({audio: true}, onStream.bind(this), function() {});

	function onStream(stream) {
		// Set the source with the HTML Audio Node
		var input = context.createMediaStreamSource(stream);
		// Set the scriptProcessorNode to get PCM data in real time
		var scriptProcessorNode = context.createScriptProcessor(4096, 1, 1);

		// Connect everythings together (do not connect input to context.destination to avoid sound looping)
		scriptProcessorNode.connect(context.destination);
		input.connect(scriptProcessorNode);

		var onAudioProcess = new RealTimeBPMAnalyzer({
			scriptNode: {
				bufferSize: 4096,
				numberOfInputChannels: 1,
				numberOfOutputChannels: 1
			},
			pushTime: 2000,
			pushCallback: function(err, bpm) {
				if(bpm && bpm.length)
					console.log('bpm', bpm[0].tempo);   // <= When stabilized, always displays the same BPM
			}
		});

		// Attach realTime function to audioprocess event.inputBuffer (AudioBuffer)
		scriptProcessorNode.onaudioprocess = function (e) {
			onAudioProcess.analyze(e);
		};
	}
	
  }
}

module.exports = App;

Any idea ?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
dlepauxcommented, Sep 23, 2018

@Bulinlinbu I develop a proto-solution for you, I keep you informed 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Benefits of Real-Time Continuous Analysis
Real-time continuous analysis is being utilised in laboratories all over the world to improve testing capabilities of chemical compounds.
Read more >
Real Analysis | Showing a function is (dis)continuous. - YouTube
We give an example of showing a function is continuous everywhere and present a classic example of a function that is nowhere continuous....
Read more >
Independently analytic and continuous, but not jointly ...
I feel like it might be that analytic in the first variable and independently continuous in the second does not imply jointly continuous....
Read more >
Real-Time Data Analytics: On Demand vs. Continuous
It consists of dynamic analysis and reporting, based on data ... Continuous Real-Time Analytics is more proactive and alerts users with ...
Read more >
Discrete vs Continuous Data – What's the Difference? - G2
Discrete data is data that is countable, whereas continuous data is quantifiable rather than countable. Read more on the data types and ......
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