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

Implement audio data provider method #233

Open
TT-ReBORN opened this issue Oct 9, 2024 · 0 comments
Open

Implement audio data provider method #233

TT-ReBORN opened this issue Oct 9, 2024 · 0 comments

Comments

@TT-ReBORN
Copy link

Hi @TheQwertiest,

I need SMP to provide real-time audio data for the currently playing track.

I am using the old foo_vis_vumeter component, which reads the left and right channels and peaks
without needing a panel to display the component.

Here is a snippet of how I use it with my peakmeter bar:

	/** Indicates if the foo_vis_vumeter component is installed. */
	VUMeter: utils.CheckComponent('foo_vis_vumeter')

	if (Component.VUMeter) {
		this.VUMeter = new ActiveXObject('VUMeter');
	}

	/**
	 * Calculates the decibel (dB) value of the given volume.
	 * @type {Function}
	 * @private
	 */
	this.toDecibel = (Level) => Math.round(2000 * Math.log(Level) / Math.LN10) / 100;

	// * Set and monitor volume level/peaks from VUMeter
	this.leftLevel  = this.toDecibel(this.VUMeter.LeftLevel);
	this.leftPeak   = this.toDecibel(this.VUMeter.LeftPeak);
	this.rightLevel = this.toDecibel(this.VUMeter.RightLevel);
	this.rightPeak  = this.toDecibel(this.VUMeter.RightPeak);

	// * Debug stuff
	DebugLog('LEFT PEAKS: ',  this.leftPeak,   '      RIGHT PEAKS: ',  this.rightPeak);
	DebugLog('LEFT LEVEL:  ', this.leftLevel,  '      RIGHT LEVEL:  ', this.rightLevel, '\n\n');

	// Outputs:
	LEFT PEAKS:  -12.86     RIGHT PEAKS:  0.36
	LEFT LEVEL:  -13.89     RIGHT LEVEL:  -0.46

	LEFT PEAKS:  1.67       RIGHT PEAKS:  2.85
	LEFT LEVEL: -1.88       RIGHT LEVEL:   1.4

	LEFT PEAKS:  4.92       RIGHT PEAKS:  5
	LEFT LEVEL:  0.28       RIGHT LEVEL:   2.18

	LEFT PEAKS:  2.23       RIGHT PEAKS:  3.08
	LEFT LEVEL:  2.01       RIGHT LEVEL:   3.03

Marc has already implement this in his JScript with fb.GetAudioChunk, see here and here.

Hope you can implement this so I can put foo_vis_vumeter component to sleep 😅.

-TT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant