Open In App

Web Audio API | AudioNode numberOfInputs Property

Last Updated : 19 Jul, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

The AudioNode.numberOfInputs property is used to return the number of inputs that are feeding the node. The Source node is used to define as nodes that contain a numberOfInputs property with a value zero.

Syntax:

var numInputs = audioNode.numberOfInputs;

Return Value: It returns an integer value greater than equal to zero.

Example 1:




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


Output:

Example 2:




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


Output:

Example 3:




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


Output:

Supported Browsers: The browser supported by AudioNode.numberOfInputs property are listed below:

  • Google Chrome 14.0
  • Edge 12.0
  • Firefox 25.0
  • Safari 6.0
  • Opera 15.0


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads