Frage

function createAudioMeter(audioContext,clipLevel,averaging,clipLag) {
    var processor = audioContext.createScriptProcessor(512);
    processor.onaudioprocess = volumeAudioProcess;
    processor.clipping = false;
    processor.lastClip = 0;
    processor.volume = 0;
    processor.clipLevel = clipLevel || 0.98;
    processor.averaging = averaging || 0.95;
    processor.clipLag = clipLag || 85;

I am confused on how we are assigning the variables "clipping", "lastClip", "volume", etc. to the ScriptProcessor. I've looked up the documentation for ScriptProcessor and it doesn't seem to have these defined already.

Thanks.

War es hilfreich?

Lösung

Are you asking what the properties are for or simply how is it possible that properties are being created ? The phrasing of your question seems to imply you're asking the second question.

If you want to know what the properties mean, you need to supply a link to the original source code so we can see everything in context. But from what I can tell, they're probably part of some code that displays a visual representation of an audio source's levels.

If you just want to know why this is possible... Well, it's possible because a ScriptProcessorNode is just an object, and you can always add properties to an object in JavaScript (unless it's been frozen).

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top