Skip to content

Implement audio data provider method #233

Description

@TT-ReBORN

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions