Friday, June 19, 2026
HomeLanguagesJavascriptWeb Audio API | AudioNode context property

Web Audio API | AudioNode context property

The AudioNode interface has a context property which returns the related BaseAudioContext, which is the object that represents the process graph the node that has participated.

Syntax:

var ctx = anAudioNode.context;

Return Value: It returns a AudioContext or OfflineAudioContext object.

Example 1:




<!DOCTYPE html>
<html>
  
<head>
    <title>
        AudioNode context property
    </title>
</head>
  
<body>
  
    <h1 style="color:green">
        neveropen
    </h1>
      
    <h2>AudioNode context property</h2>
      
    <script>
        const AudioContext =
            window.AudioContext || window.webkitAudioContext;
  
        const audioCnt = new AudioContext();
  
        // Oscillator
        const osciltr = audioCnt.createOscillator();
  
        // Gain node
        const GainNode = audioCnt.createGain();
        osciltr.connect(GainNode).connect(audioCnt.destination);
  
        console.log(osciltr.context);
    </script>
</body>
  
</html>


Output:

Example 2:




<!DOCTYPE html>
<html>
  
<head>
    <title>
        AudioNode context property
    </title>
</head>
  
<body>
    <h1 style="color:green">
        neveropen
    </h1>
      
    <h2>AudioNode context property</h2>
      
    <script>
        const AudioContext =
            window.AudioContext || window.webkitAudioContext;
          
        const audioCnt = new AudioContext();
  
        // Oscillator
        const osciltr = audioCnt.createOscillator();
  
        // Gain_node
        const gNode = audioCnt.createGain();
        osciltr.connect(gNode).connect(audioCnt.destination);
  
        console.log(osciltr.context === audioCnt);
    </script>
</body>
  
</html>


Output:

Supported Browsers: The browsers supported by AudioNode context property are listed below:

  • Google Chrome 35.0
  • Firefox 25.0
  • Apple Safari 6 -x-
  • Opera 22.0
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

2 COMMENTS

Most Popular

Dominic
32516 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6899 POSTS0 COMMENTS
Nicole Veronica
12014 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12110 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6965 POSTS0 COMMENTS