Web Audio API | AudioNode numberOfOutputs property

Last Updated : 19 Jul, 2019
The AudioNode.numberOfOutputs property is used to return the number of outputs which are coming from nodes. The value of destination node AudioDestinationNode is 0 for this attribute. Syntax:
var numOutputs = audioNode.numberOfOutputs;
Return Value: It returns an integer value greater than equal to zero. Example 1: html
<!DOCTYPE HTML> 
<html> 

<head> 
    <title> 
        Web Audio API | AudioNode numberOfOutputs property
    </title>
</head> 

<body> 
    
    <h1 style = "color:green;" > 
        GeeksforGeeks
    </h1>
    
    <h2>
        AudioNode numberOfOutputs property
    </h2>
    
    <script>
    
        // Create new Audio context
        const audioContext = new AudioContext();
        
        // Create an OscillatorNode 
        const oscillator = audioContext.createOscillator();
        const gainNode = audioContext.createGain();
         
        oscillator.connect(gainNode).connect(audioContext.destination);
        
        // Display the numberOfOutputs in console view
        console.log(oscillator.numberOfOutputs);
    </script>
</body>

</html>                    
Output: Example 2: javascript
<!DOCTYPE HTML> 
<html> 
 
<head> 
    <title> 
        Web Audio API | AudioNode numberOfOutputs property
    </title>
</head> 
 
<body> 
     
    <h1 style = "color:green;" > 
        GeeksforGeeks
    </h1>
     
    <h2>
        AudioNode numberOfOutputs property
    </h2>
     
    <script>
     
        // Create new Audio context
        const audioContext = new AudioContext();
         
        // Create an OscillatorNode 
        const oscillator = audioContext.createOscillator();
        const gainNode = audioContext.createGain();
          
        oscillator.connect(gainNode).connect(audioContext.destination);
         
        // Display the numberOfOutputs in console view
        console.log(gainNode.numberOfOutputs);
    </script>
</body>
 
</html>                   
Output: Example 3: HTML
<!DOCTYPE HTML> 
<html> 

<head> 
    <title> 
        Web Audio API | AudioNode numberOfOutputs property
    </title>
</head> 

<body> 
    
    <h1 style = "color:green;" > 
        GeeksforGeeks
    </h1>
    
    <h2>
        AudioNode numberOfOutputs property
    </h2>
    
    <script>
    
        // Create new Audio context
        const audioContext = new AudioContext();
        
        // Create an OscillatorNode 
        const oscillator = audioContext.createOscillator();
        const gainNode = audioContext.createGain();
         
        oscillator.connect(gainNode).connect(audioContext.destination);
        
        // Display the numberOfOutputs in console view
        console.log(audioContext.destination.numberOfOutputs);
    </script>
</body>

</html>                    
Output: Supported Browsers: The browser supported by AudioNode.numberOfOutputs property are listed below:
  • Google Chrome 14.0
  • Edge 12.0
  • Firefox 25.0
  • Safari 6.0
  • Opera 15.0
Comment